Merge V8 5.2.361.47 DO NOT MERGE
https://chromium.googlesource.com/v8/v8/+/5.2.361.47
FPIIM-449
Change-Id: Ibec421b85a9b88cb3a432ada642e469fe7e78346
(cherry picked from commit bcf72ee8e3b26f1d0726869c7ddb3921c68b09a8)
diff --git a/src/full-codegen/x64/full-codegen-x64.cc b/src/full-codegen/x64/full-codegen-x64.cc
index 992e7fe..1ef9cee 100644
--- a/src/full-codegen/x64/full-codegen-x64.cc
+++ b/src/full-codegen/x64/full-codegen-x64.cc
@@ -166,7 +166,8 @@
__ Push(rdi);
__ Push(info->scope()->GetScopeInfo(info->isolate()));
__ CallRuntime(Runtime::kNewScriptContext);
- PrepareForBailoutForId(BailoutId::ScriptContext(), TOS_REG);
+ PrepareForBailoutForId(BailoutId::ScriptContext(),
+ BailoutState::TOS_REGISTER);
// The new target value is not used, clobbering is safe.
DCHECK_NULL(info->scope()->new_target_var());
} else {
@@ -222,7 +223,8 @@
// Register holding this function and new target are both trashed in case we
// bailout here. But since that can happen only when new target is not used
// and we allocate a context, the value of |function_in_register| is correct.
- PrepareForBailoutForId(BailoutId::FunctionContext(), NO_REGISTERS);
+ PrepareForBailoutForId(BailoutId::FunctionContext(),
+ BailoutState::NO_REGISTERS);
// Possibly set up a local binding to the this function which is used in
// derived constructors with super calls.
@@ -286,7 +288,8 @@
// Visit the declarations and body unless there is an illegal
// redeclaration.
- PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS);
+ PrepareForBailoutForId(BailoutId::FunctionEntry(),
+ BailoutState::NO_REGISTERS);
{
Comment cmnt(masm_, "[ Declarations");
VisitDeclarations(scope()->declarations());
@@ -299,7 +302,8 @@
{
Comment cmnt(masm_, "[ Stack check");
- PrepareForBailoutForId(BailoutId::Declarations(), NO_REGISTERS);
+ PrepareForBailoutForId(BailoutId::Declarations(),
+ BailoutState::NO_REGISTERS);
Label ok;
__ CompareRoot(rsp, Heap::kStackLimitRootIndex);
__ j(above_equal, &ok, Label::kNear);
@@ -372,11 +376,11 @@
}
__ bind(&ok);
- PrepareForBailoutForId(stmt->EntryId(), NO_REGISTERS);
+ PrepareForBailoutForId(stmt->EntryId(), BailoutState::NO_REGISTERS);
// Record a mapping of the OSR id to this PC. This is used if the OSR
// entry becomes the target of a bailout. We don't expect it to be, but
// we want it to work if it is.
- PrepareForBailoutForId(stmt->OsrEntryId(), NO_REGISTERS);
+ PrepareForBailoutForId(stmt->OsrEntryId(), BailoutState::NO_REGISTERS);
}
void FullCodeGenerator::EmitProfilingCounterHandlingForReturnSequence(
@@ -425,6 +429,9 @@
}
}
+void FullCodeGenerator::RestoreContext() {
+ __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
+}
void FullCodeGenerator::StackValueContext::Plug(Variable* var) const {
DCHECK(var->IsStackAllocated() || var->IsContextSlot());
@@ -689,7 +696,7 @@
Label skip;
if (should_normalize) __ jmp(&skip, Label::kNear);
- PrepareForBailout(expr, TOS_REG);
+ PrepareForBailout(expr, BailoutState::TOS_REGISTER);
if (should_normalize) {
__ CompareRoot(rax, Heap::kTrueValueRootIndex);
Split(equal, if_true, if_false, NULL);
@@ -720,15 +727,13 @@
VariableProxy* proxy = declaration->proxy();
VariableMode mode = declaration->mode();
Variable* variable = proxy->var();
- bool hole_init = mode == LET || mode == CONST || mode == CONST_LEGACY;
+ bool hole_init = mode == LET || mode == CONST;
switch (variable->location()) {
case VariableLocation::GLOBAL:
case VariableLocation::UNALLOCATED:
+ DCHECK(!variable->binding_needs_init());
globals_->Add(variable->name(), zone());
- globals_->Add(variable->binding_needs_init()
- ? isolate()->factory()->the_hole_value()
- : isolate()->factory()->undefined_value(),
- zone());
+ globals_->Add(isolate()->factory()->undefined_value(), zone());
break;
case VariableLocation::PARAMETER:
@@ -747,7 +752,7 @@
__ LoadRoot(kScratchRegister, Heap::kTheHoleValueRootIndex);
__ movp(ContextOperand(rsi, variable->index()), kScratchRegister);
// No write barrier since the hole value is in old space.
- PrepareForBailoutForId(proxy->id(), NO_REGISTERS);
+ PrepareForBailoutForId(proxy->id(), BailoutState::NO_REGISTERS);
}
break;
@@ -767,6 +772,7 @@
}
__ Push(Smi::FromInt(variable->DeclarationPropertyAttributes()));
__ CallRuntime(Runtime::kDeclareLookupSlot);
+ PrepareForBailoutForId(proxy->id(), BailoutState::NO_REGISTERS);
break;
}
}
@@ -811,7 +817,7 @@
kDontSaveFPRegs,
EMIT_REMEMBERED_SET,
OMIT_SMI_CHECK);
- PrepareForBailoutForId(proxy->id(), NO_REGISTERS);
+ PrepareForBailoutForId(proxy->id(), BailoutState::NO_REGISTERS);
break;
}
@@ -821,6 +827,7 @@
VisitForStackValue(declaration->fun());
PushOperand(Smi::FromInt(variable->DeclarationPropertyAttributes()));
CallRuntimeWithOperands(Runtime::kDeclareLookupSlot);
+ PrepareForBailoutForId(proxy->id(), BailoutState::NO_REGISTERS);
break;
}
}
@@ -851,7 +858,7 @@
// Keep the switch value on the stack until a case matches.
VisitForStackValue(stmt->tag());
- PrepareForBailoutForId(stmt->EntryId(), NO_REGISTERS);
+ PrepareForBailoutForId(stmt->EntryId(), BailoutState::NO_REGISTERS);
ZoneList<CaseClause*>* clauses = stmt->cases();
CaseClause* default_clause = NULL; // Can occur anywhere in the list.
@@ -901,7 +908,7 @@
Label skip;
__ jmp(&skip, Label::kNear);
- PrepareForBailout(clause, TOS_REG);
+ PrepareForBailout(clause, BailoutState::TOS_REGISTER);
__ CompareRoot(rax, Heap::kTrueValueRootIndex);
__ j(not_equal, &next_test);
__ Drop(1);
@@ -929,12 +936,12 @@
Comment cmnt(masm_, "[ Case body");
CaseClause* clause = clauses->at(i);
__ bind(clause->body_target());
- PrepareForBailoutForId(clause->EntryId(), NO_REGISTERS);
+ PrepareForBailoutForId(clause->EntryId(), BailoutState::NO_REGISTERS);
VisitStatements(clause->statements());
}
__ bind(nested_statement.break_label());
- PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS);
+ PrepareForBailoutForId(stmt->ExitId(), BailoutState::NO_REGISTERS);
}
@@ -967,15 +974,13 @@
ToObjectStub stub(isolate());
__ CallStub(&stub);
__ bind(&done_convert);
- PrepareForBailoutForId(stmt->ToObjectId(), TOS_REG);
+ PrepareForBailoutForId(stmt->ToObjectId(), BailoutState::TOS_REGISTER);
__ Push(rax);
- // Check cache validity in generated code. This is a fast case for
- // the JSObject::IsSimpleEnum cache validity checks. If we cannot
- // guarantee cache validity, call the runtime system to check cache
- // validity or get the property names in a fixed array.
- // Note: Proxies never have an enum cache, so will always take the
- // slow path.
+ // Check cache validity in generated code. If we cannot guarantee cache
+ // validity, call the runtime system to check cache validity or get the
+ // property names in a fixed array. Note: Proxies never have an enum cache,
+ // so will always take the slow path.
Label call_runtime;
__ CheckEnumCache(&call_runtime);
@@ -989,7 +994,7 @@
__ bind(&call_runtime);
__ Push(rax); // Duplicate the enumerable object on the stack.
__ CallRuntime(Runtime::kForInEnumerate);
- PrepareForBailoutForId(stmt->EnumId(), TOS_REG);
+ PrepareForBailoutForId(stmt->EnumId(), BailoutState::TOS_REGISTER);
// If we got a map from the runtime call, we can do a fast
// modification check. Otherwise, we got a fixed array, and we have
@@ -1031,7 +1036,7 @@
__ Push(rax); // Array
__ movp(rax, FieldOperand(rax, FixedArray::kLengthOffset));
__ Push(rax); // Fixed array length (as smi).
- PrepareForBailoutForId(stmt->PrepareId(), NO_REGISTERS);
+ PrepareForBailoutForId(stmt->PrepareId(), BailoutState::NO_REGISTERS);
__ Push(Smi::FromInt(0)); // Initial index.
// Generate code for doing the condition check.
@@ -1073,7 +1078,7 @@
__ Push(rcx); // Enumerable.
__ Push(rbx); // Current entry.
__ CallRuntime(Runtime::kForInFilter);
- PrepareForBailoutForId(stmt->FilterId(), TOS_REG);
+ PrepareForBailoutForId(stmt->FilterId(), BailoutState::TOS_REGISTER);
__ CompareRoot(rax, Heap::kUndefinedValueRootIndex);
__ j(equal, loop_statement.continue_label());
__ movp(rbx, rax);
@@ -1085,11 +1090,11 @@
// Perform the assignment as if via '='.
{ EffectContext context(this);
EmitAssignment(stmt->each(), stmt->EachFeedbackSlot());
- PrepareForBailoutForId(stmt->AssignmentId(), NO_REGISTERS);
+ PrepareForBailoutForId(stmt->AssignmentId(), BailoutState::NO_REGISTERS);
}
// Both Crankshaft and Turbofan expect BodyId to be right before stmt->body().
- PrepareForBailoutForId(stmt->BodyId(), NO_REGISTERS);
+ PrepareForBailoutForId(stmt->BodyId(), BailoutState::NO_REGISTERS);
// Generate code for the body of the loop.
Visit(stmt->body());
@@ -1106,7 +1111,7 @@
DropOperands(5);
// Exit and decrement the loop depth.
- PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS);
+ PrepareForBailoutForId(stmt->ExitId(), BailoutState::NO_REGISTERS);
__ bind(&exit);
decrement_loop_depth();
}
@@ -1237,16 +1242,11 @@
} else if (var->mode() == DYNAMIC_LOCAL) {
Variable* local = var->local_if_not_shadowed();
__ movp(rax, ContextSlotOperandCheckExtensions(local, slow));
- if (local->mode() == LET || local->mode() == CONST ||
- local->mode() == CONST_LEGACY) {
+ if (local->mode() == LET || local->mode() == CONST) {
__ CompareRoot(rax, Heap::kTheHoleValueRootIndex);
__ j(not_equal, done);
- if (local->mode() == CONST_LEGACY) {
- __ LoadRoot(rax, Heap::kUndefinedValueRootIndex);
- } else { // LET || CONST
- __ Push(var->name());
- __ CallRuntime(Runtime::kThrowReferenceError);
- }
+ __ Push(var->name());
+ __ CallRuntime(Runtime::kThrowReferenceError);
}
__ jmp(done);
}
@@ -1270,7 +1270,7 @@
TypeofMode typeof_mode) {
// Record position before possible IC call.
SetExpressionPosition(proxy);
- PrepareForBailoutForId(proxy->BeforeId(), NO_REGISTERS);
+ PrepareForBailoutForId(proxy->BeforeId(), BailoutState::NO_REGISTERS);
Variable* var = proxy->var();
// Three cases: global variables, lookup variables, and all other types of
@@ -1301,10 +1301,6 @@
// binding in harmony mode.
__ Push(var->name());
__ CallRuntime(Runtime::kThrowReferenceError);
- } else {
- // Uninitialized legacy const bindings are unholed.
- DCHECK(var->mode() == CONST_LEGACY);
- __ LoadRoot(rax, Heap::kUndefinedValueRootIndex);
}
__ bind(&done);
context()->Plug(rax);
@@ -1382,8 +1378,9 @@
__ Move(rdx, Smi::FromInt(flags));
FastCloneShallowObjectStub stub(isolate(), expr->properties_count());
__ CallStub(&stub);
+ RestoreContext();
}
- PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG);
+ PrepareForBailoutForId(expr->CreateLiteralId(), BailoutState::TOS_REGISTER);
// If result_saved is true the result is on top of the stack. If
// result_saved is false the result is in rax.
@@ -1419,7 +1416,7 @@
__ movp(StoreDescriptor::ReceiverRegister(), Operand(rsp, 0));
EmitLoadStoreICSlot(property->GetSlot(0));
CallStoreIC();
- PrepareForBailoutForId(key->id(), NO_REGISTERS);
+ PrepareForBailoutForId(key->id(), BailoutState::NO_REGISTERS);
if (NeedsHomeObject(value)) {
EmitSetHomeObjectAccumulator(value, 0, property->GetSlot(1));
@@ -1448,7 +1445,7 @@
DCHECK(property->emit_store());
CallRuntimeWithOperands(Runtime::kInternalSetPrototype);
PrepareForBailoutForId(expr->GetIdForPropertySet(property_index),
- NO_REGISTERS);
+ BailoutState::NO_REGISTERS);
break;
case ObjectLiteral::Property::GETTER:
if (property->emit_store()) {
@@ -1502,7 +1499,7 @@
DCHECK(property->emit_store());
CallRuntimeWithOperands(Runtime::kInternalSetPrototype);
PrepareForBailoutForId(expr->GetIdForPropertySet(property_index),
- NO_REGISTERS);
+ BailoutState::NO_REGISTERS);
} else {
EmitPropertyKey(property, expr->GetIdForPropertyName(property_index));
VisitForStackValue(value);
@@ -1575,7 +1572,7 @@
FastCloneShallowArrayStub stub(isolate(), allocation_site_mode);
__ CallStub(&stub);
}
- PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG);
+ PrepareForBailoutForId(expr->CreateLiteralId(), BailoutState::TOS_REGISTER);
bool result_saved = false; // Is the result saved to the stack?
ZoneList<Expression*>* subexprs = expr->values();
@@ -1605,7 +1602,8 @@
CodeFactory::KeyedStoreIC(isolate(), language_mode()).code();
CallIC(ic);
- PrepareForBailoutForId(expr->GetIdForElement(array_index), NO_REGISTERS);
+ PrepareForBailoutForId(expr->GetIdForElement(array_index),
+ BailoutState::NO_REGISTERS);
}
// In case the array literal contains spread expressions it has two parts. The
@@ -1625,7 +1623,8 @@
VisitForStackValue(subexpr);
CallRuntimeWithOperands(Runtime::kAppendElement);
- PrepareForBailoutForId(expr->GetIdForElement(array_index), NO_REGISTERS);
+ PrepareForBailoutForId(expr->GetIdForElement(array_index),
+ BailoutState::NO_REGISTERS);
}
if (result_saved) {
@@ -1640,7 +1639,6 @@
DCHECK(expr->target()->IsValidReferenceExpressionOrThis());
Comment cmnt(masm_, "[ Assignment");
- SetExpressionPosition(expr, INSERT_BREAK);
Property* property = expr->target()->AsProperty();
LhsKind assign_type = Property::GetAssignType(property);
@@ -1704,23 +1702,27 @@
switch (assign_type) {
case VARIABLE:
EmitVariableLoad(expr->target()->AsVariableProxy());
- PrepareForBailout(expr->target(), TOS_REG);
+ PrepareForBailout(expr->target(), BailoutState::TOS_REGISTER);
break;
case NAMED_PROPERTY:
EmitNamedPropertyLoad(property);
- PrepareForBailoutForId(property->LoadId(), TOS_REG);
+ PrepareForBailoutForId(property->LoadId(),
+ BailoutState::TOS_REGISTER);
break;
case NAMED_SUPER_PROPERTY:
EmitNamedSuperPropertyLoad(property);
- PrepareForBailoutForId(property->LoadId(), TOS_REG);
+ PrepareForBailoutForId(property->LoadId(),
+ BailoutState::TOS_REGISTER);
break;
case KEYED_SUPER_PROPERTY:
EmitKeyedSuperPropertyLoad(property);
- PrepareForBailoutForId(property->LoadId(), TOS_REG);
+ PrepareForBailoutForId(property->LoadId(),
+ BailoutState::TOS_REGISTER);
break;
case KEYED_PROPERTY:
EmitKeyedPropertyLoad(property);
- PrepareForBailoutForId(property->LoadId(), TOS_REG);
+ PrepareForBailoutForId(property->LoadId(),
+ BailoutState::TOS_REGISTER);
break;
}
}
@@ -1739,7 +1741,7 @@
EmitBinaryOp(expr->binary_operation(), op);
}
// Deoptimization point in case the binary operation may have side effects.
- PrepareForBailout(expr->binary_operation(), TOS_REG);
+ PrepareForBailout(expr->binary_operation(), BailoutState::TOS_REGISTER);
} else {
VisitForAccumulatorValue(expr->value());
}
@@ -1751,7 +1753,7 @@
case VARIABLE:
EmitVariableAssignment(expr->target()->AsVariableProxy()->var(),
expr->op(), expr->AssignmentSlot());
- PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
+ PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER);
context()->Plug(rax);
break;
case NAMED_PROPERTY:
@@ -1780,21 +1782,26 @@
// this. It stays on the stack while we update the iterator.
VisitForStackValue(expr->expression());
- Label suspend, continuation, post_runtime, resume;
+ Label suspend, continuation, post_runtime, resume, exception;
__ jmp(&suspend);
__ bind(&continuation);
- // When we arrive here, the stack top is the resume mode and
- // result_register() holds the input value (the argument given to the
- // respective resume operation).
+ // When we arrive here, rax holds the generator object.
__ RecordGeneratorContinuation();
- __ Pop(rbx);
- __ SmiCompare(rbx, Smi::FromInt(JSGeneratorObject::RETURN));
- __ j(not_equal, &resume);
+ __ movp(rbx, FieldOperand(rax, JSGeneratorObject::kResumeModeOffset));
+ __ movp(rax, FieldOperand(rax, JSGeneratorObject::kInputOffset));
+ STATIC_ASSERT(JSGeneratorObject::kNext < JSGeneratorObject::kReturn);
+ STATIC_ASSERT(JSGeneratorObject::kThrow > JSGeneratorObject::kReturn);
+ __ SmiCompare(rbx, Smi::FromInt(JSGeneratorObject::kReturn));
+ __ j(less, &resume);
__ Push(result_register());
+ __ j(greater, &exception);
EmitCreateIteratorResult(true);
EmitUnwindAndReturn();
+ __ bind(&exception);
+ __ CallRuntime(Runtime::kThrow);
+
__ bind(&suspend);
OperandStackDepthIncrement(1); // Not popped on this path.
VisitForAccumulatorValue(expr->generator_object());
@@ -1810,8 +1817,7 @@
__ j(equal, &post_runtime);
__ Push(rax); // generator object
__ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1);
- __ movp(context_register(),
- Operand(rbp, StandardFrameConstants::kContextOffset));
+ RestoreContext();
__ bind(&post_runtime);
PopOperand(result_register());
@@ -1821,102 +1827,6 @@
context()->Plug(result_register());
}
-
-void FullCodeGenerator::EmitGeneratorResume(
- Expression* generator, Expression* value,
- JSGeneratorObject::ResumeMode resume_mode) {
- // The value stays in rax, and is ultimately read by the resumed generator, as
- // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it
- // is read to throw the value when the resumed generator is already closed.
- // rbx will hold the generator object until the activation has been resumed.
- VisitForStackValue(generator);
- VisitForAccumulatorValue(value);
- PopOperand(rbx);
-
- // Store input value into generator object.
- __ movp(FieldOperand(rbx, JSGeneratorObject::kInputOffset),
- result_register());
- __ movp(rcx, result_register());
- __ RecordWriteField(rbx, JSGeneratorObject::kInputOffset, rcx, rdx,
- kDontSaveFPRegs);
-
- // Load suspended function and context.
- __ movp(rsi, FieldOperand(rbx, JSGeneratorObject::kContextOffset));
- __ movp(rdi, FieldOperand(rbx, JSGeneratorObject::kFunctionOffset));
-
- // Push receiver.
- __ Push(FieldOperand(rbx, JSGeneratorObject::kReceiverOffset));
-
- // Push holes for arguments to generator function. Since the parser forced
- // context allocation for any variables in generators, the actual argument
- // values have already been copied into the context and these dummy values
- // will never be used.
- __ movp(rdx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset));
- __ LoadSharedFunctionInfoSpecialField(rdx, rdx,
- SharedFunctionInfo::kFormalParameterCountOffset);
- __ LoadRoot(rcx, Heap::kTheHoleValueRootIndex);
- Label push_argument_holes, push_frame;
- __ bind(&push_argument_holes);
- __ subp(rdx, Immediate(1));
- __ j(carry, &push_frame);
- __ Push(rcx);
- __ jmp(&push_argument_holes);
-
- // Enter a new JavaScript frame, and initialize its slots as they were when
- // the generator was suspended.
- Label resume_frame, done;
- __ bind(&push_frame);
- __ call(&resume_frame);
- __ jmp(&done);
- __ bind(&resume_frame);
- __ pushq(rbp); // Caller's frame pointer.
- __ movp(rbp, rsp);
- __ Push(rsi); // Callee's context.
- __ Push(rdi); // Callee's JS Function.
-
- // Load the operand stack size.
- __ movp(rdx, FieldOperand(rbx, JSGeneratorObject::kOperandStackOffset));
- __ movp(rdx, FieldOperand(rdx, FixedArray::kLengthOffset));
- __ SmiToInteger32(rdx, rdx);
-
- // If we are sending a value and there is no operand stack, we can jump back
- // in directly.
- if (resume_mode == JSGeneratorObject::NEXT) {
- Label slow_resume;
- __ cmpp(rdx, Immediate(0));
- __ j(not_zero, &slow_resume);
- __ movp(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset));
- __ SmiToInteger64(rcx,
- FieldOperand(rbx, JSGeneratorObject::kContinuationOffset));
- __ addp(rdx, rcx);
- __ Move(FieldOperand(rbx, JSGeneratorObject::kContinuationOffset),
- Smi::FromInt(JSGeneratorObject::kGeneratorExecuting));
- __ Push(Smi::FromInt(resume_mode)); // Consumed in continuation.
- __ jmp(rdx);
- __ bind(&slow_resume);
- }
-
- // Otherwise, we push holes for the operand stack and call the runtime to fix
- // up the stack and the handlers.
- Label push_operand_holes, call_resume;
- __ bind(&push_operand_holes);
- __ subp(rdx, Immediate(1));
- __ j(carry, &call_resume);
- __ Push(rcx);
- __ jmp(&push_operand_holes);
- __ bind(&call_resume);
- __ Push(Smi::FromInt(resume_mode)); // Consumed in continuation.
- __ Push(rbx);
- __ Push(result_register());
- __ Push(Smi::FromInt(resume_mode));
- __ CallRuntime(Runtime::kResumeJSGeneratorObject);
- // Not reached: the runtime call returns elsewhere.
- __ Abort(kGeneratorFailedToResume);
-
- __ bind(&done);
- context()->Plug(result_register());
-}
-
void FullCodeGenerator::PushOperand(MemOperand operand) {
OperandStackDepthIncrement(1);
__ Push(operand);
@@ -1936,7 +1846,8 @@
void FullCodeGenerator::EmitCreateIteratorResult(bool done) {
Label allocate, done_allocate;
- __ Allocate(JSIteratorResult::kSize, rax, rcx, rdx, &allocate, TAG_OBJECT);
+ __ Allocate(JSIteratorResult::kSize, rax, rcx, rdx, &allocate,
+ NO_ALLOCATION_FLAGS);
__ jmp(&done_allocate, Label::kNear);
__ bind(&allocate);
@@ -2222,8 +2133,7 @@
__ bind(&uninitialized_this);
EmitStoreToStackLocalOrContextSlot(var, location);
- } else if (!var->is_const_mode() ||
- (var->mode() == CONST && op == Token::INIT)) {
+ } else if (!var->is_const_mode() || op == Token::INIT) {
if (var->IsLookupSlot()) {
// Assignment to var.
__ Push(var->name());
@@ -2245,25 +2155,6 @@
EmitStoreToStackLocalOrContextSlot(var, location);
}
- } else if (var->mode() == CONST_LEGACY && op == Token::INIT) {
- // Const initializers need a write barrier.
- DCHECK(!var->IsParameter()); // No const parameters.
- if (var->IsLookupSlot()) {
- __ Push(rax);
- __ Push(rsi);
- __ Push(var->name());
- __ CallRuntime(Runtime::kInitializeLegacyConstLookupSlot);
- } else {
- DCHECK(var->IsStackLocal() || var->IsContextSlot());
- Label skip;
- MemOperand location = VarOperand(var, rcx);
- __ movp(rdx, location);
- __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex);
- __ j(not_equal, &skip);
- EmitStoreToStackLocalOrContextSlot(var, location);
- __ bind(&skip);
- }
-
} else {
DCHECK(var->mode() == CONST_LEGACY && op != Token::INIT);
if (is_strict(language_mode())) {
@@ -2285,7 +2176,7 @@
EmitLoadStoreICSlot(expr->AssignmentSlot());
CallStoreIC();
- PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
+ PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER);
context()->Plug(rax);
}
@@ -2329,45 +2220,7 @@
EmitLoadStoreICSlot(expr->AssignmentSlot());
CallIC(ic);
- PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
- context()->Plug(rax);
-}
-
-
-void FullCodeGenerator::VisitProperty(Property* expr) {
- Comment cmnt(masm_, "[ Property");
- SetExpressionPosition(expr);
-
- Expression* key = expr->key();
-
- if (key->IsPropertyName()) {
- if (!expr->IsSuperAccess()) {
- VisitForAccumulatorValue(expr->obj());
- DCHECK(!rax.is(LoadDescriptor::ReceiverRegister()));
- __ movp(LoadDescriptor::ReceiverRegister(), rax);
- EmitNamedPropertyLoad(expr);
- } else {
- VisitForStackValue(expr->obj()->AsSuperPropertyReference()->this_var());
- VisitForStackValue(
- expr->obj()->AsSuperPropertyReference()->home_object());
- EmitNamedSuperPropertyLoad(expr);
- }
- } else {
- if (!expr->IsSuperAccess()) {
- VisitForStackValue(expr->obj());
- VisitForAccumulatorValue(expr->key());
- __ Move(LoadDescriptor::NameRegister(), rax);
- PopOperand(LoadDescriptor::ReceiverRegister());
- EmitKeyedPropertyLoad(expr);
- } else {
- VisitForStackValue(expr->obj()->AsSuperPropertyReference()->this_var());
- VisitForStackValue(
- expr->obj()->AsSuperPropertyReference()->home_object());
- VisitForStackValue(expr->key());
- EmitKeyedSuperPropertyLoad(expr);
- }
- }
- PrepareForBailoutForId(expr->LoadId(), TOS_REG);
+ PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER);
context()->Plug(rax);
}
@@ -2388,7 +2241,7 @@
if (callee->IsVariableProxy()) {
{ StackValueContext context(this);
EmitVariableLoad(callee->AsVariableProxy());
- PrepareForBailout(callee, NO_REGISTERS);
+ PrepareForBailout(callee, BailoutState::NO_REGISTERS);
}
// Push undefined as receiver. This is patched in the Call builtin if it
// is a sloppy mode method.
@@ -2400,7 +2253,8 @@
DCHECK(!callee->AsProperty()->IsSuperAccess());
__ movp(LoadDescriptor::ReceiverRegister(), Operand(rsp, 0));
EmitNamedPropertyLoad(callee->AsProperty());
- PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG);
+ PrepareForBailoutForId(callee->AsProperty()->LoadId(),
+ BailoutState::TOS_REGISTER);
// Push the target function under the receiver.
PushOperand(Operand(rsp, 0));
__ movp(Operand(rsp, kPointerSize), rax);
@@ -2436,6 +2290,7 @@
// - home_object
// - key
CallRuntimeWithOperands(Runtime::kLoadFromSuper);
+ PrepareForBailoutForId(prop->LoadId(), BailoutState::TOS_REGISTER);
// Replace home_object with target function.
__ movp(Operand(rsp, kPointerSize), rax);
@@ -2460,7 +2315,8 @@
__ movp(LoadDescriptor::ReceiverRegister(), Operand(rsp, 0));
__ Move(LoadDescriptor::NameRegister(), rax);
EmitKeyedPropertyLoad(callee->AsProperty());
- PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG);
+ PrepareForBailoutForId(callee->AsProperty()->LoadId(),
+ BailoutState::TOS_REGISTER);
// Push the target function under the receiver.
PushOperand(Operand(rsp, 0));
@@ -2493,6 +2349,7 @@
// - home_object
// - key
CallRuntimeWithOperands(Runtime::kLoadKeyedFromSuper);
+ PrepareForBailoutForId(prop->LoadId(), BailoutState::TOS_REGISTER);
// Replace home_object with target function.
__ movp(Operand(rsp, kPointerSize), rax);
@@ -2512,7 +2369,7 @@
VisitForStackValue(args->at(i));
}
- PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
+ PrepareForBailoutForId(expr->CallId(), BailoutState::NO_REGISTERS);
SetCallPosition(expr, expr->tail_call_mode());
if (expr->tail_call_mode() == TailCallMode::kAllow) {
if (FLAG_trace) {
@@ -2533,15 +2390,13 @@
OperandStackDepthDecrement(arg_count + 1);
RecordJSReturnSite(expr);
-
- // Restore context register.
- __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
+ RestoreContext();
// Discard the function left on TOS.
context()->DropAndPlug(1, rax);
}
-
-void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) {
+void FullCodeGenerator::EmitResolvePossiblyDirectEval(Call* expr) {
+ int arg_count = expr->arguments()->length();
// Push copy of the first argument or undefined if it doesn't exist.
if (arg_count > 0) {
__ Push(Operand(rsp, arg_count * kPointerSize));
@@ -2558,6 +2413,9 @@
// Push the start position of the scope the calls resides in.
__ Push(Smi::FromInt(scope()->start_position()));
+ // Push the source position of the eval call.
+ __ Push(Smi::FromInt(expr->position()));
+
// Do the runtime call.
__ CallRuntime(Runtime::kResolvePossiblyDirectEval);
}
@@ -2579,7 +2437,7 @@
__ CallRuntime(Runtime::kLoadLookupSlotForCall);
PushOperand(rax); // Function.
PushOperand(rdx); // Receiver.
- PrepareForBailoutForId(expr->LookupId(), NO_REGISTERS);
+ PrepareForBailoutForId(expr->LookupId(), BailoutState::NO_REGISTERS);
// If fast case code has been generated, emit code to push the function
// and receiver and have the slow path jump around this code.
@@ -2605,7 +2463,7 @@
void FullCodeGenerator::EmitPossiblyEvalCall(Call* expr) {
- // In a call to eval, we first call RuntimeHidden_ResolvePossiblyDirectEval
+ // In a call to eval, we first call Runtime_ResolvePossiblyDirectEval
// to resolve the function we need to call. Then we call the resolved
// function using the given arguments.
ZoneList<Expression*>* args = expr->arguments();
@@ -2620,12 +2478,12 @@
// Push a copy of the function (found below the arguments) and resolve
// eval.
__ Push(Operand(rsp, (arg_count + 1) * kPointerSize));
- EmitResolvePossiblyDirectEval(arg_count);
+ EmitResolvePossiblyDirectEval(expr);
// Touch up the callee.
__ movp(Operand(rsp, (arg_count + 1) * kPointerSize), rax);
- PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS);
+ PrepareForBailoutForId(expr->EvalId(), BailoutState::NO_REGISTERS);
SetCallPosition(expr);
__ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize));
@@ -2635,8 +2493,7 @@
RelocInfo::CODE_TARGET);
OperandStackDepthDecrement(arg_count + 1);
RecordJSReturnSite(expr);
- // Restore context register.
- __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
+ RestoreContext();
context()->DropAndPlug(1, rax);
}
@@ -2675,9 +2532,8 @@
CallConstructStub stub(isolate());
__ Call(stub.GetCode(), RelocInfo::CODE_TARGET);
OperandStackDepthDecrement(arg_count + 1);
- PrepareForBailoutForId(expr->ReturnId(), TOS_REG);
- // Restore context register.
- __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
+ PrepareForBailoutForId(expr->ReturnId(), BailoutState::TOS_REGISTER);
+ RestoreContext();
context()->Plug(rax);
}
@@ -2718,10 +2574,7 @@
OperandStackDepthDecrement(arg_count + 1);
RecordJSReturnSite(expr);
-
- // Restore context register.
- __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
-
+ RestoreContext();
context()->Plug(rax);
}
@@ -3113,7 +2966,7 @@
for (Expression* const arg : *args) {
VisitForStackValue(arg);
}
- PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
+ PrepareForBailoutForId(expr->CallId(), BailoutState::NO_REGISTERS);
// Move target to rdi.
int const argc = args->length() - 2;
__ movp(rdi, Operand(rsp, (argc + 1) * kPointerSize));
@@ -3121,8 +2974,7 @@
__ Set(rax, argc);
__ Call(isolate()->builtins()->Call(), RelocInfo::CODE_TARGET);
OperandStackDepthDecrement(argc + 1);
- // Restore context register.
- __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
+ RestoreContext();
// Discard the function left on TOS.
context()->DropAndPlug(1, rax);
}
@@ -3176,12 +3028,6 @@
context()->Plug(rax);
}
-void FullCodeGenerator::EmitGetOrdinaryHasInstance(CallRuntime* expr) {
- DCHECK_EQ(0, expr->arguments()->length());
- __ LoadNativeContextSlot(Context::ORDINARY_HAS_INSTANCE_INDEX, rax);
- context()->Plug(rax);
-}
-
void FullCodeGenerator::EmitDebugIsActive(CallRuntime* expr) {
DCHECK(expr->arguments()->length() == 0);
ExternalReference debug_is_active =
@@ -3201,7 +3047,8 @@
Label runtime, done;
- __ Allocate(JSIteratorResult::kSize, rax, rcx, rdx, &runtime, TAG_OBJECT);
+ __ Allocate(JSIteratorResult::kSize, rax, rcx, rdx, &runtime,
+ NO_ALLOCATION_FLAGS);
__ LoadNativeContextSlot(Context::ITERATOR_RESULT_MAP_INDEX, rbx);
__ movp(FieldOperand(rax, HeapObject::kMapOffset), rbx);
__ LoadRoot(rbx, Heap::kEmptyFixedArrayRootIndex);
@@ -3241,9 +3088,7 @@
__ Call(isolate()->builtins()->Call(ConvertReceiverMode::kNullOrUndefined),
RelocInfo::CODE_TARGET);
OperandStackDepthDecrement(arg_count + 1);
-
- // Restore context register.
- __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
+ RestoreContext();
}
@@ -3328,7 +3173,8 @@
&materialize_true);
if (!context()->IsAccumulatorValue()) OperandStackDepthIncrement(1);
__ bind(&materialize_true);
- PrepareForBailoutForId(expr->MaterializeTrueId(), NO_REGISTERS);
+ PrepareForBailoutForId(expr->MaterializeTrueId(),
+ BailoutState::NO_REGISTERS);
if (context()->IsAccumulatorValue()) {
__ LoadRoot(rax, Heap::kTrueValueRootIndex);
} else {
@@ -3336,7 +3182,8 @@
}
__ jmp(&done, Label::kNear);
__ bind(&materialize_false);
- PrepareForBailoutForId(expr->MaterializeFalseId(), NO_REGISTERS);
+ PrepareForBailoutForId(expr->MaterializeFalseId(),
+ BailoutState::NO_REGISTERS);
if (context()->IsAccumulatorValue()) {
__ LoadRoot(rax, Heap::kFalseValueRootIndex);
} else {
@@ -3435,9 +3282,9 @@
// We need a second deoptimization point after loading the value
// in case evaluating the property load my have a side effect.
if (assign_type == VARIABLE) {
- PrepareForBailout(expr->expression(), TOS_REG);
+ PrepareForBailout(expr->expression(), BailoutState::TOS_REGISTER);
} else {
- PrepareForBailoutForId(prop->LoadId(), TOS_REG);
+ PrepareForBailoutForId(prop->LoadId(), BailoutState::TOS_REGISTER);
}
// Inline smi case if we are in a loop.
@@ -3490,7 +3337,7 @@
// Convert old value into a number.
ToNumberStub convert_stub(isolate());
__ CallStub(&convert_stub);
- PrepareForBailoutForId(expr->ToNumberId(), TOS_REG);
+ PrepareForBailoutForId(expr->ToNumberId(), BailoutState::TOS_REGISTER);
// Save result for postfix expressions.
if (expr->is_postfix()) {
@@ -3538,7 +3385,8 @@
{ EffectContext context(this);
EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(),
Token::ASSIGN, expr->CountSlot());
- PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
+ PrepareForBailoutForId(expr->AssignmentId(),
+ BailoutState::TOS_REGISTER);
context.Plug(rax);
}
// For all contexts except kEffect: We have the result on
@@ -3550,7 +3398,8 @@
// Perform the assignment as if via '='.
EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(),
Token::ASSIGN, expr->CountSlot());
- PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
+ PrepareForBailoutForId(expr->AssignmentId(),
+ BailoutState::TOS_REGISTER);
context()->Plug(rax);
}
break;
@@ -3560,7 +3409,7 @@
PopOperand(StoreDescriptor::ReceiverRegister());
EmitLoadStoreICSlot(expr->CountSlot());
CallStoreIC();
- PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
+ PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER);
if (expr->is_postfix()) {
if (!context()->IsEffect()) {
context()->PlugTOS();
@@ -3599,7 +3448,7 @@
CodeFactory::KeyedStoreIC(isolate(), language_mode()).code();
EmitLoadStoreICSlot(expr->CountSlot());
CallIC(ic);
- PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
+ PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER);
if (expr->is_postfix()) {
if (!context()->IsEffect()) {
context()->PlugTOS();
@@ -3695,7 +3544,6 @@
void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) {
Comment cmnt(masm_, "[ CompareOperation");
- SetExpressionPosition(expr);
// First we try a fast inlined version of the compare when one of
// the operands is a literal.
@@ -3715,7 +3563,8 @@
switch (op) {
case Token::IN:
VisitForStackValue(expr->right());
- CallRuntimeWithOperands(Runtime::kHasProperty);
+ SetExpressionPosition(expr);
+ EmitHasProperty();
PrepareForBailoutBeforeSplit(expr, false, NULL, NULL);
__ CompareRoot(rax, Heap::kTrueValueRootIndex);
Split(equal, if_true, if_false, fall_through);
@@ -3723,6 +3572,7 @@
case Token::INSTANCEOF: {
VisitForAccumulatorValue(expr->right());
+ SetExpressionPosition(expr);
PopOperand(rdx);
InstanceOfStub stub(isolate());
__ CallStub(&stub);
@@ -3734,6 +3584,7 @@
default: {
VisitForAccumulatorValue(expr->right());
+ SetExpressionPosition(expr);
Condition cc = CompareIC::ComputeCondition(op);
PopOperand(rdx);