diff options
Diffstat (limited to 'deps/v8/src/builtins/mips/builtins-mips.cc')
-rw-r--r-- | deps/v8/src/builtins/mips/builtins-mips.cc | 171 |
1 files changed, 77 insertions, 94 deletions
diff --git a/deps/v8/src/builtins/mips/builtins-mips.cc b/deps/v8/src/builtins/mips/builtins-mips.cc index b9c4a72dd0..78ca6c5a6f 100644 --- a/deps/v8/src/builtins/mips/builtins-mips.cc +++ b/deps/v8/src/builtins/mips/builtins-mips.cc @@ -139,7 +139,7 @@ void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) { __ LoadRoot(t2, root_index); __ ldc1(f0, FieldMemOperand(t2, HeapNumber::kValueOffset)); - Label done_loop, loop; + Label done_loop, loop, done; __ mov(a3, a0); __ bind(&loop); { @@ -195,15 +195,25 @@ void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) { // accumulator value on the left hand side (f0) and the next parameter value // on the right hand side (f2). // We need to work out which HeapNumber (or smi) the result came from. - Label compare_nan, set_value; + Label compare_nan, set_value, ool_min, ool_max; __ BranchF(nullptr, &compare_nan, eq, f0, f2); __ Move(t0, t1, f0); if (kind == MathMaxMinKind::kMin) { - __ MinNaNCheck_d(f0, f0, f2); + __ Float64Min(f0, f0, f2, &ool_min); } else { DCHECK(kind == MathMaxMinKind::kMax); - __ MaxNaNCheck_d(f0, f0, f2); + __ Float64Max(f0, f0, f2, &ool_max); } + __ jmp(&done); + + __ bind(&ool_min); + __ Float64MinOutOfLine(f0, f0, f2); + __ jmp(&done); + + __ bind(&ool_max); + __ Float64MaxOutOfLine(f0, f0, f2); + + __ bind(&done); __ Move(at, t8, f0); __ Branch(&set_value, ne, t0, Operand(at)); __ Branch(&set_value, ne, t1, Operand(t8)); @@ -331,11 +341,11 @@ void Builtins::Generate_NumberConstructor_ConstructStub(MacroAssembler* masm) { __ bind(&new_object); { FrameScope scope(masm, StackFrame::MANUAL); - FastNewObjectStub stub(masm->isolate()); __ SmiTag(t0); __ EnterBuiltinFrame(cp, a1, t0); __ Push(a0); // first argument - __ CallStub(&stub); + __ Call(CodeFactory::FastNewObject(masm->isolate()).code(), + RelocInfo::CODE_TARGET); __ Pop(a0); __ LeaveBuiltinFrame(cp, a1, t0); __ SmiUntag(t0); @@ -482,11 +492,11 @@ void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) { __ bind(&new_object); { FrameScope scope(masm, StackFrame::MANUAL); - FastNewObjectStub stub(masm->isolate()); __ SmiTag(t0); __ EnterBuiltinFrame(cp, a1, t0); __ Push(a0); // first argument - __ CallStub(&stub); + __ Call(CodeFactory::FastNewObject(masm->isolate()).code(), + RelocInfo::CODE_TARGET); __ Pop(a0); __ LeaveBuiltinFrame(cp, a1, t0); __ SmiUntag(t0); @@ -575,8 +585,8 @@ void Generate_JSConstructStubHelper(MacroAssembler* masm, bool is_api_function, if (create_implicit_receiver) { // Allocate the new receiver object. __ Push(a1, a3); - FastNewObjectStub stub(masm->isolate()); - __ CallStub(&stub); + __ Call(CodeFactory::FastNewObject(masm->isolate()).code(), + RelocInfo::CODE_TARGET); __ mov(t4, v0); __ Pop(a1, a3); @@ -854,18 +864,17 @@ void Builtins::Generate_ResumeGeneratorTrampoline(MacroAssembler* masm) { __ sw(a2, FieldMemOperand(a1, JSGeneratorObject::kResumeModeOffset)); // Load suspended function and context. - __ lw(cp, FieldMemOperand(a1, JSGeneratorObject::kContextOffset)); __ lw(t0, FieldMemOperand(a1, JSGeneratorObject::kFunctionOffset)); + __ lw(cp, FieldMemOperand(t0, JSFunction::kContextOffset)); // Flood function if we are stepping. 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); - __ li(t1, Operand(last_step_action)); + ExternalReference debug_hook = + ExternalReference::debug_hook_on_function_call_address(masm->isolate()); + __ li(t1, Operand(debug_hook)); __ lb(t1, MemOperand(t1)); - __ Branch(&prepare_step_in_if_stepping, ge, t1, Operand(StepIn)); + __ Branch(&prepare_step_in_if_stepping, ne, t1, Operand(zero_reg)); // Flood function if we need to continue stepping in the suspended generator. ExternalReference debug_suspended_generator = @@ -905,14 +914,15 @@ void Builtins::Generate_ResumeGeneratorTrampoline(MacroAssembler* masm) { __ bind(&done_loop); } - // Dispatch on the kind of generator object. - Label old_generator; - __ lw(a3, FieldMemOperand(t0, JSFunction::kSharedFunctionInfoOffset)); - __ lw(a3, FieldMemOperand(a3, SharedFunctionInfo::kFunctionDataOffset)); - __ GetObjectType(a3, a3, a3); - __ Branch(&old_generator, ne, a3, Operand(BYTECODE_ARRAY_TYPE)); + // Underlying function needs to have bytecode available. + if (FLAG_debug_code) { + __ lw(a3, FieldMemOperand(t0, JSFunction::kSharedFunctionInfoOffset)); + __ lw(a3, FieldMemOperand(a3, SharedFunctionInfo::kFunctionDataOffset)); + __ GetObjectType(a3, a3, a3); + __ Assert(eq, kMissingBytecodeArray, a3, Operand(BYTECODE_ARRAY_TYPE)); + } - // New-style (ignition/turbofan) generator object. + // Resume (Ignition/TurboFan) generator object. { __ lw(a0, FieldMemOperand(t0, JSFunction::kSharedFunctionInfoOffset)); __ lw(a0, @@ -927,54 +937,11 @@ void Builtins::Generate_ResumeGeneratorTrampoline(MacroAssembler* masm) { __ Jump(a2); } - // 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); - __ Push(ra, fp); - __ Move(fp, sp); - __ Push(cp, t0); - - // Restore the operand stack. - __ lw(a0, FieldMemOperand(a1, JSGeneratorObject::kOperandStackOffset)); - __ lw(a3, FieldMemOperand(a0, FixedArray::kLengthOffset)); - __ Addu(a0, a0, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); - __ Lsa(a3, a0, a3, kPointerSizeLog2 - 1); - { - Label done_loop, loop; - __ bind(&loop); - __ Branch(&done_loop, eq, a0, Operand(a3)); - __ lw(t1, MemOperand(a0)); - __ Push(t1); - __ Branch(USE_DELAY_SLOT, &loop); - __ addiu(a0, a0, kPointerSize); // In delay slot. - __ bind(&done_loop); - } - - // Reset operand stack so we don't leak. - __ LoadRoot(t1, Heap::kEmptyFixedArrayRootIndex); - __ sw(t1, FieldMemOperand(a1, JSGeneratorObject::kOperandStackOffset)); - - // Resume the generator function at the continuation. - __ lw(a3, FieldMemOperand(t0, JSFunction::kSharedFunctionInfoOffset)); - __ lw(a3, FieldMemOperand(a3, SharedFunctionInfo::kCodeOffset)); - __ Addu(a3, a3, Operand(Code::kHeaderSize - kHeapObjectTag)); - __ lw(a2, FieldMemOperand(a1, JSGeneratorObject::kContinuationOffset)); - __ SmiUntag(a2); - __ Addu(a3, a3, Operand(a2)); - __ li(a2, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting))); - __ sw(a2, FieldMemOperand(a1, JSGeneratorObject::kContinuationOffset)); - __ Move(v0, a1); // Continuation expects generator object in v0. - __ Jump(a3); - } - __ bind(&prepare_step_in_if_stepping); { FrameScope scope(masm, StackFrame::INTERNAL); __ Push(a1, a2, t0); - __ CallRuntime(Runtime::kDebugPrepareStepInIfStepping); + __ CallRuntime(Runtime::kDebugOnFunctionCall); __ Pop(a1, a2); } __ Branch(USE_DELAY_SLOT, &stepping_prepared); @@ -1071,6 +1038,11 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { Operand(BYTECODE_ARRAY_TYPE)); } + // Reset code age. + DCHECK_EQ(0, BytecodeArray::kNoAgeBytecodeAge); + __ sb(zero_reg, FieldMemOperand(kInterpreterBytecodeArrayRegister, + BytecodeArray::kBytecodeAgeOffset)); + // Load initial bytecode offset. __ li(kInterpreterBytecodeOffsetRegister, Operand(BytecodeArray::kHeaderSize - kHeapObjectTag)); @@ -1407,11 +1379,6 @@ void Builtins::Generate_CompileLazy(MacroAssembler* masm) { SharedFunctionInfo::kOffsetToPreviousContext)); __ lw(temp, FieldMemOperand(temp, WeakCell::kValueOffset)); __ Branch(&loop_bottom, ne, temp, Operand(native_context)); - // OSR id set to none? - __ lw(temp, FieldMemOperand(array_pointer, - SharedFunctionInfo::kOffsetToPreviousOsrAstId)); - const int bailout_id = BailoutId::None().ToInt(); - __ Branch(&loop_bottom, ne, temp, Operand(Smi::FromInt(bailout_id))); // Literals available? __ lw(temp, FieldMemOperand(array_pointer, SharedFunctionInfo::kOffsetToPreviousLiterals)); @@ -1484,13 +1451,13 @@ void Builtins::Generate_CompileLazy(MacroAssembler* masm) { __ And(t1, t1, Operand(1 << SharedFunctionInfo::kMarkedForTierUpBitWithinByte)); __ Branch(&gotta_call_runtime_no_stack, ne, t1, Operand(zero_reg)); - // Is the full code valid? + + // If SFI points to anything other than CompileLazy, install that. __ lw(entry, FieldMemOperand(entry, SharedFunctionInfo::kCodeOffset)); - __ lw(t1, FieldMemOperand(entry, Code::kFlagsOffset)); - __ And(t1, t1, Operand(Code::KindField::kMask)); - __ srl(t1, t1, Code::KindField::kShift); - __ Branch(&gotta_call_runtime_no_stack, eq, t1, Operand(Code::BUILTIN)); - // Yes, install the full code. + __ Move(t1, masm->CodeObject()); + __ Branch(&gotta_call_runtime_no_stack, eq, entry, Operand(t1)); + + // Install the SFI's code entry. __ Addu(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag)); __ sw(entry, FieldMemOperand(closure, JSFunction::kCodeEntryOffset)); __ RecordWriteCodeEntryField(closure, entry, t1); @@ -1605,14 +1572,9 @@ static void GenerateMakeCodeYoungAgainCommon(MacroAssembler* masm) { __ Jump(a0); } -#define DEFINE_CODE_AGE_BUILTIN_GENERATOR(C) \ - void Builtins::Generate_Make##C##CodeYoungAgainEvenMarking( \ - MacroAssembler* masm) { \ - GenerateMakeCodeYoungAgainCommon(masm); \ - } \ - void Builtins::Generate_Make##C##CodeYoungAgainOddMarking( \ - MacroAssembler* masm) { \ - GenerateMakeCodeYoungAgainCommon(masm); \ +#define DEFINE_CODE_AGE_BUILTIN_GENERATOR(C) \ + void Builtins::Generate_Make##C##CodeYoungAgain(MacroAssembler* masm) { \ + GenerateMakeCodeYoungAgainCommon(masm); \ } CODE_AGE_LIST(DEFINE_CODE_AGE_BUILTIN_GENERATOR) #undef DEFINE_CODE_AGE_BUILTIN_GENERATOR @@ -2173,7 +2135,8 @@ void Builtins::Generate_Apply(MacroAssembler* masm) { // Create the list of arguments from the array-like argumentsList. { - Label create_arguments, create_array, create_runtime, done_create; + Label create_arguments, create_array, create_holey_array, create_runtime, + done_create; __ JumpIfSmi(a0, &create_runtime); // Load the map of argumentsList into a2. @@ -2189,8 +2152,7 @@ void Builtins::Generate_Apply(MacroAssembler* masm) { __ Branch(&create_arguments, eq, a2, Operand(at)); // Check if argumentsList is a fast JSArray. - __ lw(v0, FieldMemOperand(a2, HeapObject::kMapOffset)); - __ lbu(v0, FieldMemOperand(v0, Map::kInstanceTypeOffset)); + __ lbu(v0, FieldMemOperand(a2, Map::kInstanceTypeOffset)); __ Branch(&create_array, eq, v0, Operand(JS_ARRAY_TYPE)); // Ask the runtime to create the list (actually a FixedArray). @@ -2216,15 +2178,32 @@ void Builtins::Generate_Apply(MacroAssembler* masm) { __ mov(a0, t0); __ Branch(&done_create); + // For holey JSArrays we need to check that the array prototype chain + // protector is intact and our prototype is the Array.prototype actually. + __ bind(&create_holey_array); + __ lw(a2, FieldMemOperand(a2, Map::kPrototypeOffset)); + __ lw(at, ContextMemOperand(t0, Context::INITIAL_ARRAY_PROTOTYPE_INDEX)); + __ Branch(&create_runtime, ne, a2, Operand(at)); + __ LoadRoot(at, Heap::kArrayProtectorRootIndex); + __ lw(a2, FieldMemOperand(at, PropertyCell::kValueOffset)); + __ Branch(&create_runtime, ne, a2, + Operand(Smi::FromInt(Isolate::kProtectorValid))); + __ lw(a2, FieldMemOperand(a0, JSArray::kLengthOffset)); + __ lw(a0, FieldMemOperand(a0, JSArray::kElementsOffset)); + __ SmiUntag(a2); + __ Branch(&done_create); + // Try to create the list from a JSArray object. __ bind(&create_array); - __ lw(a2, FieldMemOperand(a2, Map::kBitField2Offset)); - __ DecodeField<Map::ElementsKindBits>(a2); + __ lbu(t1, FieldMemOperand(a2, Map::kBitField2Offset)); + __ DecodeField<Map::ElementsKindBits>(t1); STATIC_ASSERT(FAST_SMI_ELEMENTS == 0); STATIC_ASSERT(FAST_HOLEY_SMI_ELEMENTS == 1); STATIC_ASSERT(FAST_ELEMENTS == 2); - __ Branch(&create_runtime, hi, a2, Operand(FAST_ELEMENTS)); - __ Branch(&create_runtime, eq, a2, Operand(FAST_HOLEY_SMI_ELEMENTS)); + STATIC_ASSERT(FAST_HOLEY_ELEMENTS == 3); + __ Branch(&create_holey_array, eq, t1, Operand(FAST_HOLEY_SMI_ELEMENTS)); + __ Branch(&create_holey_array, eq, t1, Operand(FAST_HOLEY_ELEMENTS)); + __ Branch(&create_runtime, hi, t1, Operand(FAST_ELEMENTS)); __ lw(a2, FieldMemOperand(a0, JSArray::kLengthOffset)); __ lw(a0, FieldMemOperand(a0, JSArray::kElementsOffset)); __ SmiUntag(a2); @@ -2259,11 +2238,15 @@ void Builtins::Generate_Apply(MacroAssembler* masm) { // Push arguments onto the stack (thisArgument is already on the stack). { __ mov(t0, zero_reg); - Label done, loop; + Label done, push, loop; + __ LoadRoot(t1, Heap::kTheHoleValueRootIndex); __ bind(&loop); __ Branch(&done, eq, t0, Operand(a2)); __ Lsa(at, a0, t0, kPointerSizeLog2); __ lw(at, FieldMemOperand(at, FixedArray::kHeaderSize)); + __ Branch(&push, ne, t1, Operand(at)); + __ LoadRoot(at, Heap::kUndefinedValueRootIndex); + __ bind(&push); __ Push(at); __ Addu(t0, t0, Operand(1)); __ Branch(&loop); |