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/s390/builtins-s390.cc b/src/s390/builtins-s390.cc
index 8c2283f..f0059bc 100644
--- a/src/s390/builtins-s390.cc
+++ b/src/s390/builtins-s390.cc
@@ -15,8 +15,7 @@
#define __ ACCESS_MASM(masm)
-void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id,
- BuiltinExtraArguments extra_args) {
+void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id) {
// ----------- S t a t e -------------
// -- r2 : number of arguments excluding receiver
// -- r3 : target
@@ -35,24 +34,8 @@
__ LoadP(cp, FieldMemOperand(r3, JSFunction::kContextOffset));
// Insert extra arguments.
- int num_extra_args = 0;
- switch (extra_args) {
- case BuiltinExtraArguments::kTarget:
- __ Push(r3);
- ++num_extra_args;
- break;
- case BuiltinExtraArguments::kNewTarget:
- __ Push(r5);
- ++num_extra_args;
- break;
- case BuiltinExtraArguments::kTargetAndNewTarget:
- __ Push(r3, r5);
- num_extra_args += 2;
- break;
- case BuiltinExtraArguments::kNone:
- break;
- }
-
+ const int num_extra_args = 2;
+ __ Push(r3, r5);
// JumpToExternalReference expects r2 to contain the number of arguments
// including the receiver and the extra arguments.
__ AddP(r2, r2, Operand(num_extra_args + 1));
@@ -132,6 +115,8 @@
void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) {
// ----------- S t a t e -------------
// -- r2 : number of arguments
+ // -- r3 : function
+ // -- cp : context
// -- lr : return address
// -- sp[(argc - n) * 8] : arg[n] (zero-based)
// -- sp[(argc + 1) * 8] : receiver
@@ -143,59 +128,63 @@
DoubleRegister const reg = (kind == MathMaxMinKind::kMin) ? d2 : d1;
// Load the accumulator with the default return value (either -Infinity or
- // +Infinity), with the tagged value in r3 and the double value in d1.
- __ LoadRoot(r3, root_index);
- __ LoadDouble(d1, FieldMemOperand(r3, HeapNumber::kValueOffset));
+ // +Infinity), with the tagged value in r7 and the double value in d1.
+ __ LoadRoot(r7, root_index);
+ __ LoadDouble(d1, FieldMemOperand(r7, HeapNumber::kValueOffset));
// Setup state for loop
// r4: address of arg[0] + kPointerSize
// r5: number of slots to drop at exit (arguments + receiver)
- __ ShiftLeftP(r4, r2, Operand(kPointerSizeLog2));
- __ AddP(r4, sp, r4);
- __ AddP(r5, r2, Operand(1));
+ __ AddP(r6, r2, Operand(1));
Label done_loop, loop;
__ bind(&loop);
{
// Check if all parameters done.
- __ CmpLogicalP(r4, sp);
- __ ble(&done_loop);
+ __ SubP(r2, Operand(1));
+ __ blt(&done_loop);
// Load the next parameter tagged value into r2.
- __ lay(r4, MemOperand(r4, -kPointerSize));
- __ LoadP(r2, MemOperand(r4));
+ __ ShiftLeftP(r1, r2, Operand(kPointerSizeLog2));
+ __ LoadP(r4, MemOperand(sp, r1));
// Load the double value of the parameter into d2, maybe converting the
- // parameter to a number first using the ToNumberStub if necessary.
+ // parameter to a number first using the ToNumber builtin if necessary.
Label convert, convert_smi, convert_number, done_convert;
__ bind(&convert);
- __ JumpIfSmi(r2, &convert_smi);
- __ LoadP(r6, FieldMemOperand(r2, HeapObject::kMapOffset));
- __ JumpIfRoot(r6, Heap::kHeapNumberMapRootIndex, &convert_number);
+ __ JumpIfSmi(r4, &convert_smi);
+ __ LoadP(r5, FieldMemOperand(r4, HeapObject::kMapOffset));
+ __ JumpIfRoot(r5, Heap::kHeapNumberMapRootIndex, &convert_number);
{
- // Parameter is not a Number, use the ToNumberStub to convert it.
- FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
- __ SmiTag(r5);
- __ Push(r3, r4, r5);
- ToNumberStub stub(masm->isolate());
- __ CallStub(&stub);
- __ Pop(r3, r4, r5);
- __ SmiUntag(r5);
+ // Parameter is not a Number, use the ToNumber builtin to convert it.
+ DCHECK(!FLAG_enable_embedded_constant_pool);
+ FrameScope scope(masm, StackFrame::MANUAL);
+ __ PushStandardFrame(r3);
+ __ SmiTag(r2);
+ __ SmiTag(r6);
+ __ Push(r2, r6, r7);
+ __ LoadRR(r2, r4);
+ __ Call(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET);
+ __ LoadRR(r4, r2);
+ __ Pop(r2, r6, r7);
{
// Restore the double accumulator value (d1).
Label done_restore;
- __ SmiToDouble(d1, r3);
- __ JumpIfSmi(r3, &done_restore);
- __ LoadDouble(d1, FieldMemOperand(r3, HeapNumber::kValueOffset));
+ __ SmiToDouble(d1, r7);
+ __ JumpIfSmi(r7, &done_restore);
+ __ LoadDouble(d1, FieldMemOperand(r7, HeapNumber::kValueOffset));
__ bind(&done_restore);
}
+ __ SmiUntag(r6);
+ __ SmiUntag(r2);
+ __ Pop(r14, fp, cp, r3);
}
__ b(&convert);
__ bind(&convert_number);
- __ LoadDouble(d2, FieldMemOperand(r2, HeapNumber::kValueOffset));
+ __ LoadDouble(d2, FieldMemOperand(r4, HeapNumber::kValueOffset));
__ b(&done_convert);
__ bind(&convert_smi);
- __ SmiToDouble(d2, r2);
+ __ SmiToDouble(d2, r4);
__ bind(&done_convert);
// Perform the actual comparison with the accumulator value on the left hand
@@ -207,26 +196,26 @@
__ b(CommuteCondition(cond_done), &compare_swap);
// Left and right hand side are equal, check for -0 vs. +0.
- __ TestDoubleIsMinusZero(reg, r6, r7);
+ __ TestDoubleIsMinusZero(reg, r1, r0);
__ bne(&loop);
// Update accumulator. Result is on the right hand side.
__ bind(&compare_swap);
__ ldr(d1, d2);
- __ LoadRR(r3, r2);
+ __ LoadRR(r7, r4);
__ b(&loop);
// At least one side is NaN, which means that the result will be NaN too.
// We still need to visit the rest of the arguments.
__ bind(&compare_nan);
- __ LoadRoot(r3, Heap::kNanValueRootIndex);
- __ LoadDouble(d1, FieldMemOperand(r3, HeapNumber::kValueOffset));
+ __ LoadRoot(r7, Heap::kNanValueRootIndex);
+ __ LoadDouble(d1, FieldMemOperand(r7, HeapNumber::kValueOffset));
__ b(&loop);
}
__ bind(&done_loop);
- __ LoadRR(r2, r3);
- __ Drop(r5);
+ __ LoadRR(r2, r7);
+ __ Drop(r6);
__ Ret();
}
@@ -254,8 +243,7 @@
}
// 2a. Convert the first argument to a number.
- ToNumberStub stub(masm->isolate());
- __ TailCallStub(&stub);
+ __ Jump(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET);
// 2b. No arguments, return +0.
__ bind(&no_arguments);
@@ -305,8 +293,7 @@
FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
__ Push(r3, r5);
__ LoadRR(r2, r4);
- ToNumberStub stub(masm->isolate());
- __ CallStub(&stub);
+ __ Call(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET);
__ LoadRR(r4, r2);
__ Pop(r3, r5);
}
@@ -699,8 +686,9 @@
__ AssertGeneratorObject(r3);
// Store input value into generator object.
- __ StoreP(r2, FieldMemOperand(r3, JSGeneratorObject::kInputOffset), r0);
- __ RecordWriteField(r3, JSGeneratorObject::kInputOffset, r2, r5,
+ __ StoreP(r2, FieldMemOperand(r3, JSGeneratorObject::kInputOrDebugPosOffset),
+ r0);
+ __ RecordWriteField(r3, JSGeneratorObject::kInputOrDebugPosOffset, r2, r5,
kLRHasNotBeenSaved, kDontSaveFPRegs);
// Store resume mode into generator object.
@@ -711,21 +699,26 @@
__ LoadP(r6, FieldMemOperand(r3, JSGeneratorObject::kFunctionOffset));
// Flood function if we are stepping.
- Label skip_flooding;
- ExternalReference step_in_enabled =
- ExternalReference::debug_step_in_enabled_address(masm->isolate());
- __ mov(ip, Operand(step_in_enabled));
- __ LoadlB(ip, MemOperand(ip));
- __ CmpP(ip, Operand::Zero());
- __ beq(&skip_flooding);
- {
- FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
- __ Push(r3, r4, r6);
- __ CallRuntime(Runtime::kDebugPrepareStepInIfStepping);
- __ Pop(r3, r4);
- __ LoadP(r6, FieldMemOperand(r3, JSGeneratorObject::kFunctionOffset));
- }
- __ bind(&skip_flooding);
+ Label prepare_step_in_if_stepping, prepare_step_in_suspended_generator;
+ Label stepping_prepared;
+ ExternalReference last_step_action =
+ ExternalReference::debug_last_step_action_address(masm->isolate());
+ STATIC_ASSERT(StepFrame > StepIn);
+ __ mov(ip, Operand(last_step_action));
+ __ LoadB(ip, MemOperand(ip));
+ __ CmpP(ip, Operand(StepIn));
+ __ bge(&prepare_step_in_if_stepping);
+
+ // Flood function if we need to continue stepping in the suspended generator.
+
+ ExternalReference debug_suspended_generator =
+ ExternalReference::debug_suspended_generator_address(masm->isolate());
+
+ __ mov(ip, Operand(debug_suspended_generator));
+ __ LoadP(ip, MemOperand(ip));
+ __ CmpP(ip, r3);
+ __ beq(&prepare_step_in_suspended_generator);
+ __ bind(&stepping_prepared);
// Push receiver.
__ LoadP(ip, FieldMemOperand(r3, JSGeneratorObject::kReceiverOffset));
@@ -830,6 +823,26 @@
__ Jump(r5);
}
}
+
+ __ bind(&prepare_step_in_if_stepping);
+ {
+ FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
+ __ Push(r3, r4, r6);
+ __ CallRuntime(Runtime::kDebugPrepareStepInIfStepping);
+ __ Pop(r3, r4);
+ __ LoadP(r6, FieldMemOperand(r3, JSGeneratorObject::kFunctionOffset));
+ }
+ __ b(&stepping_prepared);
+
+ __ bind(&prepare_step_in_suspended_generator);
+ {
+ FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
+ __ Push(r3, r4);
+ __ CallRuntime(Runtime::kDebugPrepareStepInSuspendedGenerator);
+ __ Pop(r3, r4);
+ __ LoadP(r6, FieldMemOperand(r3, JSGeneratorObject::kFunctionOffset));
+ }
+ __ b(&stepping_prepared);
}
void Builtins::Generate_ConstructedNonConstructable(MacroAssembler* masm) {
@@ -957,6 +970,21 @@
Generate_JSEntryTrampolineHelper(masm, true);
}
+static void LeaveInterpreterFrame(MacroAssembler* masm, Register scratch) {
+ Register args_count = scratch;
+
+ // Get the arguments + receiver count.
+ __ LoadP(args_count,
+ MemOperand(fp, InterpreterFrameConstants::kBytecodeArrayFromFp));
+ __ LoadlW(args_count,
+ FieldMemOperand(args_count, BytecodeArray::kParameterSizeOffset));
+
+ // Leave the frame (also dropping the register file).
+ __ LeaveFrame(StackFrame::JAVA_SCRIPT);
+
+ __ AddP(sp, sp, args_count);
+}
+
// Generate code for entering a JS function with the interpreter.
// On entry to the function the receiver and arguments have been pushed on the
// stack left to right. The actual argument count matches the formal parameter
@@ -1067,15 +1095,7 @@
masm->isolate()->heap()->SetInterpreterEntryReturnPCOffset(masm->pc_offset());
// The return value is in r2.
-
- // Get the arguments + reciever count.
- __ LoadP(r4, MemOperand(fp, InterpreterFrameConstants::kBytecodeArrayFromFp));
- __ LoadlW(r4, FieldMemOperand(r4, BytecodeArray::kParameterSizeOffset));
-
- // Leave the frame (also dropping the register file).
- __ LeaveFrame(StackFrame::JAVA_SCRIPT);
-
- __ lay(sp, MemOperand(sp, r4));
+ LeaveInterpreterFrame(masm, r4);
__ Ret();
// If the bytecode array is no longer present, then the underlying function
@@ -1091,6 +1111,31 @@
__ JumpToJSEntry(r6);
}
+void Builtins::Generate_InterpreterMarkBaselineOnReturn(MacroAssembler* masm) {
+ // Save the function and context for call to CompileBaseline.
+ __ LoadP(r3, MemOperand(fp, StandardFrameConstants::kFunctionOffset));
+ __ LoadP(kContextRegister,
+ MemOperand(fp, StandardFrameConstants::kContextOffset));
+
+ // Leave the frame before recompiling for baseline so that we don't count as
+ // an activation on the stack.
+ LeaveInterpreterFrame(masm, r4);
+
+ {
+ FrameScope frame_scope(masm, StackFrame::INTERNAL);
+ // Push return value.
+ __ push(r2);
+
+ // Push function as argument and compile for baseline.
+ __ push(r3);
+ __ CallRuntime(Runtime::kCompileBaseline);
+
+ // Restore return value.
+ __ pop(r2);
+ }
+ __ Ret();
+}
+
static void Generate_InterpreterPushArgs(MacroAssembler* masm, Register index,
Register count, Register scratch) {
Label loop;
@@ -1656,6 +1701,10 @@
void Builtins::Generate_DatePrototype_GetField(MacroAssembler* masm,
int field_index) {
// ----------- S t a t e -------------
+ // -- r2 : number of arguments
+ // -- r3 : function
+ // -- cp : context
+
// -- lr : return address
// -- sp[0] : receiver
// -----------------------------------
@@ -1665,7 +1714,7 @@
{
__ Pop(r2);
__ JumpIfSmi(r2, &receiver_not_date);
- __ CompareObjectType(r2, r3, r4, JS_DATE_TYPE);
+ __ CompareObjectType(r2, r4, r5, JS_DATE_TYPE);
__ bne(&receiver_not_date);
}
@@ -1695,7 +1744,14 @@
// 3. Raise a TypeError if the receiver is not a date.
__ bind(&receiver_not_date);
- __ TailCallRuntime(Runtime::kThrowNotDateError);
+ {
+ FrameScope scope(masm, StackFrame::MANUAL);
+ __ push(r2);
+ __ PushStandardFrame(r3);
+ __ LoadSmiLiteral(r6, Smi::FromInt(0));
+ __ push(r6);
+ __ CallRuntime(Runtime::kThrowNotDateError);
+ }
}
// static
@@ -2661,6 +2717,76 @@
__ TailCallRuntime(Runtime::kAllocateInTargetSpace);
}
+// static
+void Builtins::Generate_StringToNumber(MacroAssembler* masm) {
+ // The StringToNumber stub takes one argument in r2.
+ __ AssertString(r2);
+
+ // Check if string has a cached array index.
+ Label runtime;
+ __ LoadlW(r4, FieldMemOperand(r2, String::kHashFieldOffset));
+ __ And(r0, r4, Operand(String::kContainsCachedArrayIndexMask));
+ __ bne(&runtime);
+ __ IndexFromHash(r4, r2);
+ __ Ret();
+
+ __ bind(&runtime);
+ {
+ FrameScope frame(masm, StackFrame::INTERNAL);
+ // Push argument.
+ __ push(r2);
+ // We cannot use a tail call here because this builtin can also be called
+ // from wasm.
+ __ CallRuntime(Runtime::kStringToNumber);
+ }
+ __ Ret();
+}
+
+// static
+void Builtins::Generate_ToNumber(MacroAssembler* masm) {
+ // The ToNumber stub takes one argument in r2.
+ STATIC_ASSERT(kSmiTag == 0);
+ __ TestIfSmi(r2);
+ __ Ret(eq);
+
+ __ CompareObjectType(r2, r3, r3, HEAP_NUMBER_TYPE);
+ // r2: receiver
+ // r3: receiver instance type
+ __ Ret(eq);
+
+ __ Jump(masm->isolate()->builtins()->NonNumberToNumber(),
+ RelocInfo::CODE_TARGET);
+}
+
+// static
+void Builtins::Generate_NonNumberToNumber(MacroAssembler* masm) {
+ // The NonNumberToNumber stub takes one argument in r2.
+ __ AssertNotNumber(r2);
+
+ __ CompareObjectType(r2, r3, r3, FIRST_NONSTRING_TYPE);
+ // r2: receiver
+ // r3: receiver instance type
+ __ Jump(masm->isolate()->builtins()->StringToNumber(), RelocInfo::CODE_TARGET,
+ lt);
+
+ Label not_oddball;
+ __ CmpP(r3, Operand(ODDBALL_TYPE));
+ __ bne(¬_oddball);
+ __ LoadP(r2, FieldMemOperand(r2, Oddball::kToNumberOffset));
+ __ Ret();
+ __ bind(¬_oddball);
+
+ {
+ FrameScope frame(masm, StackFrame::INTERNAL);
+ // Push argument.
+ __ push(r2);
+ // We cannot use a tail call here because this builtin can also be called
+ // from wasm.
+ __ CallRuntime(Runtime::kToNumber);
+ }
+ __ Ret();
+}
+
void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- r2 : actual number of arguments