Merge V8 5.3.332.45. DO NOT MERGE
Test: Manual
FPIIM-449
Change-Id: Id3254828b068abdea3cb10442e0172a8c9a98e03
(cherry picked from commit 13e2dadd00298019ed862f2b2fc5068bba730bcf)
diff --git a/src/x64/code-stubs-x64.cc b/src/x64/code-stubs-x64.cc
index 602d3a0..b89438f 100644
--- a/src/x64/code-stubs-x64.cc
+++ b/src/x64/code-stubs-x64.cc
@@ -20,71 +20,29 @@
namespace v8 {
namespace internal {
+#define __ ACCESS_MASM(masm)
-static void InitializeArrayConstructorDescriptor(
- Isolate* isolate, CodeStubDescriptor* descriptor,
- int constant_stack_parameter_count) {
- Address deopt_handler = Runtime::FunctionForId(
- Runtime::kArrayConstructor)->entry;
-
- if (constant_stack_parameter_count == 0) {
- descriptor->Initialize(deopt_handler, constant_stack_parameter_count,
- JS_FUNCTION_STUB_MODE);
- } else {
- descriptor->Initialize(rax, deopt_handler, constant_stack_parameter_count,
- JS_FUNCTION_STUB_MODE);
- }
+void ArrayNArgumentsConstructorStub::Generate(MacroAssembler* masm) {
+ __ popq(rcx);
+ __ movq(MemOperand(rsp, rax, times_8, 0), rdi);
+ __ pushq(rdi);
+ __ pushq(rbx);
+ __ pushq(rcx);
+ __ addq(rax, Immediate(3));
+ __ TailCallRuntime(Runtime::kNewArray);
}
-
-static void InitializeInternalArrayConstructorDescriptor(
- Isolate* isolate, CodeStubDescriptor* descriptor,
- int constant_stack_parameter_count) {
- Address deopt_handler = Runtime::FunctionForId(
- Runtime::kInternalArrayConstructor)->entry;
-
- if (constant_stack_parameter_count == 0) {
- descriptor->Initialize(deopt_handler, constant_stack_parameter_count,
- JS_FUNCTION_STUB_MODE);
- } else {
- descriptor->Initialize(rax, deopt_handler, constant_stack_parameter_count,
- JS_FUNCTION_STUB_MODE);
- }
-}
-
-
-void ArraySingleArgumentConstructorStub::InitializeDescriptor(
- CodeStubDescriptor* descriptor) {
- InitializeArrayConstructorDescriptor(isolate(), descriptor, 1);
-}
-
-
-void ArrayNArgumentsConstructorStub::InitializeDescriptor(
- CodeStubDescriptor* descriptor) {
- InitializeArrayConstructorDescriptor(isolate(), descriptor, -1);
-}
-
-
void FastArrayPushStub::InitializeDescriptor(CodeStubDescriptor* descriptor) {
Address deopt_handler = Runtime::FunctionForId(Runtime::kArrayPush)->entry;
descriptor->Initialize(rax, deopt_handler, -1, JS_FUNCTION_STUB_MODE);
}
-void InternalArraySingleArgumentConstructorStub::InitializeDescriptor(
+void FastFunctionBindStub::InitializeDescriptor(
CodeStubDescriptor* descriptor) {
- InitializeInternalArrayConstructorDescriptor(isolate(), descriptor, 1);
+ Address deopt_handler = Runtime::FunctionForId(Runtime::kFunctionBind)->entry;
+ descriptor->Initialize(rax, deopt_handler, -1, JS_FUNCTION_STUB_MODE);
}
-
-void InternalArrayNArgumentsConstructorStub::InitializeDescriptor(
- CodeStubDescriptor* descriptor) {
- InitializeInternalArrayConstructorDescriptor(isolate(), descriptor, -1);
-}
-
-
-#define __ ACCESS_MASM(masm)
-
-
void HydrogenCodeStub::GenerateLightweightMiss(MacroAssembler* masm,
ExternalReference miss) {
// Update the static counter each time a new code stub is generated.
@@ -174,7 +132,7 @@
bool stash_exponent_copy = !input_reg.is(rsp);
__ movl(scratch1, mantissa_operand);
- __ Movsd(xmm0, mantissa_operand);
+ __ Movsd(kScratchDoubleReg, mantissa_operand);
__ movl(rcx, exponent_operand);
if (stash_exponent_copy) __ pushq(rcx);
@@ -194,7 +152,7 @@
__ jmp(&check_negative);
__ bind(&process_64_bits);
- __ Cvttsd2siq(result_reg, xmm0);
+ __ Cvttsd2siq(result_reg, kScratchDoubleReg);
__ jmp(&done, Label::kNear);
// If the double was negative, negate the integer result.
@@ -547,7 +505,6 @@
&miss, // When not a string.
&miss, // When not a number.
&miss, // When index out of range.
- STRING_INDEX_IS_ARRAY_INDEX,
RECEIVER_IS_STRING);
char_at_generator.GenerateFast(masm);
__ ret(0);
@@ -1343,8 +1300,8 @@
// rdx : slot in feedback vector (Smi)
// rdi : the function to call
Isolate* isolate = masm->isolate();
- Label initialize, done, miss, megamorphic, not_array_function,
- done_no_smi_convert;
+ Label initialize, done, miss, megamorphic, not_array_function;
+ Label done_initialize_count, done_increment_count;
// Load the cache state into r11.
__ SmiToInteger32(rdx, rdx);
@@ -1358,7 +1315,7 @@
// type-feedback-vector.h).
Label check_allocation_site;
__ cmpp(rdi, FieldOperand(r11, WeakCell::kValueOffset));
- __ j(equal, &done, Label::kFar);
+ __ j(equal, &done_increment_count, Label::kFar);
__ CompareRoot(r11, Heap::kmegamorphic_symbolRootIndex);
__ j(equal, &done, Label::kFar);
__ CompareRoot(FieldOperand(r11, HeapObject::kMapOffset),
@@ -1382,7 +1339,7 @@
__ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r11);
__ cmpp(rdi, r11);
__ j(not_equal, &megamorphic);
- __ jmp(&done);
+ __ jmp(&done_increment_count);
__ bind(&miss);
@@ -1408,17 +1365,29 @@
CreateAllocationSiteStub create_stub(isolate);
CallStubInRecordCallTarget(masm, &create_stub);
- __ jmp(&done_no_smi_convert);
+ __ jmp(&done_initialize_count);
__ bind(¬_array_function);
CreateWeakCellStub weak_cell_stub(isolate);
CallStubInRecordCallTarget(masm, &weak_cell_stub);
- __ jmp(&done_no_smi_convert);
+
+ __ bind(&done_initialize_count);
+ // Initialize the call counter.
+ __ SmiToInteger32(rdx, rdx);
+ __ Move(FieldOperand(rbx, rdx, times_pointer_size,
+ FixedArray::kHeaderSize + kPointerSize),
+ Smi::FromInt(1));
+ __ jmp(&done);
+
+ __ bind(&done_increment_count);
+
+ // Increment the call count for monomorphic function calls.
+ __ SmiAddConstant(FieldOperand(rbx, rdx, times_pointer_size,
+ FixedArray::kHeaderSize + kPointerSize),
+ Smi::FromInt(1));
__ bind(&done);
__ Integer32ToSmi(rdx, rdx);
-
- __ bind(&done_no_smi_convert);
}
@@ -1479,7 +1448,7 @@
// Increment the call count for monomorphic function calls.
__ SmiAddConstant(FieldOperand(rbx, rdx, times_pointer_size,
FixedArray::kHeaderSize + kPointerSize),
- Smi::FromInt(CallICNexus::kCallCountIncrement));
+ Smi::FromInt(1));
__ movp(rbx, rcx);
__ movp(rdx, rdi);
@@ -1529,7 +1498,7 @@
// Increment the call count for monomorphic function calls.
__ SmiAddConstant(FieldOperand(rbx, rdx, times_pointer_size,
FixedArray::kHeaderSize + kPointerSize),
- Smi::FromInt(CallICNexus::kCallCountIncrement));
+ Smi::FromInt(1));
__ bind(&call_function);
__ Set(rax, argc);
@@ -1599,7 +1568,7 @@
// Initialize the call counter.
__ Move(FieldOperand(rbx, rdx, times_pointer_size,
FixedArray::kHeaderSize + kPointerSize),
- Smi::FromInt(CallICNexus::kCallCountIncrement));
+ Smi::FromInt(1));
// Store the function. Use a stub since we need a frame for allocation.
// rbx - vector
@@ -1656,7 +1625,7 @@
StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime(isolate);
StubFailureTrampolineStub::GenerateAheadOfTime(isolate);
// It is important that the store buffer overflow stubs are generated first.
- ArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate);
+ CommonArrayConstructorStub::GenerateStubsAheadOfTime(isolate);
CreateAllocationSiteStub::GenerateAheadOfTime(isolate);
CreateWeakCellStub::GenerateAheadOfTime(isolate);
BinaryOpICStub::GenerateAheadOfTime(isolate);
@@ -2056,13 +2025,7 @@
}
__ Push(object_);
__ Push(index_); // Consumed by runtime conversion function.
- if (index_flags_ == STRING_INDEX_IS_NUMBER) {
- __ CallRuntime(Runtime::kNumberToIntegerMapMinusZero);
- } else {
- DCHECK(index_flags_ == STRING_INDEX_IS_ARRAY_INDEX);
- // NumberToSmi discards numbers that are not exact integers.
- __ CallRuntime(Runtime::kNumberToSmi);
- }
+ __ CallRuntime(Runtime::kNumberToSmi);
if (!index_.is(rax)) {
// Save the conversion result before the pop instructions below
// have a chance to overwrite it.
@@ -2383,78 +2346,12 @@
// rcx: sub string length (smi)
// rdx: from index (smi)
StringCharAtGenerator generator(rax, rdx, rcx, rax, &runtime, &runtime,
- &runtime, STRING_INDEX_IS_NUMBER,
- RECEIVER_IS_STRING);
+ &runtime, RECEIVER_IS_STRING);
generator.GenerateFast(masm);
__ ret(SUB_STRING_ARGUMENT_COUNT * kPointerSize);
generator.SkipSlow(masm, &runtime);
}
-
-void ToNumberStub::Generate(MacroAssembler* masm) {
- // The ToNumber stub takes one argument in rax.
- Label not_smi;
- __ JumpIfNotSmi(rax, ¬_smi, Label::kNear);
- __ Ret();
- __ bind(¬_smi);
-
- Label not_heap_number;
- __ CompareRoot(FieldOperand(rax, HeapObject::kMapOffset),
- Heap::kHeapNumberMapRootIndex);
- __ j(not_equal, ¬_heap_number, Label::kNear);
- __ Ret();
- __ bind(¬_heap_number);
-
- NonNumberToNumberStub stub(masm->isolate());
- __ TailCallStub(&stub);
-}
-
-void NonNumberToNumberStub::Generate(MacroAssembler* masm) {
- // The NonNumberToNumber stub takes one argument in rax.
- __ AssertNotNumber(rax);
-
- Label not_string;
- __ CmpObjectType(rax, FIRST_NONSTRING_TYPE, rdi);
- // rax: object
- // rdi: object map
- __ j(above_equal, ¬_string, Label::kNear);
- StringToNumberStub stub(masm->isolate());
- __ TailCallStub(&stub);
- __ bind(¬_string);
-
- Label not_oddball;
- __ CmpInstanceType(rdi, ODDBALL_TYPE);
- __ j(not_equal, ¬_oddball, Label::kNear);
- __ movp(rax, FieldOperand(rax, Oddball::kToNumberOffset));
- __ Ret();
- __ bind(¬_oddball);
-
- __ PopReturnAddressTo(rcx); // Pop return address.
- __ Push(rax); // Push argument.
- __ PushReturnAddressFrom(rcx); // Push return address.
- __ TailCallRuntime(Runtime::kToNumber);
-}
-
-void StringToNumberStub::Generate(MacroAssembler* masm) {
- // The StringToNumber stub takes one argument in rax.
- __ AssertString(rax);
-
- // Check if string has a cached array index.
- Label runtime;
- __ testl(FieldOperand(rax, String::kHashFieldOffset),
- Immediate(String::kContainsCachedArrayIndexMask));
- __ j(not_zero, &runtime, Label::kNear);
- __ movl(rax, FieldOperand(rax, String::kHashFieldOffset));
- __ IndexFromHash(rax, rax);
- __ Ret();
-
- __ bind(&runtime);
- __ PopReturnAddressTo(rcx); // Pop return address.
- __ Push(rax); // Push argument.
- __ PushReturnAddressFrom(rcx); // Push return address.
- __ TailCallRuntime(Runtime::kStringToNumber);
-}
-
void ToStringStub::Generate(MacroAssembler* masm) {
// The ToString stub takes one argument in rax.
Label is_number;
@@ -2489,7 +2386,6 @@
__ TailCallRuntime(Runtime::kToString);
}
-
void ToNameStub::Generate(MacroAssembler* masm) {
// The ToName stub takes one argument in rax.
Label is_number;
@@ -2672,7 +2568,7 @@
// Load rcx with the allocation site. We stick an undefined dummy value here
// and replace it with the real allocation site later when we instantiate this
// stub in BinaryOpICWithAllocationSiteStub::GetCodeCopyFromTemplate().
- __ Move(rcx, handle(isolate()->heap()->undefined_value()));
+ __ Move(rcx, isolate()->factory()->undefined_value());
// Make sure that we actually patched the allocation site.
if (FLAG_debug_code) {
@@ -3482,14 +3378,14 @@
void LoadICTrampolineStub::Generate(MacroAssembler* masm) {
__ EmitLoadTypeFeedbackVector(LoadWithVectorDescriptor::VectorRegister());
- LoadICStub stub(isolate(), state());
+ LoadICStub stub(isolate());
stub.GenerateForTrampoline(masm);
}
void KeyedLoadICTrampolineStub::Generate(MacroAssembler* masm) {
__ EmitLoadTypeFeedbackVector(LoadWithVectorDescriptor::VectorRegister());
- KeyedLoadICStub stub(isolate(), state());
+ KeyedLoadICStub stub(isolate());
stub.GenerateForTrampoline(masm);
}
@@ -3970,9 +3866,6 @@
// rdi - constructor?
// rsp[0] - return address
// rsp[8] - last argument
- Handle<Object> undefined_sentinel(
- masm->isolate()->heap()->undefined_value(),
- masm->isolate());
Label normal_sequence;
if (mode == DONT_OVERRIDE) {
@@ -4063,19 +3956,14 @@
}
}
-
-void ArrayConstructorStubBase::GenerateStubsAheadOfTime(Isolate* isolate) {
+void CommonArrayConstructorStub::GenerateStubsAheadOfTime(Isolate* isolate) {
ArrayConstructorStubAheadOfTimeHelper<ArrayNoArgumentConstructorStub>(
isolate);
ArrayConstructorStubAheadOfTimeHelper<ArraySingleArgumentConstructorStub>(
isolate);
- ArrayConstructorStubAheadOfTimeHelper<ArrayNArgumentsConstructorStub>(
- isolate);
-}
+ ArrayNArgumentsConstructorStub stub(isolate);
+ stub.GetCode();
-
-void InternalArrayConstructorStubBase::GenerateStubsAheadOfTime(
- Isolate* isolate) {
ElementsKind kinds[2] = { FAST_ELEMENTS, FAST_HOLEY_ELEMENTS };
for (int i = 0; i < 2; i++) {
// For internal arrays we only need a few things
@@ -4083,8 +3971,6 @@
stubh1.GetCode();
InternalArraySingleArgumentConstructorStub stubh2(isolate, kinds[i]);
stubh2.GetCode();
- InternalArrayNArgumentsConstructorStub stubh3(isolate, kinds[i]);
- stubh3.GetCode();
}
}
@@ -4104,13 +3990,15 @@
CreateArrayDispatchOneArgument(masm, mode);
__ bind(¬_one_case);
- CreateArrayDispatch<ArrayNArgumentsConstructorStub>(masm, mode);
+ ArrayNArgumentsConstructorStub stub(masm->isolate());
+ __ TailCallStub(&stub);
} else if (argument_count() == NONE) {
CreateArrayDispatch<ArrayNoArgumentConstructorStub>(masm, mode);
} else if (argument_count() == ONE) {
CreateArrayDispatchOneArgument(masm, mode);
} else if (argument_count() == MORE_THAN_ONE) {
- CreateArrayDispatch<ArrayNArgumentsConstructorStub>(masm, mode);
+ ArrayNArgumentsConstructorStub stub(masm->isolate());
+ __ TailCallStub(&stub);
} else {
UNREACHABLE();
}
@@ -4229,7 +4117,7 @@
__ TailCallStub(&stub1);
__ bind(¬_one_case);
- InternalArrayNArgumentsConstructorStub stubN(isolate(), kind);
+ ArrayNArgumentsConstructorStub stubN(isolate());
__ TailCallStub(&stubN);
}
@@ -4494,6 +4382,7 @@
1 * kPointerSize));
// ----------- S t a t e -------------
+ // -- rdi : function
// -- rsi : context
// -- rax : number of rest parameters
// -- rbx : pointer to first rest parameters
@@ -4504,7 +4393,7 @@
Label allocate, done_allocate;
__ leal(rcx, Operand(rax, times_pointer_size,
JSArray::kSize + FixedArray::kHeaderSize));
- __ Allocate(rcx, rdx, rdi, no_reg, &allocate, NO_ALLOCATION_FLAGS);
+ __ Allocate(rcx, rdx, r8, no_reg, &allocate, NO_ALLOCATION_FLAGS);
__ bind(&done_allocate);
// Compute the arguments.length in rdi.
@@ -4542,8 +4431,11 @@
STATIC_ASSERT(JSArray::kSize == 4 * kPointerSize);
__ Ret();
- // Fall back to %AllocateInNewSpace.
+ // Fall back to %AllocateInNewSpace (if not too big).
+ Label too_big_for_new_space;
__ bind(&allocate);
+ __ cmpl(rcx, Immediate(Page::kMaxRegularHeapObjectSize));
+ __ j(greater, &too_big_for_new_space);
{
FrameScope scope(masm, StackFrame::INTERNAL);
__ Integer32ToSmi(rax, rax);
@@ -4558,6 +4450,13 @@
__ SmiToInteger32(rax, rax);
}
__ jmp(&done_allocate);
+
+ // Fall back to %NewRestParameter.
+ __ bind(&too_big_for_new_space);
+ __ PopReturnAddressTo(kScratchRegister);
+ __ Push(rdi);
+ __ PushReturnAddressFrom(kScratchRegister);
+ __ TailCallRuntime(Runtime::kNewRestParameter);
}
}
@@ -4848,6 +4747,7 @@
// ----------- S t a t e -------------
// -- rax : number of arguments
// -- rbx : pointer to the first argument
+ // -- rdi : function
// -- rsi : context
// -- rsp[0] : return address
// -----------------------------------
@@ -4856,7 +4756,7 @@
Label allocate, done_allocate;
__ leal(rcx, Operand(rax, times_pointer_size, JSStrictArgumentsObject::kSize +
FixedArray::kHeaderSize));
- __ Allocate(rcx, rdx, rdi, no_reg, &allocate, NO_ALLOCATION_FLAGS);
+ __ Allocate(rcx, rdx, r8, no_reg, &allocate, NO_ALLOCATION_FLAGS);
__ bind(&done_allocate);
// Compute the arguments.length in rdi.
@@ -4894,8 +4794,11 @@
STATIC_ASSERT(JSStrictArgumentsObject::kSize == 4 * kPointerSize);
__ Ret();
- // Fall back to %AllocateInNewSpace.
+ // Fall back to %AllocateInNewSpace (if not too big).
+ Label too_big_for_new_space;
__ bind(&allocate);
+ __ cmpl(rcx, Immediate(Page::kMaxRegularHeapObjectSize));
+ __ j(greater, &too_big_for_new_space);
{
FrameScope scope(masm, StackFrame::INTERNAL);
__ Integer32ToSmi(rax, rax);
@@ -4910,37 +4813,13 @@
__ SmiToInteger32(rax, rax);
}
__ jmp(&done_allocate);
-}
-
-void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) {
- Register context_reg = rsi;
- Register slot_reg = rbx;
- Register result_reg = rax;
- Label slow_case;
-
- // Go up context chain to the script context.
- for (int i = 0; i < depth(); ++i) {
- __ movp(rdi, ContextOperand(context_reg, Context::PREVIOUS_INDEX));
- context_reg = rdi;
- }
-
- // Load the PropertyCell value at the specified slot.
- __ movp(result_reg, ContextOperand(context_reg, slot_reg));
- __ movp(result_reg, FieldOperand(result_reg, PropertyCell::kValueOffset));
-
- // Check that value is not the_hole.
- __ CompareRoot(result_reg, Heap::kTheHoleValueRootIndex);
- __ j(equal, &slow_case, Label::kNear);
- __ Ret();
-
- // Fallback to the runtime.
- __ bind(&slow_case);
- __ Integer32ToSmi(slot_reg, slot_reg);
+ // Fall back to %NewStrictArguments.
+ __ bind(&too_big_for_new_space);
__ PopReturnAddressTo(kScratchRegister);
- __ Push(slot_reg);
- __ Push(kScratchRegister);
- __ TailCallRuntime(Runtime::kLoadGlobalViaContext);
+ __ Push(rdi);
+ __ PushReturnAddressFrom(kScratchRegister);
+ __ TailCallRuntime(Runtime::kNewStrictArguments);
}