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-stub-assembler.h" | 5 #include "src/compiler/code-stub-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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 return Load(MachineType::Float64(), object, | 252 return Load(MachineType::Float64(), object, |
253 IntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag)); | 253 IntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag)); |
254 } | 254 } |
255 | 255 |
256 Node* CodeStubAssembler::StoreHeapNumberValue(Node* object, Node* value) { | 256 Node* CodeStubAssembler::StoreHeapNumberValue(Node* object, Node* value) { |
257 return StoreNoWriteBarrier( | 257 return StoreNoWriteBarrier( |
258 MachineRepresentation::kFloat64, object, | 258 MachineRepresentation::kFloat64, object, |
259 IntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag), value); | 259 IntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag), value); |
260 } | 260 } |
261 | 261 |
| 262 Node* CodeStubAssembler::TruncateHeapNumberValueToInt32(Node* object) { |
| 263 Node* value = LoadHeapNumberValue(object); |
| 264 return raw_assembler_->TruncateFloat64ToInt32(TruncationMode::kJavaScript, |
| 265 value); |
| 266 } |
| 267 |
262 Node* CodeStubAssembler::LoadMapBitField(Node* map) { | 268 Node* CodeStubAssembler::LoadMapBitField(Node* map) { |
263 return Load(MachineType::Uint8(), map, | 269 return Load(MachineType::Uint8(), map, |
264 IntPtrConstant(Map::kBitFieldOffset - kHeapObjectTag)); | 270 IntPtrConstant(Map::kBitFieldOffset - kHeapObjectTag)); |
265 } | 271 } |
266 | 272 |
267 Node* CodeStubAssembler::LoadMapInstanceType(Node* map) { | 273 Node* CodeStubAssembler::LoadMapInstanceType(Node* map) { |
268 return Load(MachineType::Uint8(), map, | 274 return Load(MachineType::Uint8(), map, |
269 IntPtrConstant(Map::kInstanceTypeOffset - kHeapObjectTag)); | 275 IntPtrConstant(Map::kInstanceTypeOffset - kHeapObjectTag)); |
270 } | 276 } |
271 | 277 |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 return LoadMapInstanceType(LoadMap(object)); | 503 return LoadMapInstanceType(LoadMap(object)); |
498 } | 504 } |
499 | 505 |
500 Node* CodeStubAssembler::BitFieldDecode(Node* word32, uint32_t shift, | 506 Node* CodeStubAssembler::BitFieldDecode(Node* word32, uint32_t shift, |
501 uint32_t mask) { | 507 uint32_t mask) { |
502 return raw_assembler_->Word32Shr( | 508 return raw_assembler_->Word32Shr( |
503 raw_assembler_->Word32And(word32, raw_assembler_->Int32Constant(mask)), | 509 raw_assembler_->Word32And(word32, raw_assembler_->Int32Constant(mask)), |
504 raw_assembler_->Int32Constant(shift)); | 510 raw_assembler_->Int32Constant(shift)); |
505 } | 511 } |
506 | 512 |
| 513 Node* CodeStubAssembler::ChangeInt32ToTagged(Node* value) { |
| 514 if (raw_assembler_->machine()->Is64()) { |
| 515 return SmiTag(ChangeInt32ToInt64(value)); |
| 516 } |
| 517 Variable var_result(this, MachineRepresentation::kTagged); |
| 518 Node* pair = Int32AddWithOverflow(value, value); |
| 519 Node* overflow = Projection(1, pair); |
| 520 Label if_overflow(this, Label::kDeferred), if_notoverflow(this), |
| 521 if_join(this); |
| 522 Branch(overflow, &if_overflow, &if_notoverflow); |
| 523 Bind(&if_overflow); |
| 524 { |
| 525 Node* value64 = ChangeInt32ToFloat64(value); |
| 526 Node* result = AllocateHeapNumberWithValue(value64); |
| 527 var_result.Bind(result); |
| 528 } |
| 529 Goto(&if_join); |
| 530 Bind(&if_notoverflow); |
| 531 { |
| 532 Node* result = Projection(0, pair); |
| 533 var_result.Bind(result); |
| 534 } |
| 535 Goto(&if_join); |
| 536 Bind(&if_join); |
| 537 return var_result.value(); |
| 538 } |
| 539 |
507 void CodeStubAssembler::BranchIf(Node* condition, Label* if_true, | 540 void CodeStubAssembler::BranchIf(Node* condition, Label* if_true, |
508 Label* if_false) { | 541 Label* if_false) { |
509 Label if_condition_is_true(this), if_condition_is_false(this); | 542 Label if_condition_is_true(this), if_condition_is_false(this); |
510 Branch(condition, &if_condition_is_true, &if_condition_is_false); | 543 Branch(condition, &if_condition_is_true, &if_condition_is_false); |
511 Bind(&if_condition_is_true); | 544 Bind(&if_condition_is_true); |
512 Goto(if_true); | 545 Goto(if_true); |
513 Bind(&if_condition_is_false); | 546 Bind(&if_condition_is_false); |
514 Goto(if_false); | 547 Goto(if_false); |
515 } | 548 } |
516 | 549 |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
915 } | 948 } |
916 } | 949 } |
917 } | 950 } |
918 | 951 |
919 bound_ = true; | 952 bound_ = true; |
920 } | 953 } |
921 | 954 |
922 } // namespace compiler | 955 } // namespace compiler |
923 } // namespace internal | 956 } // namespace internal |
924 } // namespace v8 | 957 } // namespace v8 |
OLD | NEW |