OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 ASSERT(extra_args == NO_EXTRA_ARGUMENTS); | 67 ASSERT(extra_args == NO_EXTRA_ARGUMENTS); |
68 } | 68 } |
69 | 69 |
70 // JumpToExternalReference expects eax to contain the number of arguments | 70 // JumpToExternalReference expects eax to contain the number of arguments |
71 // including the receiver and the extra arguments. | 71 // including the receiver and the extra arguments. |
72 __ add(eax, Immediate(num_extra_args + 1)); | 72 __ add(eax, Immediate(num_extra_args + 1)); |
73 __ JumpToExternalReference(ExternalReference(id, masm->isolate())); | 73 __ JumpToExternalReference(ExternalReference(id, masm->isolate())); |
74 } | 74 } |
75 | 75 |
76 | 76 |
77 void Builtins::Generate_JSConstructCall(MacroAssembler* masm) { | |
78 // ----------- S t a t e ------------- | |
79 // -- eax: number of arguments | |
80 // -- edi: constructor function | |
81 // ----------------------------------- | |
82 | |
83 Label slow, non_function_call; | |
84 // Check that function is not a smi. | |
85 __ JumpIfSmi(edi, &non_function_call); | |
86 // Check that function is a JSFunction. | |
87 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); | |
88 __ j(not_equal, &slow); | |
89 | |
90 // Jump to the function-specific construct stub. | |
91 __ mov(ebx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); | |
92 __ mov(ebx, FieldOperand(ebx, SharedFunctionInfo::kConstructStubOffset)); | |
93 __ lea(ebx, FieldOperand(ebx, Code::kHeaderSize)); | |
94 __ jmp(ebx); | |
95 | |
96 // edi: called object | |
97 // eax: number of arguments | |
98 // ecx: object map | |
99 Label do_call; | |
100 __ bind(&slow); | |
101 __ CmpInstanceType(ecx, JS_FUNCTION_PROXY_TYPE); | |
102 __ j(not_equal, &non_function_call); | |
103 __ GetBuiltinEntry(edx, Builtins::CALL_FUNCTION_PROXY_AS_CONSTRUCTOR); | |
104 __ jmp(&do_call); | |
105 | |
106 __ bind(&non_function_call); | |
107 __ GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR); | |
108 __ bind(&do_call); | |
109 // Set expected number of arguments to zero (not changing eax). | |
110 __ Set(ebx, Immediate(0)); | |
111 Handle<Code> arguments_adaptor = | |
112 masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(); | |
113 __ SetCallKind(ecx, CALL_AS_METHOD); | |
114 __ jmp(arguments_adaptor, RelocInfo::CODE_TARGET); | |
115 } | |
116 | |
117 | |
118 static void Generate_JSConstructStubHelper(MacroAssembler* masm, | 77 static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
119 bool is_api_function, | 78 bool is_api_function, |
120 bool count_constructions) { | 79 bool count_constructions) { |
| 80 // ----------- S t a t e ------------- |
| 81 // -- eax: number of arguments |
| 82 // -- edi: constructor function |
| 83 // ----------------------------------- |
| 84 |
121 // Should never count constructions for api objects. | 85 // Should never count constructions for api objects. |
122 ASSERT(!is_api_function || !count_constructions); | 86 ASSERT(!is_api_function || !count_constructions); |
123 | 87 |
124 // Enter a construct frame. | 88 // Enter a construct frame. |
125 { | 89 { |
126 FrameScope scope(masm, StackFrame::CONSTRUCT); | 90 FrameScope scope(masm, StackFrame::CONSTRUCT); |
127 | 91 |
128 // Store a smi-tagged arguments count on the stack. | 92 // Store a smi-tagged arguments count on the stack. |
129 __ SmiTag(eax); | 93 __ SmiTag(eax); |
130 __ push(eax); | 94 __ push(eax); |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 __ bind(&entry); | 411 __ bind(&entry); |
448 __ cmp(ecx, eax); | 412 __ cmp(ecx, eax); |
449 __ j(not_equal, &loop); | 413 __ j(not_equal, &loop); |
450 | 414 |
451 // Get the function from the stack and call it. | 415 // Get the function from the stack and call it. |
452 // kPointerSize for the receiver. | 416 // kPointerSize for the receiver. |
453 __ mov(edi, Operand(esp, eax, times_4, kPointerSize)); | 417 __ mov(edi, Operand(esp, eax, times_4, kPointerSize)); |
454 | 418 |
455 // Invoke the code. | 419 // Invoke the code. |
456 if (is_construct) { | 420 if (is_construct) { |
457 __ call(masm->isolate()->builtins()->JSConstructCall(), | 421 CallConstructStub stub(NO_CALL_FUNCTION_FLAGS); |
458 RelocInfo::CODE_TARGET); | 422 __ CallStub(&stub); |
459 } else { | 423 } else { |
460 ParameterCount actual(eax); | 424 ParameterCount actual(eax); |
461 __ InvokeFunction(edi, actual, CALL_FUNCTION, | 425 __ InvokeFunction(edi, actual, CALL_FUNCTION, |
462 NullCallWrapper(), CALL_AS_METHOD); | 426 NullCallWrapper(), CALL_AS_METHOD); |
463 } | 427 } |
464 | 428 |
465 // Exit the internal frame. Notice that this also removes the empty. | 429 // Exit the internal frame. Notice that this also removes the empty. |
466 // context and the function left on the stack by the code | 430 // context and the function left on the stack by the code |
467 // invocation. | 431 // invocation. |
468 } | 432 } |
(...skipping 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1724 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); | 1688 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); |
1725 generator.Generate(); | 1689 generator.Generate(); |
1726 } | 1690 } |
1727 | 1691 |
1728 | 1692 |
1729 #undef __ | 1693 #undef __ |
1730 } | 1694 } |
1731 } // namespace v8::internal | 1695 } // namespace v8::internal |
1732 | 1696 |
1733 #endif // V8_TARGET_ARCH_IA32 | 1697 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |