| 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 2244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2330 __ movq(Operand(rsp, 2 * kPointerSize), rdx); | 2334 __ movq(Operand(rsp, 2 * kPointerSize), rdx); |
| 2331 | 2335 |
| 2332 // Try the new space allocation. Start out with computing the size of | 2336 // Try the new space allocation. Start out with computing the size of |
| 2333 // the arguments object and the elements array. | 2337 // the arguments object and the elements array. |
| 2334 Label add_arguments_object; | 2338 Label add_arguments_object; |
| 2335 __ bind(&try_allocate); | 2339 __ bind(&try_allocate); |
| 2336 __ testl(rcx, rcx); | 2340 __ testl(rcx, rcx); |
| 2337 __ j(zero, &add_arguments_object); | 2341 __ j(zero, &add_arguments_object); |
| 2338 __ leal(rcx, Operand(rcx, times_pointer_size, FixedArray::kHeaderSize)); | 2342 __ leal(rcx, Operand(rcx, times_pointer_size, FixedArray::kHeaderSize)); |
| 2339 __ bind(&add_arguments_object); | 2343 __ bind(&add_arguments_object); |
| 2340 __ addl(rcx, Immediate(Heap::kArgumentsObjectSize)); | 2344 __ addl(rcx, Immediate(GetArgumentsObjectSize())); |
| 2341 | 2345 |
| 2342 // Do the allocation of both objects in one go. | 2346 // Do the allocation of both objects in one go. |
| 2343 __ AllocateInNewSpace(rcx, rax, rdx, rbx, &runtime, TAG_OBJECT); | 2347 __ AllocateInNewSpace(rcx, rax, rdx, rbx, &runtime, TAG_OBJECT); |
| 2344 | 2348 |
| 2345 // Get the arguments boilerplate from the current (global) context. | 2349 // Get the arguments boilerplate from the current (global) context. |
| 2346 int offset = Context::SlotOffset(Context::ARGUMENTS_BOILERPLATE_INDEX); | |
| 2347 __ movq(rdi, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX))); | 2350 __ movq(rdi, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX))); |
| 2348 __ movq(rdi, FieldOperand(rdi, GlobalObject::kGlobalContextOffset)); | 2351 __ movq(rdi, FieldOperand(rdi, GlobalObject::kGlobalContextOffset)); |
| 2349 __ movq(rdi, Operand(rdi, offset)); | 2352 __ movq(rdi, Operand(rdi, |
| 2353 Context::SlotOffset(GetArgumentsBoilerplateIndex()))); |
| 2350 | 2354 |
| 2351 // Copy the JS object part. | 2355 // Copy the JS object part. |
| 2352 STATIC_ASSERT(JSObject::kHeaderSize == 3 * kPointerSize); | 2356 STATIC_ASSERT(JSObject::kHeaderSize == 3 * kPointerSize); |
| 2353 __ movq(kScratchRegister, FieldOperand(rdi, 0 * kPointerSize)); | 2357 __ movq(kScratchRegister, FieldOperand(rdi, 0 * kPointerSize)); |
| 2354 __ movq(rdx, FieldOperand(rdi, 1 * kPointerSize)); | 2358 __ movq(rdx, FieldOperand(rdi, 1 * kPointerSize)); |
| 2355 __ movq(rbx, FieldOperand(rdi, 2 * kPointerSize)); | 2359 __ movq(rbx, FieldOperand(rdi, 2 * kPointerSize)); |
| 2356 __ movq(FieldOperand(rax, 0 * kPointerSize), kScratchRegister); | 2360 __ movq(FieldOperand(rax, 0 * kPointerSize), kScratchRegister); |
| 2357 __ movq(FieldOperand(rax, 1 * kPointerSize), rdx); | 2361 __ movq(FieldOperand(rax, 1 * kPointerSize), rdx); |
| 2358 __ movq(FieldOperand(rax, 2 * kPointerSize), rbx); | 2362 __ movq(FieldOperand(rax, 2 * kPointerSize), rbx); |
| 2359 | 2363 |
| 2360 // Setup the callee in-object property. | 2364 if (type_ == NEW_NON_STRICT) { |
| 2361 ASSERT(Heap::arguments_callee_index == 0); | 2365 // Setup the callee in-object property. |
| 2362 __ movq(kScratchRegister, Operand(rsp, 3 * kPointerSize)); | 2366 ASSERT(Heap::kArgumentsCalleeIndex == 1); |
| 2363 __ movq(FieldOperand(rax, JSObject::kHeaderSize), kScratchRegister); | 2367 __ movq(kScratchRegister, Operand(rsp, 3 * kPointerSize)); |
| 2368 __ movq(FieldOperand(rax, JSObject::kHeaderSize + |
| 2369 Heap::kArgumentsCalleeIndex * kPointerSize), |
| 2370 kScratchRegister); |
| 2371 } |
| 2364 | 2372 |
| 2365 // Get the length (smi tagged) and set that as an in-object property too. | 2373 // Get the length (smi tagged) and set that as an in-object property too. |
| 2366 ASSERT(Heap::arguments_length_index == 1); | 2374 ASSERT(Heap::kArgumentsLengthIndex == 0); |
| 2367 __ movq(rcx, Operand(rsp, 1 * kPointerSize)); | 2375 __ movq(rcx, Operand(rsp, 1 * kPointerSize)); |
| 2368 __ movq(FieldOperand(rax, JSObject::kHeaderSize + kPointerSize), rcx); | 2376 __ movq(FieldOperand(rax, JSObject::kHeaderSize + |
| 2377 Heap::kArgumentsLengthIndex * kPointerSize), |
| 2378 rcx); |
| 2369 | 2379 |
| 2370 // If there are no actual arguments, we're done. | 2380 // If there are no actual arguments, we're done. |
| 2371 Label done; | 2381 Label done; |
| 2372 __ SmiTest(rcx); | 2382 __ SmiTest(rcx); |
| 2373 __ j(zero, &done); | 2383 __ j(zero, &done); |
| 2374 | 2384 |
| 2375 // Get the parameters pointer from the stack and untag the length. | 2385 // Get the parameters pointer from the stack and untag the length. |
| 2376 __ movq(rdx, Operand(rsp, 2 * kPointerSize)); | 2386 __ movq(rdx, Operand(rsp, 2 * kPointerSize)); |
| 2377 | 2387 |
| 2378 // Setup the elements pointer in the allocated arguments object and | 2388 // Setup the elements pointer in the allocated arguments object and |
| 2379 // initialize the header in the elements fixed array. | 2389 // initialize the header in the elements fixed array. |
| 2380 __ lea(rdi, Operand(rax, Heap::kArgumentsObjectSize)); | 2390 __ lea(rdi, Operand(rax, GetArgumentsObjectSize())); |
| 2381 __ movq(FieldOperand(rax, JSObject::kElementsOffset), rdi); | 2391 __ movq(FieldOperand(rax, JSObject::kElementsOffset), rdi); |
| 2382 __ LoadRoot(kScratchRegister, Heap::kFixedArrayMapRootIndex); | 2392 __ LoadRoot(kScratchRegister, Heap::kFixedArrayMapRootIndex); |
| 2383 __ movq(FieldOperand(rdi, FixedArray::kMapOffset), kScratchRegister); | 2393 __ movq(FieldOperand(rdi, FixedArray::kMapOffset), kScratchRegister); |
| 2384 __ movq(FieldOperand(rdi, FixedArray::kLengthOffset), rcx); | 2394 __ movq(FieldOperand(rdi, FixedArray::kLengthOffset), rcx); |
| 2385 __ SmiToInteger32(rcx, rcx); // Untag length for the loop below. | 2395 __ SmiToInteger32(rcx, rcx); // Untag length for the loop below. |
| 2386 | 2396 |
| 2387 // Copy the fixed array slots. | 2397 // Copy the fixed array slots. |
| 2388 Label loop; | 2398 Label loop; |
| 2389 __ bind(&loop); | 2399 __ bind(&loop); |
| 2390 __ movq(kScratchRegister, Operand(rdx, -1 * kPointerSize)); // Skip receiver. | 2400 __ movq(kScratchRegister, Operand(rdx, -1 * kPointerSize)); // Skip receiver. |
| (...skipping 2660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5051 // Do a tail call to the rewritten stub. | 5061 // Do a tail call to the rewritten stub. |
| 5052 __ jmp(rdi); | 5062 __ jmp(rdi); |
| 5053 } | 5063 } |
| 5054 | 5064 |
| 5055 | 5065 |
| 5056 #undef __ | 5066 #undef __ |
| 5057 | 5067 |
| 5058 } } // namespace v8::internal | 5068 } } // namespace v8::internal |
| 5059 | 5069 |
| 5060 #endif // V8_TARGET_ARCH_X64 | 5070 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |