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 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1289 Node* CodeStubAssembler::LoadContextElement(Node* context, Node* slot_index) { | 1289 Node* CodeStubAssembler::LoadContextElement(Node* context, Node* slot_index) { |
1290 Node* offset = | 1290 Node* offset = |
1291 IntPtrAdd(WordShl(slot_index, kPointerSizeLog2), | 1291 IntPtrAdd(WordShl(slot_index, kPointerSizeLog2), |
1292 IntPtrConstant(Context::kHeaderSize - kHeapObjectTag)); | 1292 IntPtrConstant(Context::kHeaderSize - kHeapObjectTag)); |
1293 return Load(MachineType::AnyTagged(), context, offset); | 1293 return Load(MachineType::AnyTagged(), context, offset); |
1294 } | 1294 } |
1295 | 1295 |
1296 Node* CodeStubAssembler::StoreContextElement(Node* context, int slot_index, | 1296 Node* CodeStubAssembler::StoreContextElement(Node* context, int slot_index, |
1297 Node* value) { | 1297 Node* value) { |
1298 int offset = Context::SlotOffset(slot_index); | 1298 int offset = Context::SlotOffset(slot_index); |
1299 return Store(MachineRepresentation::kTagged, context, IntPtrConstant(offset), | 1299 return Store(context, IntPtrConstant(offset), value); |
1300 value); | |
1301 } | 1300 } |
1302 | 1301 |
1303 Node* CodeStubAssembler::StoreContextElement(Node* context, Node* slot_index, | 1302 Node* CodeStubAssembler::StoreContextElement(Node* context, Node* slot_index, |
1304 Node* value) { | 1303 Node* value) { |
1305 Node* offset = | 1304 Node* offset = |
1306 IntPtrAdd(WordShl(slot_index, kPointerSizeLog2), | 1305 IntPtrAdd(WordShl(slot_index, kPointerSizeLog2), |
1307 IntPtrConstant(Context::kHeaderSize - kHeapObjectTag)); | 1306 IntPtrConstant(Context::kHeaderSize - kHeapObjectTag)); |
1308 return Store(MachineRepresentation::kTagged, context, offset, value); | 1307 return Store(context, offset, value); |
1309 } | 1308 } |
1310 | 1309 |
1311 Node* CodeStubAssembler::LoadNativeContext(Node* context) { | 1310 Node* CodeStubAssembler::LoadNativeContext(Node* context) { |
1312 return LoadContextElement(context, Context::NATIVE_CONTEXT_INDEX); | 1311 return LoadContextElement(context, Context::NATIVE_CONTEXT_INDEX); |
1313 } | 1312 } |
1314 | 1313 |
1315 Node* CodeStubAssembler::LoadJSArrayElementsMap(ElementsKind kind, | 1314 Node* CodeStubAssembler::LoadJSArrayElementsMap(ElementsKind kind, |
1316 Node* native_context) { | 1315 Node* native_context) { |
1317 CSA_ASSERT(this, IsNativeContext(native_context)); | 1316 CSA_ASSERT(this, IsNativeContext(native_context)); |
1318 return LoadFixedArrayElement(native_context, | 1317 return LoadFixedArrayElement(native_context, |
1319 IntPtrConstant(Context::ArrayMapIndex(kind))); | 1318 IntPtrConstant(Context::ArrayMapIndex(kind))); |
1320 } | 1319 } |
1321 | 1320 |
1322 Node* CodeStubAssembler::StoreHeapNumberValue(Node* object, Node* value) { | 1321 Node* CodeStubAssembler::StoreHeapNumberValue(Node* object, Node* value) { |
1323 return StoreObjectFieldNoWriteBarrier(object, HeapNumber::kValueOffset, value, | 1322 return StoreObjectFieldNoWriteBarrier(object, HeapNumber::kValueOffset, value, |
1324 MachineRepresentation::kFloat64); | 1323 MachineRepresentation::kFloat64); |
1325 } | 1324 } |
1326 | 1325 |
1327 Node* CodeStubAssembler::StoreObjectField( | 1326 Node* CodeStubAssembler::StoreObjectField( |
1328 Node* object, int offset, Node* value) { | 1327 Node* object, int offset, Node* value) { |
1329 return Store(MachineRepresentation::kTagged, object, | 1328 return Store(object, IntPtrConstant(offset - kHeapObjectTag), value); |
1330 IntPtrConstant(offset - kHeapObjectTag), value); | |
1331 } | 1329 } |
1332 | 1330 |
1333 Node* CodeStubAssembler::StoreObjectField(Node* object, Node* offset, | 1331 Node* CodeStubAssembler::StoreObjectField(Node* object, Node* offset, |
1334 Node* value) { | 1332 Node* value) { |
1335 int const_offset; | 1333 int const_offset; |
1336 if (ToInt32Constant(offset, const_offset)) { | 1334 if (ToInt32Constant(offset, const_offset)) { |
1337 return StoreObjectField(object, const_offset, value); | 1335 return StoreObjectField(object, const_offset, value); |
1338 } | 1336 } |
1339 return Store(MachineRepresentation::kTagged, object, | 1337 return Store(object, IntPtrSub(offset, IntPtrConstant(kHeapObjectTag)), |
1340 IntPtrSub(offset, IntPtrConstant(kHeapObjectTag)), value); | 1338 value); |
1341 } | 1339 } |
1342 | 1340 |
1343 Node* CodeStubAssembler::StoreObjectFieldNoWriteBarrier( | 1341 Node* CodeStubAssembler::StoreObjectFieldNoWriteBarrier( |
1344 Node* object, int offset, Node* value, MachineRepresentation rep) { | 1342 Node* object, int offset, Node* value, MachineRepresentation rep) { |
1345 return StoreNoWriteBarrier(rep, object, | 1343 return StoreNoWriteBarrier(rep, object, |
1346 IntPtrConstant(offset - kHeapObjectTag), value); | 1344 IntPtrConstant(offset - kHeapObjectTag), value); |
1347 } | 1345 } |
1348 | 1346 |
1349 Node* CodeStubAssembler::StoreObjectFieldNoWriteBarrier( | 1347 Node* CodeStubAssembler::StoreObjectFieldNoWriteBarrier( |
1350 Node* object, Node* offset, Node* value, MachineRepresentation rep) { | 1348 Node* object, Node* offset, Node* value, MachineRepresentation rep) { |
(...skipping 24 matching lines...) Expand all Loading... |
1375 Node* value, | 1373 Node* value, |
1376 WriteBarrierMode barrier_mode, | 1374 WriteBarrierMode barrier_mode, |
1377 int additional_offset, | 1375 int additional_offset, |
1378 ParameterMode parameter_mode) { | 1376 ParameterMode parameter_mode) { |
1379 DCHECK(barrier_mode == SKIP_WRITE_BARRIER || | 1377 DCHECK(barrier_mode == SKIP_WRITE_BARRIER || |
1380 barrier_mode == UPDATE_WRITE_BARRIER); | 1378 barrier_mode == UPDATE_WRITE_BARRIER); |
1381 int header_size = | 1379 int header_size = |
1382 FixedArray::kHeaderSize + additional_offset - kHeapObjectTag; | 1380 FixedArray::kHeaderSize + additional_offset - kHeapObjectTag; |
1383 Node* offset = ElementOffsetFromIndex(index_node, FAST_HOLEY_ELEMENTS, | 1381 Node* offset = ElementOffsetFromIndex(index_node, FAST_HOLEY_ELEMENTS, |
1384 parameter_mode, header_size); | 1382 parameter_mode, header_size); |
1385 MachineRepresentation rep = MachineRepresentation::kTagged; | |
1386 if (barrier_mode == SKIP_WRITE_BARRIER) { | 1383 if (barrier_mode == SKIP_WRITE_BARRIER) { |
1387 return StoreNoWriteBarrier(rep, object, offset, value); | 1384 return StoreNoWriteBarrier(MachineRepresentation::kTagged, object, offset, |
| 1385 value); |
1388 } else { | 1386 } else { |
1389 return Store(rep, object, offset, value); | 1387 return Store(object, offset, value); |
1390 } | 1388 } |
1391 } | 1389 } |
1392 | 1390 |
1393 Node* CodeStubAssembler::StoreFixedDoubleArrayElement( | 1391 Node* CodeStubAssembler::StoreFixedDoubleArrayElement( |
1394 Node* object, Node* index_node, Node* value, ParameterMode parameter_mode) { | 1392 Node* object, Node* index_node, Node* value, ParameterMode parameter_mode) { |
1395 CSA_ASSERT(this, IsFixedDoubleArray(object)); | 1393 CSA_ASSERT(this, IsFixedDoubleArray(object)); |
1396 Node* offset = | 1394 Node* offset = |
1397 ElementOffsetFromIndex(index_node, FAST_DOUBLE_ELEMENTS, parameter_mode, | 1395 ElementOffsetFromIndex(index_node, FAST_DOUBLE_ELEMENTS, parameter_mode, |
1398 FixedArray::kHeaderSize - kHeapObjectTag); | 1396 FixedArray::kHeaderSize - kHeapObjectTag); |
1399 MachineRepresentation rep = MachineRepresentation::kFloat64; | 1397 MachineRepresentation rep = MachineRepresentation::kFloat64; |
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2137 if_hole = &store_double_hole; | 2135 if_hole = &store_double_hole; |
2138 } else { | 2136 } else { |
2139 // In all the other cases don't check for holes and copy the data as is. | 2137 // In all the other cases don't check for holes and copy the data as is. |
2140 if_hole = nullptr; | 2138 if_hole = nullptr; |
2141 } | 2139 } |
2142 | 2140 |
2143 Node* value = LoadElementAndPrepareForStore( | 2141 Node* value = LoadElementAndPrepareForStore( |
2144 from_array, var_from_offset.value(), from_kind, to_kind, if_hole); | 2142 from_array, var_from_offset.value(), from_kind, to_kind, if_hole); |
2145 | 2143 |
2146 if (needs_write_barrier) { | 2144 if (needs_write_barrier) { |
2147 Store(MachineRepresentation::kTagged, to_array, to_offset, value); | 2145 Store(to_array, to_offset, value); |
2148 } else if (to_double_elements) { | 2146 } else if (to_double_elements) { |
2149 StoreNoWriteBarrier(MachineRepresentation::kFloat64, to_array, to_offset, | 2147 StoreNoWriteBarrier(MachineRepresentation::kFloat64, to_array, to_offset, |
2150 value); | 2148 value); |
2151 } else { | 2149 } else { |
2152 StoreNoWriteBarrier(MachineRepresentation::kTagged, to_array, to_offset, | 2150 StoreNoWriteBarrier(MachineRepresentation::kTagged, to_array, to_offset, |
2153 value); | 2151 value); |
2154 } | 2152 } |
2155 Goto(&next_iter); | 2153 Goto(&next_iter); |
2156 | 2154 |
2157 if (if_hole == &store_double_hole) { | 2155 if (if_hole == &store_double_hole) { |
(...skipping 6022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8180 | 8178 |
8181 Node* CodeStubAssembler::IsDebugActive() { | 8179 Node* CodeStubAssembler::IsDebugActive() { |
8182 Node* is_debug_active = Load( | 8180 Node* is_debug_active = Load( |
8183 MachineType::Uint8(), | 8181 MachineType::Uint8(), |
8184 ExternalConstant(ExternalReference::debug_is_active_address(isolate()))); | 8182 ExternalConstant(ExternalReference::debug_is_active_address(isolate()))); |
8185 return WordNotEqual(is_debug_active, Int32Constant(0)); | 8183 return WordNotEqual(is_debug_active, Int32Constant(0)); |
8186 } | 8184 } |
8187 | 8185 |
8188 } // namespace internal | 8186 } // namespace internal |
8189 } // namespace v8 | 8187 } // namespace v8 |
OLD | NEW |