7 #if V8_TARGET_ARCH_IA32
18 #define __ ACCESS_MASM(masm)
37 int num_extra_args = 0;
40 Register scratch =
ebx;
50 __ add(
eax, Immediate(num_extra_args + 1));
51 __ JumpToExternalReference(ExternalReference(
id, masm->isolate()));
55 static void CallRuntimePassFunction(
63 __ CallRuntime(function_id, 1);
69 static void GenerateTailCallToSharedCode(MacroAssembler* masm) {
77 static void GenerateTailCallToReturnedCode(MacroAssembler* masm) {
90 ExternalReference stack_limit =
91 ExternalReference::address_of_stack_limit(masm->isolate());
92 __ cmp(
esp, Operand::StaticVariable(stack_limit));
95 CallRuntimePassFunction(masm, Runtime::kTryInstallOptimizedCode);
96 GenerateTailCallToReturnedCode(masm);
99 GenerateTailCallToSharedCode(masm);
103 static void Generate_JSConstructStubHelper(MacroAssembler* masm,
104 bool is_api_function,
105 bool create_memento) {
113 DCHECK(!is_api_function || !create_memento);
117 FrameScope scope(masm, StackFrame::CONSTRUCT);
119 if (create_memento) {
120 __ AssertUndefinedOrAllocationSite(
ebx);
133 Label rt_call, allocated;
134 if (FLAG_inline_new) {
135 Label undo_allocation;
136 ExternalReference debug_step_in_fp =
137 ExternalReference::debug_step_in_fp_address(masm->isolate());
138 __ cmp(Operand::StaticVariable(debug_step_in_fp), Immediate(0));
146 __ JumpIfSmi(
eax, &rt_call);
160 if (!is_api_function) {
181 __ CallRuntime(Runtime::kFinalizeInstanceSize, 1);
195 if (create_memento) {
201 Factory* factory = masm->isolate()->factory();
208 __ mov(
ecx, factory->empty_fixed_array());
216 __ mov(
edx, factory->undefined_value());
218 if (!is_api_function) {
219 Label no_inobject_slack_tracking;
223 __ j(
equal, &no_inobject_slack_tracking);
231 if (FLAG_debug_code) {
234 kUnexpectedNumberOfPreAllocatedPropertyFields);
237 __ mov(
edx, factory->one_pointer_filler_map());
240 __ bind(&no_inobject_slack_tracking);
243 if (create_memento) {
250 factory->allocation_memento_map());
283 __ Assert(
positive, kPropertyAllocationCountFailed);
305 __ mov(
eax, factory->fixed_array_map());
315 __ mov(
edx, factory->undefined_value());
342 __ bind(&undo_allocation);
343 __ UndoAllocationInNewSpace(
ebx);
349 if (create_memento) {
361 if (create_memento) {
362 __ CallRuntime(Runtime::kNewObjectWithAllocationSite, 2);
364 __ CallRuntime(Runtime::kNewObject, 1);
371 Label count_incremented;
372 if (create_memento) {
373 __ jmp(&count_incremented);
380 if (create_memento) {
382 __ cmp(
ecx, masm->isolate()->factory()->undefined_value());
383 __ j(
equal, &count_incremented);
388 __ bind(&count_incremented);
418 if (is_api_function) {
421 masm->isolate()->builtins()->HandleApiCallConstruct();
424 ParameterCount actual(
eax);
430 if (!is_api_function) {
431 masm->isolate()->heap()->SetConstructStubDeoptPCOffset(masm->pc_offset());
440 Label use_receiver, exit;
443 __ JumpIfSmi(
eax, &use_receiver);
452 __ bind(&use_receiver);
467 __ IncrementCounter(masm->isolate()->counters()->constructed_objects(), 1);
473 Generate_JSConstructStubHelper(masm,
false, FLAG_pretenuring_call_new);
478 Generate_JSConstructStubHelper(masm,
true,
false);
482 static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
487 __ Move(
esi, Immediate(0));
509 __ Move(
ecx, Immediate(0));
513 __ push(Operand(
edx, 0));
526 __ mov(
ebx, masm->isolate()->factory()->undefined_value());
530 ParameterCount actual(
eax);
544 Generate_JSEntryTrampolineHelper(masm,
false);
549 Generate_JSEntryTrampolineHelper(masm,
true);
554 CallRuntimePassFunction(masm, Runtime::kCompileLazy);
555 GenerateTailCallToReturnedCode(masm);
560 static void CallCompileOptimized(MacroAssembler* masm,
bool concurrent) {
567 __ Push(masm->isolate()->factory()->ToBoolean(concurrent));
569 __ CallRuntime(Runtime::kCompileOptimized, 2);
576 CallCompileOptimized(masm,
false);
577 GenerateTailCallToReturnedCode(masm);
582 CallCompileOptimized(masm,
true);
583 GenerateTailCallToReturnedCode(masm);
587 static void GenerateMakeCodeYoungAgainCommon(MacroAssembler* masm) {
596 __ sub(Operand(
esp, 0), Immediate(5));
600 FrameScope scope(masm, StackFrame::MANUAL);
601 __ PrepareCallCFunction(2,
ebx);
603 Immediate(ExternalReference::isolate_address(masm->isolate())));
606 ExternalReference::get_make_code_young_function(masm->isolate()), 2);
612 #define DEFINE_CODE_AGE_BUILTIN_GENERATOR(C) \
613 void Builtins::Generate_Make##C##CodeYoungAgainEvenMarking( \
614 MacroAssembler* masm) { \
615 GenerateMakeCodeYoungAgainCommon(masm); \
617 void Builtins::Generate_Make##C##CodeYoungAgainOddMarking( \
618 MacroAssembler* masm) { \
619 GenerateMakeCodeYoungAgainCommon(masm); \
622 #undef DEFINE_CODE_AGE_BUILTIN_GENERATOR
634 FrameScope scope(masm, StackFrame::MANUAL);
635 __ PrepareCallCFunction(2,
ebx);
637 Immediate(ExternalReference::isolate_address(masm->isolate())));
640 ExternalReference::get_mark_code_as_executed_function(masm->isolate()),
659 GenerateMakeCodeYoungAgainCommon(masm);
663 static void Generate_NotifyStubFailureHelper(MacroAssembler* masm,
673 __ CallRuntime(Runtime::kNotifyStubFailure, 0, save_doubles);
689 Generate_NotifyStubFailureHelper(masm,
kSaveFPRegs);
693 static void Generate_NotifyDeoptimizedHelper(MacroAssembler* masm,
700 __ CallRuntime(Runtime::kNotifyDeoptimized, 1);
710 Label not_no_registers, not_tos_eax;
715 __ bind(¬_no_registers);
721 __ bind(¬_tos_eax);
722 __ Abort(kNoCasesLeft);
742 Factory* factory = masm->isolate()->factory();
749 __ push(Immediate(factory->undefined_value()));
757 Label slow, non_function;
760 __ JumpIfSmi(
edi, &non_function);
766 Label shift_arguments;
767 __ Move(
edx, Immediate(0));
768 { Label convert_to_object, use_global_proxy, patch_receiver;
788 __ JumpIfSmi(
ebx, &convert_to_object);
789 __ cmp(
ebx, factory->null_value());
790 __ j(
equal, &use_global_proxy);
791 __ cmp(
ebx, factory->undefined_value());
792 __ j(
equal, &use_global_proxy);
797 __ bind(&convert_to_object);
807 __ Move(
edx, Immediate(0));
815 __ jmp(&patch_receiver);
817 __ bind(&use_global_proxy);
822 __ bind(&patch_receiver);
825 __ jmp(&shift_arguments);
830 __ Move(
edx, Immediate(1));
833 __ bind(&non_function);
834 __ Move(
edx, Immediate(2));
845 __ bind(&shift_arguments);
859 { Label
function, non_proxy;
862 __ Move(
ebx, Immediate(0));
863 __ cmp(
edx, Immediate(1));
870 __ GetBuiltinEntry(
edx, Builtins::CALL_FUNCTION_PROXY);
871 __ jmp(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(),
875 __ GetBuiltinEntry(
edx, Builtins::CALL_NON_FUNCTION);
876 __ jmp(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(),
891 masm->isolate()->builtins()->ArgumentsAdaptorTrampoline());
893 ParameterCount expected(0);
905 __ push(Operand(
ebp, kFunctionOffset));
906 __ push(Operand(
ebp, kArgumentsOffset));
913 ExternalReference real_stack_limit =
914 ExternalReference::address_of_real_stack_limit(masm->isolate());
915 __ mov(
edi, Operand::StaticVariable(real_stack_limit));
936 const int kLimitOffset =
938 const int kIndexOffset = kLimitOffset - 1 *
kPointerSize;
940 __ push(Immediate(0));
943 __ mov(
ebx, Operand(
ebp, kReceiverOffset));
946 Label push_receiver, use_global_proxy;
947 __ mov(
edi, Operand(
ebp, kFunctionOffset));
956 Label call_to_object;
962 Factory* factory = masm->isolate()->factory();
972 __ JumpIfSmi(
ebx, &call_to_object);
973 __ cmp(
ebx, factory->null_value());
974 __ j(
equal, &use_global_proxy);
975 __ cmp(
ebx, factory->undefined_value());
976 __ j(
equal, &use_global_proxy);
981 __ bind(&call_to_object);
985 __ jmp(&push_receiver);
987 __ bind(&use_global_proxy);
993 __ bind(&push_receiver);
1000 __ mov(key, Operand(
ebp, kIndexOffset));
1003 __ mov(receiver, Operand(
ebp, kArgumentsOffset));
1006 if (FLAG_vector_ics) {
1010 Handle<Code> ic = CodeFactory::KeyedLoadIC(masm->isolate()).code();
1021 __ mov(key, Operand(
ebp, kIndexOffset));
1023 __ mov(Operand(
ebp, kIndexOffset), key);
1026 __ cmp(key, Operand(
ebp, kLimitOffset));
1031 ParameterCount actual(
eax);
1034 __ mov(
edi, Operand(
ebp, kFunctionOffset));
1039 frame_scope.GenerateLeaveFrame();
1043 __ bind(&call_proxy);
1046 __ Move(
ebx, Immediate(0));
1047 __ GetBuiltinEntry(
edx, Builtins::CALL_FUNCTION_PROXY);
1048 __ call(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(),
1063 Label generic_array_code;
1068 if (FLAG_debug_code) {
1073 __ Assert(
not_zero, kUnexpectedInitialMapForInternalArrayFunction);
1075 __ Assert(
equal, kUnexpectedInitialMapForInternalArrayFunction);
1081 InternalArrayConstructorStub stub(masm->isolate());
1082 __ TailCallStub(&stub);
1092 Label generic_array_code;
1097 if (FLAG_debug_code) {
1102 __ Assert(
not_zero, kUnexpectedInitialMapForArrayFunction);
1104 __ Assert(
equal, kUnexpectedInitialMapForArrayFunction);
1109 __ mov(
ebx, masm->isolate()->factory()->undefined_value());
1110 ArrayConstructorStub stub(masm->isolate());
1111 __ TailCallStub(&stub);
1123 Counters* counters = masm->isolate()->counters();
1124 __ IncrementCounter(counters->string_ctor_calls(), 1);
1126 if (FLAG_debug_code) {
1129 __ Assert(
equal, kUnexpectedStringFunction);
1136 __ j(
zero, &no_arguments);
1144 Label not_cached, argument_is_string;
1145 __ LookupNumberStringCache(
eax,
1150 __ IncrementCounter(counters->string_ctor_cached_number(), 1);
1151 __ bind(&argument_is_string);
1168 __ LoadGlobalFunctionInitialMap(
edi,
ecx);
1169 if (FLAG_debug_code) {
1172 __ Assert(
equal, kUnexpectedStringWrapperInstanceSize);
1174 __ Assert(
equal, kUnexpectedUnusedPropertiesOfStringWrapper);
1179 Factory* factory = masm->isolate()->factory();
1180 __ Move(
ecx, Immediate(factory->empty_fixed_array()));
1195 Label convert_argument;
1196 __ bind(¬_cached);
1198 __ JumpIfSmi(
eax, &convert_argument);
1202 __ IncrementCounter(counters->string_ctor_string_value(), 1);
1203 __ jmp(&argument_is_string);
1206 __ bind(&convert_argument);
1207 __ IncrementCounter(counters->string_ctor_conversions(), 1);
1216 __ jmp(&argument_is_string);
1220 __ bind(&no_arguments);
1221 __ Move(
ebx, Immediate(factory->empty_string()));
1225 __ jmp(&argument_is_string);
1229 __ bind(&gc_required);
1230 __ IncrementCounter(counters->string_ctor_gc_required(), 1);
1234 __ CallRuntime(Runtime::kNewStringWrapper, 1);
1240 static void ArgumentsAdaptorStackCheck(MacroAssembler* masm,
1241 Label* stack_overflow) {
1250 ExternalReference real_stack_limit =
1251 ExternalReference::address_of_real_stack_limit(masm->isolate());
1252 __ mov(
edx, Operand::StaticVariable(real_stack_limit));
1267 static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) {
1286 static void LeaveArgumentsAdaptorFrame(MacroAssembler* masm) {
1308 Label invoke, dont_adapt_arguments;
1309 __ IncrementCounter(masm->isolate()->counters()->arguments_adaptors(), 1);
1311 Label stack_overflow;
1312 ArgumentsAdaptorStackCheck(masm, &stack_overflow);
1314 Label enough, too_few;
1319 __ j(
equal, &dont_adapt_arguments);
1323 EnterArgumentsAdaptorFrame(masm);
1333 __ push(Operand(
eax, 0));
1342 EnterArgumentsAdaptorFrame(masm);
1351 __ sub(
eax, Immediate(1));
1356 __ push(Operand(
edi, 0));
1365 __ push(Immediate(masm->isolate()->factory()->undefined_value()));
1377 masm->isolate()->heap()->SetArgumentsAdaptorDeoptPCOffset(masm->pc_offset());
1380 LeaveArgumentsAdaptorFrame(masm);
1386 __ bind(&dont_adapt_arguments);
1389 __ bind(&stack_overflow);
1391 FrameScope frame(masm, StackFrame::MANUAL);
1392 EnterArgumentsAdaptorFrame(masm);
1406 __ CallRuntime(Runtime::kCompileForOnStackReplacement, 1);
1411 __ cmp(
eax, Immediate(0));
1439 ExternalReference stack_limit =
1440 ExternalReference::address_of_stack_limit(masm->isolate());
1441 __ cmp(
esp, Operand::StaticVariable(stack_limit));
1445 __ CallRuntime(Runtime::kStackGuard, 0);
1447 __ jmp(masm->isolate()->builtins()->OnStackReplacement(),
static const int kAllocationSiteOffset
static const int kPretenureCreateCountOffset
static const int kLengthOffset
static const int kCallInstructionLength
static void Generate_InternalArrayCode(MacroAssembler *masm)
static void Generate_FunctionApply(MacroAssembler *masm)
static void Generate_Adaptor(MacroAssembler *masm, CFunctionId id, BuiltinExtraArguments extra_args)
static void Generate_NotifyDeoptimized(MacroAssembler *masm)
static void Generate_JSConstructEntryTrampoline(MacroAssembler *masm)
static void Generate_CompileLazy(MacroAssembler *masm)
static void Generate_JSEntryTrampoline(MacroAssembler *masm)
static void Generate_OnStackReplacement(MacroAssembler *masm)
static void Generate_MarkCodeAsExecutedTwice(MacroAssembler *masm)
static void Generate_NotifyLazyDeoptimized(MacroAssembler *masm)
static void Generate_ArgumentsAdaptorTrampoline(MacroAssembler *masm)
static void Generate_JSConstructStubApi(MacroAssembler *masm)
static void Generate_FunctionCall(MacroAssembler *masm)
static void Generate_MarkCodeAsExecutedOnce(MacroAssembler *masm)
static void Generate_NotifyStubFailureSaveDoubles(MacroAssembler *masm)
static void Generate_NotifySoftDeoptimized(MacroAssembler *masm)
static void Generate_ArrayCode(MacroAssembler *masm)
static void Generate_StringConstructCode(MacroAssembler *masm)
static void Generate_NotifyStubFailure(MacroAssembler *masm)
static void Generate_CompileOptimized(MacroAssembler *masm)
static void Generate_OsrAfterStackCheck(MacroAssembler *masm)
static void Generate_InOptimizationQueue(MacroAssembler *masm)
static void Generate_CompileOptimizedConcurrent(MacroAssembler *masm)
static void Generate_JSConstructStubGeneric(MacroAssembler *masm)
static const int kHeaderSize
static const int kDeoptimizationDataOffset
@ INTERNAL_ARRAY_FUNCTION_INDEX
static int SlotOffset(int index)
static const int kFunctionArgOffset
static const int kArgcOffset
static const int kReceiverArgOffset
static const int kArgvOffset
static const int kLengthOffset
static const int kHeaderSize
static int OffsetOfElementAt(int index)
static const int kGlobalProxyOffset
static const int kMapOffset
static const int kSharedFunctionInfoOffset
static const int kNoSlackTracking
static const int kContextOffset
static const int kFinishSlackTracking
static const int kCodeEntryOffset
static const int kPrototypeOrInitialMapOffset
static const int kHeaderSize
static const int kPropertiesOffset
static const int kElementsOffset
static const int kValueOffset
static const int kFunctionOffset
static const Register ReceiverRegister()
static const Register NameRegister()
static const int kBitField3Offset
static const int kInstanceSizeOffset
static const int kPreAllocatedPropertyFieldsOffset
static const int kInObjectPropertiesOffset
static const int kUnusedPropertyFieldsOffset
static void MaybeCallEntryHook(MacroAssembler *masm)
static const int kFormalParameterCountOffset
static const int kDontAdaptArgumentsSentinel
static const int kNativeBitWithinByte
static const int kStrictModeBitWithinByte
static const int kCodeOffset
static Smi * FromInt(int value)
static const int kContextOffset
static const int kExpressionsOffset
static const int kCallerSPOffset
static const Register SlotRegister()
#define DCHECK(condition)
static int Push(SpecialRPOStackFrame *stack, int depth, BasicBlock *child, int unvisited)
Operand FieldOperand(Register object, int offset)
const int kPointerSizeLog2
Condition NegateCondition(Condition cond)
OStream & dec(OStream &os)
STATIC_ASSERT(sizeof(CPURegister)==sizeof(Register))
const intptr_t kSmiTagMask
@ REGISTER_VALUE_IS_INT32
@ NO_CALL_CONSTRUCTOR_FLAGS
Debugger support for the V8 JavaScript engine.