Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: src/x64/code-stubs-x64.cc

Issue 6725030: [Arguments] Introduce a new backing store for non-strict arguments objects. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/arguments
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« src/runtime.cc ('K') | « src/runtime.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2323 matching lines...) Expand 10 before | Expand all | Expand 10 after
2334 __ Integer32ToSmiField(Operand(rsp, 1 * kPointerSize), rcx); 2334 __ Integer32ToSmiField(Operand(rsp, 1 * kPointerSize), rcx);
2335 // Do not clobber the length index for the indexing operation since 2335 // Do not clobber the length index for the indexing operation since
2336 // it is used compute the size for allocation later. 2336 // it is used compute the size for allocation later.
2337 __ lea(rdx, Operand(rdx, rcx, times_pointer_size, kDisplacement)); 2337 __ lea(rdx, Operand(rdx, rcx, times_pointer_size, kDisplacement));
2338 __ movq(Operand(rsp, 2 * kPointerSize), rdx); 2338 __ movq(Operand(rsp, 2 * kPointerSize), rdx);
2339 2339
2340 // Try the new space allocation. Start out with computing the size of 2340 // Try the new space allocation. Start out with computing the size of
2341 // the arguments object and the elements array. 2341 // the arguments object and the elements array.
2342 Label add_arguments_object; 2342 Label add_arguments_object;
2343 __ bind(&try_allocate); 2343 __ bind(&try_allocate);
2344 __ testl(rcx, rcx); 2344 if (type_ == NEW_NON_STRICT) {
2345 __ j(zero, &add_arguments_object); 2345 __ TailCallRuntime(Runtime::kNewArgumentsFast, 3, 1);
2346 __ leal(rcx, Operand(rcx, times_pointer_size, FixedArray::kHeaderSize)); 2346 } else {
2347 __ bind(&add_arguments_object); 2347 __ testl(rcx, rcx);
2348 __ addl(rcx, Immediate(GetArgumentsObjectSize())); 2348 __ j(zero, &add_arguments_object);
2349 __ leal(rcx, Operand(rcx, times_pointer_size, FixedArray::kHeaderSize));
2350 __ bind(&add_arguments_object);
2351 __ addl(rcx, Immediate(GetArgumentsObjectSize()));
2349 2352
2350 // Do the allocation of both objects in one go. 2353 // Do the allocation of both objects in one go.
2351 __ AllocateInNewSpace(rcx, rax, rdx, rbx, &runtime, TAG_OBJECT); 2354 __ AllocateInNewSpace(rcx, rax, rdx, rbx, &runtime, TAG_OBJECT);
2352 2355
2353 // Get the arguments boilerplate from the current (global) context. 2356 // Get the arguments boilerplate from the current (global) context.
2354 __ movq(rdi, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX))); 2357 __ movq(rdi, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX)));
2355 __ movq(rdi, FieldOperand(rdi, GlobalObject::kGlobalContextOffset)); 2358 __ movq(rdi, FieldOperand(rdi, GlobalObject::kGlobalContextOffset));
2356 __ movq(rdi, Operand(rdi, 2359 __ movq(rdi, Operand(rdi,
2357 Context::SlotOffset(GetArgumentsBoilerplateIndex()))); 2360 Context::SlotOffset(GetArgumentsBoilerplateIndex())));
2358 2361
2359 // Copy the JS object part. 2362 // Copy the JS object part.
2360 STATIC_ASSERT(JSObject::kHeaderSize == 3 * kPointerSize); 2363 STATIC_ASSERT(JSObject::kHeaderSize == 3 * kPointerSize);
2361 __ movq(kScratchRegister, FieldOperand(rdi, 0 * kPointerSize)); 2364 __ movq(kScratchRegister, FieldOperand(rdi, 0 * kPointerSize));
2362 __ movq(rdx, FieldOperand(rdi, 1 * kPointerSize)); 2365 __ movq(rdx, FieldOperand(rdi, 1 * kPointerSize));
2363 __ movq(rbx, FieldOperand(rdi, 2 * kPointerSize)); 2366 __ movq(rbx, FieldOperand(rdi, 2 * kPointerSize));
2364 __ movq(FieldOperand(rax, 0 * kPointerSize), kScratchRegister); 2367 __ movq(FieldOperand(rax, 0 * kPointerSize), kScratchRegister);
2365 __ movq(FieldOperand(rax, 1 * kPointerSize), rdx); 2368 __ movq(FieldOperand(rax, 1 * kPointerSize), rdx);
2366 __ movq(FieldOperand(rax, 2 * kPointerSize), rbx); 2369 __ movq(FieldOperand(rax, 2 * kPointerSize), rbx);
2367 2370
2368 if (type_ == NEW_NON_STRICT) { 2371 if (type_ == NEW_NON_STRICT) {
2369 // Setup the callee in-object property. 2372 // Setup the callee in-object property.
2370 ASSERT(Heap::kArgumentsCalleeIndex == 1); 2373 ASSERT(Heap::kArgumentsCalleeIndex == 1);
2371 __ movq(kScratchRegister, Operand(rsp, 3 * kPointerSize)); 2374 __ movq(kScratchRegister, Operand(rsp, 3 * kPointerSize));
2375 __ movq(FieldOperand(rax, JSObject::kHeaderSize +
2376 Heap::kArgumentsCalleeIndex * kPointerSize),
2377 kScratchRegister);
2378 }
2379
2380 // Get the length (smi tagged) and set that as an in-object property too.
2381 ASSERT(Heap::kArgumentsLengthIndex == 0);
2382 __ movq(rcx, Operand(rsp, 1 * kPointerSize));
2372 __ movq(FieldOperand(rax, JSObject::kHeaderSize + 2383 __ movq(FieldOperand(rax, JSObject::kHeaderSize +
2373 Heap::kArgumentsCalleeIndex * kPointerSize), 2384 Heap::kArgumentsLengthIndex * kPointerSize),
2374 kScratchRegister); 2385 rcx);
2386
2387 // If there are no actual arguments, we're done.
2388 Label done;
2389 __ SmiTest(rcx);
2390 __ j(zero, &done);
2391
2392 // Get the parameters pointer from the stack and untag the length.
2393 __ movq(rdx, Operand(rsp, 2 * kPointerSize));
2394
2395 // Setup the elements pointer in the allocated arguments object and
2396 // initialize the header in the elements fixed array.
2397 __ lea(rdi, Operand(rax, GetArgumentsObjectSize()));
2398 __ movq(FieldOperand(rax, JSObject::kElementsOffset), rdi);
2399 __ LoadRoot(kScratchRegister, Heap::kFixedArrayMapRootIndex);
2400 __ movq(FieldOperand(rdi, FixedArray::kMapOffset), kScratchRegister);
2401 __ movq(FieldOperand(rdi, FixedArray::kLengthOffset), rcx);
2402 __ SmiToInteger32(rcx, rcx); // Untag length for the loop below.
2403
2404 // Copy the fixed array slots.
2405 Label loop;
2406 __ bind(&loop);
2407 __ movq(kScratchRegister, Operand(rdx, -1 * kPointerSize)); // Skip receive r.
2408 __ movq(FieldOperand(rdi, FixedArray::kHeaderSize), kScratchRegister);
2409 __ addq(rdi, Immediate(kPointerSize));
2410 __ subq(rdx, Immediate(kPointerSize));
2411 __ decl(rcx);
2412 __ j(not_zero, &loop);
2413
2414 // Return and remove the on-stack parameters.
2415 __ bind(&done);
2416 __ ret(3 * kPointerSize);
2417
2418 // Do the runtime call to allocate the arguments object.
2419 __ bind(&runtime);
2420 __ TailCallRuntime(Runtime::kNewStrictArgumentsFast, 3, 1);
2375 } 2421 }
2376
2377 // Get the length (smi tagged) and set that as an in-object property too.
2378 ASSERT(Heap::kArgumentsLengthIndex == 0);
2379 __ movq(rcx, Operand(rsp, 1 * kPointerSize));
2380 __ movq(FieldOperand(rax, JSObject::kHeaderSize +
2381 Heap::kArgumentsLengthIndex * kPointerSize),
2382 rcx);
2383
2384 // If there are no actual arguments, we're done.
2385 Label done;
2386 __ SmiTest(rcx);
2387 __ j(zero, &done);
2388
2389 // Get the parameters pointer from the stack and untag the length.
2390 __ movq(rdx, Operand(rsp, 2 * kPointerSize));
2391
2392 // Setup the elements pointer in the allocated arguments object and
2393 // initialize the header in the elements fixed array.
2394 __ lea(rdi, Operand(rax, GetArgumentsObjectSize()));
2395 __ movq(FieldOperand(rax, JSObject::kElementsOffset), rdi);
2396 __ LoadRoot(kScratchRegister, Heap::kFixedArrayMapRootIndex);
2397 __ movq(FieldOperand(rdi, FixedArray::kMapOffset), kScratchRegister);
2398 __ movq(FieldOperand(rdi, FixedArray::kLengthOffset), rcx);
2399 __ SmiToInteger32(rcx, rcx); // Untag length for the loop below.
2400
2401 // Copy the fixed array slots.
2402 Label loop;
2403 __ bind(&loop);
2404 __ movq(kScratchRegister, Operand(rdx, -1 * kPointerSize)); // Skip receiver.
2405 __ movq(FieldOperand(rdi, FixedArray::kHeaderSize), kScratchRegister);
2406 __ addq(rdi, Immediate(kPointerSize));
2407 __ subq(rdx, Immediate(kPointerSize));
2408 __ decl(rcx);
2409 __ j(not_zero, &loop);
2410
2411 // Return and remove the on-stack parameters.
2412 __ bind(&done);
2413 __ ret(3 * kPointerSize);
2414
2415 // Do the runtime call to allocate the arguments object.
2416 __ bind(&runtime);
2417 __ TailCallRuntime(Runtime::kNewArgumentsFast, 3, 1);
2418 } 2422 }
2419 2423
2420 2424
2421 void RegExpExecStub::Generate(MacroAssembler* masm) { 2425 void RegExpExecStub::Generate(MacroAssembler* masm) {
2422 // Just jump directly to runtime if native RegExp is not selected at compile 2426 // Just jump directly to runtime if native RegExp is not selected at compile
2423 // time or if regexp entry in generated code is turned off runtime switch or 2427 // time or if regexp entry in generated code is turned off runtime switch or
2424 // at compilation. 2428 // at compilation.
2425 #ifdef V8_INTERPRETED_REGEXP 2429 #ifdef V8_INTERPRETED_REGEXP
2426 __ TailCallRuntime(Runtime::kRegExpExec, 4, 1); 2430 __ TailCallRuntime(Runtime::kRegExpExec, 4, 1);
2427 #else // V8_INTERPRETED_REGEXP 2431 #else // V8_INTERPRETED_REGEXP
(...skipping 2653 matching lines...) Expand 10 before | Expand all | Expand 10 after
5081 // Do a tail call to the rewritten stub. 5085 // Do a tail call to the rewritten stub.
5082 __ jmp(rdi); 5086 __ jmp(rdi);
5083 } 5087 }
5084 5088
5085 5089
5086 #undef __ 5090 #undef __
5087 5091
5088 } } // namespace v8::internal 5092 } } // namespace v8::internal
5089 5093
5090 #endif // V8_TARGET_ARCH_X64 5094 #endif // V8_TARGET_ARCH_X64
OLDNEW
« src/runtime.cc ('K') | « src/runtime.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698