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

Side by Side Diff: src/code-stub-assembler.cc

Issue 2469273003: [stubs] Add a utility class to generate code to access builtin arguments (Closed)
Patch Set: Review feedback Created 4 years, 1 month 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
« no previous file with comments | « src/code-stub-assembler.h ('k') | src/compiler/frame-elider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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 #include "src/code-stub-assembler.h" 4 #include "src/code-stub-assembler.h"
5 #include "src/code-factory.h" 5 #include "src/code-factory.h"
6 #include "src/frames-inl.h" 6 #include "src/frames-inl.h"
7 #include "src/frames.h" 7 #include "src/frames.h"
8 #include "src/ic/handler-configuration.h" 8 #include "src/ic/handler-configuration.h"
9 #include "src/ic/stub-cache.h" 9 #include "src/ic/stub-cache.h"
10 10
(...skipping 8738 matching lines...) Expand 10 before | Expand all | Expand 10 after
8749 CSA_ASSERT(HasInstanceType(buffer, JS_ARRAY_BUFFER_TYPE)); 8749 CSA_ASSERT(HasInstanceType(buffer, JS_ARRAY_BUFFER_TYPE));
8750 8750
8751 Node* buffer_bit_field = LoadObjectField( 8751 Node* buffer_bit_field = LoadObjectField(
8752 buffer, JSArrayBuffer::kBitFieldOffset, MachineType::Uint32()); 8752 buffer, JSArrayBuffer::kBitFieldOffset, MachineType::Uint32());
8753 Node* was_neutered_mask = Int32Constant(JSArrayBuffer::WasNeutered::kMask); 8753 Node* was_neutered_mask = Int32Constant(JSArrayBuffer::WasNeutered::kMask);
8754 8754
8755 return Word32NotEqual(Word32And(buffer_bit_field, was_neutered_mask), 8755 return Word32NotEqual(Word32And(buffer_bit_field, was_neutered_mask),
8756 Int32Constant(0)); 8756 Int32Constant(0));
8757 } 8757 }
8758 8758
8759 CodeStubArguments::CodeStubArguments(CodeStubAssembler* assembler,
8760 compiler::Node* argc,
8761 CodeStubAssembler::ParameterMode mode)
8762 : assembler_(assembler),
8763 argc_(argc),
8764 arguments_(nullptr),
8765 fp_(assembler->LoadFramePointer()) {
8766 compiler::Node* offset = assembler->ElementOffsetFromIndex(
8767 argc_, FAST_ELEMENTS, mode,
8768 (StandardFrameConstants::kFixedSlotCountAboveFp - 1) * kPointerSize);
8769 arguments_ = assembler_->IntPtrAddFoldConstants(fp_, offset);
8770 if (mode == CodeStubAssembler::INTEGER_PARAMETERS) {
8771 argc_ = assembler->ChangeInt32ToIntPtr(argc_);
8772 } else if (mode == CodeStubAssembler::SMI_PARAMETERS) {
8773 argc_ = assembler->SmiUntag(argc_);
8774 }
8775 }
8776
8777 compiler::Node* CodeStubArguments::GetReceiver() {
8778 return assembler_->Load(MachineType::AnyTagged(), arguments_,
8779 assembler_->IntPtrConstant(kPointerSize));
8780 }
8781
8782 compiler::Node* CodeStubArguments::AtIndex(
8783 compiler::Node* index, CodeStubAssembler::ParameterMode mode) {
8784 typedef compiler::Node Node;
8785 Node* negated_index = assembler_->IntPtrSubFoldConstants(
8786 assembler_->IntPtrOrSmiConstant(0, mode), index);
8787 Node* offset =
8788 assembler_->ElementOffsetFromIndex(negated_index, FAST_ELEMENTS, mode, 0);
8789 return assembler_->Load(MachineType::AnyTagged(), arguments_, offset);
8790 }
8791
8792 compiler::Node* CodeStubArguments::AtIndex(int index) {
8793 return AtIndex(assembler_->IntPtrConstant(index));
8794 }
8795
8796 void CodeStubArguments::ForEach(const CodeStubAssembler::VariableList& vars,
8797 CodeStubArguments::ForEachBodyFunction body,
8798 compiler::Node* first, compiler::Node* last,
8799 CodeStubAssembler::ParameterMode mode) {
8800 assembler_->Comment("CodeStubArguments::ForEach");
8801 DCHECK_IMPLIES(first == nullptr || last == nullptr,
8802 mode == CodeStubAssembler::INTPTR_PARAMETERS);
8803 if (first == nullptr) {
8804 first = assembler_->IntPtrOrSmiConstant(0, mode);
8805 }
8806 if (last == nullptr) {
8807 last = argc_;
8808 }
8809 compiler::Node* start = assembler_->IntPtrSubFoldConstants(
8810 arguments_,
8811 assembler_->ElementOffsetFromIndex(first, FAST_ELEMENTS, mode));
8812 compiler::Node* end = assembler_->IntPtrSubFoldConstants(
8813 arguments_,
8814 assembler_->ElementOffsetFromIndex(last, FAST_ELEMENTS, mode));
8815 assembler_->BuildFastLoop(
8816 vars, MachineType::PointerRepresentation(), start, end,
8817 [body](CodeStubAssembler* assembler, compiler::Node* current) {
8818 Node* arg = assembler->Load(MachineType::AnyTagged(), current);
8819 body(assembler, arg);
8820 },
8821 -kPointerSize, CodeStubAssembler::IndexAdvanceMode::kPost);
8822 }
8823
8824 void CodeStubArguments::PopAndReturn(compiler::Node* value) {
8825 assembler_->PopAndReturn(
8826 assembler_->IntPtrAddFoldConstants(argc_, assembler_->IntPtrConstant(1)),
8827 value);
8828 }
8829
8759 } // namespace internal 8830 } // namespace internal
8760 } // namespace v8 8831 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-stub-assembler.h ('k') | src/compiler/frame-elider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698