OLD | NEW |
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 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
(...skipping 8194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8205 } | 8205 } |
8206 | 8206 |
8207 Node* CodeStubAssembler::IsDetachedBuffer(Node* buffer) { | 8207 Node* CodeStubAssembler::IsDetachedBuffer(Node* buffer) { |
8208 CSA_ASSERT(this, HasInstanceType(buffer, JS_ARRAY_BUFFER_TYPE)); | 8208 CSA_ASSERT(this, HasInstanceType(buffer, JS_ARRAY_BUFFER_TYPE)); |
8209 | 8209 |
8210 Node* buffer_bit_field = LoadObjectField( | 8210 Node* buffer_bit_field = LoadObjectField( |
8211 buffer, JSArrayBuffer::kBitFieldOffset, MachineType::Uint32()); | 8211 buffer, JSArrayBuffer::kBitFieldOffset, MachineType::Uint32()); |
8212 return IsSetWord32<JSArrayBuffer::WasNeutered>(buffer_bit_field); | 8212 return IsSetWord32<JSArrayBuffer::WasNeutered>(buffer_bit_field); |
8213 } | 8213 } |
8214 | 8214 |
8215 CodeStubArguments::CodeStubArguments(CodeStubAssembler* assembler, Node* argc) | 8215 CodeStubArguments::CodeStubArguments(CodeStubAssembler* assembler, Node* argc, |
| 8216 Node* fp, |
| 8217 CodeStubAssembler::ParameterMode mode) |
8216 : assembler_(assembler), | 8218 : assembler_(assembler), |
| 8219 argc_mode_(mode), |
8217 argc_(argc), | 8220 argc_(argc), |
8218 arguments_(nullptr), | 8221 arguments_(nullptr), |
8219 fp_(assembler->LoadFramePointer()) { | 8222 fp_(fp != nullptr ? fp : assembler->LoadFramePointer()) { |
8220 argc_ = assembler->ChangeUint32ToWord(argc_); | |
8221 Node* offset = assembler->ElementOffsetFromIndex( | 8223 Node* offset = assembler->ElementOffsetFromIndex( |
8222 argc_, FAST_ELEMENTS, CodeStubAssembler::INTPTR_PARAMETERS, | 8224 argc_, FAST_ELEMENTS, mode, |
8223 (StandardFrameConstants::kFixedSlotCountAboveFp - 1) * kPointerSize); | 8225 (StandardFrameConstants::kFixedSlotCountAboveFp - 1) * kPointerSize); |
8224 arguments_ = assembler_->IntPtrAdd(fp_, offset); | 8226 arguments_ = assembler_->IntPtrAdd(fp_, offset); |
8225 } | 8227 } |
8226 | 8228 |
8227 Node* CodeStubArguments::GetReceiver() const { | 8229 Node* CodeStubArguments::GetReceiver() const { |
8228 return assembler_->Load(MachineType::AnyTagged(), arguments_, | 8230 return assembler_->Load(MachineType::AnyTagged(), arguments_, |
8229 assembler_->IntPtrConstant(kPointerSize)); | 8231 assembler_->IntPtrConstant(kPointerSize)); |
8230 } | 8232 } |
8231 | 8233 |
| 8234 Node* CodeStubArguments::AtIndexPtr( |
| 8235 Node* index, CodeStubAssembler::ParameterMode mode) const { |
| 8236 typedef compiler::Node Node; |
| 8237 Node* negated_index = assembler_->IntPtrOrSmiSub( |
| 8238 assembler_->IntPtrOrSmiConstant(0, mode), index, mode); |
| 8239 Node* offset = |
| 8240 assembler_->ElementOffsetFromIndex(negated_index, FAST_ELEMENTS, mode, 0); |
| 8241 return assembler_->IntPtrAdd(arguments_, offset); |
| 8242 } |
| 8243 |
8232 Node* CodeStubArguments::AtIndex(Node* index, | 8244 Node* CodeStubArguments::AtIndex(Node* index, |
8233 CodeStubAssembler::ParameterMode mode) const { | 8245 CodeStubAssembler::ParameterMode mode) const { |
8234 typedef compiler::Node Node; | 8246 DCHECK_EQ(argc_mode_, mode); |
8235 CSA_ASSERT(assembler_, assembler_->UintPtrLessThan( | 8247 CSA_ASSERT(assembler_, |
8236 mode == CodeStubAssembler::INTPTR_PARAMETERS | 8248 assembler_->UintPtrOrSmiLessThan(index, GetLength(), mode)); |
8237 ? index | 8249 return assembler_->Load(MachineType::AnyTagged(), AtIndexPtr(index, mode)); |
8238 : assembler_->SmiUntag(index), | |
8239 GetLength())); | |
8240 Node* negated_index = | |
8241 assembler_->IntPtrSub(assembler_->IntPtrOrSmiConstant(0, mode), index); | |
8242 Node* offset = | |
8243 assembler_->ElementOffsetFromIndex(negated_index, FAST_ELEMENTS, mode, 0); | |
8244 return assembler_->Load(MachineType::AnyTagged(), arguments_, offset); | |
8245 } | 8250 } |
8246 | 8251 |
8247 Node* CodeStubArguments::AtIndex(int index) const { | 8252 Node* CodeStubArguments::AtIndex(int index) const { |
8248 return AtIndex(assembler_->IntPtrConstant(index)); | 8253 return AtIndex(assembler_->IntPtrConstant(index)); |
8249 } | 8254 } |
8250 | 8255 |
8251 void CodeStubArguments::ForEach( | 8256 void CodeStubArguments::ForEach( |
8252 const CodeStubAssembler::VariableList& vars, | 8257 const CodeStubAssembler::VariableList& vars, |
8253 const CodeStubArguments::ForEachBodyFunction& body, Node* first, Node* last, | 8258 const CodeStubArguments::ForEachBodyFunction& body, Node* first, Node* last, |
8254 CodeStubAssembler::ParameterMode mode) { | 8259 CodeStubAssembler::ParameterMode mode) { |
8255 assembler_->Comment("CodeStubArguments::ForEach"); | 8260 assembler_->Comment("CodeStubArguments::ForEach"); |
8256 DCHECK_IMPLIES(first == nullptr || last == nullptr, | |
8257 mode == CodeStubAssembler::INTPTR_PARAMETERS); | |
8258 if (first == nullptr) { | 8261 if (first == nullptr) { |
8259 first = assembler_->IntPtrOrSmiConstant(0, mode); | 8262 first = assembler_->IntPtrOrSmiConstant(0, mode); |
8260 } | 8263 } |
8261 if (last == nullptr) { | 8264 if (last == nullptr) { |
| 8265 DCHECK_EQ(mode, argc_mode_); |
8262 last = argc_; | 8266 last = argc_; |
8263 } | 8267 } |
8264 Node* start = assembler_->IntPtrSub( | 8268 Node* start = assembler_->IntPtrSub( |
8265 arguments_, | 8269 arguments_, |
8266 assembler_->ElementOffsetFromIndex(first, FAST_ELEMENTS, mode)); | 8270 assembler_->ElementOffsetFromIndex(first, FAST_ELEMENTS, mode)); |
8267 Node* end = assembler_->IntPtrSub( | 8271 Node* end = assembler_->IntPtrSub( |
8268 arguments_, | 8272 arguments_, |
8269 assembler_->ElementOffsetFromIndex(last, FAST_ELEMENTS, mode)); | 8273 assembler_->ElementOffsetFromIndex(last, FAST_ELEMENTS, mode)); |
8270 assembler_->BuildFastLoop( | 8274 assembler_->BuildFastLoop( |
8271 vars, MachineType::PointerRepresentation(), start, end, | 8275 vars, MachineType::PointerRepresentation(), start, end, |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8384 formatted.c_str(), TENURED); | 8388 formatted.c_str(), TENURED); |
8385 CallRuntime(Runtime::kGlobalPrint, NoContextConstant(), | 8389 CallRuntime(Runtime::kGlobalPrint, NoContextConstant(), |
8386 HeapConstant(string)); | 8390 HeapConstant(string)); |
8387 } | 8391 } |
8388 CallRuntime(Runtime::kGlobalPrint, NoContextConstant(), tagged_value); | 8392 CallRuntime(Runtime::kGlobalPrint, NoContextConstant(), tagged_value); |
8389 #endif | 8393 #endif |
8390 } | 8394 } |
8391 | 8395 |
8392 } // namespace internal | 8396 } // namespace internal |
8393 } // namespace v8 | 8397 } // namespace v8 |
OLD | NEW |