OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 4161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4172 int original_height = frame_->height(); | 4172 int original_height = frame_->height(); |
4173 #endif | 4173 #endif |
4174 Comment cmnt(masm_, "[ CallNew"); | 4174 Comment cmnt(masm_, "[ CallNew"); |
4175 | 4175 |
4176 // According to ECMA-262, section 11.2.2, page 44, the function | 4176 // According to ECMA-262, section 11.2.2, page 44, the function |
4177 // expression in new calls must be evaluated before the | 4177 // expression in new calls must be evaluated before the |
4178 // arguments. This is different from ordinary calls, where the | 4178 // arguments. This is different from ordinary calls, where the |
4179 // actual function to call is resolved after the arguments have been | 4179 // actual function to call is resolved after the arguments have been |
4180 // evaluated. | 4180 // evaluated. |
4181 | 4181 |
4182 // Compute function to call and use the global object as the | 4182 // Push constructor on the stack. If it's not a function it's used as |
4183 // receiver. There is no need to use the global proxy here because | 4183 // receiver for CALL_NON_FUNCTION, otherwise the value on the stack is |
4184 // it will always be replaced with a newly allocated object. | 4184 // ignored. |
4185 Load(node->expression()); | 4185 Load(node->expression()); |
4186 LoadGlobal(); | |
4187 | 4186 |
4188 // Push the arguments ("left-to-right") on the stack. | 4187 // Push the arguments ("left-to-right") on the stack. |
4189 ZoneList<Expression*>* args = node->arguments(); | 4188 ZoneList<Expression*>* args = node->arguments(); |
4190 int arg_count = args->length(); | 4189 int arg_count = args->length(); |
4191 for (int i = 0; i < arg_count; i++) { | 4190 for (int i = 0; i < arg_count; i++) { |
4192 Load(args->at(i)); | 4191 Load(args->at(i)); |
4193 } | 4192 } |
4194 | 4193 |
| 4194 // Spill everything from here to simplify the implementation. |
4195 VirtualFrame::SpilledScope spilled_scope(frame_); | 4195 VirtualFrame::SpilledScope spilled_scope(frame_); |
4196 | 4196 |
4197 // r0: the number of arguments. | 4197 // Load the argument count into r0 and the function into r1 as per |
| 4198 // calling convention. |
4198 __ mov(r0, Operand(arg_count)); | 4199 __ mov(r0, Operand(arg_count)); |
4199 // Load the function into r1 as per calling convention. | 4200 __ ldr(r1, frame_->ElementAt(arg_count)); |
4200 __ ldr(r1, frame_->ElementAt(arg_count + 1)); | |
4201 | 4201 |
4202 // Call the construct call builtin that handles allocation and | 4202 // Call the construct call builtin that handles allocation and |
4203 // constructor invocation. | 4203 // constructor invocation. |
4204 CodeForSourcePosition(node->position()); | 4204 CodeForSourcePosition(node->position()); |
4205 Handle<Code> ic(Builtins::builtin(Builtins::JSConstructCall)); | 4205 Handle<Code> ic(Builtins::builtin(Builtins::JSConstructCall)); |
4206 frame_->CallCodeObject(ic, RelocInfo::CONSTRUCT_CALL, arg_count + 1); | 4206 frame_->CallCodeObject(ic, RelocInfo::CONSTRUCT_CALL, arg_count + 1); |
| 4207 frame_->EmitPush(r0); |
4207 | 4208 |
4208 // Discard old TOS value and push r0 on the stack (same as Pop(), push(r0)). | |
4209 __ str(r0, frame_->Top()); | |
4210 ASSERT_EQ(original_height + 1, frame_->height()); | 4209 ASSERT_EQ(original_height + 1, frame_->height()); |
4211 } | 4210 } |
4212 | 4211 |
4213 | 4212 |
4214 void CodeGenerator::GenerateClassOf(ZoneList<Expression*>* args) { | 4213 void CodeGenerator::GenerateClassOf(ZoneList<Expression*>* args) { |
4215 Register scratch = VirtualFrame::scratch0(); | 4214 Register scratch = VirtualFrame::scratch0(); |
4216 JumpTarget null, function, leave, non_function_constructor; | 4215 JumpTarget null, function, leave, non_function_constructor; |
4217 | 4216 |
4218 // Load the object into register. | 4217 // Load the object into register. |
4219 ASSERT(args->length() == 1); | 4218 ASSERT(args->length() == 1); |
(...skipping 7545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11765 __ bind(&string_add_runtime); | 11764 __ bind(&string_add_runtime); |
11766 __ TailCallRuntime(Runtime::kStringAdd, 2, 1); | 11765 __ TailCallRuntime(Runtime::kStringAdd, 2, 1); |
11767 } | 11766 } |
11768 | 11767 |
11769 | 11768 |
11770 #undef __ | 11769 #undef __ |
11771 | 11770 |
11772 } } // namespace v8::internal | 11771 } } // namespace v8::internal |
11773 | 11772 |
11774 #endif // V8_TARGET_ARCH_ARM | 11773 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |