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 2293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2304 ASSERT(frame_->height() == original_height); | 2304 ASSERT(frame_->height() == original_height); |
2305 } | 2305 } |
2306 | 2306 |
2307 | 2307 |
2308 void CodeGenerator::InstantiateFunction( | 2308 void CodeGenerator::InstantiateFunction( |
2309 Handle<SharedFunctionInfo> function_info) { | 2309 Handle<SharedFunctionInfo> function_info) { |
2310 VirtualFrame::SpilledScope spilled_scope; | 2310 VirtualFrame::SpilledScope spilled_scope; |
2311 __ mov(r0, Operand(function_info)); | 2311 __ mov(r0, Operand(function_info)); |
2312 // Use the fast case closure allocation code that allocates in new | 2312 // Use the fast case closure allocation code that allocates in new |
2313 // space for nested functions that don't need literals cloning. | 2313 // space for nested functions that don't need literals cloning. |
2314 if (false && | 2314 if (scope()->is_function_scope() && function_info->num_literals() == 0) { |
2315 scope()->is_function_scope() && function_info->num_literals() == 0) { | |
2316 FastNewClosureStub stub; | 2315 FastNewClosureStub stub; |
2317 frame_->EmitPush(r0); | 2316 frame_->EmitPush(r0); |
2318 frame_->CallStub(&stub, 1); | 2317 frame_->CallStub(&stub, 1); |
2319 frame_->EmitPush(r0); | 2318 frame_->EmitPush(r0); |
2320 } else { | 2319 } else { |
2321 // Create a new closure. | 2320 // Create a new closure. |
2322 frame_->EmitPush(cp); | 2321 frame_->EmitPush(cp); |
2323 frame_->EmitPush(r0); | 2322 frame_->EmitPush(r0); |
2324 frame_->CallRuntime(Runtime::kNewClosure, 2); | 2323 frame_->CallRuntime(Runtime::kNewClosure, 2); |
2325 frame_->EmitPush(r0); | 2324 frame_->EmitPush(r0); |
(...skipping 2194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4520 break; | 4519 break; |
4521 } | 4520 } |
4522 | 4521 |
4523 default: | 4522 default: |
4524 UNREACHABLE(); | 4523 UNREACHABLE(); |
4525 } | 4524 } |
4526 } | 4525 } |
4527 | 4526 |
4528 | 4527 |
4529 void FastNewClosureStub::Generate(MacroAssembler* masm) { | 4528 void FastNewClosureStub::Generate(MacroAssembler* masm) { |
4530 // Clone the boilerplate in new space. Set the context to the | 4529 // Create a new closure from the given function info in new |
4531 // current context in cp. | 4530 // space. Set the context to the current context in cp. |
4532 Label gc; | 4531 Label gc; |
4533 | 4532 |
4534 // Pop the boilerplate function from the stack. | 4533 // Pop the function info from the stack. |
4535 __ pop(r3); | 4534 __ pop(r3); |
4536 | 4535 |
4537 // Attempt to allocate new JSFunction in new space. | 4536 // Attempt to allocate new JSFunction in new space. |
4538 __ AllocateInNewSpace(JSFunction::kSize / kPointerSize, | 4537 __ AllocateInNewSpace(JSFunction::kSize / kPointerSize, |
4539 r0, | 4538 r0, |
4540 r1, | 4539 r1, |
4541 r2, | 4540 r2, |
4542 &gc, | 4541 &gc, |
4543 TAG_OBJECT); | 4542 TAG_OBJECT); |
4544 | 4543 |
4545 // Compute the function map in the current global context and set that | 4544 // Compute the function map in the current global context and set that |
4546 // as the map of the allocated object. | 4545 // as the map of the allocated object. |
4547 __ ldr(r2, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_INDEX))); | 4546 __ ldr(r2, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_INDEX))); |
4548 __ ldr(r2, FieldMemOperand(r2, GlobalObject::kGlobalContextOffset)); | 4547 __ ldr(r2, FieldMemOperand(r2, GlobalObject::kGlobalContextOffset)); |
4549 __ ldr(r2, MemOperand(r2, Context::SlotOffset(Context::FUNCTION_MAP_INDEX))); | 4548 __ ldr(r2, MemOperand(r2, Context::SlotOffset(Context::FUNCTION_MAP_INDEX))); |
4550 __ str(r2, FieldMemOperand(r0, HeapObject::kMapOffset)); | 4549 __ str(r2, FieldMemOperand(r0, HeapObject::kMapOffset)); |
4551 | 4550 |
4552 // Clone the rest of the boilerplate fields. We don't have to update | 4551 // Initialize the rest of the function. We don't have to update the |
4553 // the write barrier because the allocated object is in new space. | 4552 // write barrier because the allocated object is in new space. |
4554 for (int offset = kPointerSize; | 4553 __ LoadRoot(r1, Heap::kEmptyFixedArrayRootIndex); |
4555 offset < JSFunction::kSize; | 4554 __ LoadRoot(r2, Heap::kTheHoleValueRootIndex); |
4556 offset += kPointerSize) { | 4555 __ str(r1, FieldMemOperand(r0, JSObject::kPropertiesOffset)); |
4557 if (offset == JSFunction::kContextOffset) { | 4556 __ str(r1, FieldMemOperand(r0, JSObject::kElementsOffset)); |
4558 __ str(cp, FieldMemOperand(r0, offset)); | 4557 __ str(r2, FieldMemOperand(r0, JSFunction::kPrototypeOrInitialMapOffset)); |
4559 } else { | 4558 __ str(r3, FieldMemOperand(r0, JSFunction::kSharedFunctionInfoOffset)); |
4560 __ ldr(r1, FieldMemOperand(r3, offset)); | 4559 __ str(cp, FieldMemOperand(r0, JSFunction::kContextOffset)); |
4561 __ str(r1, FieldMemOperand(r0, offset)); | 4560 __ str(r1, FieldMemOperand(r0, JSFunction::kLiteralsOffset)); |
4562 } | |
4563 } | |
4564 | 4561 |
4565 // Return result. The argument boilerplate has been popped already. | 4562 // Return result. The argument function info has been popped already. |
4566 __ Ret(); | 4563 __ Ret(); |
4567 | 4564 |
4568 // Create a new closure through the slower runtime call. | 4565 // Create a new closure through the slower runtime call. |
4569 __ bind(&gc); | 4566 __ bind(&gc); |
4570 __ push(cp); | 4567 __ push(cp); |
4571 __ push(r3); | 4568 __ push(r3); |
4572 __ TailCallRuntime(Runtime::kNewClosure, 2, 1); | 4569 __ TailCallRuntime(Runtime::kNewClosure, 2, 1); |
4573 } | 4570 } |
4574 | 4571 |
4575 | 4572 |
(...skipping 3468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8044 | 8041 |
8045 // Just jump to runtime to add the two strings. | 8042 // Just jump to runtime to add the two strings. |
8046 __ bind(&string_add_runtime); | 8043 __ bind(&string_add_runtime); |
8047 __ TailCallRuntime(Runtime::kStringAdd, 2, 1); | 8044 __ TailCallRuntime(Runtime::kStringAdd, 2, 1); |
8048 } | 8045 } |
8049 | 8046 |
8050 | 8047 |
8051 #undef __ | 8048 #undef __ |
8052 | 8049 |
8053 } } // namespace v8::internal | 8050 } } // namespace v8::internal |
OLD | NEW |