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/s390/builtins-s390.cc b/src/s390/builtins-s390.cc
index 12b52c1..8c2283f 100644
--- a/src/s390/builtins-s390.cc
+++ b/src/s390/builtins-s390.cc
@@ -596,15 +596,10 @@
// r2: number of arguments
// r3: constructor function
// r5: new target
- if (is_api_function) {
- __ LoadP(cp, FieldMemOperand(r3, JSFunction::kContextOffset));
- Handle<Code> code = masm->isolate()->builtins()->HandleApiCallConstruct();
- __ Call(code, RelocInfo::CODE_TARGET);
- } else {
- ParameterCount actual(r2);
- __ InvokeFunction(r3, r5, actual, CALL_FUNCTION,
- CheckDebugStepCallWrapper());
- }
+
+ ParameterCount actual(r2);
+ __ InvokeFunction(r3, r5, actual, CALL_FUNCTION,
+ CheckDebugStepCallWrapper());
// Store offset of return address for deoptimizer.
if (create_implicit_receiver && !is_api_function) {
@@ -693,6 +688,150 @@
Generate_JSConstructStubHelper(masm, false, false, true);
}
+// static
+void Builtins::Generate_ResumeGeneratorTrampoline(MacroAssembler* masm) {
+ // ----------- S t a t e -------------
+ // -- r2 : the value to pass to the generator
+ // -- r3 : the JSGeneratorObject to resume
+ // -- r4 : the resume mode (tagged)
+ // -- lr : return address
+ // -----------------------------------
+ __ AssertGeneratorObject(r3);
+
+ // Store input value into generator object.
+ __ StoreP(r2, FieldMemOperand(r3, JSGeneratorObject::kInputOffset), r0);
+ __ RecordWriteField(r3, JSGeneratorObject::kInputOffset, r2, r5,
+ kLRHasNotBeenSaved, kDontSaveFPRegs);
+
+ // Store resume mode into generator object.
+ __ StoreP(r4, FieldMemOperand(r3, JSGeneratorObject::kResumeModeOffset));
+
+ // Load suspended function and context.
+ __ LoadP(cp, FieldMemOperand(r3, JSGeneratorObject::kContextOffset));
+ __ 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);
+
+ // Push receiver.
+ __ LoadP(ip, FieldMemOperand(r3, JSGeneratorObject::kReceiverOffset));
+ __ Push(ip);
+
+ // ----------- S t a t e -------------
+ // -- r3 : the JSGeneratorObject to resume
+ // -- r4 : the resume mode (tagged)
+ // -- r6 : generator function
+ // -- cp : generator context
+ // -- lr : return address
+ // -- sp[0] : generator receiver
+ // -----------------------------------
+
+ // 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(r5, FieldMemOperand(r6, JSFunction::kSharedFunctionInfoOffset));
+ __ LoadW(
+ r2, FieldMemOperand(r5, SharedFunctionInfo::kFormalParameterCountOffset));
+ {
+ Label loop, done_loop;
+ __ LoadRoot(ip, Heap::kTheHoleValueRootIndex);
+#if V8_TARGET_ARCH_S390X
+ __ CmpP(r2, Operand::Zero());
+ __ beq(&done_loop);
+#else
+ __ SmiUntag(r2);
+ __ LoadAndTestP(r2, r2);
+ __ beq(&done_loop);
+#endif
+ __ LoadRR(r1, r2);
+ __ bind(&loop);
+ __ push(ip);
+ __ BranchOnCount(r1, &loop);
+ __ bind(&done_loop);
+ }
+
+ // Dispatch on the kind of generator object.
+ Label old_generator;
+ __ LoadP(r5, FieldMemOperand(r5, SharedFunctionInfo::kFunctionDataOffset));
+ __ CompareObjectType(r5, r5, r5, BYTECODE_ARRAY_TYPE);
+ __ bne(&old_generator, Label::kNear);
+
+ // New-style (ignition/turbofan) generator object
+ {
+ // We abuse new.target both to indicate that this is a resume call and to
+ // pass in the generator object. In ordinary calls, new.target is always
+ // undefined because generator functions are non-constructable.
+ __ LoadRR(r5, r3);
+ __ LoadRR(r3, r6);
+ __ LoadP(ip, FieldMemOperand(r3, JSFunction::kCodeEntryOffset));
+ __ JumpToJSEntry(ip);
+ }
+ // Old-style (full-codegen) generator object
+ __ bind(&old_generator);
+ {
+ // Enter a new JavaScript frame, and initialize its slots as they were when
+ // the generator was suspended.
+ FrameScope scope(masm, StackFrame::MANUAL);
+ __ PushStandardFrame(r6);
+
+ // Restore the operand stack.
+ __ LoadP(r2, FieldMemOperand(r3, JSGeneratorObject::kOperandStackOffset));
+ __ LoadP(r5, FieldMemOperand(r2, FixedArray::kLengthOffset));
+ __ AddP(r2, r2,
+ Operand(FixedArray::kHeaderSize - kHeapObjectTag - kPointerSize));
+ {
+ Label loop, done_loop;
+ __ SmiUntag(r5);
+ __ LoadAndTestP(r5, r5);
+ __ beq(&done_loop);
+ __ LoadRR(r1, r5);
+ __ bind(&loop);
+ __ LoadP(ip, MemOperand(r2, kPointerSize));
+ __ la(r2, MemOperand(r2, kPointerSize));
+ __ Push(ip);
+ __ BranchOnCount(r1, &loop);
+ __ bind(&done_loop);
+ }
+
+ // Reset operand stack so we don't leak.
+ __ LoadRoot(ip, Heap::kEmptyFixedArrayRootIndex);
+ __ StoreP(ip, FieldMemOperand(r3, JSGeneratorObject::kOperandStackOffset),
+ r0);
+
+ // Resume the generator function at the continuation.
+ __ LoadP(r5, FieldMemOperand(r6, JSFunction::kSharedFunctionInfoOffset));
+ __ LoadP(r5, FieldMemOperand(r5, SharedFunctionInfo::kCodeOffset));
+ __ AddP(r5, r5, Operand(Code::kHeaderSize - kHeapObjectTag));
+ {
+ ConstantPoolUnavailableScope constant_pool_unavailable(masm);
+ __ LoadP(r4, FieldMemOperand(r3, JSGeneratorObject::kContinuationOffset));
+ __ SmiUntag(r4);
+ __ AddP(r5, r5, r4);
+ __ LoadSmiLiteral(r4,
+ Smi::FromInt(JSGeneratorObject::kGeneratorExecuting));
+ __ StoreP(r4, FieldMemOperand(r3, JSGeneratorObject::kContinuationOffset),
+ r0);
+ __ LoadRR(r2, r3); // Continuation expects generator object in r2.
+ __ Jump(r5);
+ }
+ }
+}
+
void Builtins::Generate_ConstructedNonConstructable(MacroAssembler* masm) {
FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
__ push(r3);
@@ -835,14 +974,16 @@
// The function builds an interpreter frame. See InterpreterFrameConstants in
// frames.h for its layout.
void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
+ ProfileEntryHookStub::MaybeCallEntryHook(masm);
+
// Open a frame scope to indicate that there is a frame on the stack. The
// MANUAL indicates that the scope shouldn't actually generate code to set up
// the frame (that is done below).
FrameScope frame_scope(masm, StackFrame::MANUAL);
__ PushStandardFrame(r3);
- // Get the bytecode array from the function object and load the pointer to the
- // first entry into kInterpreterBytecodeRegister.
+ // Get the bytecode array from the function object (or from the DebugInfo if
+ // it is present) and load it into kInterpreterBytecodeArrayRegister.
__ LoadP(r2, FieldMemOperand(r3, JSFunction::kSharedFunctionInfoOffset));
Label array_done;
Register debug_info = r4;
@@ -858,8 +999,13 @@
FieldMemOperand(debug_info, DebugInfo::kAbstractCodeIndex));
__ bind(&array_done);
+ // Check function data field is actually a BytecodeArray object.
+ Label bytecode_array_not_present;
+ __ CompareRoot(kInterpreterBytecodeArrayRegister,
+ Heap::kUndefinedValueRootIndex);
+ __ beq(&bytecode_array_not_present);
+
if (FLAG_debug_code) {
- // Check function data field is actually a BytecodeArray object.
__ TestIfSmi(kInterpreterBytecodeArrayRegister);
__ Assert(ne, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry);
__ CompareObjectType(kInterpreterBytecodeArrayRegister, r2, no_reg,
@@ -867,9 +1013,13 @@
__ Assert(eq, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry);
}
- // Push new.target, bytecode array and zero for bytecode array offset.
- __ LoadImmP(r2, Operand::Zero());
- __ Push(r5, kInterpreterBytecodeArrayRegister, r2);
+ // Load the initial bytecode offset.
+ __ mov(kInterpreterBytecodeOffsetRegister,
+ Operand(BytecodeArray::kHeaderSize - kHeapObjectTag));
+
+ // Push new.target, bytecode array and Smi tagged bytecode array offset.
+ __ SmiTag(r4, kInterpreterBytecodeOffsetRegister);
+ __ Push(r5, kInterpreterBytecodeArrayRegister, r4);
// Allocate the local and temporary register file on the stack.
{
@@ -901,18 +1051,8 @@
__ bind(&no_args);
}
- // TODO(rmcilroy): List of things not currently dealt with here but done in
- // fullcodegen's prologue:
- // - Call ProfileEntryHookStub when isolate has a function_entry_hook.
- // - Code aging of the BytecodeArray object.
-
- // Load accumulator, register file, bytecode offset, dispatch table into
- // registers.
+ // Load accumulator and dispatch table into registers.
__ LoadRoot(kInterpreterAccumulatorRegister, Heap::kUndefinedValueRootIndex);
- __ AddP(kInterpreterRegisterFileRegister, fp,
- Operand(InterpreterFrameConstants::kRegisterFilePointerFromFp));
- __ mov(kInterpreterBytecodeOffsetRegister,
- Operand(BytecodeArray::kHeaderSize - kHeapObjectTag));
__ mov(kInterpreterDispatchTableRegister,
Operand(ExternalReference::interpreter_dispatch_table_address(
masm->isolate())));
@@ -922,32 +1062,33 @@
kInterpreterBytecodeOffsetRegister));
__ ShiftLeftP(ip, r3, Operand(kPointerSizeLog2));
__ LoadP(ip, MemOperand(kInterpreterDispatchTableRegister, ip));
- // TODO(rmcilroy): Make dispatch table point to code entrys to avoid untagging
- // and header removal.
- __ AddP(ip, ip, Operand(Code::kHeaderSize - kHeapObjectTag));
__ Call(ip);
- // Even though the first bytecode handler was called, we will never return.
- __ Abort(kUnexpectedReturnFromBytecodeHandler);
-}
+ masm->isolate()->heap()->SetInterpreterEntryReturnPCOffset(masm->pc_offset());
-void Builtins::Generate_InterpreterExitTrampoline(MacroAssembler* masm) {
- // TODO(rmcilroy): List of things not currently dealt with here but done in
- // fullcodegen's EmitReturnSequence.
- // - Supporting FLAG_trace for Runtime::TraceExit.
- // - Support profiler (specifically decrementing profiling_counter
- // appropriately and calling out to HandleInterrupts if necessary).
+ // The return value is in r2.
- // The return value is in accumulator, which is already 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);
- // Drop receiver + arguments and return.
- __ LoadlW(r0, FieldMemOperand(kInterpreterBytecodeArrayRegister,
- BytecodeArray::kParameterSizeOffset));
- __ AddP(sp, sp, r0);
+ __ lay(sp, MemOperand(sp, r4));
__ Ret();
+
+ // If the bytecode array is no longer present, then the underlying function
+ // has been switched to a different kind of code and we heal the closure by
+ // switching the code entry field over to the new code object as well.
+ __ bind(&bytecode_array_not_present);
+ __ LeaveFrame(StackFrame::JAVA_SCRIPT);
+ __ LoadP(r6, FieldMemOperand(r3, JSFunction::kSharedFunctionInfoOffset));
+ __ LoadP(r6, FieldMemOperand(r6, SharedFunctionInfo::kCodeOffset));
+ __ AddP(r6, r6, Operand(Code::kHeaderSize - kHeapObjectTag));
+ __ StoreP(r6, FieldMemOperand(r3, JSFunction::kCodeEntryOffset), r0);
+ __ RecordWriteCodeEntryField(r3, r6, r7);
+ __ JumpToJSEntry(r6);
}
static void Generate_InterpreterPushArgs(MacroAssembler* masm, Register index,
@@ -1010,24 +1151,24 @@
__ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET);
}
-static void Generate_EnterBytecodeDispatch(MacroAssembler* masm) {
- // Initialize register file register and dispatch table register.
- __ AddP(kInterpreterRegisterFileRegister, fp,
- Operand(InterpreterFrameConstants::kRegisterFilePointerFromFp));
+void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) {
+ // Set the return address to the correct point in the interpreter entry
+ // trampoline.
+ Smi* interpreter_entry_return_pc_offset(
+ masm->isolate()->heap()->interpreter_entry_return_pc_offset());
+ DCHECK_NE(interpreter_entry_return_pc_offset, Smi::FromInt(0));
+ __ Move(r4, masm->isolate()->builtins()->InterpreterEntryTrampoline());
+ __ AddP(r14, r4, Operand(interpreter_entry_return_pc_offset->value() +
+ Code::kHeaderSize - kHeapObjectTag));
+
+ // Initialize the dispatch table register.
__ mov(kInterpreterDispatchTableRegister,
Operand(ExternalReference::interpreter_dispatch_table_address(
masm->isolate())));
- // Get the context from the frame.
- __ LoadP(kContextRegister,
- MemOperand(kInterpreterRegisterFileRegister,
- InterpreterFrameConstants::kContextFromRegisterPointer));
-
// Get the bytecode array pointer from the frame.
- __ LoadP(
- kInterpreterBytecodeArrayRegister,
- MemOperand(kInterpreterRegisterFileRegister,
- InterpreterFrameConstants::kBytecodeArrayFromRegisterPointer));
+ __ LoadP(kInterpreterBytecodeArrayRegister,
+ MemOperand(fp, InterpreterFrameConstants::kBytecodeArrayFromFp));
if (FLAG_debug_code) {
// Check function data field is actually a BytecodeArray object.
@@ -1040,9 +1181,7 @@
// Get the target bytecode offset from the frame.
__ LoadP(kInterpreterBytecodeOffsetRegister,
- MemOperand(
- kInterpreterRegisterFileRegister,
- InterpreterFrameConstants::kBytecodeOffsetFromRegisterPointer));
+ MemOperand(fp, InterpreterFrameConstants::kBytecodeOffsetFromFp));
__ SmiUntag(kInterpreterBytecodeOffsetRegister);
// Dispatch to the target bytecode.
@@ -1050,59 +1189,157 @@
kInterpreterBytecodeOffsetRegister));
__ ShiftLeftP(ip, r3, Operand(kPointerSizeLog2));
__ LoadP(ip, MemOperand(kInterpreterDispatchTableRegister, ip));
- __ AddP(ip, ip, Operand(Code::kHeaderSize - kHeapObjectTag));
__ Jump(ip);
}
-static void Generate_InterpreterNotifyDeoptimizedHelper(
- MacroAssembler* masm, Deoptimizer::BailoutType type) {
- // Enter an internal frame.
- {
- FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
-
- // Pass the deoptimization type to the runtime system.
- __ LoadSmiLiteral(r3, Smi::FromInt(static_cast<int>(type)));
- __ Push(r3);
- __ CallRuntime(Runtime::kNotifyDeoptimized);
- // Tear down internal frame.
- }
-
- // Drop state (we don't use these for interpreter deopts) and and pop the
- // accumulator value into the accumulator register.
- __ Drop(1);
- __ Pop(kInterpreterAccumulatorRegister);
-
- // Enter the bytecode dispatch.
- Generate_EnterBytecodeDispatch(masm);
-}
-
-void Builtins::Generate_InterpreterNotifyDeoptimized(MacroAssembler* masm) {
- Generate_InterpreterNotifyDeoptimizedHelper(masm, Deoptimizer::EAGER);
-}
-
-void Builtins::Generate_InterpreterNotifySoftDeoptimized(MacroAssembler* masm) {
- Generate_InterpreterNotifyDeoptimizedHelper(masm, Deoptimizer::SOFT);
-}
-
-void Builtins::Generate_InterpreterNotifyLazyDeoptimized(MacroAssembler* masm) {
- Generate_InterpreterNotifyDeoptimizedHelper(masm, Deoptimizer::LAZY);
-}
-
-void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) {
- // Set the address of the interpreter entry trampoline as a return address.
- // This simulates the initial call to bytecode handlers in interpreter entry
- // trampoline. The return will never actually be taken, but our stack walker
- // uses this address to determine whether a frame is interpreted.
- __ mov(r14,
- Operand(masm->isolate()->builtins()->InterpreterEntryTrampoline()));
-
- Generate_EnterBytecodeDispatch(masm);
-}
-
void Builtins::Generate_CompileLazy(MacroAssembler* masm) {
+ // ----------- S t a t e -------------
+ // -- r2 : argument count (preserved for callee)
+ // -- r5 : new target (preserved for callee)
+ // -- r3 : target function (preserved for callee)
+ // -----------------------------------
+ // First lookup code, maybe we don't need to compile!
+ Label gotta_call_runtime;
+ Label maybe_call_runtime;
+ Label try_shared;
+ Label loop_top, loop_bottom;
+
+ Register closure = r3;
+ Register map = r8;
+ Register index = r4;
+ __ LoadP(map,
+ FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset));
+ __ LoadP(map,
+ FieldMemOperand(map, SharedFunctionInfo::kOptimizedCodeMapOffset));
+ __ LoadP(index, FieldMemOperand(map, FixedArray::kLengthOffset));
+ __ CmpSmiLiteral(index, Smi::FromInt(2), r0);
+ __ blt(&gotta_call_runtime);
+
+ // Find literals.
+ // r9 : native context
+ // r4 : length / index
+ // r8 : optimized code map
+ // r5 : new target
+ // r3 : closure
+ Register native_context = r9;
+ __ LoadP(native_context, NativeContextMemOperand());
+
+ __ bind(&loop_top);
+ Register temp = r1;
+ Register array_pointer = r7;
+
+ // Does the native context match?
+ __ SmiToPtrArrayOffset(array_pointer, index);
+ __ AddP(array_pointer, map, array_pointer);
+ __ LoadP(temp, FieldMemOperand(array_pointer,
+ SharedFunctionInfo::kOffsetToPreviousContext));
+ __ LoadP(temp, FieldMemOperand(temp, WeakCell::kValueOffset));
+ __ CmpP(temp, native_context);
+ __ bne(&loop_bottom, Label::kNear);
+ // OSR id set to none?
+ __ LoadP(temp,
+ FieldMemOperand(array_pointer,
+ SharedFunctionInfo::kOffsetToPreviousOsrAstId));
+ const int bailout_id = BailoutId::None().ToInt();
+ __ CmpSmiLiteral(temp, Smi::FromInt(bailout_id), r0);
+ __ bne(&loop_bottom, Label::kNear);
+ // Literals available?
+ __ LoadP(temp,
+ FieldMemOperand(array_pointer,
+ SharedFunctionInfo::kOffsetToPreviousLiterals));
+ __ LoadP(temp, FieldMemOperand(temp, WeakCell::kValueOffset));
+ __ JumpIfSmi(temp, &gotta_call_runtime);
+
+ // Save the literals in the closure.
+ __ StoreP(temp, FieldMemOperand(closure, JSFunction::kLiteralsOffset), r0);
+ __ RecordWriteField(closure, JSFunction::kLiteralsOffset, temp, r6,
+ kLRHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET,
+ OMIT_SMI_CHECK);
+
+ // Code available?
+ Register entry = r6;
+ __ LoadP(entry,
+ FieldMemOperand(array_pointer,
+ SharedFunctionInfo::kOffsetToPreviousCachedCode));
+ __ LoadP(entry, FieldMemOperand(entry, WeakCell::kValueOffset));
+ __ JumpIfSmi(entry, &maybe_call_runtime);
+
+ // Found literals and code. Get them into the closure and return.
+ // Store code entry in the closure.
+ __ AddP(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag));
+
+ Label install_optimized_code_and_tailcall;
+ __ bind(&install_optimized_code_and_tailcall);
+ __ StoreP(entry, FieldMemOperand(closure, JSFunction::kCodeEntryOffset), r0);
+ __ RecordWriteCodeEntryField(closure, entry, r7);
+
+ // Link the closure into the optimized function list.
+ // r6 : code entry
+ // r9: native context
+ // r3 : closure
+ __ LoadP(
+ r7, ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST));
+ __ StoreP(r7, FieldMemOperand(closure, JSFunction::kNextFunctionLinkOffset),
+ r0);
+ __ RecordWriteField(closure, JSFunction::kNextFunctionLinkOffset, r7, temp,
+ kLRHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET,
+ OMIT_SMI_CHECK);
+ const int function_list_offset =
+ Context::SlotOffset(Context::OPTIMIZED_FUNCTIONS_LIST);
+ __ StoreP(
+ closure,
+ ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST), r0);
+ // Save closure before the write barrier.
+ __ LoadRR(r7, closure);
+ __ RecordWriteContextSlot(native_context, function_list_offset, r7, temp,
+ kLRHasNotBeenSaved, kDontSaveFPRegs);
+ __ JumpToJSEntry(entry);
+
+ __ bind(&loop_bottom);
+ __ SubSmiLiteral(index, index, Smi::FromInt(SharedFunctionInfo::kEntryLength),
+ r0);
+ __ CmpSmiLiteral(index, Smi::FromInt(1), r0);
+ __ bgt(&loop_top);
+
+ // We found neither literals nor code.
+ __ b(&gotta_call_runtime);
+
+ __ bind(&maybe_call_runtime);
+
+ // Last possibility. Check the context free optimized code map entry.
+ __ LoadP(entry,
+ FieldMemOperand(map, FixedArray::kHeaderSize +
+ SharedFunctionInfo::kSharedCodeIndex));
+ __ LoadP(entry, FieldMemOperand(entry, WeakCell::kValueOffset));
+ __ JumpIfSmi(entry, &try_shared);
+
+ // Store code entry in the closure.
+ __ AddP(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag));
+ __ b(&install_optimized_code_and_tailcall);
+
+ __ bind(&try_shared);
+ // Is the full code valid?
+ __ LoadP(entry,
+ FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset));
+ __ LoadP(entry, FieldMemOperand(entry, SharedFunctionInfo::kCodeOffset));
+ __ LoadlW(r7, FieldMemOperand(entry, Code::kFlagsOffset));
+ __ DecodeField<Code::KindField>(r7);
+ __ CmpP(r7, Operand(Code::BUILTIN));
+ __ beq(&gotta_call_runtime);
+ // Yes, install the full code.
+ __ AddP(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag));
+ __ StoreP(entry, FieldMemOperand(closure, JSFunction::kCodeEntryOffset), r0);
+ __ RecordWriteCodeEntryField(closure, entry, r7);
+ __ JumpToJSEntry(entry);
+
+ __ bind(&gotta_call_runtime);
GenerateTailCallToReturnedCode(masm, Runtime::kCompileLazy);
}
+void Builtins::Generate_CompileBaseline(MacroAssembler* masm) {
+ GenerateTailCallToReturnedCode(masm, Runtime::kCompileBaseline);
+}
+
void Builtins::Generate_CompileOptimized(MacroAssembler* masm) {
GenerateTailCallToReturnedCode(masm,
Runtime::kCompileOptimized_NotConcurrent);
@@ -1242,14 +1479,19 @@
__ SmiUntag(r8);
// Switch on the state.
Label with_tos_register, unknown_state;
- __ CmpP(r8, Operand(FullCodeGenerator::NO_REGISTERS));
+ __ CmpP(
+ r8,
+ Operand(static_cast<intptr_t>(Deoptimizer::BailoutState::NO_REGISTERS)));
__ bne(&with_tos_register);
__ la(sp, MemOperand(sp, 1 * kPointerSize)); // Remove state.
__ Ret();
__ bind(&with_tos_register);
+ DCHECK_EQ(kInterpreterAccumulatorRegister.code(), r2.code());
__ LoadP(r2, MemOperand(sp, 1 * kPointerSize));
- __ CmpP(r8, Operand(FullCodeGenerator::TOS_REG));
+ __ CmpP(
+ r8,
+ Operand(static_cast<intptr_t>(Deoptimizer::BailoutState::TOS_REGISTER)));
__ bne(&unknown_state);
__ la(sp, MemOperand(sp, 2 * kPointerSize)); // Remove state.
__ Ret();
@@ -1457,28 +1699,6 @@
}
// static
-void Builtins::Generate_FunctionHasInstance(MacroAssembler* masm) {
- // ----------- S t a t e -------------
- // -- r2 : argc
- // -- sp[0] : first argument (left-hand side)
- // -- sp[4] : receiver (right-hand side)
- // -----------------------------------
-
- {
- FrameScope scope(masm, StackFrame::INTERNAL);
- __ LoadP(InstanceOfDescriptor::LeftRegister(),
- MemOperand(fp, 2 * kPointerSize)); // Load left-hand side.
- __ LoadP(InstanceOfDescriptor::RightRegister(),
- MemOperand(fp, 3 * kPointerSize)); // Load right-hand side.
- InstanceOfStub stub(masm->isolate(), true);
- __ CallStub(&stub);
- }
-
- // Pop the argument and the receiver.
- __ Ret(2);
-}
-
-// static
void Builtins::Generate_FunctionPrototypeApply(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- r2 : argc
@@ -2416,6 +2636,31 @@
RelocInfo::CODE_TARGET);
}
+// static
+void Builtins::Generate_AllocateInNewSpace(MacroAssembler* masm) {
+ // ----------- S t a t e -------------
+ // -- r3 : requested object size (untagged)
+ // -- lr : return address
+ // -----------------------------------
+ __ SmiTag(r3);
+ __ Push(r3);
+ __ LoadSmiLiteral(cp, Smi::FromInt(0));
+ __ TailCallRuntime(Runtime::kAllocateInNewSpace);
+}
+
+// static
+void Builtins::Generate_AllocateInOldSpace(MacroAssembler* masm) {
+ // ----------- S t a t e -------------
+ // -- r3 : requested object size (untagged)
+ // -- lr : return address
+ // -----------------------------------
+ __ SmiTag(r3);
+ __ LoadSmiLiteral(r4, Smi::FromInt(AllocateTargetSpace::encode(OLD_SPACE)));
+ __ Push(r3, r4);
+ __ LoadSmiLiteral(cp, Smi::FromInt(0));
+ __ TailCallRuntime(Runtime::kAllocateInTargetSpace);
+}
+
void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- r2 : actual number of arguments