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 4450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4461 variable.Bind( | 4461 variable.Bind( |
4462 IntPtrOrSmiAdd(variable.value(), IntPtrOrSmiConstant(value, mode), mode)); | 4462 IntPtrOrSmiAdd(variable.value(), IntPtrOrSmiConstant(value, mode), mode)); |
4463 } | 4463 } |
4464 | 4464 |
4465 void CodeStubAssembler::Use(Label* label) { | 4465 void CodeStubAssembler::Use(Label* label) { |
4466 GotoIf(Word32Equal(Int32Constant(0), Int32Constant(1)), label); | 4466 GotoIf(Word32Equal(Int32Constant(0), Int32Constant(1)), label); |
4467 } | 4467 } |
4468 | 4468 |
4469 void CodeStubAssembler::TryToName(Node* key, Label* if_keyisindex, | 4469 void CodeStubAssembler::TryToName(Node* key, Label* if_keyisindex, |
4470 Variable* var_index, Label* if_keyisunique, | 4470 Variable* var_index, Label* if_keyisunique, |
4471 Variable* var_unique, Label* if_bailout) { | 4471 Variable* var_unique, Label* if_bailout, |
| 4472 Label* if_notinternalized) { |
4472 DCHECK_EQ(MachineType::PointerRepresentation(), var_index->rep()); | 4473 DCHECK_EQ(MachineType::PointerRepresentation(), var_index->rep()); |
4473 DCHECK_EQ(MachineRepresentation::kTagged, var_unique->rep()); | 4474 DCHECK_EQ(MachineRepresentation::kTagged, var_unique->rep()); |
4474 Comment("TryToName"); | 4475 Comment("TryToName"); |
4475 | 4476 |
4476 Label if_hascachedindex(this), if_keyisnotindex(this), if_thinstring(this); | 4477 Label if_hascachedindex(this), if_keyisnotindex(this), if_thinstring(this); |
4477 // Handle Smi and HeapNumber keys. | 4478 // Handle Smi and HeapNumber keys. |
4478 var_index->Bind(TryToIntptr(key, &if_keyisnotindex)); | 4479 var_index->Bind(TryToIntptr(key, &if_keyisnotindex)); |
4479 Goto(if_keyisindex); | 4480 Goto(if_keyisindex); |
4480 | 4481 |
4481 BIND(&if_keyisnotindex); | 4482 BIND(&if_keyisnotindex); |
(...skipping 18 matching lines...) Expand all Loading... |
4500 // Check if we have a ThinString. | 4501 // Check if we have a ThinString. |
4501 GotoIf(Word32Equal(key_instance_type, Int32Constant(THIN_STRING_TYPE)), | 4502 GotoIf(Word32Equal(key_instance_type, Int32Constant(THIN_STRING_TYPE)), |
4502 &if_thinstring); | 4503 &if_thinstring); |
4503 GotoIf( | 4504 GotoIf( |
4504 Word32Equal(key_instance_type, Int32Constant(THIN_ONE_BYTE_STRING_TYPE)), | 4505 Word32Equal(key_instance_type, Int32Constant(THIN_ONE_BYTE_STRING_TYPE)), |
4505 &if_thinstring); | 4506 &if_thinstring); |
4506 // Finally, check if |key| is internalized. | 4507 // Finally, check if |key| is internalized. |
4507 STATIC_ASSERT(kNotInternalizedTag != 0); | 4508 STATIC_ASSERT(kNotInternalizedTag != 0); |
4508 Node* not_internalized = | 4509 Node* not_internalized = |
4509 Word32And(key_instance_type, Int32Constant(kIsNotInternalizedMask)); | 4510 Word32And(key_instance_type, Int32Constant(kIsNotInternalizedMask)); |
4510 GotoIf(Word32NotEqual(not_internalized, Int32Constant(0)), if_bailout); | 4511 GotoIf(Word32NotEqual(not_internalized, Int32Constant(0)), |
| 4512 if_notinternalized != nullptr ? if_notinternalized : if_bailout); |
4511 Goto(if_keyisunique); | 4513 Goto(if_keyisunique); |
4512 | 4514 |
4513 BIND(&if_thinstring); | 4515 BIND(&if_thinstring); |
4514 var_unique->Bind(LoadObjectField(key, ThinString::kActualOffset)); | 4516 var_unique->Bind(LoadObjectField(key, ThinString::kActualOffset)); |
4515 Goto(if_keyisunique); | 4517 Goto(if_keyisunique); |
4516 | 4518 |
4517 BIND(&if_hascachedindex); | 4519 BIND(&if_hascachedindex); |
4518 var_index->Bind(DecodeWordFromWord32<Name::ArrayIndexValueBits>(hash)); | 4520 var_index->Bind(DecodeWordFromWord32<Name::ArrayIndexValueBits>(hash)); |
4519 Goto(if_keyisindex); | 4521 Goto(if_keyisindex); |
4520 } | 4522 } |
4521 | 4523 |
| 4524 void CodeStubAssembler::TryInternalizeString( |
| 4525 Node* string, Label* if_index, Variable* var_index, Label* if_internalized, |
| 4526 Variable* var_internalized, Label* if_not_internalized, Label* if_bailout) { |
| 4527 DCHECK(var_index->rep() == MachineType::PointerRepresentation()); |
| 4528 DCHECK(var_internalized->rep() == MachineRepresentation::kTagged); |
| 4529 Node* function = ExternalConstant( |
| 4530 ExternalReference::try_internalize_string_function(isolate())); |
| 4531 Node* result = CallCFunction1(MachineType::AnyTagged(), |
| 4532 MachineType::AnyTagged(), function, string); |
| 4533 Label internalized(this); |
| 4534 GotoIf(TaggedIsNotSmi(result), &internalized); |
| 4535 Node* word_result = SmiUntag(result); |
| 4536 GotoIf(WordEqual(word_result, IntPtrConstant(ResultSentinel::kNotFound)), |
| 4537 if_not_internalized); |
| 4538 GotoIf(WordEqual(word_result, IntPtrConstant(ResultSentinel::kUnsupported)), |
| 4539 if_bailout); |
| 4540 var_index->Bind(word_result); |
| 4541 Goto(if_index); |
| 4542 |
| 4543 BIND(&internalized); |
| 4544 var_internalized->Bind(result); |
| 4545 Goto(if_internalized); |
| 4546 } |
| 4547 |
4522 template <typename Dictionary> | 4548 template <typename Dictionary> |
4523 Node* CodeStubAssembler::EntryToIndex(Node* entry, int field_index) { | 4549 Node* CodeStubAssembler::EntryToIndex(Node* entry, int field_index) { |
4524 Node* entry_index = IntPtrMul(entry, IntPtrConstant(Dictionary::kEntrySize)); | 4550 Node* entry_index = IntPtrMul(entry, IntPtrConstant(Dictionary::kEntrySize)); |
4525 return IntPtrAdd(entry_index, IntPtrConstant(Dictionary::kElementsStartIndex + | 4551 return IntPtrAdd(entry_index, IntPtrConstant(Dictionary::kElementsStartIndex + |
4526 field_index)); | 4552 field_index)); |
4527 } | 4553 } |
4528 | 4554 |
4529 template Node* CodeStubAssembler::EntryToIndex<NameDictionary>(Node*, int); | 4555 template Node* CodeStubAssembler::EntryToIndex<NameDictionary>(Node*, int); |
4530 template Node* CodeStubAssembler::EntryToIndex<GlobalDictionary>(Node*, int); | 4556 template Node* CodeStubAssembler::EntryToIndex<GlobalDictionary>(Node*, int); |
4531 template Node* CodeStubAssembler::EntryToIndex<SeededNumberDictionary>(Node*, | 4557 template Node* CodeStubAssembler::EntryToIndex<SeededNumberDictionary>(Node*, |
(...skipping 4015 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8547 formatted.c_str(), TENURED); | 8573 formatted.c_str(), TENURED); |
8548 CallRuntime(Runtime::kGlobalPrint, NoContextConstant(), | 8574 CallRuntime(Runtime::kGlobalPrint, NoContextConstant(), |
8549 HeapConstant(string)); | 8575 HeapConstant(string)); |
8550 } | 8576 } |
8551 CallRuntime(Runtime::kDebugPrint, NoContextConstant(), tagged_value); | 8577 CallRuntime(Runtime::kDebugPrint, NoContextConstant(), tagged_value); |
8552 #endif | 8578 #endif |
8553 } | 8579 } |
8554 | 8580 |
8555 } // namespace internal | 8581 } // namespace internal |
8556 } // namespace v8 | 8582 } // namespace v8 |
OLD | NEW |