OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 <iomanip> | 5 #include <iomanip> |
6 #include <sstream> | 6 #include <sstream> |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/accessors.h" | 10 #include "src/accessors.h" |
(...skipping 1463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1474 } | 1474 } |
1475 break; | 1475 break; |
1476 } | 1476 } |
1477 return; | 1477 return; |
1478 } | 1478 } |
1479 | 1479 |
1480 switch (type) { | 1480 switch (type) { |
1481 case FIXED_ARRAY_TYPE: | 1481 case FIXED_ARRAY_TYPE: |
1482 FixedArray::BodyDescriptor::IterateBody(this, object_size, v); | 1482 FixedArray::BodyDescriptor::IterateBody(this, object_size, v); |
1483 break; | 1483 break; |
1484 case CONSTANT_POOL_ARRAY_TYPE: | |
1485 reinterpret_cast<ConstantPoolArray*>(this)->ConstantPoolIterateBody(v); | |
1486 break; | |
1487 case FIXED_DOUBLE_ARRAY_TYPE: | 1484 case FIXED_DOUBLE_ARRAY_TYPE: |
1488 break; | 1485 break; |
1489 case JS_OBJECT_TYPE: | 1486 case JS_OBJECT_TYPE: |
1490 case JS_CONTEXT_EXTENSION_OBJECT_TYPE: | 1487 case JS_CONTEXT_EXTENSION_OBJECT_TYPE: |
1491 case JS_GENERATOR_OBJECT_TYPE: | 1488 case JS_GENERATOR_OBJECT_TYPE: |
1492 case JS_MODULE_TYPE: | 1489 case JS_MODULE_TYPE: |
1493 case JS_VALUE_TYPE: | 1490 case JS_VALUE_TYPE: |
1494 case JS_DATE_TYPE: | 1491 case JS_DATE_TYPE: |
1495 case JS_ARRAY_TYPE: | 1492 case JS_ARRAY_TYPE: |
1496 case JS_ARRAY_BUFFER_TYPE: | 1493 case JS_ARRAY_BUFFER_TYPE: |
(...skipping 7984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9481 | 9478 |
9482 bool Map::EquivalentToForNormalization(Map* other, | 9479 bool Map::EquivalentToForNormalization(Map* other, |
9483 PropertyNormalizationMode mode) { | 9480 PropertyNormalizationMode mode) { |
9484 int properties = mode == CLEAR_INOBJECT_PROPERTIES | 9481 int properties = mode == CLEAR_INOBJECT_PROPERTIES |
9485 ? 0 : other->inobject_properties(); | 9482 ? 0 : other->inobject_properties(); |
9486 return CheckEquivalent(this, other) && bit_field2() == other->bit_field2() && | 9483 return CheckEquivalent(this, other) && bit_field2() == other->bit_field2() && |
9487 inobject_properties() == properties; | 9484 inobject_properties() == properties; |
9488 } | 9485 } |
9489 | 9486 |
9490 | 9487 |
9491 void ConstantPoolArray::ConstantPoolIterateBody(ObjectVisitor* v) { | |
9492 // Unfortunately the serializer relies on pointers within an object being | |
9493 // visited in-order, so we have to iterate both the code and heap pointers in | |
9494 // the small section before doing so in the extended section. | |
9495 for (int s = 0; s <= final_section(); ++s) { | |
9496 LayoutSection section = static_cast<LayoutSection>(s); | |
9497 ConstantPoolArray::Iterator code_iter(this, ConstantPoolArray::CODE_PTR, | |
9498 section); | |
9499 while (!code_iter.is_finished()) { | |
9500 v->VisitCodeEntry(reinterpret_cast<Address>( | |
9501 RawFieldOfElementAt(code_iter.next_index()))); | |
9502 } | |
9503 | |
9504 ConstantPoolArray::Iterator heap_iter(this, ConstantPoolArray::HEAP_PTR, | |
9505 section); | |
9506 while (!heap_iter.is_finished()) { | |
9507 v->VisitPointer(RawFieldOfElementAt(heap_iter.next_index())); | |
9508 } | |
9509 } | |
9510 } | |
9511 | |
9512 | |
9513 void ConstantPoolArray::ClearPtrEntries(Isolate* isolate) { | |
9514 Type type[] = { CODE_PTR, HEAP_PTR }; | |
9515 Address default_value[] = { | |
9516 isolate->builtins()->builtin(Builtins::kIllegal)->entry(), | |
9517 reinterpret_cast<Address>(isolate->heap()->undefined_value()) }; | |
9518 | |
9519 for (int i = 0; i < 2; ++i) { | |
9520 for (int s = 0; s <= final_section(); ++s) { | |
9521 LayoutSection section = static_cast<LayoutSection>(s); | |
9522 if (number_of_entries(type[i], section) > 0) { | |
9523 int offset = OffsetOfElementAt(first_index(type[i], section)); | |
9524 MemsetPointer( | |
9525 reinterpret_cast<Address*>(HeapObject::RawField(this, offset)), | |
9526 default_value[i], | |
9527 number_of_entries(type[i], section)); | |
9528 } | |
9529 } | |
9530 } | |
9531 } | |
9532 | |
9533 | |
9534 void JSFunction::JSFunctionIterateBody(int object_size, ObjectVisitor* v) { | 9488 void JSFunction::JSFunctionIterateBody(int object_size, ObjectVisitor* v) { |
9535 // Iterate over all fields in the body but take care in dealing with | 9489 // Iterate over all fields in the body but take care in dealing with |
9536 // the code entry. | 9490 // the code entry. |
9537 IteratePointers(v, kPropertiesOffset, kCodeEntryOffset); | 9491 IteratePointers(v, kPropertiesOffset, kCodeEntryOffset); |
9538 v->VisitCodeEntry(this->address() + kCodeEntryOffset); | 9492 v->VisitCodeEntry(this->address() + kCodeEntryOffset); |
9539 IteratePointers(v, kCodeEntryOffset + kPointerSize, object_size); | 9493 IteratePointers(v, kCodeEntryOffset + kPointerSize, object_size); |
9540 } | 9494 } |
9541 | 9495 |
9542 | 9496 |
9543 void JSFunction::MarkForOptimization() { | 9497 void JSFunction::MarkForOptimization() { |
(...skipping 2102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11646 if ((name != NULL) && (name[0] != '\0')) { | 11600 if ((name != NULL) && (name[0] != '\0')) { |
11647 os << "name = " << name << "\n"; | 11601 os << "name = " << name << "\n"; |
11648 } | 11602 } |
11649 if (kind() == OPTIMIZED_FUNCTION) { | 11603 if (kind() == OPTIMIZED_FUNCTION) { |
11650 os << "stack_slots = " << stack_slots() << "\n"; | 11604 os << "stack_slots = " << stack_slots() << "\n"; |
11651 } | 11605 } |
11652 | 11606 |
11653 os << "Instructions (size = " << instruction_size() << ")\n"; | 11607 os << "Instructions (size = " << instruction_size() << ")\n"; |
11654 { | 11608 { |
11655 Isolate* isolate = GetIsolate(); | 11609 Isolate* isolate = GetIsolate(); |
11656 int decode_size = is_crankshafted() | 11610 int size = instruction_size(); |
11657 ? static_cast<int>(safepoint_table_offset()) | 11611 int safepoint_offset = |
11658 : instruction_size(); | 11612 is_crankshafted() ? static_cast<int>(safepoint_table_offset()) : size; |
11659 // If there might be a back edge table, stop before reaching it. | 11613 int back_edge_offset = (kind() == Code::FUNCTION) |
11660 if (kind() == Code::FUNCTION) { | 11614 ? static_cast<int>(back_edge_table_offset()) |
11661 decode_size = | 11615 : size; |
11662 Min(decode_size, static_cast<int>(back_edge_table_offset())); | 11616 int constant_pool_offset = FLAG_enable_embedded_constant_pool |
| 11617 ? this->constant_pool_offset() |
| 11618 : size; |
| 11619 |
| 11620 // Stop before reaching any embedded tables |
| 11621 int code_size = Min(safepoint_offset, back_edge_offset); |
| 11622 code_size = Min(code_size, constant_pool_offset); |
| 11623 byte* begin = instruction_start(); |
| 11624 byte* end = begin + code_size; |
| 11625 Disassembler::Decode(isolate, &os, begin, end, this); |
| 11626 |
| 11627 if (constant_pool_offset < size) { |
| 11628 int constant_pool_size = size - constant_pool_offset; |
| 11629 DCHECK((constant_pool_size & kPointerAlignmentMask) == 0); |
| 11630 os << "\nConstant Pool (size = " << constant_pool_size << ")\n"; |
| 11631 Vector<char> buf = Vector<char>::New(50); |
| 11632 intptr_t* ptr = reinterpret_cast<intptr_t*>(begin + constant_pool_offset); |
| 11633 for (int i = 0; i < constant_pool_size; i += kPointerSize, ptr++) { |
| 11634 SNPrintF(buf, "%4d %08" V8PRIxPTR, i, *ptr); |
| 11635 os << static_cast<const void*>(ptr) << " " << buf.start() << "\n"; |
| 11636 } |
11663 } | 11637 } |
11664 byte* begin = instruction_start(); | |
11665 byte* end = begin + decode_size; | |
11666 Disassembler::Decode(isolate, &os, begin, end, this); | |
11667 } | 11638 } |
11668 os << "\n"; | 11639 os << "\n"; |
11669 | 11640 |
11670 if (kind() == FUNCTION) { | 11641 if (kind() == FUNCTION) { |
11671 DeoptimizationOutputData* data = | 11642 DeoptimizationOutputData* data = |
11672 DeoptimizationOutputData::cast(this->deoptimization_data()); | 11643 DeoptimizationOutputData::cast(this->deoptimization_data()); |
11673 data->DeoptimizationOutputDataPrint(os); | 11644 data->DeoptimizationOutputDataPrint(os); |
11674 } else if (kind() == OPTIMIZED_FUNCTION) { | 11645 } else if (kind() == OPTIMIZED_FUNCTION) { |
11675 DeoptimizationInputData* data = | 11646 DeoptimizationInputData* data = |
11676 DeoptimizationInputData::cast(this->deoptimization_data()); | 11647 DeoptimizationInputData::cast(this->deoptimization_data()); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11735 HandlerTable::cast(handler_table())->HandlerTableReturnPrint(os); | 11706 HandlerTable::cast(handler_table())->HandlerTableReturnPrint(os); |
11736 } | 11707 } |
11737 os << "\n"; | 11708 os << "\n"; |
11738 } | 11709 } |
11739 | 11710 |
11740 os << "RelocInfo (size = " << relocation_size() << ")\n"; | 11711 os << "RelocInfo (size = " << relocation_size() << ")\n"; |
11741 for (RelocIterator it(this); !it.done(); it.next()) { | 11712 for (RelocIterator it(this); !it.done(); it.next()) { |
11742 it.rinfo()->Print(GetIsolate(), os); | 11713 it.rinfo()->Print(GetIsolate(), os); |
11743 } | 11714 } |
11744 os << "\n"; | 11715 os << "\n"; |
11745 | |
11746 #ifdef OBJECT_PRINT | |
11747 if (FLAG_enable_ool_constant_pool) { | |
11748 ConstantPoolArray* pool = constant_pool(); | |
11749 if (pool->length()) { | |
11750 os << "Constant Pool\n"; | |
11751 pool->Print(os); | |
11752 os << "\n"; | |
11753 } | |
11754 } | |
11755 #endif | |
11756 } | 11716 } |
11757 #endif // ENABLE_DISASSEMBLER | 11717 #endif // ENABLE_DISASSEMBLER |
11758 | 11718 |
11759 | 11719 |
11760 Handle<FixedArray> JSObject::SetFastElementsCapacity( | 11720 Handle<FixedArray> JSObject::SetFastElementsCapacity( |
11761 Handle<JSObject> object, int capacity, | 11721 Handle<JSObject> object, int capacity, |
11762 SetFastElementsCapacitySmiMode smi_mode) { | 11722 SetFastElementsCapacitySmiMode smi_mode) { |
11763 // We should never end in here with a pixel or external array. | 11723 // We should never end in here with a pixel or external array. |
11764 DCHECK(!object->HasExternalArrayElements()); | 11724 DCHECK(!object->HasExternalArrayElements()); |
11765 | 11725 |
(...skipping 5226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16992 Handle<Object> new_value) { | 16952 Handle<Object> new_value) { |
16993 if (cell->value() != *new_value) { | 16953 if (cell->value() != *new_value) { |
16994 cell->set_value(*new_value); | 16954 cell->set_value(*new_value); |
16995 Isolate* isolate = cell->GetIsolate(); | 16955 Isolate* isolate = cell->GetIsolate(); |
16996 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 16956 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
16997 isolate, DependentCode::kPropertyCellChangedGroup); | 16957 isolate, DependentCode::kPropertyCellChangedGroup); |
16998 } | 16958 } |
16999 } | 16959 } |
17000 } // namespace internal | 16960 } // namespace internal |
17001 } // namespace v8 | 16961 } // namespace v8 |
OLD | NEW |