| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/compiler/code-assembler.h" | 5 #include "src/compiler/code-assembler.h" |
| 6 | 6 |
| 7 #include <ostream> | 7 #include <ostream> |
| 8 | 8 |
| 9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
| 10 #include "src/compiler/graph.h" | 10 #include "src/compiler/graph.h" |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 Node* CodeAssembler::LoadRoot(Heap::RootListIndex root_index) { | 198 Node* CodeAssembler::LoadRoot(Heap::RootListIndex root_index) { |
| 199 if (isolate()->heap()->RootCanBeTreatedAsConstant(root_index)) { | 199 if (isolate()->heap()->RootCanBeTreatedAsConstant(root_index)) { |
| 200 Handle<Object> root = isolate()->heap()->root_handle(root_index); | 200 Handle<Object> root = isolate()->heap()->root_handle(root_index); |
| 201 if (root->IsSmi()) { | 201 if (root->IsSmi()) { |
| 202 return SmiConstant(Smi::cast(*root)); | 202 return SmiConstant(Smi::cast(*root)); |
| 203 } else { | 203 } else { |
| 204 return HeapConstant(Handle<HeapObject>::cast(root)); | 204 return HeapConstant(Handle<HeapObject>::cast(root)); |
| 205 } | 205 } |
| 206 } | 206 } |
| 207 | 207 |
| 208 compiler::Node* roots_array_start = | 208 Node* roots_array_start = |
| 209 ExternalConstant(ExternalReference::roots_array_start(isolate())); | 209 ExternalConstant(ExternalReference::roots_array_start(isolate())); |
| 210 USE(roots_array_start); | 210 return Load(MachineType::AnyTagged(), roots_array_start, |
| 211 | 211 IntPtrConstant(root_index * kPointerSize)); |
| 212 // TODO(danno): Implement the root-access case where the root is not constant | |
| 213 // and must be loaded from the root array. | |
| 214 UNIMPLEMENTED(); | |
| 215 return nullptr; | |
| 216 } | 212 } |
| 217 | 213 |
| 218 Node* CodeAssembler::Store(MachineRepresentation rep, Node* base, Node* value) { | 214 Node* CodeAssembler::Store(MachineRepresentation rep, Node* base, Node* value) { |
| 219 return raw_assembler_->Store(rep, base, value, kFullWriteBarrier); | 215 return raw_assembler_->Store(rep, base, value, kFullWriteBarrier); |
| 220 } | 216 } |
| 221 | 217 |
| 222 Node* CodeAssembler::Store(MachineRepresentation rep, Node* base, Node* index, | 218 Node* CodeAssembler::Store(MachineRepresentation rep, Node* base, Node* index, |
| 223 Node* value) { | 219 Node* value) { |
| 224 return raw_assembler_->Store(rep, base, index, value, kFullWriteBarrier); | 220 return raw_assembler_->Store(rep, base, index, value, kFullWriteBarrier); |
| 225 } | 221 } |
| 226 | 222 |
| 227 Node* CodeAssembler::StoreNoWriteBarrier(MachineRepresentation rep, Node* base, | 223 Node* CodeAssembler::StoreNoWriteBarrier(MachineRepresentation rep, Node* base, |
| 228 Node* value) { | 224 Node* value) { |
| 229 return raw_assembler_->Store(rep, base, value, kNoWriteBarrier); | 225 return raw_assembler_->Store(rep, base, value, kNoWriteBarrier); |
| 230 } | 226 } |
| 231 | 227 |
| 232 Node* CodeAssembler::StoreNoWriteBarrier(MachineRepresentation rep, Node* base, | 228 Node* CodeAssembler::StoreNoWriteBarrier(MachineRepresentation rep, Node* base, |
| 233 Node* index, Node* value) { | 229 Node* index, Node* value) { |
| 234 return raw_assembler_->Store(rep, base, index, value, kNoWriteBarrier); | 230 return raw_assembler_->Store(rep, base, index, value, kNoWriteBarrier); |
| 235 } | 231 } |
| 236 | 232 |
| 237 Node* CodeAssembler::AtomicStore(MachineRepresentation rep, Node* base, | 233 Node* CodeAssembler::AtomicStore(MachineRepresentation rep, Node* base, |
| 238 Node* index, Node* value) { | 234 Node* index, Node* value) { |
| 239 return raw_assembler_->AtomicStore(rep, base, index, value); | 235 return raw_assembler_->AtomicStore(rep, base, index, value); |
| 240 } | 236 } |
| 241 | 237 |
| 238 Node* CodeAssembler::StoreRoot(Heap::RootListIndex root_index, Node* value) { |
| 239 DCHECK(Heap::RootCanBeWrittenAfterInitialization(root_index)); |
| 240 Node* roots_array_start = |
| 241 ExternalConstant(ExternalReference::roots_array_start(isolate())); |
| 242 return StoreNoWriteBarrier(MachineRepresentation::kTagged, roots_array_start, |
| 243 IntPtrConstant(root_index * kPointerSize), value); |
| 244 } |
| 245 |
| 242 Node* CodeAssembler::Projection(int index, Node* value) { | 246 Node* CodeAssembler::Projection(int index, Node* value) { |
| 243 return raw_assembler_->Projection(index, value); | 247 return raw_assembler_->Projection(index, value); |
| 244 } | 248 } |
| 245 | 249 |
| 246 void CodeAssembler::BranchIf(Node* condition, Label* if_true, Label* if_false) { | 250 void CodeAssembler::BranchIf(Node* condition, Label* if_true, Label* if_false) { |
| 247 Label if_condition_is_true(this), if_condition_is_false(this); | 251 Label if_condition_is_true(this), if_condition_is_false(this); |
| 248 Branch(condition, &if_condition_is_true, &if_condition_is_false); | 252 Branch(condition, &if_condition_is_true, &if_condition_is_false); |
| 249 Bind(&if_condition_is_true); | 253 Bind(&if_condition_is_true); |
| 250 Goto(if_true); | 254 Goto(if_true); |
| 251 Bind(&if_condition_is_false); | 255 Bind(&if_condition_is_false); |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 } | 699 } |
| 696 } | 700 } |
| 697 } | 701 } |
| 698 | 702 |
| 699 bound_ = true; | 703 bound_ = true; |
| 700 } | 704 } |
| 701 | 705 |
| 702 } // namespace compiler | 706 } // namespace compiler |
| 703 } // namespace internal | 707 } // namespace internal |
| 704 } // namespace v8 | 708 } // namespace v8 |
| OLD | NEW |