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/mips/full-codegen-mips.cc b/src/full-codegen/mips/full-codegen-mips.cc
index f329a23..e61c3e4 100644
--- a/src/full-codegen/mips/full-codegen-mips.cc
+++ b/src/full-codegen/mips/full-codegen-mips.cc
@@ -186,7 +186,8 @@
__ push(a1);
__ 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 {
@@ -242,7 +243,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.
@@ -305,7 +307,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());
@@ -318,7 +321,8 @@
{
Comment cmnt(masm_, "[ Stack check");
- PrepareForBailoutForId(BailoutId::Declarations(), NO_REGISTERS);
+ PrepareForBailoutForId(BailoutId::Declarations(),
+ BailoutState::NO_REGISTERS);
Label ok;
__ LoadRoot(at, Heap::kStackLimitRootIndex);
__ Branch(&ok, hs, sp, Operand(at));
@@ -397,11 +401,11 @@
EmitProfilingCounterReset();
__ 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(
@@ -459,6 +463,9 @@
}
}
+void FullCodeGenerator::RestoreContext() {
+ __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
+}
void FullCodeGenerator::StackValueContext::Plug(Variable* var) const {
DCHECK(var->IsStackAllocated() || var->IsContextSlot());
@@ -724,7 +731,7 @@
Label skip;
if (should_normalize) __ Branch(&skip);
- PrepareForBailout(expr, TOS_REG);
+ PrepareForBailout(expr, BailoutState::TOS_REGISTER);
if (should_normalize) {
__ LoadRoot(t0, Heap::kTrueValueRootIndex);
Split(eq, a0, Operand(t0), if_true, if_false, NULL);
@@ -758,15 +765,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:
@@ -785,7 +790,7 @@
__ LoadRoot(at, Heap::kTheHoleValueRootIndex);
__ sw(at, ContextMemOperand(cp, variable->index()));
// No write barrier since the_hole_value is in old space.
- PrepareForBailoutForId(proxy->id(), NO_REGISTERS);
+ PrepareForBailoutForId(proxy->id(), BailoutState::NO_REGISTERS);
}
break;
@@ -807,6 +812,7 @@
__ Push(a2, a0);
__ Push(Smi::FromInt(variable->DeclarationPropertyAttributes()));
__ CallRuntime(Runtime::kDeclareLookupSlot);
+ PrepareForBailoutForId(proxy->id(), BailoutState::NO_REGISTERS);
break;
}
}
@@ -852,7 +858,7 @@
kDontSaveFPRegs,
EMIT_REMEMBERED_SET,
OMIT_SMI_CHECK);
- PrepareForBailoutForId(proxy->id(), NO_REGISTERS);
+ PrepareForBailoutForId(proxy->id(), BailoutState::NO_REGISTERS);
break;
}
@@ -864,6 +870,7 @@
VisitForStackValue(declaration->fun());
PushOperand(Smi::FromInt(variable->DeclarationPropertyAttributes()));
CallRuntimeWithOperands(Runtime::kDeclareLookupSlot);
+ PrepareForBailoutForId(proxy->id(), BailoutState::NO_REGISTERS);
break;
}
}
@@ -895,7 +902,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.
@@ -945,7 +952,7 @@
Label skip;
__ Branch(&skip);
- PrepareForBailout(clause, TOS_REG);
+ PrepareForBailout(clause, BailoutState::TOS_REGISTER);
__ LoadRoot(at, Heap::kTrueValueRootIndex);
__ Branch(&next_test, ne, v0, Operand(at));
__ Drop(1);
@@ -972,12 +979,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);
}
@@ -1013,15 +1020,13 @@
__ CallStub(&stub);
__ mov(a0, v0);
__ bind(&done_convert);
- PrepareForBailoutForId(stmt->ToObjectId(), TOS_REG);
+ PrepareForBailoutForId(stmt->ToObjectId(), BailoutState::TOS_REGISTER);
__ push(a0);
- // 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);
@@ -1035,7 +1040,7 @@
__ bind(&call_runtime);
__ push(a0); // 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
@@ -1073,7 +1078,7 @@
__ Push(a1, v0); // Smi and array
__ lw(a1, FieldMemOperand(v0, FixedArray::kLengthOffset));
__ Push(a1); // Fixed array length (as smi).
- PrepareForBailoutForId(stmt->PrepareId(), NO_REGISTERS);
+ PrepareForBailoutForId(stmt->PrepareId(), BailoutState::NO_REGISTERS);
__ li(a0, Operand(Smi::FromInt(0)));
__ Push(a0); // Initial index.
@@ -1114,7 +1119,7 @@
// just skip it.
__ Push(a1, a3); // Enumerable and current entry.
__ CallRuntime(Runtime::kForInFilter);
- PrepareForBailoutForId(stmt->FilterId(), TOS_REG);
+ PrepareForBailoutForId(stmt->FilterId(), BailoutState::TOS_REGISTER);
__ mov(a3, result_register());
__ LoadRoot(at, Heap::kUndefinedValueRootIndex);
__ Branch(loop_statement.continue_label(), eq, a3, Operand(at));
@@ -1126,11 +1131,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());
@@ -1149,7 +1154,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();
}
@@ -1278,19 +1283,13 @@
} else if (var->mode() == DYNAMIC_LOCAL) {
Variable* local = var->local_if_not_shadowed();
__ lw(v0, ContextSlotOperandCheckExtensions(local, slow));
- if (local->mode() == LET || local->mode() == CONST ||
- local->mode() == CONST_LEGACY) {
+ if (local->mode() == LET || local->mode() == CONST) {
__ LoadRoot(at, Heap::kTheHoleValueRootIndex);
__ subu(at, v0, at); // Sub as compare: at == 0 on eq.
- if (local->mode() == CONST_LEGACY) {
- __ LoadRoot(a0, Heap::kUndefinedValueRootIndex);
- __ Movz(v0, a0, at); // Conditional move: return Undefined if TheHole.
- } else { // LET || CONST
- __ Branch(done, ne, at, Operand(zero_reg));
- __ li(a0, Operand(var->name()));
- __ push(a0);
- __ CallRuntime(Runtime::kThrowReferenceError);
- }
+ __ Branch(done, ne, at, Operand(zero_reg));
+ __ li(a0, Operand(var->name()));
+ __ push(a0);
+ __ CallRuntime(Runtime::kThrowReferenceError);
}
__ Branch(done);
}
@@ -1314,7 +1313,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
@@ -1348,11 +1347,6 @@
__ push(a0);
__ CallRuntime(Runtime::kThrowReferenceError);
__ bind(&done);
- } else {
- // Uninitialized legacy const bindings are unholed.
- DCHECK(var->mode() == CONST_LEGACY);
- __ LoadRoot(a0, Heap::kUndefinedValueRootIndex);
- __ Movz(v0, a0, at); // Conditional move: Undefined if TheHole.
}
context()->Plug(v0);
break;
@@ -1424,8 +1418,9 @@
} else {
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 v0.
@@ -1462,7 +1457,7 @@
__ lw(StoreDescriptor::ReceiverRegister(), MemOperand(sp));
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));
@@ -1496,7 +1491,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()) {
@@ -1553,7 +1548,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);
@@ -1625,7 +1620,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();
@@ -1657,7 +1652,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
@@ -1677,7 +1673,8 @@
VisitForStackValue(subexpr);
CallRuntimeWithOperands(Runtime::kAppendElement);
- PrepareForBailoutForId(expr->GetIdForElement(array_index), NO_REGISTERS);
+ PrepareForBailoutForId(expr->GetIdForElement(array_index),
+ BailoutState::NO_REGISTERS);
}
if (result_saved) {
@@ -1692,7 +1689,6 @@
DCHECK(expr->target()->IsValidReferenceExpressionOrThis());
Comment cmnt(masm_, "[ Assignment");
- SetExpressionPosition(expr, INSERT_BREAK);
Property* property = expr->target()->AsProperty();
LhsKind assign_type = Property::GetAssignType(property);
@@ -1761,23 +1757,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;
}
}
@@ -1797,7 +1797,7 @@
}
// 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());
}
@@ -1809,7 +1809,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(v0);
break;
case NAMED_PROPERTY:
@@ -1838,20 +1838,24 @@
// 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, v0 holds the generator object.
__ RecordGeneratorContinuation();
- __ pop(a1);
- __ Branch(&resume, ne, a1, Operand(Smi::FromInt(JSGeneratorObject::RETURN)));
- __ push(result_register());
+ __ lw(a1, FieldMemOperand(v0, JSGeneratorObject::kResumeModeOffset));
+ __ lw(v0, FieldMemOperand(v0, JSGeneratorObject::kInputOffset));
+ __ Branch(&resume, eq, a1, Operand(Smi::FromInt(JSGeneratorObject::kNext)));
+ __ Push(result_register());
+ __ Branch(&exception, eq, a1,
+ Operand(Smi::FromInt(JSGeneratorObject::kThrow)));
EmitCreateIteratorResult(true);
EmitUnwindAndReturn();
+ __ bind(&exception);
+ __ CallRuntime(Runtime::kThrow);
+
__ bind(&suspend);
OperandStackDepthIncrement(1); // Not popped on this path.
VisitForAccumulatorValue(expr->generator_object());
@@ -1866,7 +1870,7 @@
__ Branch(&post_runtime, eq, sp, Operand(a1));
__ push(v0); // generator object
__ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1);
- __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
+ RestoreContext();
__ bind(&post_runtime);
PopOperand(result_register());
EmitReturnSequence();
@@ -1875,103 +1879,6 @@
context()->Plug(result_register());
}
-
-void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
- Expression *value,
- JSGeneratorObject::ResumeMode resume_mode) {
- // The value stays in a0, 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.
- // a1 will hold the generator object until the activation has been resumed.
- VisitForStackValue(generator);
- VisitForAccumulatorValue(value);
- PopOperand(a1);
-
- // Store input value into generator object.
- __ sw(result_register(),
- FieldMemOperand(a1, JSGeneratorObject::kInputOffset));
- __ mov(a2, result_register());
- __ RecordWriteField(a1, JSGeneratorObject::kInputOffset, a2, a3,
- kRAHasBeenSaved, kDontSaveFPRegs);
-
- // Load suspended function and context.
- __ lw(cp, FieldMemOperand(a1, JSGeneratorObject::kContextOffset));
- __ lw(t0, FieldMemOperand(a1, JSGeneratorObject::kFunctionOffset));
-
- // Load receiver and store as the first argument.
- __ lw(a2, FieldMemOperand(a1, JSGeneratorObject::kReceiverOffset));
- __ push(a2);
-
- // 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.
- __ lw(a3, FieldMemOperand(t0, JSFunction::kSharedFunctionInfoOffset));
- __ lw(a3,
- FieldMemOperand(a3, SharedFunctionInfo::kFormalParameterCountOffset));
- __ LoadRoot(a2, Heap::kTheHoleValueRootIndex);
- Label push_argument_holes, push_frame;
- __ bind(&push_argument_holes);
- __ Subu(a3, a3, Operand(Smi::FromInt(1)));
- __ Branch(&push_frame, lt, a3, Operand(zero_reg));
- __ push(a2);
- __ 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);
- // ra = return address.
- // fp = caller's frame pointer.
- // cp = callee's context,
- // t0 = callee's JS function.
- __ PushStandardFrame(t0);
-
- // Load the operand stack size.
- __ lw(a3, FieldMemOperand(a1, JSGeneratorObject::kOperandStackOffset));
- __ lw(a3, FieldMemOperand(a3, FixedArray::kLengthOffset));
- __ SmiUntag(a3);
-
- // 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;
- __ Branch(&slow_resume, ne, a3, Operand(zero_reg));
- __ lw(a3, FieldMemOperand(t0, JSFunction::kCodeEntryOffset));
- __ lw(a2, FieldMemOperand(a1, JSGeneratorObject::kContinuationOffset));
- __ SmiUntag(a2);
- __ Addu(a3, a3, Operand(a2));
- __ li(a2, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting)));
- __ sw(a2, FieldMemOperand(a1, JSGeneratorObject::kContinuationOffset));
- __ Push(Smi::FromInt(resume_mode)); // Consumed in continuation.
- __ Jump(a3);
- __ 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);
- __ Subu(a3, a3, Operand(1));
- __ Branch(&call_resume, lt, a3, Operand(zero_reg));
- __ push(a2);
- __ Branch(&push_operand_holes);
- __ bind(&call_resume);
- __ Push(Smi::FromInt(resume_mode)); // Consumed in continuation.
- DCHECK(!result_register().is(a1));
- __ Push(a1, result_register());
- __ Push(Smi::FromInt(resume_mode));
- __ CallRuntime(Runtime::kResumeJSGeneratorObject);
- // Not reached: the runtime call returns elsewhere.
- __ stop("not-reached");
-
- __ bind(&done);
- context()->Plug(result_register());
-}
-
void FullCodeGenerator::PushOperands(Register reg1, Register reg2) {
OperandStackDepthIncrement(2);
__ Push(reg1, reg2);
@@ -2006,7 +1913,8 @@
void FullCodeGenerator::EmitCreateIteratorResult(bool done) {
Label allocate, done_allocate;
- __ Allocate(JSIteratorResult::kSize, v0, a2, a3, &allocate, TAG_OBJECT);
+ __ Allocate(JSIteratorResult::kSize, v0, a2, a3, &allocate,
+ NO_ALLOCATION_FLAGS);
__ jmp(&done_allocate);
__ bind(&allocate);
@@ -2333,8 +2241,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());
@@ -2356,24 +2263,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()) {
- __ li(a0, Operand(var->name()));
- __ Push(v0, cp, a0); // Context and name.
- __ CallRuntime(Runtime::kInitializeLegacyConstLookupSlot);
- } else {
- DCHECK(var->IsStackAllocated() || var->IsContextSlot());
- Label skip;
- MemOperand location = VarOperand(var, a1);
- __ lw(a2, location);
- __ LoadRoot(at, Heap::kTheHoleValueRootIndex);
- __ Branch(&skip, ne, a2, Operand(at));
- EmitStoreToStackLocalOrContextSlot(var, location);
- __ bind(&skip);
- }
-
} else {
DCHECK(var->mode() == CONST_LEGACY && op != Token::INIT);
if (is_strict(language_mode())) {
@@ -2397,7 +2286,7 @@
EmitLoadStoreICSlot(expr->AssignmentSlot());
CallStoreIC();
- PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
+ PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER);
context()->Plug(v0);
}
@@ -2448,44 +2337,7 @@
EmitLoadStoreICSlot(expr->AssignmentSlot());
CallIC(ic);
- PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
- context()->Plug(v0);
-}
-
-
-void FullCodeGenerator::VisitProperty(Property* expr) {
- Comment cmnt(masm_, "[ Property");
- SetExpressionPosition(expr);
-
- Expression* key = expr->key();
-
- if (key->IsPropertyName()) {
- if (!expr->IsSuperAccess()) {
- VisitForAccumulatorValue(expr->obj());
- __ Move(LoadDescriptor::ReceiverRegister(), v0);
- 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(), v0);
- 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(v0);
}
@@ -2506,7 +2358,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 method prologue if it
// is a sloppy mode method.
@@ -2519,7 +2371,8 @@
DCHECK(!callee->AsProperty()->IsSuperAccess());
__ lw(LoadDescriptor::ReceiverRegister(), MemOperand(sp, 0));
EmitNamedPropertyLoad(callee->AsProperty());
- PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG);
+ PrepareForBailoutForId(callee->AsProperty()->LoadId(),
+ BailoutState::TOS_REGISTER);
// Push the target function under the receiver.
__ lw(at, MemOperand(sp, 0));
PushOperand(at);
@@ -2556,6 +2409,7 @@
// - home_object
// - key
CallRuntimeWithOperands(Runtime::kLoadFromSuper);
+ PrepareForBailoutForId(prop->LoadId(), BailoutState::TOS_REGISTER);
// Replace home_object with target function.
__ sw(v0, MemOperand(sp, kPointerSize));
@@ -2580,7 +2434,8 @@
__ lw(LoadDescriptor::ReceiverRegister(), MemOperand(sp, 0));
__ Move(LoadDescriptor::NameRegister(), v0);
EmitKeyedPropertyLoad(callee->AsProperty());
- PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG);
+ PrepareForBailoutForId(callee->AsProperty()->LoadId(),
+ BailoutState::TOS_REGISTER);
// Push the target function under the receiver.
__ lw(at, MemOperand(sp, 0));
@@ -2614,6 +2469,7 @@
// - home_object
// - key
CallRuntimeWithOperands(Runtime::kLoadKeyedFromSuper);
+ PrepareForBailoutForId(prop->LoadId(), BailoutState::TOS_REGISTER);
// Replace home_object with target function.
__ sw(v0, MemOperand(sp, kPointerSize));
@@ -2633,7 +2489,7 @@
VisitForStackValue(args->at(i));
}
- PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
+ PrepareForBailoutForId(expr->CallId(), BailoutState::NO_REGISTERS);
// Record source position of the IC call.
SetCallPosition(expr, expr->tail_call_mode());
if (expr->tail_call_mode() == TailCallMode::kAllow) {
@@ -2655,31 +2511,33 @@
OperandStackDepthDecrement(arg_count + 1);
RecordJSReturnSite(expr);
- // Restore context register.
- __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
+ RestoreContext();
context()->DropAndPlug(1, v0);
}
-
-void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) {
- // t3: copy of the first argument or undefined if it doesn't exist.
+void FullCodeGenerator::EmitResolvePossiblyDirectEval(Call* expr) {
+ int arg_count = expr->arguments()->length();
+ // t4: copy of the first argument or undefined if it doesn't exist.
if (arg_count > 0) {
- __ lw(t3, MemOperand(sp, arg_count * kPointerSize));
+ __ lw(t4, MemOperand(sp, arg_count * kPointerSize));
} else {
- __ LoadRoot(t3, Heap::kUndefinedValueRootIndex);
+ __ LoadRoot(t4, Heap::kUndefinedValueRootIndex);
}
- // t2: the receiver of the enclosing function.
- __ lw(t2, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
+ // t3: the receiver of the enclosing function.
+ __ lw(t3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
- // t1: the language mode.
- __ li(t1, Operand(Smi::FromInt(language_mode())));
+ // t2: the language mode.
+ __ li(t2, Operand(Smi::FromInt(language_mode())));
- // t0: the start position of the scope the calls resides in.
- __ li(t0, Operand(Smi::FromInt(scope()->start_position())));
+ // t1: the start position of the scope the calls resides in.
+ __ li(t1, Operand(Smi::FromInt(scope()->start_position())));
+
+ // t0: the source position of the eval call.
+ __ li(t0, Operand(Smi::FromInt(expr->position())));
// Do the runtime call.
- __ Push(t3, t2, t1, t0);
+ __ Push(t4, t3, t2, t1, t0);
__ CallRuntime(Runtime::kResolvePossiblyDirectEval);
}
@@ -2701,7 +2559,7 @@
__ Push(callee->name());
__ CallRuntime(Runtime::kLoadLookupSlotForCall);
PushOperands(v0, v1); // Function, 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
@@ -2728,7 +2586,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();
@@ -2744,12 +2602,12 @@
// resolve eval.
__ lw(a1, MemOperand(sp, (arg_count + 1) * kPointerSize));
__ push(a1);
- EmitResolvePossiblyDirectEval(arg_count);
+ EmitResolvePossiblyDirectEval(expr);
// Touch up the stack with the resolved function.
__ sw(v0, MemOperand(sp, (arg_count + 1) * kPointerSize));
- PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS);
+ PrepareForBailoutForId(expr->EvalId(), BailoutState::NO_REGISTERS);
// Record source position for debugger.
SetCallPosition(expr);
__ lw(a1, MemOperand(sp, (arg_count + 1) * kPointerSize));
@@ -2759,8 +2617,7 @@
RelocInfo::CODE_TARGET);
OperandStackDepthDecrement(arg_count + 1);
RecordJSReturnSite(expr);
- // Restore context register.
- __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
+ RestoreContext();
context()->DropAndPlug(1, v0);
}
@@ -2799,9 +2656,8 @@
CallConstructStub stub(isolate());
__ Call(stub.GetCode(), RelocInfo::CODE_TARGET);
OperandStackDepthDecrement(arg_count + 1);
- PrepareForBailoutForId(expr->ReturnId(), TOS_REG);
- // Restore context register.
- __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
+ PrepareForBailoutForId(expr->ReturnId(), BailoutState::TOS_REGISTER);
+ RestoreContext();
context()->Plug(v0);
}
@@ -2844,9 +2700,7 @@
OperandStackDepthDecrement(arg_count + 1);
RecordJSReturnSite(expr);
-
- // Restore context register.
- __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
+ RestoreContext();
context()->Plug(v0);
}
@@ -3250,7 +3104,7 @@
for (Expression* const arg : *args) {
VisitForStackValue(arg);
}
- PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
+ PrepareForBailoutForId(expr->CallId(), BailoutState::NO_REGISTERS);
// Move target to a1.
int const argc = args->length() - 2;
__ lw(a1, MemOperand(sp, (argc + 1) * kPointerSize));
@@ -3258,8 +3112,7 @@
__ li(a0, Operand(argc));
__ Call(isolate()->builtins()->Call(), RelocInfo::CODE_TARGET);
OperandStackDepthDecrement(argc + 1);
- // Restore context register.
- __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
+ RestoreContext();
// Discard the function left on TOS.
context()->DropAndPlug(1, v0);
}
@@ -3310,12 +3163,6 @@
context()->Plug(v0);
}
-void FullCodeGenerator::EmitGetOrdinaryHasInstance(CallRuntime* expr) {
- DCHECK_EQ(0, expr->arguments()->length());
- __ LoadNativeContextSlot(Context::ORDINARY_HAS_INSTANCE_INDEX, v0);
- context()->Plug(v0);
-}
-
void FullCodeGenerator::EmitDebugIsActive(CallRuntime* expr) {
DCHECK(expr->arguments()->length() == 0);
ExternalReference debug_is_active =
@@ -3335,7 +3182,8 @@
Label runtime, done;
- __ Allocate(JSIteratorResult::kSize, v0, a2, a3, &runtime, TAG_OBJECT);
+ __ Allocate(JSIteratorResult::kSize, v0, a2, a3, &runtime,
+ NO_ALLOCATION_FLAGS);
__ LoadNativeContextSlot(Context::ITERATOR_RESULT_MAP_INDEX, a1);
__ Pop(a2, a3);
__ LoadRoot(t0, Heap::kEmptyFixedArrayRootIndex);
@@ -3376,9 +3224,7 @@
__ Call(isolate()->builtins()->Call(ConvertReceiverMode::kNullOrUndefined),
RelocInfo::CODE_TARGET);
OperandStackDepthDecrement(arg_count + 1);
-
- // Restore context register.
- __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
+ RestoreContext();
}
@@ -3462,12 +3308,14 @@
&materialize_true);
if (!context()->IsAccumulatorValue()) OperandStackDepthIncrement(1);
__ bind(&materialize_true);
- PrepareForBailoutForId(expr->MaterializeTrueId(), NO_REGISTERS);
+ PrepareForBailoutForId(expr->MaterializeTrueId(),
+ BailoutState::NO_REGISTERS);
__ LoadRoot(v0, Heap::kTrueValueRootIndex);
if (context()->IsStackValue()) __ push(v0);
__ jmp(&done);
__ bind(&materialize_false);
- PrepareForBailoutForId(expr->MaterializeFalseId(), NO_REGISTERS);
+ PrepareForBailoutForId(expr->MaterializeFalseId(),
+ BailoutState::NO_REGISTERS);
__ LoadRoot(v0, Heap::kFalseValueRootIndex);
if (context()->IsStackValue()) __ push(v0);
__ bind(&done);
@@ -3567,9 +3415,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.
@@ -3620,7 +3468,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()) {
@@ -3666,7 +3514,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(v0);
}
// For all contexts except EffectConstant we have the result on
@@ -3677,7 +3526,8 @@
} else {
EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(),
Token::ASSIGN, expr->CountSlot());
- PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
+ PrepareForBailoutForId(expr->AssignmentId(),
+ BailoutState::TOS_REGISTER);
context()->Plug(v0);
}
break;
@@ -3688,7 +3538,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();
@@ -3728,7 +3578,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();
@@ -3825,7 +3675,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.
@@ -3845,7 +3694,8 @@
switch (op) {
case Token::IN:
VisitForStackValue(expr->right());
- CallRuntimeWithOperands(Runtime::kHasProperty);
+ SetExpressionPosition(expr);
+ EmitHasProperty();
PrepareForBailoutBeforeSplit(expr, false, NULL, NULL);
__ LoadRoot(t0, Heap::kTrueValueRootIndex);
Split(eq, v0, Operand(t0), if_true, if_false, fall_through);
@@ -3853,6 +3703,7 @@
case Token::INSTANCEOF: {
VisitForAccumulatorValue(expr->right());
+ SetExpressionPosition(expr);
__ mov(a0, result_register());
PopOperand(a1);
InstanceOfStub stub(isolate());
@@ -3865,6 +3716,7 @@
default: {
VisitForAccumulatorValue(expr->right());
+ SetExpressionPosition(expr);
Condition cc = CompareIC::ComputeCondition(op);
__ mov(a0, result_register());
PopOperand(a1);