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/ppc/full-codegen-ppc.cc b/src/full-codegen/ppc/full-codegen-ppc.cc
index 301ccf5..50248c1 100644
--- a/src/full-codegen/ppc/full-codegen-ppc.cc
+++ b/src/full-codegen/ppc/full-codegen-ppc.cc
@@ -182,7 +182,8 @@
__ push(r4);
__ 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 {
@@ -238,7 +239,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.
@@ -300,7 +302,8 @@
}
// Visit the declarations and body.
- PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS);
+ PrepareForBailoutForId(BailoutId::FunctionEntry(),
+ BailoutState::NO_REGISTERS);
{
Comment cmnt(masm_, "[ Declarations");
VisitDeclarations(scope()->declarations());
@@ -313,7 +316,8 @@
{
Comment cmnt(masm_, "[ Stack check");
- PrepareForBailoutForId(BailoutId::Declarations(), NO_REGISTERS);
+ PrepareForBailoutForId(BailoutId::Declarations(),
+ BailoutState::NO_REGISTERS);
Label ok;
__ LoadRoot(ip, Heap::kStackLimitRootIndex);
__ cmpl(sp, ip);
@@ -390,11 +394,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(
@@ -450,6 +454,9 @@
}
}
+void FullCodeGenerator::RestoreContext() {
+ __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
+}
void FullCodeGenerator::StackValueContext::Plug(Variable* var) const {
DCHECK(var->IsStackAllocated() || var->IsContextSlot());
@@ -690,7 +697,7 @@
Label skip;
if (should_normalize) __ b(&skip);
- PrepareForBailout(expr, TOS_REG);
+ PrepareForBailout(expr, BailoutState::TOS_REGISTER);
if (should_normalize) {
__ LoadRoot(ip, Heap::kTrueValueRootIndex);
__ cmp(r3, ip);
@@ -723,15 +730,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:
@@ -750,7 +755,7 @@
__ LoadRoot(ip, Heap::kTheHoleValueRootIndex);
__ StoreP(ip, ContextMemOperand(cp, variable->index()), r0);
// No write barrier since the_hole_value is in old space.
- PrepareForBailoutForId(proxy->id(), NO_REGISTERS);
+ PrepareForBailoutForId(proxy->id(), BailoutState::NO_REGISTERS);
}
break;
@@ -771,6 +776,7 @@
__ Push(r5, r3);
__ Push(Smi::FromInt(variable->DeclarationPropertyAttributes()));
__ CallRuntime(Runtime::kDeclareLookupSlot);
+ PrepareForBailoutForId(proxy->id(), BailoutState::NO_REGISTERS);
break;
}
}
@@ -812,7 +818,7 @@
__ RecordWriteContextSlot(cp, offset, result_register(), r5,
kLRHasBeenSaved, kDontSaveFPRegs,
EMIT_REMEMBERED_SET, OMIT_SMI_CHECK);
- PrepareForBailoutForId(proxy->id(), NO_REGISTERS);
+ PrepareForBailoutForId(proxy->id(), BailoutState::NO_REGISTERS);
break;
}
@@ -824,6 +830,7 @@
VisitForStackValue(declaration->fun());
PushOperand(Smi::FromInt(variable->DeclarationPropertyAttributes()));
CallRuntimeWithOperands(Runtime::kDeclareLookupSlot);
+ PrepareForBailoutForId(proxy->id(), BailoutState::NO_REGISTERS);
break;
}
}
@@ -855,7 +862,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.
@@ -904,7 +911,7 @@
Label skip;
__ b(&skip);
- PrepareForBailout(clause, TOS_REG);
+ PrepareForBailout(clause, BailoutState::TOS_REGISTER);
__ LoadRoot(ip, Heap::kTrueValueRootIndex);
__ cmp(r3, ip);
__ bne(&next_test);
@@ -933,12 +940,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);
}
@@ -971,15 +978,13 @@
ToObjectStub stub(isolate());
__ CallStub(&stub);
__ bind(&done_convert);
- PrepareForBailoutForId(stmt->ToObjectId(), TOS_REG);
+ PrepareForBailoutForId(stmt->ToObjectId(), BailoutState::TOS_REGISTER);
__ push(r3);
- // 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);
@@ -993,7 +998,7 @@
__ bind(&call_runtime);
__ push(r3); // 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
@@ -1035,7 +1040,7 @@
__ Push(r4, r3); // Smi and array
__ LoadP(r4, FieldMemOperand(r3, FixedArray::kLengthOffset));
__ Push(r4); // Fixed array length (as smi).
- PrepareForBailoutForId(stmt->PrepareId(), NO_REGISTERS);
+ PrepareForBailoutForId(stmt->PrepareId(), BailoutState::NO_REGISTERS);
__ LoadSmiLiteral(r3, Smi::FromInt(0));
__ Push(r3); // Initial index.
@@ -1079,7 +1084,7 @@
// just skip it.
__ Push(r4, r6); // Enumerable and current entry.
__ CallRuntime(Runtime::kForInFilter);
- PrepareForBailoutForId(stmt->FilterId(), TOS_REG);
+ PrepareForBailoutForId(stmt->FilterId(), BailoutState::TOS_REGISTER);
__ mr(r6, r3);
__ LoadRoot(r0, Heap::kUndefinedValueRootIndex);
__ cmp(r3, r0);
@@ -1093,11 +1098,11 @@
{
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());
@@ -1116,7 +1121,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();
}
@@ -1246,17 +1251,12 @@
} else if (var->mode() == DYNAMIC_LOCAL) {
Variable* local = var->local_if_not_shadowed();
__ LoadP(r3, ContextSlotOperandCheckExtensions(local, slow));
- if (local->mode() == LET || local->mode() == CONST ||
- local->mode() == CONST_LEGACY) {
+ if (local->mode() == LET || local->mode() == CONST) {
__ CompareRoot(r3, Heap::kTheHoleValueRootIndex);
__ bne(done);
- if (local->mode() == CONST_LEGACY) {
- __ LoadRoot(r3, Heap::kUndefinedValueRootIndex);
- } else { // LET || CONST
- __ mov(r3, Operand(var->name()));
- __ push(r3);
- __ CallRuntime(Runtime::kThrowReferenceError);
- }
+ __ mov(r3, Operand(var->name()));
+ __ push(r3);
+ __ CallRuntime(Runtime::kThrowReferenceError);
}
__ b(done);
}
@@ -1280,7 +1280,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
@@ -1312,10 +1312,6 @@
__ mov(r3, Operand(var->name()));
__ push(r3);
__ CallRuntime(Runtime::kThrowReferenceError);
- } else {
- // Uninitialized legacy const bindings are unholed.
- DCHECK(var->mode() == CONST_LEGACY);
- __ LoadRoot(r3, Heap::kUndefinedValueRootIndex);
}
__ bind(&done);
context()->Plug(r3);
@@ -1389,8 +1385,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 r3.
@@ -1426,7 +1423,7 @@
__ LoadP(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));
@@ -1460,7 +1457,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()) {
@@ -1516,7 +1513,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);
@@ -1589,7 +1586,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();
@@ -1619,7 +1616,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
@@ -1639,7 +1637,8 @@
VisitForStackValue(subexpr);
CallRuntimeWithOperands(Runtime::kAppendElement);
- PrepareForBailoutForId(expr->GetIdForElement(array_index), NO_REGISTERS);
+ PrepareForBailoutForId(expr->GetIdForElement(array_index),
+ BailoutState::NO_REGISTERS);
}
if (result_saved) {
@@ -1654,7 +1653,6 @@
DCHECK(expr->target()->IsValidReferenceExpressionOrThis());
Comment cmnt(masm_, "[ Assignment");
- SetExpressionPosition(expr, INSERT_BREAK);
Property* property = expr->target()->AsProperty();
LhsKind assign_type = Property::GetAssignType(property);
@@ -1723,23 +1721,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;
}
}
@@ -1757,7 +1759,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());
}
@@ -1769,7 +1771,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(r3);
break;
case NAMED_PROPERTY:
@@ -1798,21 +1800,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;
__ b(&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, r3 holds the generator object.
__ RecordGeneratorContinuation();
- __ pop(r4);
- __ CmpSmiLiteral(r4, Smi::FromInt(JSGeneratorObject::RETURN), r0);
- __ bne(&resume);
- __ push(result_register());
+ __ LoadP(r4, FieldMemOperand(r3, JSGeneratorObject::kResumeModeOffset));
+ __ LoadP(r3, FieldMemOperand(r3, JSGeneratorObject::kInputOffset));
+ STATIC_ASSERT(JSGeneratorObject::kNext < JSGeneratorObject::kReturn);
+ STATIC_ASSERT(JSGeneratorObject::kThrow > JSGeneratorObject::kReturn);
+ __ CmpSmiLiteral(r4, Smi::FromInt(JSGeneratorObject::kReturn), r0);
+ __ blt(&resume);
+ __ Push(result_register());
+ __ bgt(&exception);
EmitCreateIteratorResult(true);
EmitUnwindAndReturn();
+ __ bind(&exception);
+ __ CallRuntime(Runtime::kThrow);
+
__ bind(&suspend);
OperandStackDepthIncrement(1); // Not popped on this path.
VisitForAccumulatorValue(expr->generator_object());
@@ -1829,7 +1836,7 @@
__ beq(&post_runtime);
__ push(r3); // generator object
__ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1);
- __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
+ RestoreContext();
__ bind(&post_runtime);
PopOperand(result_register());
EmitReturnSequence();
@@ -1838,120 +1845,6 @@
context()->Plug(result_register());
}
-
-void FullCodeGenerator::EmitGeneratorResume(
- Expression* generator, Expression* value,
- JSGeneratorObject::ResumeMode resume_mode) {
- // The value stays in r3, 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.
- // r4 will hold the generator object until the activation has been resumed.
- VisitForStackValue(generator);
- VisitForAccumulatorValue(value);
- PopOperand(r4);
-
- // Store input value into generator object.
- __ StoreP(result_register(),
- FieldMemOperand(r4, JSGeneratorObject::kInputOffset), r0);
- __ mr(r5, result_register());
- __ RecordWriteField(r4, JSGeneratorObject::kInputOffset, r5, r6,
- kLRHasBeenSaved, kDontSaveFPRegs);
-
- // Load suspended function and context.
- __ LoadP(cp, FieldMemOperand(r4, JSGeneratorObject::kContextOffset));
- __ LoadP(r7, FieldMemOperand(r4, JSGeneratorObject::kFunctionOffset));
-
- // Load receiver and store as the first argument.
- __ LoadP(r5, FieldMemOperand(r4, JSGeneratorObject::kReceiverOffset));
- __ push(r5);
-
- // 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.
- __ LoadP(r6, FieldMemOperand(r7, JSFunction::kSharedFunctionInfoOffset));
- __ LoadWordArith(
- r6, FieldMemOperand(r6, SharedFunctionInfo::kFormalParameterCountOffset));
- __ LoadRoot(r5, Heap::kTheHoleValueRootIndex);
- Label argument_loop, push_frame;
-#if V8_TARGET_ARCH_PPC64
- __ cmpi(r6, Operand::Zero());
- __ beq(&push_frame);
-#else
- __ SmiUntag(r6, SetRC);
- __ beq(&push_frame, cr0);
-#endif
- __ mtctr(r6);
- __ bind(&argument_loop);
- __ push(r5);
- __ bdnz(&argument_loop);
-
- // Enter a new JavaScript frame, and initialize its slots as they were when
- // the generator was suspended.
- Label resume_frame, done;
- __ bind(&push_frame);
- __ b(&resume_frame, SetLK);
- __ b(&done);
- __ bind(&resume_frame);
- // lr = return address.
- // fp = caller's frame pointer.
- // cp = callee's context,
- // r7 = callee's JS function.
- __ PushStandardFrame(r7);
-
- // Load the operand stack size.
- __ LoadP(r6, FieldMemOperand(r4, JSGeneratorObject::kOperandStackOffset));
- __ LoadP(r6, FieldMemOperand(r6, FixedArray::kLengthOffset));
- __ SmiUntag(r6, SetRC);
-
- // If we are sending a value and there is no operand stack, we can jump back
- // in directly.
- Label call_resume;
- if (resume_mode == JSGeneratorObject::NEXT) {
- Label slow_resume;
- __ bne(&slow_resume, cr0);
- __ LoadP(ip, FieldMemOperand(r7, JSFunction::kCodeEntryOffset));
- {
- ConstantPoolUnavailableScope constant_pool_unavailable(masm_);
- if (FLAG_enable_embedded_constant_pool) {
- __ LoadConstantPoolPointerRegisterFromCodeTargetAddress(ip);
- }
- __ LoadP(r5, FieldMemOperand(r4, JSGeneratorObject::kContinuationOffset));
- __ SmiUntag(r5);
- __ add(ip, ip, r5);
- __ LoadSmiLiteral(r5,
- Smi::FromInt(JSGeneratorObject::kGeneratorExecuting));
- __ StoreP(r5, FieldMemOperand(r4, JSGeneratorObject::kContinuationOffset),
- r0);
- __ Push(Smi::FromInt(resume_mode)); // Consumed in continuation.
- __ Jump(ip);
- __ bind(&slow_resume);
- }
- } else {
- __ beq(&call_resume, cr0);
- }
-
- // Otherwise, we push holes for the operand stack and call the runtime to fix
- // up the stack and the handlers.
- Label operand_loop;
- __ mtctr(r6);
- __ bind(&operand_loop);
- __ push(r5);
- __ bdnz(&operand_loop);
-
- __ bind(&call_resume);
- __ Push(Smi::FromInt(resume_mode)); // Consumed in continuation.
- DCHECK(!result_register().is(r4));
- __ Push(r4, 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);
@@ -1987,7 +1880,8 @@
void FullCodeGenerator::EmitCreateIteratorResult(bool done) {
Label allocate, done_allocate;
- __ Allocate(JSIteratorResult::kSize, r3, r5, r6, &allocate, TAG_OBJECT);
+ __ Allocate(JSIteratorResult::kSize, r3, r5, r6, &allocate,
+ NO_ALLOCATION_FLAGS);
__ b(&done_allocate);
__ bind(&allocate);
@@ -2346,8 +2240,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());
@@ -2368,25 +2261,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(r3);
- __ mov(r3, Operand(var->name()));
- __ Push(cp, r3); // Context and name.
- __ CallRuntime(Runtime::kInitializeLegacyConstLookupSlot);
- } else {
- DCHECK(var->IsStackAllocated() || var->IsContextSlot());
- Label skip;
- MemOperand location = VarOperand(var, r4);
- __ LoadP(r5, location);
- __ CompareRoot(r5, Heap::kTheHoleValueRootIndex);
- __ bne(&skip);
- EmitStoreToStackLocalOrContextSlot(var, location);
- __ bind(&skip);
- }
-
} else {
DCHECK(var->mode() == CONST_LEGACY && op != Token::INIT);
if (is_strict(language_mode())) {
@@ -2409,7 +2283,7 @@
EmitLoadStoreICSlot(expr->AssignmentSlot());
CallStoreIC();
- PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
+ PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER);
context()->Plug(r3);
}
@@ -2454,44 +2328,7 @@
EmitLoadStoreICSlot(expr->AssignmentSlot());
CallIC(ic);
- PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
- context()->Plug(r3);
-}
-
-
-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(), r3);
- 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(), r3);
- 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(r3);
}
@@ -2512,7 +2349,7 @@
{
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.
@@ -2525,7 +2362,8 @@
DCHECK(!callee->AsProperty()->IsSuperAccess());
__ LoadP(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.
__ LoadP(r0, MemOperand(sp, 0));
PushOperand(r0);
@@ -2562,6 +2400,7 @@
// - home_object
// - key
CallRuntimeWithOperands(Runtime::kLoadFromSuper);
+ PrepareForBailoutForId(prop->LoadId(), BailoutState::TOS_REGISTER);
// Replace home_object with target function.
__ StoreP(r3, MemOperand(sp, kPointerSize));
@@ -2585,7 +2424,8 @@
__ LoadP(LoadDescriptor::ReceiverRegister(), MemOperand(sp, 0));
__ Move(LoadDescriptor::NameRegister(), r3);
EmitKeyedPropertyLoad(callee->AsProperty());
- PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG);
+ PrepareForBailoutForId(callee->AsProperty()->LoadId(),
+ BailoutState::TOS_REGISTER);
// Push the target function under the receiver.
__ LoadP(ip, MemOperand(sp, 0));
@@ -2619,6 +2459,7 @@
// - home_object
// - key
CallRuntimeWithOperands(Runtime::kLoadKeyedFromSuper);
+ PrepareForBailoutForId(prop->LoadId(), BailoutState::TOS_REGISTER);
// Replace home_object with target function.
__ StoreP(r3, MemOperand(sp, kPointerSize));
@@ -2638,7 +2479,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) {
@@ -2659,13 +2500,13 @@
OperandStackDepthDecrement(arg_count + 1);
RecordJSReturnSite(expr);
- // Restore context register.
- __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
+ RestoreContext();
context()->DropAndPlug(1, r3);
}
-void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) {
+void FullCodeGenerator::EmitResolvePossiblyDirectEval(Call* expr) {
+ int arg_count = expr->arguments()->length();
// r7: copy of the first argument or undefined if it doesn't exist.
if (arg_count > 0) {
__ LoadP(r7, MemOperand(sp, arg_count * kPointerSize), r0);
@@ -2682,8 +2523,11 @@
// r4: the start position of the scope the calls resides in.
__ LoadSmiLiteral(r4, Smi::FromInt(scope()->start_position()));
+ // r3: the source position of the eval call.
+ __ LoadSmiLiteral(r3, Smi::FromInt(expr->position()));
+
// Do the runtime call.
- __ Push(r7, r6, r5, r4);
+ __ Push(r7, r6, r5, r4, r3);
__ CallRuntime(Runtime::kResolvePossiblyDirectEval);
}
@@ -2704,7 +2548,7 @@
__ Push(callee->name());
__ CallRuntime(Runtime::kLoadLookupSlotForCall);
PushOperands(r3, r4); // 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 code.
@@ -2731,9 +2575,9 @@
void FullCodeGenerator::EmitPossiblyEvalCall(Call* expr) {
- // In a call to eval, we first call RuntimeHidden_ResolvePossiblyDirectEval
- // to resolve the function we need to call. Then we call the resolved
- // function using the given arguments.
+ // 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();
int arg_count = args->length();
@@ -2748,12 +2592,12 @@
// resolve eval.
__ LoadP(r4, MemOperand(sp, (arg_count + 1) * kPointerSize), r0);
__ push(r4);
- EmitResolvePossiblyDirectEval(arg_count);
+ EmitResolvePossiblyDirectEval(expr);
// Touch up the stack with the resolved function.
__ StoreP(r3, MemOperand(sp, (arg_count + 1) * kPointerSize), r0);
- PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS);
+ PrepareForBailoutForId(expr->EvalId(), BailoutState::NO_REGISTERS);
// Record source position for debugger.
SetCallPosition(expr);
@@ -2764,8 +2608,7 @@
RelocInfo::CODE_TARGET);
OperandStackDepthDecrement(arg_count + 1);
RecordJSReturnSite(expr);
- // Restore context register.
- __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
+ RestoreContext();
context()->DropAndPlug(1, r3);
}
@@ -2804,9 +2647,8 @@
CallConstructStub stub(isolate());
__ Call(stub.GetCode(), RelocInfo::CODE_TARGET);
OperandStackDepthDecrement(arg_count + 1);
- PrepareForBailoutForId(expr->ReturnId(), TOS_REG);
- // Restore context register.
- __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
+ PrepareForBailoutForId(expr->ReturnId(), BailoutState::TOS_REGISTER);
+ RestoreContext();
context()->Plug(r3);
}
@@ -2849,9 +2691,7 @@
OperandStackDepthDecrement(arg_count + 1);
RecordJSReturnSite(expr);
-
- // Restore context register.
- __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
+ RestoreContext();
context()->Plug(r3);
}
@@ -3230,7 +3070,7 @@
for (Expression* const arg : *args) {
VisitForStackValue(arg);
}
- PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
+ PrepareForBailoutForId(expr->CallId(), BailoutState::NO_REGISTERS);
// Move target to r4.
int const argc = args->length() - 2;
__ LoadP(r4, MemOperand(sp, (argc + 1) * kPointerSize));
@@ -3238,8 +3078,7 @@
__ mov(r3, Operand(argc));
__ Call(isolate()->builtins()->Call(), RelocInfo::CODE_TARGET);
OperandStackDepthDecrement(argc + 1);
- // Restore context register.
- __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
+ RestoreContext();
// Discard the function left on TOS.
context()->DropAndPlug(1, r3);
}
@@ -3291,12 +3130,6 @@
context()->Plug(r3);
}
-void FullCodeGenerator::EmitGetOrdinaryHasInstance(CallRuntime* expr) {
- DCHECK_EQ(0, expr->arguments()->length());
- __ LoadNativeContextSlot(Context::ORDINARY_HAS_INSTANCE_INDEX, r3);
- context()->Plug(r3);
-}
-
void FullCodeGenerator::EmitDebugIsActive(CallRuntime* expr) {
DCHECK(expr->arguments()->length() == 0);
ExternalReference debug_is_active =
@@ -3316,7 +3149,8 @@
Label runtime, done;
- __ Allocate(JSIteratorResult::kSize, r3, r5, r6, &runtime, TAG_OBJECT);
+ __ Allocate(JSIteratorResult::kSize, r3, r5, r6, &runtime,
+ NO_ALLOCATION_FLAGS);
__ LoadNativeContextSlot(Context::ITERATOR_RESULT_MAP_INDEX, r4);
__ Pop(r5, r6);
__ LoadRoot(r7, Heap::kEmptyFixedArrayRootIndex);
@@ -3357,9 +3191,7 @@
__ Call(isolate()->builtins()->Call(ConvertReceiverMode::kNullOrUndefined),
RelocInfo::CODE_TARGET);
OperandStackDepthDecrement(arg_count + 1);
-
- // Restore context register.
- __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
+ RestoreContext();
}
@@ -3439,12 +3271,14 @@
&materialize_true, &materialize_true);
if (!context()->IsAccumulatorValue()) OperandStackDepthIncrement(1);
__ bind(&materialize_true);
- PrepareForBailoutForId(expr->MaterializeTrueId(), NO_REGISTERS);
+ PrepareForBailoutForId(expr->MaterializeTrueId(),
+ BailoutState::NO_REGISTERS);
__ LoadRoot(r3, Heap::kTrueValueRootIndex);
if (context()->IsStackValue()) __ push(r3);
__ b(&done);
__ bind(&materialize_false);
- PrepareForBailoutForId(expr->MaterializeFalseId(), NO_REGISTERS);
+ PrepareForBailoutForId(expr->MaterializeFalseId(),
+ BailoutState::NO_REGISTERS);
__ LoadRoot(r3, Heap::kFalseValueRootIndex);
if (context()->IsStackValue()) __ push(r3);
__ bind(&done);
@@ -3544,9 +3378,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.
@@ -3598,7 +3432,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()) {
@@ -3645,7 +3479,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(r3);
}
// For all contexts except EffectConstant We have the result on
@@ -3656,7 +3491,8 @@
} else {
EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(),
Token::ASSIGN, expr->CountSlot());
- PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
+ PrepareForBailoutForId(expr->AssignmentId(),
+ BailoutState::TOS_REGISTER);
context()->Plug(r3);
}
break;
@@ -3666,7 +3502,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();
@@ -3705,7 +3541,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();
@@ -3804,7 +3640,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.
@@ -3824,7 +3659,8 @@
switch (op) {
case Token::IN:
VisitForStackValue(expr->right());
- CallRuntimeWithOperands(Runtime::kHasProperty);
+ SetExpressionPosition(expr);
+ EmitHasProperty();
PrepareForBailoutBeforeSplit(expr, false, NULL, NULL);
__ CompareRoot(r3, Heap::kTrueValueRootIndex);
Split(eq, if_true, if_false, fall_through);
@@ -3832,6 +3668,7 @@
case Token::INSTANCEOF: {
VisitForAccumulatorValue(expr->right());
+ SetExpressionPosition(expr);
PopOperand(r4);
InstanceOfStub stub(isolate());
__ CallStub(&stub);
@@ -3843,6 +3680,7 @@
default: {
VisitForAccumulatorValue(expr->right());
+ SetExpressionPosition(expr);
Condition cond = CompareIC::ComputeCondition(op);
PopOperand(r4);