void LCodeGen::DoDeclareGlobals(LDeclareGlobals* instr) {
DCHECK(ToRegister(instr->context()).is(cp));
- __ push(cp); // The context is the first argument.
__ Move(scratch0(), instr->hydrogen()->pairs());
__ push(scratch0());
__ mov(scratch0(), Operand(Smi::FromInt(instr->hydrogen()->flags())));
__ push(scratch0());
- CallRuntime(Runtime::kDeclareGlobals, 3, instr);
+ CallRuntime(Runtime::kDeclareGlobals, 2, instr);
}
// here.
__ LoadHeapObject(scratch1, instr->hydrogen()->pairs());
__ Mov(scratch2, Smi::FromInt(instr->hydrogen()->flags()));
- __ Push(cp, scratch1, scratch2); // The context is the first argument.
- CallRuntime(Runtime::kDeclareGlobals, 3, instr);
+ __ Push(scratch1, scratch2);
+ CallRuntime(Runtime::kDeclareGlobals, 2, instr);
}
DeclareGlobalsLanguageMode::encode(language_mode());
Node* flags = jsgraph()->Constant(encoded_flags);
Node* pairs = jsgraph()->Constant(data);
- const Operator* op = javascript()->CallRuntime(Runtime::kDeclareGlobals, 3);
- Node* call = NewNode(op, current_context(), pairs, flags);
+ const Operator* op = javascript()->CallRuntime(Runtime::kDeclareGlobals, 2);
+ Node* call = NewNode(op, pairs, flags);
PrepareFrameState(call, BailoutId::Declarations());
globals()->clear();
}
__ mov(r2, Operand(variable->name()));
// Declaration nodes are always introduced in one of four modes.
DCHECK(IsDeclaredVariableMode(mode));
- PropertyAttributes attr =
- IsImmutableVariableMode(mode) ? READ_ONLY : NONE;
- __ mov(r1, Operand(Smi::FromInt(attr)));
// Push initial value, if any.
// Note: For variables we must not push an initial value (such as
// 'undefined') because we may have a (legal) redeclaration and we
// must not destroy the current value.
if (hole_init) {
__ LoadRoot(r0, Heap::kTheHoleValueRootIndex);
- __ Push(cp, r2, r1, r0);
} else {
__ mov(r0, Operand(Smi::FromInt(0))); // Indicates no initial value.
- __ Push(cp, r2, r1, r0);
}
- __ CallRuntime(Runtime::kDeclareLookupSlot, 4);
+ __ Push(r2, r0);
+ __ CallRuntime(IsImmutableVariableMode(mode)
+ ? Runtime::kDeclareReadOnlyLookupSlot
+ : Runtime::kDeclareLookupSlot,
+ 2);
break;
}
}
case VariableLocation::LOOKUP: {
Comment cmnt(masm_, "[ FunctionDeclaration");
__ mov(r2, Operand(variable->name()));
- __ mov(r1, Operand(Smi::FromInt(NONE)));
- __ Push(cp, r2, r1);
+ __ Push(r2);
// Push initial value for function declaration.
VisitForStackValue(declaration->fun());
- __ CallRuntime(Runtime::kDeclareLookupSlot, 4);
+ __ CallRuntime(Runtime::kDeclareLookupSlot, 2);
break;
}
}
void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) {
// Call the runtime to declare the globals.
- // The context is the first argument.
__ mov(r1, Operand(pairs));
__ mov(r0, Operand(Smi::FromInt(DeclareGlobalsFlags())));
- __ Push(cp, r1, r0);
- __ CallRuntime(Runtime::kDeclareGlobals, 3);
+ __ Push(r1, r0);
+ __ CallRuntime(Runtime::kDeclareGlobals, 2);
// Return value is ignored.
}
__ Mov(x2, Operand(variable->name()));
// Declaration nodes are always introduced in one of four modes.
DCHECK(IsDeclaredVariableMode(mode));
- PropertyAttributes attr = IsImmutableVariableMode(mode) ? READ_ONLY
- : NONE;
- __ Mov(x1, Smi::FromInt(attr));
// Push initial value, if any.
// Note: For variables we must not push an initial value (such as
// 'undefined') because we may have a (legal) redeclaration and we
// must not destroy the current value.
if (hole_init) {
__ LoadRoot(x0, Heap::kTheHoleValueRootIndex);
- __ Push(cp, x2, x1, x0);
+ __ Push(x2, x0);
} else {
// Pushing 0 (xzr) indicates no initial value.
- __ Push(cp, x2, x1, xzr);
+ __ Push(x2, xzr);
}
- __ CallRuntime(Runtime::kDeclareLookupSlot, 4);
+ __ CallRuntime(IsImmutableVariableMode(mode)
+ ? Runtime::kDeclareReadOnlyLookupSlot
+ : Runtime::kDeclareLookupSlot,
+ 2);
break;
}
}
case VariableLocation::LOOKUP: {
Comment cmnt(masm_, "[ Function Declaration");
__ Mov(x2, Operand(variable->name()));
- __ Mov(x1, Smi::FromInt(NONE));
- __ Push(cp, x2, x1);
+ __ Push(x2);
// Push initial value for function declaration.
VisitForStackValue(declaration->fun());
- __ CallRuntime(Runtime::kDeclareLookupSlot, 4);
+ __ CallRuntime(Runtime::kDeclareLookupSlot, 2);
break;
}
}
flags = x10;
__ Mov(flags, Smi::FromInt(DeclareGlobalsFlags()));
}
- __ Push(cp, x11, flags);
- __ CallRuntime(Runtime::kDeclareGlobals, 3);
+ __ Push(x11, flags);
+ __ CallRuntime(Runtime::kDeclareGlobals, 2);
// Return value is ignored.
}
case VariableLocation::LOOKUP: {
Comment cmnt(masm_, "[ VariableDeclaration");
- __ push(esi);
__ push(Immediate(variable->name()));
// VariableDeclaration nodes are always introduced in one of four modes.
DCHECK(IsDeclaredVariableMode(mode));
- PropertyAttributes attr =
- IsImmutableVariableMode(mode) ? READ_ONLY : NONE;
- __ push(Immediate(Smi::FromInt(attr)));
// Push initial value, if any.
// Note: For variables we must not push an initial value (such as
// 'undefined') because we may have a (legal) redeclaration and we
} else {
__ push(Immediate(Smi::FromInt(0))); // Indicates no initial value.
}
- __ CallRuntime(Runtime::kDeclareLookupSlot, 4);
+ __ CallRuntime(IsImmutableVariableMode(mode)
+ ? Runtime::kDeclareReadOnlyLookupSlot
+ : Runtime::kDeclareLookupSlot,
+ 2);
break;
}
}
case VariableLocation::LOOKUP: {
Comment cmnt(masm_, "[ FunctionDeclaration");
- __ push(esi);
__ push(Immediate(variable->name()));
- __ push(Immediate(Smi::FromInt(NONE)));
VisitForStackValue(declaration->fun());
- __ CallRuntime(Runtime::kDeclareLookupSlot, 4);
+ __ CallRuntime(Runtime::kDeclareLookupSlot, 2);
break;
}
}
void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) {
// Call the runtime to declare the globals.
- __ push(esi); // The context is the first argument.
__ Push(pairs);
__ Push(Smi::FromInt(DeclareGlobalsFlags()));
- __ CallRuntime(Runtime::kDeclareGlobals, 3);
+ __ CallRuntime(Runtime::kDeclareGlobals, 2);
// Return value is ignored.
}
__ li(a2, Operand(variable->name()));
// Declaration nodes are always introduced in one of four modes.
DCHECK(IsDeclaredVariableMode(mode));
- PropertyAttributes attr =
- IsImmutableVariableMode(mode) ? READ_ONLY : NONE;
- __ li(a1, Operand(Smi::FromInt(attr)));
// Push initial value, if any.
// Note: For variables we must not push an initial value (such as
// 'undefined') because we may have a (legal) redeclaration and we
// must not destroy the current value.
if (hole_init) {
__ LoadRoot(a0, Heap::kTheHoleValueRootIndex);
- __ Push(cp, a2, a1, a0);
} else {
DCHECK(Smi::FromInt(0) == 0);
__ mov(a0, zero_reg); // Smi::FromInt(0) indicates no initial value.
- __ Push(cp, a2, a1, a0);
}
- __ CallRuntime(Runtime::kDeclareLookupSlot, 4);
+ __ Push(a2, a0);
+ __ CallRuntime(IsImmutableVariableMode(mode)
+ ? Runtime::kDeclareReadOnlyLookupSlot
+ : Runtime::kDeclareLookupSlot,
+ 2);
break;
}
}
case VariableLocation::LOOKUP: {
Comment cmnt(masm_, "[ FunctionDeclaration");
__ li(a2, Operand(variable->name()));
- __ li(a1, Operand(Smi::FromInt(NONE)));
- __ Push(cp, a2, a1);
+ __ Push(a2);
// Push initial value for function declaration.
VisitForStackValue(declaration->fun());
- __ CallRuntime(Runtime::kDeclareLookupSlot, 4);
+ __ CallRuntime(Runtime::kDeclareLookupSlot, 2);
break;
}
}
void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) {
// Call the runtime to declare the globals.
- // The context is the first argument.
__ li(a1, Operand(pairs));
__ li(a0, Operand(Smi::FromInt(DeclareGlobalsFlags())));
- __ Push(cp, a1, a0);
- __ CallRuntime(Runtime::kDeclareGlobals, 3);
+ __ Push(a1, a0);
+ __ CallRuntime(Runtime::kDeclareGlobals, 2);
// Return value is ignored.
}
__ li(a2, Operand(variable->name()));
// Declaration nodes are always introduced in one of four modes.
DCHECK(IsDeclaredVariableMode(mode));
- PropertyAttributes attr =
- IsImmutableVariableMode(mode) ? READ_ONLY : NONE;
- __ li(a1, Operand(Smi::FromInt(attr)));
// Push initial value, if any.
// Note: For variables we must not push an initial value (such as
// 'undefined') because we may have a (legal) redeclaration and we
// must not destroy the current value.
if (hole_init) {
__ LoadRoot(a0, Heap::kTheHoleValueRootIndex);
- __ Push(cp, a2, a1, a0);
} else {
DCHECK(Smi::FromInt(0) == 0);
__ mov(a0, zero_reg); // Smi::FromInt(0) indicates no initial value.
- __ Push(cp, a2, a1, a0);
}
- __ CallRuntime(Runtime::kDeclareLookupSlot, 4);
+ __ Push(a2, a0);
+ __ CallRuntime(IsImmutableVariableMode(mode)
+ ? Runtime::kDeclareReadOnlyLookupSlot
+ : Runtime::kDeclareLookupSlot,
+ 2);
break;
}
}
case VariableLocation::LOOKUP: {
Comment cmnt(masm_, "[ FunctionDeclaration");
__ li(a2, Operand(variable->name()));
- __ li(a1, Operand(Smi::FromInt(NONE)));
- __ Push(cp, a2, a1);
+ __ Push(a2);
// Push initial value for function declaration.
VisitForStackValue(declaration->fun());
- __ CallRuntime(Runtime::kDeclareLookupSlot, 4);
+ __ CallRuntime(Runtime::kDeclareLookupSlot, 2);
break;
}
}
void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) {
// Call the runtime to declare the globals.
- // The context is the first argument.
__ li(a1, Operand(pairs));
__ li(a0, Operand(Smi::FromInt(DeclareGlobalsFlags())));
- __ Push(cp, a1, a0);
- __ CallRuntime(Runtime::kDeclareGlobals, 3);
+ __ Push(a1, a0);
+ __ CallRuntime(Runtime::kDeclareGlobals, 2);
// Return value is ignored.
}
__ mov(r5, Operand(variable->name()));
// Declaration nodes are always introduced in one of four modes.
DCHECK(IsDeclaredVariableMode(mode));
- PropertyAttributes attr =
- IsImmutableVariableMode(mode) ? READ_ONLY : NONE;
- __ LoadSmiLiteral(r4, Smi::FromInt(attr));
// Push initial value, if any.
// Note: For variables we must not push an initial value (such as
// 'undefined') because we may have a (legal) redeclaration and we
// must not destroy the current value.
if (hole_init) {
__ LoadRoot(r3, Heap::kTheHoleValueRootIndex);
- __ Push(cp, r5, r4, r3);
+ __ Push(r5, r3);
} else {
__ LoadSmiLiteral(r3, Smi::FromInt(0)); // Indicates no initial value.
- __ Push(cp, r5, r4, r3);
+ __ Push(r5, r3);
}
- __ CallRuntime(Runtime::kDeclareLookupSlot, 4);
+ __ CallRuntime(IsImmutableVariableMode(mode)
+ ? Runtime::kDeclareReadOnlyLookupSlot
+ : Runtime::kDeclareLookupSlot,
+ 2);
break;
}
}
case VariableLocation::LOOKUP: {
Comment cmnt(masm_, "[ FunctionDeclaration");
__ mov(r5, Operand(variable->name()));
- __ LoadSmiLiteral(r4, Smi::FromInt(NONE));
- __ Push(cp, r5, r4);
+ __ Push(r5);
// Push initial value for function declaration.
VisitForStackValue(declaration->fun());
- __ CallRuntime(Runtime::kDeclareLookupSlot, 4);
+ __ CallRuntime(Runtime::kDeclareLookupSlot, 2);
break;
}
}
void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) {
// Call the runtime to declare the globals.
- // The context is the first argument.
__ mov(r4, Operand(pairs));
__ LoadSmiLiteral(r3, Smi::FromInt(DeclareGlobalsFlags()));
- __ Push(cp, r4, r3);
- __ CallRuntime(Runtime::kDeclareGlobals, 3);
+ __ Push(r4, r3);
+ __ CallRuntime(Runtime::kDeclareGlobals, 2);
// Return value is ignored.
}
case VariableLocation::LOOKUP: {
Comment cmnt(masm_, "[ VariableDeclaration");
- __ Push(rsi);
__ Push(variable->name());
// Declaration nodes are always introduced in one of four modes.
DCHECK(IsDeclaredVariableMode(mode));
- PropertyAttributes attr =
- IsImmutableVariableMode(mode) ? READ_ONLY : NONE;
- __ Push(Smi::FromInt(attr));
// Push initial value, if any.
// Note: For variables we must not push an initial value (such as
// 'undefined') because we may have a (legal) redeclaration and we
} else {
__ Push(Smi::FromInt(0)); // Indicates no initial value.
}
- __ CallRuntime(Runtime::kDeclareLookupSlot, 4);
+ __ CallRuntime(IsImmutableVariableMode(mode)
+ ? Runtime::kDeclareReadOnlyLookupSlot
+ : Runtime::kDeclareLookupSlot,
+ 2);
break;
}
}
case VariableLocation::LOOKUP: {
Comment cmnt(masm_, "[ FunctionDeclaration");
- __ Push(rsi);
__ Push(variable->name());
- __ Push(Smi::FromInt(NONE));
VisitForStackValue(declaration->fun());
- __ CallRuntime(Runtime::kDeclareLookupSlot, 4);
+ __ CallRuntime(Runtime::kDeclareLookupSlot, 2);
break;
}
}
void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) {
// Call the runtime to declare the globals.
- __ Push(rsi); // The context is the first argument.
__ Push(pairs);
__ Push(Smi::FromInt(DeclareGlobalsFlags()));
- __ CallRuntime(Runtime::kDeclareGlobals, 3);
+ __ CallRuntime(Runtime::kDeclareGlobals, 2);
// Return value is ignored.
}
case VariableLocation::LOOKUP: {
Comment cmnt(masm_, "[ VariableDeclaration");
- __ push(esi);
__ push(Immediate(variable->name()));
// VariableDeclaration nodes are always introduced in one of four modes.
DCHECK(IsDeclaredVariableMode(mode));
- PropertyAttributes attr =
- IsImmutableVariableMode(mode) ? READ_ONLY : NONE;
- __ push(Immediate(Smi::FromInt(attr)));
// Push initial value, if any.
// Note: For variables we must not push an initial value (such as
// 'undefined') because we may have a (legal) redeclaration and we
} else {
__ push(Immediate(Smi::FromInt(0))); // Indicates no initial value.
}
- __ CallRuntime(Runtime::kDeclareLookupSlot, 4);
+ __ CallRuntime(IsImmutableVariableMode(mode)
+ ? Runtime::kDeclareReadOnlyLookupSlot
+ : Runtime::kDeclareLookupSlot,
+ 2);
break;
}
}
case VariableLocation::LOOKUP: {
Comment cmnt(masm_, "[ FunctionDeclaration");
- __ push(esi);
__ push(Immediate(variable->name()));
- __ push(Immediate(Smi::FromInt(NONE)));
VisitForStackValue(declaration->fun());
- __ CallRuntime(Runtime::kDeclareLookupSlot, 4);
+ __ CallRuntime(Runtime::kDeclareLookupSlot, 2);
break;
}
}
void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) {
// Call the runtime to declare the globals.
- __ push(esi); // The context is the first argument.
__ Push(pairs);
__ Push(Smi::FromInt(DeclareGlobalsFlags()));
- __ CallRuntime(Runtime::kDeclareGlobals, 3);
+ __ CallRuntime(Runtime::kDeclareGlobals, 2);
// Return value is ignored.
}
void LCodeGen::DoDeclareGlobals(LDeclareGlobals* instr) {
DCHECK(ToRegister(instr->context()).is(esi));
- __ push(esi); // The context is the first argument.
__ push(Immediate(instr->hydrogen()->pairs()));
__ push(Immediate(Smi::FromInt(instr->hydrogen()->flags())));
- CallRuntime(Runtime::kDeclareGlobals, 3, instr);
+ CallRuntime(Runtime::kDeclareGlobals, 2, instr);
}
DCHECK(ToRegister(instr->context()).is(cp));
__ li(scratch0(), instr->hydrogen()->pairs());
__ li(scratch1(), Operand(Smi::FromInt(instr->hydrogen()->flags())));
- // The context is the first argument.
- __ Push(cp, scratch0(), scratch1());
- CallRuntime(Runtime::kDeclareGlobals, 3, instr);
+ __ Push(scratch0(), scratch1());
+ CallRuntime(Runtime::kDeclareGlobals, 2, instr);
}
DCHECK(ToRegister(instr->context()).is(cp));
__ li(scratch0(), instr->hydrogen()->pairs());
__ li(scratch1(), Operand(Smi::FromInt(instr->hydrogen()->flags())));
- // The context is the first argument.
- __ Push(cp, scratch0(), scratch1());
- CallRuntime(Runtime::kDeclareGlobals, 3, instr);
+ __ Push(scratch0(), scratch1());
+ CallRuntime(Runtime::kDeclareGlobals, 2, instr);
}
void LCodeGen::DoDeclareGlobals(LDeclareGlobals* instr) {
DCHECK(ToRegister(instr->context()).is(cp));
- __ push(cp); // The context is the first argument.
__ Move(scratch0(), instr->hydrogen()->pairs());
__ push(scratch0());
__ LoadSmiLiteral(scratch0(), Smi::FromInt(instr->hydrogen()->flags()));
__ push(scratch0());
- CallRuntime(Runtime::kDeclareGlobals, 3, instr);
+ CallRuntime(Runtime::kDeclareGlobals, 2, instr);
}
RUNTIME_FUNCTION(Runtime_DeclareGlobals) {
HandleScope scope(isolate);
- DCHECK(args.length() == 3);
+ DCHECK_EQ(2, args.length());
Handle<GlobalObject> global(isolate->global_object());
+ Handle<Context> context(isolate->context());
- CONVERT_ARG_HANDLE_CHECKED(Context, context, 0);
- CONVERT_ARG_HANDLE_CHECKED(FixedArray, pairs, 1);
- CONVERT_SMI_ARG_CHECKED(flags, 2);
+ CONVERT_ARG_HANDLE_CHECKED(FixedArray, pairs, 0);
+ CONVERT_SMI_ARG_CHECKED(flags, 1);
// Traverse the name/value pairs and set the properties.
int length = pairs->length();
}
-RUNTIME_FUNCTION(Runtime_DeclareLookupSlot) {
- HandleScope scope(isolate);
- DCHECK(args.length() == 4);
+namespace {
+Object* DeclareLookupSlot(Isolate* isolate, Handle<String> name,
+ Handle<Object> initial_value,
+ PropertyAttributes attr) {
// Declarations are always made in a function, eval or script context. In
// the case of eval code, the context passed is the context of the caller,
// which may be some nested context and not the declaration context.
- CONVERT_ARG_HANDLE_CHECKED(Context, context_arg, 0);
- Handle<Context> context(context_arg->declaration_context());
- CONVERT_ARG_HANDLE_CHECKED(String, name, 1);
- CONVERT_SMI_ARG_CHECKED(attr_arg, 2);
- PropertyAttributes attr = static_cast<PropertyAttributes>(attr_arg);
- RUNTIME_ASSERT(attr == READ_ONLY || attr == NONE);
- CONVERT_ARG_HANDLE_CHECKED(Object, initial_value, 3);
+ Handle<Context> context_arg(isolate->context(), isolate);
+ Handle<Context> context(context_arg->declaration_context(), isolate);
// TODO(verwaest): Unify the encoding indicating "var" with DeclareGlobals.
bool is_var = *initial_value == NULL;
return isolate->heap()->undefined_value();
}
+} // namespace
+
+
+RUNTIME_FUNCTION(Runtime_DeclareLookupSlot) {
+ HandleScope scope(isolate);
+ DCHECK_EQ(2, args.length());
+ CONVERT_ARG_HANDLE_CHECKED(String, name, 0);
+ CONVERT_ARG_HANDLE_CHECKED(Object, initial_value, 1);
+
+ return DeclareLookupSlot(isolate, name, initial_value, NONE);
+}
+
+
+RUNTIME_FUNCTION(Runtime_DeclareReadOnlyLookupSlot) {
+ HandleScope scope(isolate);
+ DCHECK_EQ(2, args.length());
+ CONVERT_ARG_HANDLE_CHECKED(String, name, 0);
+ CONVERT_ARG_HANDLE_CHECKED(Object, initial_value, 1);
+
+ return DeclareLookupSlot(isolate, name, initial_value, READ_ONLY);
+}
+
RUNTIME_FUNCTION(Runtime_InitializeLegacyConstLookupSlot) {
HandleScope scope(isolate);
#define FOR_EACH_INTRINSIC_SCOPES(F) \
F(ThrowConstAssignError, 0, 1) \
- F(DeclareGlobals, 3, 1) \
+ F(DeclareGlobals, 2, 1) \
F(InitializeVarGlobal, 3, 1) \
F(InitializeConstGlobal, 2, 1) \
- F(DeclareLookupSlot, 4, 1) \
+ F(DeclareLookupSlot, 2, 1) \
+ F(DeclareReadOnlyLookupSlot, 2, 1) \
F(InitializeLegacyConstLookupSlot, 3, 1) \
F(NewArguments, 1, 1) /* TODO(turbofan): Only temporary */ \
F(NewSloppyArguments, 3, 1) \
void LCodeGen::DoDeclareGlobals(LDeclareGlobals* instr) {
DCHECK(ToRegister(instr->context()).is(rsi));
- __ Push(rsi); // The context is the first argument.
__ Push(instr->hydrogen()->pairs());
__ Push(Smi::FromInt(instr->hydrogen()->flags()));
- CallRuntime(Runtime::kDeclareGlobals, 3, instr);
+ CallRuntime(Runtime::kDeclareGlobals, 2, instr);
}
void LCodeGen::DoDeclareGlobals(LDeclareGlobals* instr) {
DCHECK(ToRegister(instr->context()).is(esi));
- __ push(esi); // The context is the first argument.
__ push(Immediate(instr->hydrogen()->pairs()));
__ push(Immediate(Smi::FromInt(instr->hydrogen()->flags())));
- CallRuntime(Runtime::kDeclareGlobals, 3, instr);
+ CallRuntime(Runtime::kDeclareGlobals, 2, instr);
}