mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1052514: Use AsmJSNumLit in AsmJSModule.h; r=luke
This commit is contained in:
parent
9bf1f39c10
commit
c99071e27e
@ -106,17 +106,22 @@ ValidateGlobalVariable(JSContext *cx, const AsmJSModule &module, AsmJSModule::Gl
|
||||
|
||||
switch (global.varInitKind()) {
|
||||
case AsmJSModule::Global::InitConstant: {
|
||||
const Value &v = global.varInitConstant();
|
||||
switch (global.varInitCoercion()) {
|
||||
case AsmJS_ToInt32:
|
||||
const AsmJSNumLit &lit = global.varInitNumLit();
|
||||
const Value &v = lit.value();
|
||||
switch (lit.which()) {
|
||||
case AsmJSNumLit::Fixnum:
|
||||
case AsmJSNumLit::NegativeInt:
|
||||
case AsmJSNumLit::BigUnsigned:
|
||||
*(int32_t *)datum = v.toInt32();
|
||||
break;
|
||||
case AsmJS_ToNumber:
|
||||
case AsmJSNumLit::Double:
|
||||
*(double *)datum = v.toDouble();
|
||||
break;
|
||||
case AsmJS_FRound:
|
||||
case AsmJSNumLit::Float:
|
||||
*(float *)datum = static_cast<float>(v.toDouble());
|
||||
break;
|
||||
case AsmJSNumLit::OutOfRangeInt:
|
||||
MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE("OutOfRangeInt isn't valid in the first place");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ class AsmJSNumLit
|
||||
return float(value_.toDouble());
|
||||
}
|
||||
|
||||
Value value() const {
|
||||
const Value &value() const {
|
||||
JS_ASSERT(which_ != OutOfRangeInt);
|
||||
return value_;
|
||||
}
|
||||
@ -168,10 +168,10 @@ class AsmJSModule
|
||||
struct {
|
||||
uint32_t index_;
|
||||
VarInitKind initKind_;
|
||||
AsmJSCoercion coercion_;
|
||||
union {
|
||||
Value constant_; // will only contain int32/double
|
||||
} init;
|
||||
AsmJSCoercion coercion_;
|
||||
AsmJSNumLit numLit_;
|
||||
} u;
|
||||
} var;
|
||||
uint32_t ffiIndex_;
|
||||
Scalar::Type viewType_;
|
||||
@ -196,7 +196,7 @@ class AsmJSModule
|
||||
if (name_)
|
||||
MarkStringUnbarriered(trc, &name_, "asm.js global name");
|
||||
JS_ASSERT_IF(pod.which_ == Variable && pod.u.var.initKind_ == InitConstant,
|
||||
!pod.u.var.init.constant_.isMarkable());
|
||||
!pod.u.var.u.numLit_.value().isMarkable());
|
||||
}
|
||||
|
||||
public:
|
||||
@ -212,14 +212,15 @@ class AsmJSModule
|
||||
JS_ASSERT(pod.which_ == Variable);
|
||||
return pod.u.var.initKind_;
|
||||
}
|
||||
const Value &varInitConstant() const {
|
||||
const AsmJSNumLit &varInitNumLit() const {
|
||||
JS_ASSERT(pod.which_ == Variable);
|
||||
JS_ASSERT(pod.u.var.initKind_ == InitConstant);
|
||||
return pod.u.var.init.constant_;
|
||||
return pod.u.var.u.numLit_;
|
||||
}
|
||||
AsmJSCoercion varInitCoercion() const {
|
||||
JS_ASSERT(pod.which_ == Variable);
|
||||
return pod.u.var.coercion_;
|
||||
JS_ASSERT(pod.u.var.initKind_ == InitImport);
|
||||
return pod.u.var.u.coercion_;
|
||||
}
|
||||
PropertyName *varImportField() const {
|
||||
JS_ASSERT(pod.which_ == Variable);
|
||||
@ -816,14 +817,13 @@ class AsmJSModule
|
||||
PropertyName *bufferArgumentName() const {
|
||||
return bufferArgumentName_;
|
||||
}
|
||||
bool addGlobalVarInit(const Value &v, AsmJSCoercion coercion, uint32_t *globalIndex) {
|
||||
bool addGlobalVarInit(const AsmJSNumLit &lit, uint32_t *globalIndex) {
|
||||
JS_ASSERT(!isFinishedWithModulePrologue());
|
||||
if (pod.numGlobalVars_ == UINT32_MAX)
|
||||
return false;
|
||||
Global g(Global::Variable, nullptr);
|
||||
g.pod.u.var.initKind_ = Global::InitConstant;
|
||||
g.pod.u.var.init.constant_ = v;
|
||||
g.pod.u.var.coercion_ = coercion;
|
||||
g.pod.u.var.u.numLit_ = lit;
|
||||
g.pod.u.var.index_ = *globalIndex = pod.numGlobalVars_++;
|
||||
return globals_.append(g);
|
||||
}
|
||||
@ -831,7 +831,7 @@ class AsmJSModule
|
||||
JS_ASSERT(!isFinishedWithModulePrologue());
|
||||
Global g(Global::Variable, name);
|
||||
g.pod.u.var.initKind_ = Global::InitImport;
|
||||
g.pod.u.var.coercion_ = coercion;
|
||||
g.pod.u.var.u.coercion_ = coercion;
|
||||
g.pod.u.var.index_ = *globalIndex = pod.numGlobalVars_++;
|
||||
return globals_.append(g);
|
||||
}
|
||||
|
@ -1350,7 +1350,7 @@ class MOZ_STACK_CLASS ModuleCompiler
|
||||
bool addGlobalVarInit(PropertyName *varName, const AsmJSNumLit &lit, bool isConst) {
|
||||
uint32_t index;
|
||||
VarType type = VarType::Of(lit);
|
||||
if (!module_->addGlobalVarInit(lit.value(), type.toCoercion(), &index))
|
||||
if (!module_->addGlobalVarInit(lit, &index))
|
||||
return false;
|
||||
|
||||
Global::Which which = isConst ? Global::ConstantLiteral : Global::Variable;
|
||||
|
Loading…
Reference in New Issue
Block a user