OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 __ JumpToExternalReference(ExternalReference(id, masm->isolate()), 1); | 72 __ JumpToExternalReference(ExternalReference(id, masm->isolate()), 1); |
73 } | 73 } |
74 | 74 |
75 | 75 |
76 void Builtins::Generate_JSConstructCall(MacroAssembler* masm) { | 76 void Builtins::Generate_JSConstructCall(MacroAssembler* masm) { |
77 // ----------- S t a t e ------------- | 77 // ----------- S t a t e ------------- |
78 // -- rax: number of arguments | 78 // -- rax: number of arguments |
79 // -- rdi: constructor function | 79 // -- rdi: constructor function |
80 // ----------------------------------- | 80 // ----------------------------------- |
81 | 81 |
82 Label non_function_call; | 82 Label slow, non_function_call; |
83 // Check that function is not a smi. | 83 // Check that function is not a smi. |
84 __ JumpIfSmi(rdi, &non_function_call); | 84 __ JumpIfSmi(rdi, &non_function_call); |
85 // Check that function is a JSFunction. | 85 // Check that function is a JSFunction. |
86 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); | 86 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); |
87 __ j(not_equal, &non_function_call); | 87 __ j(not_equal, &slow); |
88 | 88 |
89 // Jump to the function-specific construct stub. | 89 // Jump to the function-specific construct stub. |
90 __ movq(rbx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); | 90 __ movq(rbx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); |
91 __ movq(rbx, FieldOperand(rbx, SharedFunctionInfo::kConstructStubOffset)); | 91 __ movq(rbx, FieldOperand(rbx, SharedFunctionInfo::kConstructStubOffset)); |
92 __ lea(rbx, FieldOperand(rbx, Code::kHeaderSize)); | 92 __ lea(rbx, FieldOperand(rbx, Code::kHeaderSize)); |
93 __ jmp(rbx); | 93 __ jmp(rbx); |
94 | 94 |
95 // rdi: called object | 95 // rdi: called object |
96 // rax: number of arguments | 96 // rax: number of arguments |
| 97 // rcx: object map |
| 98 Label do_call; |
| 99 __ bind(&slow); |
| 100 __ CmpInstanceType(rcx, JS_FUNCTION_PROXY_TYPE); |
| 101 __ j(not_equal, &non_function_call); |
| 102 __ GetBuiltinEntry(rdx, Builtins::CALL_FUNCTION_PROXY_AS_CONSTRUCTOR); |
| 103 __ jmp(&do_call); |
| 104 |
97 __ bind(&non_function_call); | 105 __ bind(&non_function_call); |
| 106 __ GetBuiltinEntry(rdx, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR); |
| 107 __ bind(&do_call); |
98 // Set expected number of arguments to zero (not changing rax). | 108 // Set expected number of arguments to zero (not changing rax). |
99 __ Set(rbx, 0); | 109 __ Set(rbx, 0); |
100 __ GetBuiltinEntry(rdx, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR); | |
101 __ SetCallKind(rcx, CALL_AS_METHOD); | 110 __ SetCallKind(rcx, CALL_AS_METHOD); |
102 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), | 111 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), |
103 RelocInfo::CODE_TARGET); | 112 RelocInfo::CODE_TARGET); |
104 } | 113 } |
105 | 114 |
106 | 115 |
107 static void Generate_JSConstructStubHelper(MacroAssembler* masm, | 116 static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
108 bool is_api_function, | 117 bool is_api_function, |
109 bool count_constructions) { | 118 bool count_constructions) { |
110 // Should never count constructions for api objects. | 119 // Should never count constructions for api objects. |
(...skipping 1443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1554 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); | 1563 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); |
1555 generator.Generate(); | 1564 generator.Generate(); |
1556 } | 1565 } |
1557 | 1566 |
1558 | 1567 |
1559 #undef __ | 1568 #undef __ |
1560 | 1569 |
1561 } } // namespace v8::internal | 1570 } } // namespace v8::internal |
1562 | 1571 |
1563 #endif // V8_TARGET_ARCH_X64 | 1572 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |