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

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

Issue 1238143002: [stubs] Optimize LoadGlobalViaContextStub and StoreGlobalViaContextStub. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix ARM typo. Created 5 years, 4 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
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_ARM64 7 #if V8_TARGET_ARCH_ARM64
8 8
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 5476 matching lines...) Expand 10 before | Expand all | Expand 10 after
5487 5487
5488 Label fast_elements_case; 5488 Label fast_elements_case;
5489 __ CompareAndBranch(kind, FAST_ELEMENTS, eq, &fast_elements_case); 5489 __ CompareAndBranch(kind, FAST_ELEMENTS, eq, &fast_elements_case);
5490 GenerateCase(masm, FAST_HOLEY_ELEMENTS); 5490 GenerateCase(masm, FAST_HOLEY_ELEMENTS);
5491 5491
5492 __ Bind(&fast_elements_case); 5492 __ Bind(&fast_elements_case);
5493 GenerateCase(masm, FAST_ELEMENTS); 5493 GenerateCase(masm, FAST_ELEMENTS);
5494 } 5494 }
5495 5495
5496 5496
5497 void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) {
5498 Register context = cp;
5499 Register result = x0;
5500 Register slot = x2;
5501 Register name = x3;
5502 Label slow_case;
5503
5504 // Go up the context chain to the script context.
5505 for (int i = 0; i < depth(); ++i) {
5506 __ Ldr(result, ContextMemOperand(context, Context::PREVIOUS_INDEX));
5507 context = result;
5508 }
5509
5510 // Load the PropertyCell value at the specified slot.
5511 __ Add(result, context, Operand(slot, LSL, kPointerSizeLog2));
5512 __ Ldr(result, ContextMemOperand(result));
5513 __ Ldr(result, FieldMemOperand(result, PropertyCell::kValueOffset));
5514
5515 // If the result is not the_hole, return. Otherwise, handle in the runtime.
5516 __ JumpIfRoot(result, Heap::kTheHoleValueRootIndex, &slow_case);
5517 __ Ret();
5518
5519 // Fallback to runtime.
5520 __ Bind(&slow_case);
5521 __ SmiTag(slot);
5522 __ Push(slot, name);
5523 __ TailCallRuntime(Runtime::kLoadGlobalViaContext, 2, 1);
5524 }
5525
5526
5527 void StoreGlobalViaContextStub::Generate(MacroAssembler* masm) {
5528 Register context = cp;
5529 Register value = x0;
5530 Register slot = x2;
5531 Register name = x3;
5532 Register context_temp = x10;
5533 Register cell = x10;
5534 Register cell_details = x11;
5535 Register cell_value = x12;
5536 Register cell_value_map = x13;
5537 Register value_map = x14;
5538 Label fast_heapobject_case, fast_smi_case, slow_case;
5539
5540 if (FLAG_debug_code) {
5541 __ CompareRoot(value, Heap::kTheHoleValueRootIndex);
5542 __ Check(ne, kUnexpectedValue);
5543 __ AssertName(name);
5544 }
5545
5546 // Go up the context chain to the script context.
5547 for (int i = 0; i < depth(); i++) {
5548 __ Ldr(context_temp, ContextMemOperand(context, Context::PREVIOUS_INDEX));
5549 context = context_temp;
5550 }
5551
5552 // Load the PropertyCell at the specified slot.
5553 __ Add(cell, context, Operand(slot, LSL, kPointerSizeLog2));
5554 __ Ldr(cell, ContextMemOperand(cell));
5555
5556 // Load PropertyDetails for the cell (actually only the cell_type and kind).
5557 __ Ldr(cell_details,
5558 UntagSmiFieldMemOperand(cell, PropertyCell::kDetailsOffset));
5559 __ And(cell_details, cell_details,
5560 PropertyDetails::PropertyCellTypeField::kMask |
5561 PropertyDetails::KindField::kMask);
5562
5563 // Check if PropertyCell holds mutable data.
5564 Label not_mutable_data;
5565 __ Cmp(cell_details, PropertyDetails::PropertyCellTypeField::encode(
5566 PropertyCellType::kMutable) |
5567 PropertyDetails::KindField::encode(kData));
5568 __ B(ne, &not_mutable_data);
5569 __ JumpIfSmi(value, &fast_smi_case);
5570 __ Bind(&fast_heapobject_case);
5571 __ Str(value, FieldMemOperand(cell, PropertyCell::kValueOffset));
5572 // RecordWriteField clobbers the value register, so we copy it before the
5573 // call.
5574 __ Mov(x11, value);
5575 __ RecordWriteField(cell, PropertyCell::kValueOffset, x11, x12,
5576 kLRHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET,
5577 OMIT_SMI_CHECK);
5578 __ Ret();
5579
5580 __ Bind(&not_mutable_data);
5581 // Check if PropertyCell value matches the new value (relevant for Constant,
5582 // ConstantType and Undefined cells).
5583 Label not_same_value;
5584 __ Ldr(cell_value, FieldMemOperand(cell, PropertyCell::kValueOffset));
5585 __ Cmp(cell_value, value);
5586 __ B(ne, &not_same_value);
5587
5588 if (FLAG_debug_code) {
5589 Label done;
5590 // This can only be true for Constant, ConstantType and Undefined cells,
5591 // because we never store the_hole via this stub.
5592 __ Cmp(cell_details, PropertyDetails::PropertyCellTypeField::encode(
5593 PropertyCellType::kConstant) |
5594 PropertyDetails::KindField::encode(kData));
5595 __ B(eq, &done);
5596 __ Cmp(cell_details, PropertyDetails::PropertyCellTypeField::encode(
5597 PropertyCellType::kConstantType) |
5598 PropertyDetails::KindField::encode(kData));
5599 __ B(eq, &done);
5600 __ Cmp(cell_details, PropertyDetails::PropertyCellTypeField::encode(
5601 PropertyCellType::kUndefined) |
5602 PropertyDetails::KindField::encode(kData));
5603 __ Check(eq, kUnexpectedValue);
5604 __ Bind(&done);
5605 }
5606 __ Ret();
5607 __ Bind(&not_same_value);
5608
5609 // Check if PropertyCell contains data with constant type.
5610 __ Cmp(cell_details, PropertyDetails::PropertyCellTypeField::encode(
5611 PropertyCellType::kConstantType) |
5612 PropertyDetails::KindField::encode(kData));
5613 __ B(ne, &slow_case);
5614
5615 // Now either both old and new values must be smis or both must be heap
5616 // objects with same map.
5617 Label value_is_heap_object;
5618 __ JumpIfNotSmi(value, &value_is_heap_object);
5619 __ JumpIfNotSmi(cell_value, &slow_case);
5620 // Old and new values are smis, no need for a write barrier here.
5621 __ Bind(&fast_smi_case);
5622 __ Str(value, FieldMemOperand(cell, PropertyCell::kValueOffset));
5623 __ Ret();
5624
5625 __ Bind(&value_is_heap_object);
5626 __ JumpIfSmi(cell_value, &slow_case);
5627
5628 __ Ldr(cell_value_map, FieldMemOperand(cell_value, HeapObject::kMapOffset));
5629 __ Ldr(value_map, FieldMemOperand(value, HeapObject::kMapOffset));
5630 __ Cmp(cell_value_map, value_map);
5631 __ B(eq, &fast_heapobject_case);
5632
5633 // Fall back to the runtime.
5634 __ Bind(&slow_case);
5635 __ SmiTag(slot);
5636 __ Push(slot, name, value);
5637 __ TailCallRuntime(is_strict(language_mode())
5638 ? Runtime::kStoreGlobalViaContext_Strict
5639 : Runtime::kStoreGlobalViaContext_Sloppy,
5640 3, 1);
5641 }
5642
5643
5497 // The number of register that CallApiFunctionAndReturn will need to save on 5644 // The number of register that CallApiFunctionAndReturn will need to save on
5498 // the stack. The space for these registers need to be allocated in the 5645 // the stack. The space for these registers need to be allocated in the
5499 // ExitFrame before calling CallApiFunctionAndReturn. 5646 // ExitFrame before calling CallApiFunctionAndReturn.
5500 static const int kCallApiFunctionSpillSpace = 4; 5647 static const int kCallApiFunctionSpillSpace = 4;
5501 5648
5502 5649
5503 static int AddressOffset(ExternalReference ref0, ExternalReference ref1) { 5650 static int AddressOffset(ExternalReference ref0, ExternalReference ref1) {
5504 return static_cast<int>(ref0.address() - ref1.address()); 5651 return static_cast<int>(ref0.address() - ref1.address());
5505 } 5652 }
5506 5653
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
5837 MemOperand(fp, 6 * kPointerSize), NULL); 5984 MemOperand(fp, 6 * kPointerSize), NULL);
5838 } 5985 }
5839 5986
5840 5987
5841 #undef __ 5988 #undef __
5842 5989
5843 } // namespace internal 5990 } // namespace internal
5844 } // namespace v8 5991 } // namespace v8
5845 5992
5846 #endif // V8_TARGET_ARCH_ARM64 5993 #endif // V8_TARGET_ARCH_ARM64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698