Bug 860102 - Rooting hazards in asm.js. r=luke,terrence

--HG--
extra : rebase_source : 491465843620512882d1aea68b0f2cbab83e6d77
This commit is contained in:
Steve Fink 2013-04-11 16:45:50 -07:00
parent 63a8075a3a
commit c5a23960de
2 changed files with 11 additions and 8 deletions

View File

@ -31,7 +31,7 @@ LinkFail(JSContext *cx, const char *str)
}
static bool
ValidateGlobalVariable(JSContext *cx, const AsmJSModule &module, AsmJSModule::Global global,
ValidateGlobalVariable(JSContext *cx, const AsmJSModule &module, AsmJSModule::Global &global,
HandleValue importVal)
{
JS_ASSERT(global.which() == AsmJSModule::Global::Variable);
@ -71,7 +71,7 @@ ValidateGlobalVariable(JSContext *cx, const AsmJSModule &module, AsmJSModule::Gl
}
static bool
ValidateFFI(JSContext *cx, AsmJSModule::Global global, HandleValue importVal,
ValidateFFI(JSContext *cx, AsmJSModule::Global &global, HandleValue importVal,
AutoObjectVector *ffis)
{
RootedPropertyName field(cx, global.ffiField());
@ -87,7 +87,7 @@ ValidateFFI(JSContext *cx, AsmJSModule::Global global, HandleValue importVal,
}
static bool
ValidateArrayView(JSContext *cx, AsmJSModule::Global global, HandleValue globalVal,
ValidateArrayView(JSContext *cx, AsmJSModule::Global &global, HandleValue globalVal,
HandleValue bufferVal)
{
RootedPropertyName field(cx, global.viewName());
@ -102,7 +102,7 @@ ValidateArrayView(JSContext *cx, AsmJSModule::Global global, HandleValue globalV
}
static bool
ValidateMathBuiltin(JSContext *cx, AsmJSModule::Global global, HandleValue globalVal)
ValidateMathBuiltin(JSContext *cx, AsmJSModule::Global &global, HandleValue globalVal)
{
RootedValue v(cx);
if (!GetProperty(cx, globalVal, cx->names().Math, &v))
@ -137,7 +137,7 @@ ValidateMathBuiltin(JSContext *cx, AsmJSModule::Global global, HandleValue globa
}
static bool
ValidateGlobalConstant(JSContext *cx, AsmJSModule::Global global, HandleValue globalVal)
ValidateGlobalConstant(JSContext *cx, AsmJSModule::Global &global, HandleValue globalVal)
{
RootedPropertyName field(cx, global.constantName());
RootedValue v(cx);
@ -216,7 +216,7 @@ DynamicallyLinkModule(JSContext *cx, CallArgs args, AsmJSModule &module)
return false;
for (unsigned i = 0; i < module.numGlobals(); i++) {
AsmJSModule::Global global = module.global(i);
AsmJSModule::Global &global = module.global(i);
switch (global.which()) {
case AsmJSModule::Global::Variable:
if (!ValidateGlobalVariable(cx, module, global, importVal))

View File

@ -62,7 +62,7 @@ class AsmJSModule
uint32_t index_;
VarInitKind initKind_;
union {
Value constant_;
Value constant_; // will only contain int32/double
AsmJSCoercion coercion_;
} init;
} var;
@ -79,6 +79,8 @@ class AsmJSModule
void trace(JSTracer *trc) {
if (name_)
MarkString(trc, &name_, "asm.js global name");
JS_ASSERT_IF(which_ == Variable && u.var.initKind_ == InitConstant,
!u.var.init.constant_.isMarkable());
}
public:
@ -370,6 +372,7 @@ class AsmJSModule
}
bool addGlobalVarInitConstant(const Value &v, uint32_t *globalIndex) {
JS_ASSERT(!v.isMarkable());
if (numGlobalVars_ == UINT32_MAX)
return false;
Global g(Global::Variable);
@ -451,7 +454,7 @@ class AsmJSModule
unsigned numGlobals() const {
return globals_.length();
}
Global global(unsigned i) const {
Global &global(unsigned i) {
return globals_[i];
}
unsigned numFuncPtrTableElems() const {