OLD | NEW |
---|---|
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 36 matching lines...) Loading... | |
47 __ JumpToBuiltin(ExternalReference(id)); | 47 __ JumpToBuiltin(ExternalReference(id)); |
48 } | 48 } |
49 | 49 |
50 | 50 |
51 void Builtins::Generate_JSConstructCall(MacroAssembler* masm) { | 51 void Builtins::Generate_JSConstructCall(MacroAssembler* masm) { |
52 // ----------- S t a t e ------------- | 52 // ----------- S t a t e ------------- |
53 // -- eax: number of arguments | 53 // -- eax: number of arguments |
54 // -- edi: constructor function | 54 // -- edi: constructor function |
55 // ----------------------------------- | 55 // ----------------------------------- |
56 | 56 |
57 Label non_function_call; | |
58 // Check that function is not a Smi. | |
59 __ test(edi, Immediate(kSmiTagMask)); | |
60 __ j(zero, &non_function_call); | |
61 // Check that function is a JSFunction | |
62 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); | |
63 __ j(not_equal, &non_function_call); | |
64 | |
57 // Enter a construct frame. | 65 // Enter a construct frame. |
58 __ EnterConstructFrame(); | 66 __ EnterConstructFrame(); |
59 | |
60 // Store a smi-tagged arguments count on the stack. | 67 // Store a smi-tagged arguments count on the stack. |
61 __ shl(eax, kSmiTagSize); | 68 __ shl(eax, kSmiTagSize); |
62 __ push(eax); | 69 __ push(eax); |
63 | 70 |
64 // Push the function to invoke on the stack. | 71 // Push the function to invoke on the stack. |
65 __ push(edi); | 72 __ push(edi); |
66 | 73 |
67 // Try to allocate the object without transitioning into C code. If any of the | 74 // Try to allocate the object without transitioning into C code. If any of the |
68 // preconditions is not met, the code bails out to the runtime call. | 75 // preconditions is not met, the code bails out to the runtime call. |
69 Label rt_call, allocated; | 76 Label rt_call, allocated; |
70 if (FLAG_inline_new) { | 77 if (FLAG_inline_new) { |
71 Label undo_allocation; | 78 Label undo_allocation; |
72 ExternalReference debug_step_in_fp = | 79 ExternalReference debug_step_in_fp = |
73 ExternalReference::debug_step_in_fp_address(); | 80 ExternalReference::debug_step_in_fp_address(); |
74 __ cmp(Operand::StaticVariable(debug_step_in_fp), Immediate(0)); | 81 __ cmp(Operand::StaticVariable(debug_step_in_fp), Immediate(0)); |
75 __ j(not_equal, &rt_call); | 82 __ j(not_equal, &rt_call); |
76 // Check that function is not a Smi. | |
77 __ test(edi, Immediate(kSmiTagMask)); | |
78 __ j(zero, &rt_call); | |
79 // Check that function is a JSFunction | |
80 __ CmpObjectType(edi, JS_FUNCTION_TYPE, eax); | |
81 __ j(not_equal, &rt_call); | |
82 | 83 |
83 // Verified that the constructor is a JSFunction. | 84 // Verified that the constructor is a JSFunction. |
84 // Load the initial map and verify that it is in fact a map. | 85 // Load the initial map and verify that it is in fact a map. |
85 // edi: constructor | 86 // edi: constructor |
86 __ mov(eax, FieldOperand(edi, JSFunction::kPrototypeOrInitialMapOffset)); | 87 __ mov(eax, FieldOperand(edi, JSFunction::kPrototypeOrInitialMapOffset)); |
87 // Will both indicate a NULL and a Smi | 88 // Will both indicate a NULL and a Smi |
88 __ test(eax, Immediate(kSmiTagMask)); | 89 __ test(eax, Immediate(kSmiTagMask)); |
89 __ j(zero, &rt_call); | 90 __ j(zero, &rt_call); |
90 // edi: constructor | 91 // edi: constructor |
91 // eax: initial map (if proven valid below) | 92 // eax: initial map (if proven valid below) |
(...skipping 201 matching lines...) Loading... | |
293 __ bind(&exit); | 294 __ bind(&exit); |
294 __ mov(ebx, Operand(esp, kPointerSize)); // get arguments count | 295 __ mov(ebx, Operand(esp, kPointerSize)); // get arguments count |
295 __ LeaveConstructFrame(); | 296 __ LeaveConstructFrame(); |
296 | 297 |
297 // Remove caller arguments from the stack and return. | 298 // Remove caller arguments from the stack and return. |
298 ASSERT(kSmiTagSize == 1 && kSmiTag == 0); | 299 ASSERT(kSmiTagSize == 1 && kSmiTag == 0); |
299 __ pop(ecx); | 300 __ pop(ecx); |
300 __ lea(esp, Operand(esp, ebx, times_2, 1 * kPointerSize)); // 1 ~ receiver | 301 __ lea(esp, Operand(esp, ebx, times_2, 1 * kPointerSize)); // 1 ~ receiver |
301 __ push(ecx); | 302 __ push(ecx); |
302 __ ret(0); | 303 __ ret(0); |
304 | |
305 // edi: called object | |
306 // eax: number of arguments | |
307 __ bind(&non_function_call); | |
308 | |
309 __ xor_(ebx, Operand(ebx)); | |
Mads Ager (chromium)
2009/04/28 10:50:15
Add a comment that this is setting the arguments c
Kevin Millikin (Chromium)
2009/04/28 11:48:43
Setting the expected number of arguments (not chan
| |
310 __ GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION); | |
311 __ jmp(Handle<Code>(builtin(ArgumentsAdaptorTrampoline)), | |
312 RelocInfo::CODE_TARGET); | |
303 } | 313 } |
304 | 314 |
305 | 315 |
306 static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, | 316 static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, |
307 bool is_construct) { | 317 bool is_construct) { |
308 // Clear the context before we push it when entering the JS frame. | 318 // Clear the context before we push it when entering the JS frame. |
309 __ xor_(esi, Operand(esi)); // clear esi | 319 __ xor_(esi, Operand(esi)); // clear esi |
310 | 320 |
311 // Enter an internal frame. | 321 // Enter an internal frame. |
312 __ EnterInternalFrame(); | 322 __ EnterInternalFrame(); |
(...skipping 434 matching lines...) Loading... | |
747 // Dont adapt arguments. | 757 // Dont adapt arguments. |
748 // ------------------------------------------- | 758 // ------------------------------------------- |
749 __ bind(&dont_adapt_arguments); | 759 __ bind(&dont_adapt_arguments); |
750 __ jmp(Operand(edx)); | 760 __ jmp(Operand(edx)); |
751 } | 761 } |
752 | 762 |
753 | 763 |
754 #undef __ | 764 #undef __ |
755 | 765 |
756 } } // namespace v8::internal | 766 } } // namespace v8::internal |
OLD | NEW |