| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 61 |
| 62 void FastNewClosureStub::Generate(MacroAssembler* masm) { | 62 void FastNewClosureStub::Generate(MacroAssembler* masm) { |
| 63 // Create a new closure from the given function info in new | 63 // Create a new closure from the given function info in new |
| 64 // space. Set the context to the current context in rsi. | 64 // space. Set the context to the current context in rsi. |
| 65 Label gc; | 65 Label gc; |
| 66 __ AllocateInNewSpace(JSFunction::kSize, rax, rbx, rcx, &gc, TAG_OBJECT); | 66 __ AllocateInNewSpace(JSFunction::kSize, rax, rbx, rcx, &gc, TAG_OBJECT); |
| 67 | 67 |
| 68 // Get the function info from the stack. | 68 // Get the function info from the stack. |
| 69 __ movq(rdx, Operand(rsp, 1 * kPointerSize)); | 69 __ movq(rdx, Operand(rsp, 1 * kPointerSize)); |
| 70 | 70 |
| 71 int map_index = strict_mode_ == kStrictMode |
| 72 ? Context::STRICT_MODE_FUNCTION_MAP_INDEX |
| 73 : Context::FUNCTION_MAP_INDEX; |
| 74 |
| 71 // Compute the function map in the current global context and set that | 75 // Compute the function map in the current global context and set that |
| 72 // as the map of the allocated object. | 76 // as the map of the allocated object. |
| 73 __ movq(rcx, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX))); | 77 __ movq(rcx, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX))); |
| 74 __ movq(rcx, FieldOperand(rcx, GlobalObject::kGlobalContextOffset)); | 78 __ movq(rcx, FieldOperand(rcx, GlobalObject::kGlobalContextOffset)); |
| 75 __ movq(rcx, Operand(rcx, Context::SlotOffset(Context::FUNCTION_MAP_INDEX))); | 79 __ movq(rcx, Operand(rcx, Context::SlotOffset(map_index))); |
| 76 __ movq(FieldOperand(rax, JSObject::kMapOffset), rcx); | 80 __ movq(FieldOperand(rax, JSObject::kMapOffset), rcx); |
| 77 | 81 |
| 78 // Initialize the rest of the function. We don't have to update the | 82 // Initialize the rest of the function. We don't have to update the |
| 79 // write barrier because the allocated object is in new space. | 83 // write barrier because the allocated object is in new space. |
| 80 __ LoadRoot(rbx, Heap::kEmptyFixedArrayRootIndex); | 84 __ LoadRoot(rbx, Heap::kEmptyFixedArrayRootIndex); |
| 81 __ LoadRoot(rcx, Heap::kTheHoleValueRootIndex); | 85 __ LoadRoot(rcx, Heap::kTheHoleValueRootIndex); |
| 82 __ LoadRoot(rdi, Heap::kUndefinedValueRootIndex); | 86 __ LoadRoot(rdi, Heap::kUndefinedValueRootIndex); |
| 83 __ movq(FieldOperand(rax, JSObject::kPropertiesOffset), rbx); | 87 __ movq(FieldOperand(rax, JSObject::kPropertiesOffset), rbx); |
| 84 __ movq(FieldOperand(rax, JSObject::kElementsOffset), rbx); | 88 __ movq(FieldOperand(rax, JSObject::kElementsOffset), rbx); |
| 85 __ movq(FieldOperand(rax, JSFunction::kPrototypeOrInitialMapOffset), rcx); | 89 __ movq(FieldOperand(rax, JSFunction::kPrototypeOrInitialMapOffset), rcx); |
| (...skipping 2280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2366 __ movq(Operand(rsp, 2 * kPointerSize), rdx); | 2370 __ movq(Operand(rsp, 2 * kPointerSize), rdx); |
| 2367 | 2371 |
| 2368 // Try the new space allocation. Start out with computing the size of | 2372 // Try the new space allocation. Start out with computing the size of |
| 2369 // the arguments object and the elements array. | 2373 // the arguments object and the elements array. |
| 2370 Label add_arguments_object; | 2374 Label add_arguments_object; |
| 2371 __ bind(&try_allocate); | 2375 __ bind(&try_allocate); |
| 2372 __ testl(rcx, rcx); | 2376 __ testl(rcx, rcx); |
| 2373 __ j(zero, &add_arguments_object); | 2377 __ j(zero, &add_arguments_object); |
| 2374 __ leal(rcx, Operand(rcx, times_pointer_size, FixedArray::kHeaderSize)); | 2378 __ leal(rcx, Operand(rcx, times_pointer_size, FixedArray::kHeaderSize)); |
| 2375 __ bind(&add_arguments_object); | 2379 __ bind(&add_arguments_object); |
| 2376 __ addl(rcx, Immediate(Heap::kArgumentsObjectSize)); | 2380 __ addl(rcx, Immediate(GetArgumentsObjectSize())); |
| 2377 | 2381 |
| 2378 // Do the allocation of both objects in one go. | 2382 // Do the allocation of both objects in one go. |
| 2379 __ AllocateInNewSpace(rcx, rax, rdx, rbx, &runtime, TAG_OBJECT); | 2383 __ AllocateInNewSpace(rcx, rax, rdx, rbx, &runtime, TAG_OBJECT); |
| 2380 | 2384 |
| 2381 // Get the arguments boilerplate from the current (global) context. | 2385 // Get the arguments boilerplate from the current (global) context. |
| 2382 int offset = Context::SlotOffset(Context::ARGUMENTS_BOILERPLATE_INDEX); | |
| 2383 __ movq(rdi, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX))); | 2386 __ movq(rdi, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX))); |
| 2384 __ movq(rdi, FieldOperand(rdi, GlobalObject::kGlobalContextOffset)); | 2387 __ movq(rdi, FieldOperand(rdi, GlobalObject::kGlobalContextOffset)); |
| 2385 __ movq(rdi, Operand(rdi, offset)); | 2388 __ movq(rdi, Operand(rdi, |
| 2389 Context::SlotOffset(GetArgumentsBoilerplateIndex()))); |
| 2386 | 2390 |
| 2387 // Copy the JS object part. | 2391 // Copy the JS object part. |
| 2388 STATIC_ASSERT(JSObject::kHeaderSize == 3 * kPointerSize); | 2392 STATIC_ASSERT(JSObject::kHeaderSize == 3 * kPointerSize); |
| 2389 __ movq(kScratchRegister, FieldOperand(rdi, 0 * kPointerSize)); | 2393 __ movq(kScratchRegister, FieldOperand(rdi, 0 * kPointerSize)); |
| 2390 __ movq(rdx, FieldOperand(rdi, 1 * kPointerSize)); | 2394 __ movq(rdx, FieldOperand(rdi, 1 * kPointerSize)); |
| 2391 __ movq(rbx, FieldOperand(rdi, 2 * kPointerSize)); | 2395 __ movq(rbx, FieldOperand(rdi, 2 * kPointerSize)); |
| 2392 __ movq(FieldOperand(rax, 0 * kPointerSize), kScratchRegister); | 2396 __ movq(FieldOperand(rax, 0 * kPointerSize), kScratchRegister); |
| 2393 __ movq(FieldOperand(rax, 1 * kPointerSize), rdx); | 2397 __ movq(FieldOperand(rax, 1 * kPointerSize), rdx); |
| 2394 __ movq(FieldOperand(rax, 2 * kPointerSize), rbx); | 2398 __ movq(FieldOperand(rax, 2 * kPointerSize), rbx); |
| 2395 | 2399 |
| 2396 // Setup the callee in-object property. | 2400 if (type_ == NEW_NON_STRICT) { |
| 2397 ASSERT(Heap::arguments_callee_index == 0); | 2401 // Setup the callee in-object property. |
| 2398 __ movq(kScratchRegister, Operand(rsp, 3 * kPointerSize)); | 2402 ASSERT(Heap::kArgumentsCalleeIndex == 1); |
| 2399 __ movq(FieldOperand(rax, JSObject::kHeaderSize), kScratchRegister); | 2403 __ movq(kScratchRegister, Operand(rsp, 3 * kPointerSize)); |
| 2404 __ movq(FieldOperand(rax, JSObject::kHeaderSize + |
| 2405 Heap::kArgumentsCalleeIndex * kPointerSize), |
| 2406 kScratchRegister); |
| 2407 } |
| 2400 | 2408 |
| 2401 // Get the length (smi tagged) and set that as an in-object property too. | 2409 // Get the length (smi tagged) and set that as an in-object property too. |
| 2402 ASSERT(Heap::arguments_length_index == 1); | 2410 ASSERT(Heap::kArgumentsLengthIndex == 0); |
| 2403 __ movq(rcx, Operand(rsp, 1 * kPointerSize)); | 2411 __ movq(rcx, Operand(rsp, 1 * kPointerSize)); |
| 2404 __ movq(FieldOperand(rax, JSObject::kHeaderSize + kPointerSize), rcx); | 2412 __ movq(FieldOperand(rax, JSObject::kHeaderSize + |
| 2413 Heap::kArgumentsLengthIndex * kPointerSize), |
| 2414 rcx); |
| 2405 | 2415 |
| 2406 // If there are no actual arguments, we're done. | 2416 // If there are no actual arguments, we're done. |
| 2407 Label done; | 2417 Label done; |
| 2408 __ SmiTest(rcx); | 2418 __ SmiTest(rcx); |
| 2409 __ j(zero, &done); | 2419 __ j(zero, &done); |
| 2410 | 2420 |
| 2411 // Get the parameters pointer from the stack and untag the length. | 2421 // Get the parameters pointer from the stack and untag the length. |
| 2412 __ movq(rdx, Operand(rsp, 2 * kPointerSize)); | 2422 __ movq(rdx, Operand(rsp, 2 * kPointerSize)); |
| 2413 | 2423 |
| 2414 // Setup the elements pointer in the allocated arguments object and | 2424 // Setup the elements pointer in the allocated arguments object and |
| 2415 // initialize the header in the elements fixed array. | 2425 // initialize the header in the elements fixed array. |
| 2416 __ lea(rdi, Operand(rax, Heap::kArgumentsObjectSize)); | 2426 __ lea(rdi, Operand(rax, GetArgumentsObjectSize())); |
| 2417 __ movq(FieldOperand(rax, JSObject::kElementsOffset), rdi); | 2427 __ movq(FieldOperand(rax, JSObject::kElementsOffset), rdi); |
| 2418 __ LoadRoot(kScratchRegister, Heap::kFixedArrayMapRootIndex); | 2428 __ LoadRoot(kScratchRegister, Heap::kFixedArrayMapRootIndex); |
| 2419 __ movq(FieldOperand(rdi, FixedArray::kMapOffset), kScratchRegister); | 2429 __ movq(FieldOperand(rdi, FixedArray::kMapOffset), kScratchRegister); |
| 2420 __ movq(FieldOperand(rdi, FixedArray::kLengthOffset), rcx); | 2430 __ movq(FieldOperand(rdi, FixedArray::kLengthOffset), rcx); |
| 2421 __ SmiToInteger32(rcx, rcx); // Untag length for the loop below. | 2431 __ SmiToInteger32(rcx, rcx); // Untag length for the loop below. |
| 2422 | 2432 |
| 2423 // Copy the fixed array slots. | 2433 // Copy the fixed array slots. |
| 2424 Label loop; | 2434 Label loop; |
| 2425 __ bind(&loop); | 2435 __ bind(&loop); |
| 2426 __ movq(kScratchRegister, Operand(rdx, -1 * kPointerSize)); // Skip receiver. | 2436 __ movq(kScratchRegister, Operand(rdx, -1 * kPointerSize)); // Skip receiver. |
| (...skipping 2649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5076 // Do a tail call to the rewritten stub. | 5086 // Do a tail call to the rewritten stub. |
| 5077 __ jmp(rdi); | 5087 __ jmp(rdi); |
| 5078 } | 5088 } |
| 5079 | 5089 |
| 5080 | 5090 |
| 5081 #undef __ | 5091 #undef __ |
| 5082 | 5092 |
| 5083 } } // namespace v8::internal | 5093 } } // namespace v8::internal |
| 5084 | 5094 |
| 5085 #endif // V8_TARGET_ARCH_X64 | 5095 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |