Upgrade V8 to 5.1.281.57 DO NOT MERGE
FPIIM-449
Change-Id: Id981b686b4d587ac31697662eb98bb34be42ad90
(cherry picked from commit 3b9bc31999c9787eb726ecdbfd5796bfdec32a18)
diff --git a/src/full-codegen/x64/full-codegen-x64.cc b/src/full-codegen/x64/full-codegen-x64.cc
index 910b2cf..992e7fe 100644
--- a/src/full-codegen/x64/full-codegen-x64.cc
+++ b/src/full-codegen/x64/full-codegen-x64.cc
@@ -286,35 +286,32 @@
// Visit the declarations and body unless there is an illegal
// redeclaration.
- if (scope()->HasIllegalRedeclaration()) {
+ PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS);
+ {
Comment cmnt(masm_, "[ Declarations");
- VisitForEffect(scope()->GetIllegalRedeclaration());
+ VisitDeclarations(scope()->declarations());
+ }
- } else {
- PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS);
- { Comment cmnt(masm_, "[ Declarations");
- VisitDeclarations(scope()->declarations());
- }
+ // Assert that the declarations do not use ICs. Otherwise the debugger
+ // won't be able to redirect a PC at an IC to the correct IC in newly
+ // recompiled code.
+ DCHECK_EQ(0, ic_total_count_);
- // Assert that the declarations do not use ICs. Otherwise the debugger
- // won't be able to redirect a PC at an IC to the correct IC in newly
- // recompiled code.
- DCHECK_EQ(0, ic_total_count_);
+ {
+ Comment cmnt(masm_, "[ Stack check");
+ PrepareForBailoutForId(BailoutId::Declarations(), NO_REGISTERS);
+ Label ok;
+ __ CompareRoot(rsp, Heap::kStackLimitRootIndex);
+ __ j(above_equal, &ok, Label::kNear);
+ __ call(isolate()->builtins()->StackCheck(), RelocInfo::CODE_TARGET);
+ __ bind(&ok);
+ }
- { Comment cmnt(masm_, "[ Stack check");
- PrepareForBailoutForId(BailoutId::Declarations(), NO_REGISTERS);
- Label ok;
- __ CompareRoot(rsp, Heap::kStackLimitRootIndex);
- __ j(above_equal, &ok, Label::kNear);
- __ call(isolate()->builtins()->StackCheck(), RelocInfo::CODE_TARGET);
- __ bind(&ok);
- }
-
- { Comment cmnt(masm_, "[ Body");
- DCHECK(loop_depth() == 0);
- VisitStatements(literal()->body());
- DCHECK(loop_depth() == 0);
- }
+ {
+ Comment cmnt(masm_, "[ Body");
+ DCHECK(loop_depth() == 0);
+ VisitStatements(literal()->body());
+ DCHECK(loop_depth() == 0);
}
// Always emit a 'return undefined' in case control fell off the end of
@@ -500,7 +497,7 @@
true,
true_label_,
false_label_);
- DCHECK(lit->IsNull() || lit->IsUndefined() || !lit->IsUndetectableObject());
+ DCHECK(lit->IsNull() || lit->IsUndefined() || !lit->IsUndetectable());
if (lit->IsUndefined() || lit->IsNull() || lit->IsFalse()) {
if (false_label_ != fall_through_) __ jmp(false_label_);
} else if (lit->IsTrue() || lit->IsJSObject()) {
@@ -606,7 +603,7 @@
Label* if_true,
Label* if_false,
Label* fall_through) {
- Handle<Code> ic = ToBooleanStub::GetUninitialized(isolate());
+ Handle<Code> ic = ToBooleanICStub::GetUninitialized(isolate());
CallIC(ic, condition->test_id());
__ CompareRoot(result_register(), Heap::kTrueValueRootIndex);
Split(equal, if_true, if_false, fall_through);
@@ -947,14 +944,14 @@
FeedbackVectorSlot slot = stmt->ForInFeedbackSlot();
- Label loop, exit;
- ForIn loop_statement(this, stmt);
- increment_loop_depth();
-
// Get the object to enumerate over.
SetExpressionAsStatementPosition(stmt->enumerable());
VisitForAccumulatorValue(stmt->enumerable());
- OperandStackDepthIncrement(ForIn::kElementCount);
+ OperandStackDepthIncrement(5);
+
+ Label loop, exit;
+ Iteration loop_statement(this, stmt);
+ increment_loop_depth();
// If the object is null or undefined, skip over the loop, otherwise convert
// it to a JS receiver. See ECMA-262 version 5, section 12.6.4.
@@ -1029,11 +1026,6 @@
// We got a fixed array in register rax. Iterate through that.
__ bind(&fixed_array);
- // No need for a write barrier, we are storing a Smi in the feedback vector.
- int const vector_index = SmiFromSlot(slot)->value();
- __ EmitLoadTypeFeedbackVector(rbx);
- __ Move(FieldOperand(rbx, FixedArray::OffsetOfElementAt(vector_index)),
- TypeFeedbackVector::MegamorphicSentinel(isolate()));
__ movp(rcx, Operand(rsp, 0 * kPointerSize)); // Get enumerated object
__ Push(Smi::FromInt(1)); // Smi(1) indicates slow check
__ Push(rax); // Array
@@ -1069,12 +1061,8 @@
__ cmpp(rdx, FieldOperand(rcx, HeapObject::kMapOffset));
__ j(equal, &update_each, Label::kNear);
- // We might get here from TurboFan or Crankshaft when something in the
- // for-in loop body deopts and only now notice in fullcodegen, that we
- // can now longer use the enum cache, i.e. left fast mode. So better record
- // this information here, in case we later OSR back into this loop or
- // reoptimize the whole function w/o rerunning the loop with the slow
- // mode object in fullcodegen (which would result in a deopt loop).
+ // We need to filter the key, record slow-path here.
+ int const vector_index = SmiFromSlot(slot)->value();
__ EmitLoadTypeFeedbackVector(rdx);
__ Move(FieldOperand(rdx, FixedArray::OffsetOfElementAt(vector_index)),
TypeFeedbackVector::MegamorphicSentinel(isolate()));
@@ -1115,8 +1103,7 @@
// Remove the pointers stored on the stack.
__ bind(loop_statement.break_label());
- __ addp(rsp, Immediate(5 * kPointerSize));
- OperandStackDepthDecrement(ForIn::kElementCount);
+ DropOperands(5);
// Exit and decrement the loop depth.
PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS);
@@ -1125,31 +1112,6 @@
}
-void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info,
- bool pretenure) {
- // Use the fast case closure allocation code that allocates in new
- // space for nested functions that don't need literals cloning. If
- // we're running with the --always-opt or the --prepare-always-opt
- // flag, we need to use the runtime function so that the new function
- // we are creating here gets a chance to have its code optimized and
- // doesn't just get a copy of the existing unoptimized code.
- if (!FLAG_always_opt &&
- !FLAG_prepare_always_opt &&
- !pretenure &&
- scope()->is_function_scope() &&
- info->num_literals() == 0) {
- FastNewClosureStub stub(isolate(), info->language_mode(), info->kind());
- __ Move(rbx, info);
- __ CallStub(&stub);
- } else {
- __ Push(info);
- __ CallRuntime(pretenure ? Runtime::kNewClosure_Tenured
- : Runtime::kNewClosure);
- }
- context()->Plug(rax);
-}
-
-
void FullCodeGenerator::EmitSetHomeObject(Expression* initializer, int offset,
FeedbackVectorSlot slot) {
DCHECK(NeedsHomeObject(initializer));
@@ -1578,12 +1540,6 @@
}
}
- if (expr->has_function()) {
- DCHECK(result_saved);
- __ Push(Operand(rsp, 0));
- __ CallRuntime(Runtime::kToFastProperties);
- }
-
if (result_saved) {
context()->PlugTOS();
} else {
@@ -1824,65 +1780,45 @@
// this. It stays on the stack while we update the iterator.
VisitForStackValue(expr->expression());
- switch (expr->yield_kind()) {
- case Yield::kSuspend:
- // Pop value from top-of-stack slot; box result into result register.
- EmitCreateIteratorResult(false);
- __ Push(result_register());
- // Fall through.
- case Yield::kInitial: {
- Label suspend, continuation, post_runtime, resume;
+ Label suspend, continuation, post_runtime, resume;
- __ 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).
- __ RecordGeneratorContinuation();
- __ Pop(rbx);
- __ SmiCompare(rbx, Smi::FromInt(JSGeneratorObject::RETURN));
- __ j(not_equal, &resume);
- __ Push(result_register());
- EmitCreateIteratorResult(true);
- EmitUnwindAndReturn();
+ __ 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).
+ __ RecordGeneratorContinuation();
+ __ Pop(rbx);
+ __ SmiCompare(rbx, Smi::FromInt(JSGeneratorObject::RETURN));
+ __ j(not_equal, &resume);
+ __ Push(result_register());
+ EmitCreateIteratorResult(true);
+ EmitUnwindAndReturn();
- __ bind(&suspend);
- VisitForAccumulatorValue(expr->generator_object());
- DCHECK(continuation.pos() > 0 && Smi::IsValid(continuation.pos()));
- __ Move(FieldOperand(rax, JSGeneratorObject::kContinuationOffset),
- Smi::FromInt(continuation.pos()));
- __ movp(FieldOperand(rax, JSGeneratorObject::kContextOffset), rsi);
- __ movp(rcx, rsi);
- __ RecordWriteField(rax, JSGeneratorObject::kContextOffset, rcx, rdx,
- kDontSaveFPRegs);
- __ leap(rbx, Operand(rbp, StandardFrameConstants::kExpressionsOffset));
- __ cmpp(rsp, rbx);
- __ j(equal, &post_runtime);
- __ Push(rax); // generator object
- __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1);
- __ movp(context_register(),
- Operand(rbp, StandardFrameConstants::kContextOffset));
- __ bind(&post_runtime);
+ __ bind(&suspend);
+ OperandStackDepthIncrement(1); // Not popped on this path.
+ VisitForAccumulatorValue(expr->generator_object());
+ DCHECK(continuation.pos() > 0 && Smi::IsValid(continuation.pos()));
+ __ Move(FieldOperand(rax, JSGeneratorObject::kContinuationOffset),
+ Smi::FromInt(continuation.pos()));
+ __ movp(FieldOperand(rax, JSGeneratorObject::kContextOffset), rsi);
+ __ movp(rcx, rsi);
+ __ RecordWriteField(rax, JSGeneratorObject::kContextOffset, rcx, rdx,
+ kDontSaveFPRegs);
+ __ leap(rbx, Operand(rbp, StandardFrameConstants::kExpressionsOffset));
+ __ cmpp(rsp, rbx);
+ __ j(equal, &post_runtime);
+ __ Push(rax); // generator object
+ __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1);
+ __ movp(context_register(),
+ Operand(rbp, StandardFrameConstants::kContextOffset));
+ __ bind(&post_runtime);
- PopOperand(result_register());
- EmitReturnSequence();
+ PopOperand(result_register());
+ EmitReturnSequence();
- __ bind(&resume);
- context()->Plug(result_register());
- break;
- }
-
- case Yield::kFinal: {
- // Pop value from top-of-stack slot, box result into result register.
- OperandStackDepthDecrement(1);
- EmitCreateIteratorResult(true);
- EmitUnwindAndReturn();
- break;
- }
-
- case Yield::kDelegating:
- UNREACHABLE();
- }
+ __ bind(&resume);
+ context()->Plug(result_register());
}
@@ -1911,7 +1847,10 @@
// Push receiver.
__ Push(FieldOperand(rbx, JSGeneratorObject::kReceiverOffset));
- // Push holes for arguments to generator function.
+ // 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);
@@ -2014,19 +1953,7 @@
__ LoadRoot(FieldOperand(rax, JSIteratorResult::kDoneOffset),
done ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex);
STATIC_ASSERT(JSIteratorResult::kSize == 5 * kPointerSize);
-}
-
-
-void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) {
- SetExpressionPosition(prop);
- Literal* key = prop->key()->AsLiteral();
- DCHECK(!key->value()->IsSmi());
- DCHECK(!prop->IsSuperAccess());
-
- __ Move(LoadDescriptor::NameRegister(), key->value());
- __ Move(LoadDescriptor::SlotRegister(),
- SmiFromSlot(prop->PropertyFeedbackSlot()));
- CallLoadIC(NOT_INSIDE_TYPEOF);
+ OperandStackDepthDecrement(1);
}
@@ -2586,7 +2513,7 @@
}
PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
- SetCallPosition(expr);
+ SetCallPosition(expr, expr->tail_call_mode());
if (expr->tail_call_mode() == TailCallMode::kAllow) {
if (FLAG_trace) {
__ CallRuntime(Runtime::kTraceTailCall);
@@ -2944,9 +2871,10 @@
__ CmpObjectType(rax, FIRST_JS_RECEIVER_TYPE, rax);
__ j(below, &null, Label::kNear);
- // Return 'Function' for JSFunction objects.
- __ CmpInstanceType(rax, JS_FUNCTION_TYPE);
- __ j(equal, &function, Label::kNear);
+ // Return 'Function' for JSFunction and JSBoundFunction objects.
+ __ CmpInstanceType(rax, FIRST_FUNCTION_TYPE);
+ STATIC_ASSERT(LAST_FUNCTION_TYPE == LAST_TYPE);
+ __ j(above_equal, &function, Label::kNear);
// Check if the constructor in the map is a JS function.
__ GetMapConstructor(rax, rax, rbx);
@@ -3065,23 +2993,6 @@
}
-void FullCodeGenerator::EmitToInteger(CallRuntime* expr) {
- ZoneList<Expression*>* args = expr->arguments();
- DCHECK_EQ(1, args->length());
-
- // Load the argument into rax and convert it.
- VisitForAccumulatorValue(args->at(0));
-
- // Convert the object to an integer.
- Label done_convert;
- __ JumpIfSmi(rax, &done_convert, Label::kNear);
- __ Push(rax);
- __ CallRuntime(Runtime::kToInteger);
- __ bind(&done_convert);
- context()->Plug(rax);
-}
-
-
void FullCodeGenerator::EmitStringCharFromCode(CallRuntime* expr) {
ZoneList<Expression*>* args = expr->arguments();
DCHECK(args->length() == 1);
@@ -3265,6 +3176,11 @@
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);
@@ -3305,11 +3221,13 @@
void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) {
- // Push the builtins object as receiver.
+ // Push function.
+ __ LoadNativeContextSlot(expr->context_index(), rax);
+ PushOperand(rax);
+
+ // Push undefined as receiver.
OperandStackDepthIncrement(1);
__ PushRoot(Heap::kUndefinedValueRootIndex);
-
- __ LoadNativeContextSlot(expr->context_index(), rax);
}
@@ -3323,59 +3241,9 @@
__ Call(isolate()->builtins()->Call(ConvertReceiverMode::kNullOrUndefined),
RelocInfo::CODE_TARGET);
OperandStackDepthDecrement(arg_count + 1);
-}
-
-void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
- ZoneList<Expression*>* args = expr->arguments();
- int arg_count = args->length();
-
- if (expr->is_jsruntime()) {
- Comment cmnt(masm_, "[ CallRuntime");
-
- EmitLoadJSRuntimeFunction(expr);
-
- // Push the target function under the receiver.
- PushOperand(Operand(rsp, 0));
- __ movp(Operand(rsp, kPointerSize), rax);
-
- // Push the arguments ("left-to-right").
- for (int i = 0; i < arg_count; i++) {
- VisitForStackValue(args->at(i));
- }
-
- PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
- EmitCallJSRuntimeFunction(expr);
-
- // Restore context register.
- __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
- context()->DropAndPlug(1, rax);
-
- } else {
- const Runtime::Function* function = expr->function();
- switch (function->function_id) {
-#define CALL_INTRINSIC_GENERATOR(Name) \
- case Runtime::kInline##Name: { \
- Comment cmnt(masm_, "[ Inline" #Name); \
- return Emit##Name(expr); \
- }
- FOR_EACH_FULL_CODE_INTRINSIC(CALL_INTRINSIC_GENERATOR)
-#undef CALL_INTRINSIC_GENERATOR
- default: {
- Comment cmnt(masm_, "[ CallRuntime for unhandled intrinsic");
- // Push the arguments ("left-to-right").
- for (int i = 0; i < arg_count; i++) {
- VisitForStackValue(args->at(i));
- }
-
- // Call the C runtime.
- PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
- __ CallRuntime(function, arg_count);
- OperandStackDepthDecrement(arg_count);
- context()->Plug(rax);
- }
- }
- }
+ // Restore context register.
+ __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
}
@@ -3618,11 +3486,11 @@
__ jmp(&stub_call, Label::kNear);
__ bind(&slow);
}
- if (!is_strong(language_mode())) {
- ToNumberStub convert_stub(isolate());
- __ CallStub(&convert_stub);
- PrepareForBailoutForId(expr->ToNumberId(), TOS_REG);
- }
+
+ // Convert old value into a number.
+ ToNumberStub convert_stub(isolate());
+ __ CallStub(&convert_stub);
+ PrepareForBailoutForId(expr->ToNumberId(), TOS_REG);
// Save result for postfix expressions.
if (expr->is_postfix()) {
@@ -3662,9 +3530,6 @@
patch_site.EmitPatchInfo();
__ bind(&done);
- if (is_strong(language_mode())) {
- PrepareForBailoutForId(expr->ToNumberId(), TOS_REG);
- }
// Store the value returned in rax.
switch (assign_type) {
case VARIABLE:
@@ -3919,21 +3784,16 @@
__ CompareRoot(rax, nil_value);
Split(equal, if_true, if_false, fall_through);
} else {
- Handle<Code> ic = CompareNilICStub::GetUninitialized(isolate(), nil);
- CallIC(ic, expr->CompareOperationFeedbackId());
- __ CompareRoot(rax, Heap::kTrueValueRootIndex);
- Split(equal, if_true, if_false, fall_through);
+ __ JumpIfSmi(rax, if_false);
+ __ movp(rax, FieldOperand(rax, HeapObject::kMapOffset));
+ __ testb(FieldOperand(rax, Map::kBitFieldOffset),
+ Immediate(1 << Map::kIsUndetectable));
+ Split(not_zero, if_true, if_false, fall_through);
}
context()->Plug(if_true, if_false);
}
-void FullCodeGenerator::VisitThisFunction(ThisFunction* expr) {
- __ movp(rax, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
- context()->Plug(rax);
-}
-
-
Register FullCodeGenerator::result_register() {
return rax;
}
@@ -3943,6 +3803,10 @@
return rsi;
}
+void FullCodeGenerator::LoadFromFrameField(int frame_offset, Register value) {
+ DCHECK(IsAligned(frame_offset, kPointerSize));
+ __ movp(value, Operand(rbp, frame_offset));
+}
void FullCodeGenerator::StoreToFrameField(int frame_offset, Register value) {
DCHECK(IsAligned(frame_offset, kPointerSize));
@@ -4012,11 +3876,6 @@
}
-void FullCodeGenerator::EmitLoadStoreICSlot(FeedbackVectorSlot slot) {
- DCHECK(!slot.IsInvalid());
- __ Move(VectorStoreICTrampolineDescriptor::SlotRegister(), SmiFromSlot(slot));
-}
-
void FullCodeGenerator::DeferredCommands::EmitCommands() {
__ Pop(result_register()); // Restore the accumulator.
__ Pop(rdx); // Get the token.
@@ -4072,7 +3931,6 @@
*jns_offset_address = kJnsOffset;
break;
case ON_STACK_REPLACEMENT:
- case OSR_AFTER_STACK_CHECK:
// sub <profiling_counter>, <delta> ;; Not changed
// nop
// nop
@@ -4110,16 +3968,10 @@
DCHECK_EQ(kNopByteOne, *jns_instr_address);
DCHECK_EQ(kNopByteTwo, *(call_target_address - 2));
- if (Assembler::target_address_at(call_target_address,
- unoptimized_code) ==
- isolate->builtins()->OnStackReplacement()->entry()) {
- return ON_STACK_REPLACEMENT;
- }
-
- DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
- Assembler::target_address_at(call_target_address,
- unoptimized_code));
- return OSR_AFTER_STACK_CHECK;
+ DCHECK_EQ(
+ isolate->builtins()->OnStackReplacement()->entry(),
+ Assembler::target_address_at(call_target_address, unoptimized_code));
+ return ON_STACK_REPLACEMENT;
}
} // namespace internal