| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 21 matching lines...) Expand all Loading... |
| 32 #include "bootstrapper.h" | 32 #include "bootstrapper.h" |
| 33 #include "code-stubs.h" | 33 #include "code-stubs.h" |
| 34 #include "regexp-macro-assembler.h" | 34 #include "regexp-macro-assembler.h" |
| 35 #include "stub-cache.h" | 35 #include "stub-cache.h" |
| 36 #include "runtime.h" | 36 #include "runtime.h" |
| 37 | 37 |
| 38 namespace v8 { | 38 namespace v8 { |
| 39 namespace internal { | 39 namespace internal { |
| 40 | 40 |
| 41 | 41 |
| 42 void FastCloneShallowObjectStub::InitializeInterfaceDescriptor( |
| 43 Isolate* isolate, |
| 44 CodeStubInterfaceDescriptor* descriptor) { |
| 45 static Register registers[] = { rax, rbx, rcx, rdx }; |
| 46 descriptor->register_param_count_ = 4; |
| 47 descriptor->register_params_ = registers; |
| 48 descriptor->stack_parameter_count_ = NULL; |
| 49 descriptor->deoptimization_handler_ = |
| 50 Runtime::FunctionForId(Runtime::kCreateObjectLiteralShallow)->entry; |
| 51 } |
| 52 |
| 53 |
| 42 void KeyedLoadFastElementStub::InitializeInterfaceDescriptor( | 54 void KeyedLoadFastElementStub::InitializeInterfaceDescriptor( |
| 43 Isolate* isolate, | 55 Isolate* isolate, |
| 44 CodeStubInterfaceDescriptor* descriptor) { | 56 CodeStubInterfaceDescriptor* descriptor) { |
| 45 static Register registers[] = { rdx, rax }; | 57 static Register registers[] = { rdx, rax }; |
| 46 descriptor->register_param_count_ = 2; | 58 descriptor->register_param_count_ = 2; |
| 47 descriptor->register_params_ = registers; | 59 descriptor->register_params_ = registers; |
| 48 descriptor->deoptimization_handler_ = | 60 descriptor->deoptimization_handler_ = |
| 49 FUNCTION_ADDR(KeyedLoadIC_MissFromStubFailure); | 61 FUNCTION_ADDR(KeyedLoadIC_MissFromStubFailure); |
| 50 } | 62 } |
| 51 | 63 |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 GenerateFastCloneShallowArrayCommon(masm, length_, mode, | 489 GenerateFastCloneShallowArrayCommon(masm, length_, mode, |
| 478 allocation_site_mode_, | 490 allocation_site_mode_, |
| 479 &slow_case); | 491 &slow_case); |
| 480 __ ret(3 * kPointerSize); | 492 __ ret(3 * kPointerSize); |
| 481 | 493 |
| 482 __ bind(&slow_case); | 494 __ bind(&slow_case); |
| 483 __ TailCallRuntime(Runtime::kCreateArrayLiteralShallow, 3, 1); | 495 __ TailCallRuntime(Runtime::kCreateArrayLiteralShallow, 3, 1); |
| 484 } | 496 } |
| 485 | 497 |
| 486 | 498 |
| 487 void FastCloneShallowObjectStub::Generate(MacroAssembler* masm) { | |
| 488 // Stack layout on entry: | |
| 489 // | |
| 490 // [rsp + kPointerSize]: object literal flags. | |
| 491 // [rsp + (2 * kPointerSize)]: constant properties. | |
| 492 // [rsp + (3 * kPointerSize)]: literal index. | |
| 493 // [rsp + (4 * kPointerSize)]: literals array. | |
| 494 | |
| 495 // Load boilerplate object into ecx and check if we need to create a | |
| 496 // boilerplate. | |
| 497 Label slow_case; | |
| 498 __ movq(rcx, Operand(rsp, 4 * kPointerSize)); | |
| 499 __ movq(rax, Operand(rsp, 3 * kPointerSize)); | |
| 500 SmiIndex index = masm->SmiToIndex(rax, rax, kPointerSizeLog2); | |
| 501 __ movq(rcx, | |
| 502 FieldOperand(rcx, index.reg, index.scale, FixedArray::kHeaderSize)); | |
| 503 __ CompareRoot(rcx, Heap::kUndefinedValueRootIndex); | |
| 504 __ j(equal, &slow_case); | |
| 505 | |
| 506 // Check that the boilerplate contains only fast properties and we can | |
| 507 // statically determine the instance size. | |
| 508 int size = JSObject::kHeaderSize + length_ * kPointerSize; | |
| 509 __ movq(rax, FieldOperand(rcx, HeapObject::kMapOffset)); | |
| 510 __ movzxbq(rax, FieldOperand(rax, Map::kInstanceSizeOffset)); | |
| 511 __ cmpq(rax, Immediate(size >> kPointerSizeLog2)); | |
| 512 __ j(not_equal, &slow_case); | |
| 513 | |
| 514 // Allocate the JS object and copy header together with all in-object | |
| 515 // properties from the boilerplate. | |
| 516 __ AllocateInNewSpace(size, rax, rbx, rdx, &slow_case, TAG_OBJECT); | |
| 517 for (int i = 0; i < size; i += kPointerSize) { | |
| 518 __ movq(rbx, FieldOperand(rcx, i)); | |
| 519 __ movq(FieldOperand(rax, i), rbx); | |
| 520 } | |
| 521 | |
| 522 // Return and remove the on-stack parameters. | |
| 523 __ ret(4 * kPointerSize); | |
| 524 | |
| 525 __ bind(&slow_case); | |
| 526 __ TailCallRuntime(Runtime::kCreateObjectLiteralShallow, 4, 1); | |
| 527 } | |
| 528 | |
| 529 | |
| 530 // The stub expects its argument on the stack and returns its result in tos_: | 499 // The stub expects its argument on the stack and returns its result in tos_: |
| 531 // zero for false, and a non-zero value for true. | 500 // zero for false, and a non-zero value for true. |
| 532 void ToBooleanStub::Generate(MacroAssembler* masm) { | 501 void ToBooleanStub::Generate(MacroAssembler* masm) { |
| 533 // This stub overrides SometimesSetsUpAFrame() to return false. That means | 502 // This stub overrides SometimesSetsUpAFrame() to return false. That means |
| 534 // we cannot call anything that could cause a GC from this stub. | 503 // we cannot call anything that could cause a GC from this stub. |
| 535 Label patch; | 504 Label patch; |
| 536 const Register argument = rax; | 505 const Register argument = rax; |
| 537 const Register map = rdx; | 506 const Register map = rdx; |
| 538 | 507 |
| 539 if (!types_.IsEmpty()) { | 508 if (!types_.IsEmpty()) { |
| (...skipping 6183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6723 #endif | 6692 #endif |
| 6724 | 6693 |
| 6725 __ Ret(); | 6694 __ Ret(); |
| 6726 } | 6695 } |
| 6727 | 6696 |
| 6728 #undef __ | 6697 #undef __ |
| 6729 | 6698 |
| 6730 } } // namespace v8::internal | 6699 } } // namespace v8::internal |
| 6731 | 6700 |
| 6732 #endif // V8_TARGET_ARCH_X64 | 6701 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |