OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 // Review notes: | 5 // Review notes: |
6 // | 6 // |
7 // - The use of macros in these inline functions may seem superfluous | 7 // - The use of macros in these inline functions may seem superfluous |
8 // but it is absolutely needed to make sure gcc generates optimal | 8 // but it is absolutely needed to make sure gcc generates optimal |
9 // code. gcc is not happy when attempting to inline too deep. | 9 // code. gcc is not happy when attempting to inline too deep. |
10 // | 10 // |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 #define BOOL_ACCESSORS(holder, field, name, offset) \ | 135 #define BOOL_ACCESSORS(holder, field, name, offset) \ |
136 bool holder::name() const { \ | 136 bool holder::name() const { \ |
137 return BooleanBit::get(field(), offset); \ | 137 return BooleanBit::get(field(), offset); \ |
138 } \ | 138 } \ |
139 void holder::set_##name(bool value) { \ | 139 void holder::set_##name(bool value) { \ |
140 set_##field(BooleanBit::set(field(), offset, value)); \ | 140 set_##field(BooleanBit::set(field(), offset, value)); \ |
141 } | 141 } |
142 | 142 |
143 | 143 |
144 bool Object::IsFixedArrayBase() const { | 144 bool Object::IsFixedArrayBase() const { |
145 return IsFixedArray() || IsFixedDoubleArray() || IsConstantPoolArray() || | 145 return IsFixedArray() || IsFixedDoubleArray() || IsFixedTypedArrayBase() || |
146 IsFixedTypedArrayBase() || IsExternalArray(); | 146 IsExternalArray(); |
147 } | 147 } |
148 | 148 |
149 | 149 |
150 // External objects are not extensible, so the map check is enough. | 150 // External objects are not extensible, so the map check is enough. |
151 bool Object::IsExternal() const { | 151 bool Object::IsExternal() const { |
152 return Object::IsHeapObject() && | 152 return Object::IsHeapObject() && |
153 HeapObject::cast(this)->map() == | 153 HeapObject::cast(this)->map() == |
154 HeapObject::cast(this)->GetHeap()->external_map(); | 154 HeapObject::cast(this)->GetHeap()->external_map(); |
155 } | 155 } |
156 | 156 |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 TYPE_CHECKER(JSMap, JS_MAP_TYPE) | 693 TYPE_CHECKER(JSMap, JS_MAP_TYPE) |
694 TYPE_CHECKER(JSSetIterator, JS_SET_ITERATOR_TYPE) | 694 TYPE_CHECKER(JSSetIterator, JS_SET_ITERATOR_TYPE) |
695 TYPE_CHECKER(JSMapIterator, JS_MAP_ITERATOR_TYPE) | 695 TYPE_CHECKER(JSMapIterator, JS_MAP_ITERATOR_TYPE) |
696 TYPE_CHECKER(JSWeakMap, JS_WEAK_MAP_TYPE) | 696 TYPE_CHECKER(JSWeakMap, JS_WEAK_MAP_TYPE) |
697 TYPE_CHECKER(JSWeakSet, JS_WEAK_SET_TYPE) | 697 TYPE_CHECKER(JSWeakSet, JS_WEAK_SET_TYPE) |
698 TYPE_CHECKER(JSContextExtensionObject, JS_CONTEXT_EXTENSION_OBJECT_TYPE) | 698 TYPE_CHECKER(JSContextExtensionObject, JS_CONTEXT_EXTENSION_OBJECT_TYPE) |
699 TYPE_CHECKER(Map, MAP_TYPE) | 699 TYPE_CHECKER(Map, MAP_TYPE) |
700 TYPE_CHECKER(FixedArray, FIXED_ARRAY_TYPE) | 700 TYPE_CHECKER(FixedArray, FIXED_ARRAY_TYPE) |
701 TYPE_CHECKER(FixedDoubleArray, FIXED_DOUBLE_ARRAY_TYPE) | 701 TYPE_CHECKER(FixedDoubleArray, FIXED_DOUBLE_ARRAY_TYPE) |
702 TYPE_CHECKER(WeakFixedArray, FIXED_ARRAY_TYPE) | 702 TYPE_CHECKER(WeakFixedArray, FIXED_ARRAY_TYPE) |
703 TYPE_CHECKER(ConstantPoolArray, CONSTANT_POOL_ARRAY_TYPE) | |
704 | 703 |
705 | 704 |
706 bool Object::IsJSWeakCollection() const { | 705 bool Object::IsJSWeakCollection() const { |
707 return IsJSWeakMap() || IsJSWeakSet(); | 706 return IsJSWeakMap() || IsJSWeakSet(); |
708 } | 707 } |
709 | 708 |
710 | 709 |
711 bool Object::IsDescriptorArray() const { | 710 bool Object::IsDescriptorArray() const { |
712 return IsFixedArray(); | 711 return IsFixedArray(); |
713 } | 712 } |
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1536 if (type == SYMBOL_TYPE) { | 1535 if (type == SYMBOL_TYPE) { |
1537 return false; | 1536 return false; |
1538 } | 1537 } |
1539 DCHECK(type < FIRST_NONSTRING_TYPE); | 1538 DCHECK(type < FIRST_NONSTRING_TYPE); |
1540 // There are four string representations: sequential strings, external | 1539 // There are four string representations: sequential strings, external |
1541 // strings, cons strings, and sliced strings. | 1540 // strings, cons strings, and sliced strings. |
1542 // Only the former two contain raw values and no heap pointers (besides the | 1541 // Only the former two contain raw values and no heap pointers (besides the |
1543 // map-word). | 1542 // map-word). |
1544 return ((type & kIsIndirectStringMask) != kIsIndirectStringTag); | 1543 return ((type & kIsIndirectStringMask) != kIsIndirectStringTag); |
1545 } | 1544 } |
1546 // The ConstantPoolArray contains heap pointers, but also raw values. | |
1547 if (type == CONSTANT_POOL_ARRAY_TYPE) return true; | |
1548 return (type <= LAST_DATA_TYPE); | 1545 return (type <= LAST_DATA_TYPE); |
1549 } | 1546 } |
1550 | 1547 |
1551 | 1548 |
1552 void HeapObject::IteratePointers(ObjectVisitor* v, int start, int end) { | 1549 void HeapObject::IteratePointers(ObjectVisitor* v, int start, int end) { |
1553 v->VisitPointers(reinterpret_cast<Object**>(FIELD_ADDR(this, start)), | 1550 v->VisitPointers(reinterpret_cast<Object**>(FIELD_ADDR(this, start)), |
1554 reinterpret_cast<Object**>(FIELD_ADDR(this, end))); | 1551 reinterpret_cast<Object**>(FIELD_ADDR(this, end))); |
1555 } | 1552 } |
1556 | 1553 |
1557 | 1554 |
(...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2414 } | 2411 } |
2415 | 2412 |
2416 | 2413 |
2417 void ArrayList::Clear(int index, Object* undefined) { | 2414 void ArrayList::Clear(int index, Object* undefined) { |
2418 DCHECK(undefined->IsUndefined()); | 2415 DCHECK(undefined->IsUndefined()); |
2419 FixedArray::cast(this) | 2416 FixedArray::cast(this) |
2420 ->set(kFirstIndex + index, undefined, SKIP_WRITE_BARRIER); | 2417 ->set(kFirstIndex + index, undefined, SKIP_WRITE_BARRIER); |
2421 } | 2418 } |
2422 | 2419 |
2423 | 2420 |
2424 void ConstantPoolArray::NumberOfEntries::increment(Type type) { | |
2425 DCHECK(type < NUMBER_OF_TYPES); | |
2426 element_counts_[type]++; | |
2427 } | |
2428 | |
2429 | |
2430 int ConstantPoolArray::NumberOfEntries::equals( | |
2431 const ConstantPoolArray::NumberOfEntries& other) const { | |
2432 for (int i = 0; i < NUMBER_OF_TYPES; i++) { | |
2433 if (element_counts_[i] != other.element_counts_[i]) return false; | |
2434 } | |
2435 return true; | |
2436 } | |
2437 | |
2438 | |
2439 bool ConstantPoolArray::NumberOfEntries::is_empty() const { | |
2440 return total_count() == 0; | |
2441 } | |
2442 | |
2443 | |
2444 int ConstantPoolArray::NumberOfEntries::count_of(Type type) const { | |
2445 DCHECK(type < NUMBER_OF_TYPES); | |
2446 return element_counts_[type]; | |
2447 } | |
2448 | |
2449 | |
2450 int ConstantPoolArray::NumberOfEntries::base_of(Type type) const { | |
2451 int base = 0; | |
2452 DCHECK(type < NUMBER_OF_TYPES); | |
2453 for (int i = 0; i < type; i++) { | |
2454 base += element_counts_[i]; | |
2455 } | |
2456 return base; | |
2457 } | |
2458 | |
2459 | |
2460 int ConstantPoolArray::NumberOfEntries::total_count() const { | |
2461 int count = 0; | |
2462 for (int i = 0; i < NUMBER_OF_TYPES; i++) { | |
2463 count += element_counts_[i]; | |
2464 } | |
2465 return count; | |
2466 } | |
2467 | |
2468 | |
2469 int ConstantPoolArray::NumberOfEntries::are_in_range(int min, int max) const { | |
2470 for (int i = FIRST_TYPE; i < NUMBER_OF_TYPES; i++) { | |
2471 if (element_counts_[i] < min || element_counts_[i] > max) { | |
2472 return false; | |
2473 } | |
2474 } | |
2475 return true; | |
2476 } | |
2477 | |
2478 | |
2479 int ConstantPoolArray::Iterator::next_index() { | |
2480 DCHECK(!is_finished()); | |
2481 int ret = next_index_++; | |
2482 update_section(); | |
2483 return ret; | |
2484 } | |
2485 | |
2486 | |
2487 bool ConstantPoolArray::Iterator::is_finished() { | |
2488 return next_index_ > array_->last_index(type_, final_section_); | |
2489 } | |
2490 | |
2491 | |
2492 void ConstantPoolArray::Iterator::update_section() { | |
2493 if (next_index_ > array_->last_index(type_, current_section_) && | |
2494 current_section_ != final_section_) { | |
2495 DCHECK(final_section_ == EXTENDED_SECTION); | |
2496 current_section_ = EXTENDED_SECTION; | |
2497 next_index_ = array_->first_index(type_, EXTENDED_SECTION); | |
2498 } | |
2499 } | |
2500 | |
2501 | |
2502 bool ConstantPoolArray::is_extended_layout() { | |
2503 uint32_t small_layout_1 = READ_UINT32_FIELD(this, kSmallLayout1Offset); | |
2504 return IsExtendedField::decode(small_layout_1); | |
2505 } | |
2506 | |
2507 | |
2508 ConstantPoolArray::LayoutSection ConstantPoolArray::final_section() { | |
2509 return is_extended_layout() ? EXTENDED_SECTION : SMALL_SECTION; | |
2510 } | |
2511 | |
2512 | |
2513 int ConstantPoolArray::first_extended_section_index() { | |
2514 DCHECK(is_extended_layout()); | |
2515 uint32_t small_layout_2 = READ_UINT32_FIELD(this, kSmallLayout2Offset); | |
2516 return TotalCountField::decode(small_layout_2); | |
2517 } | |
2518 | |
2519 | |
2520 int ConstantPoolArray::get_extended_section_header_offset() { | |
2521 return RoundUp(SizeFor(NumberOfEntries(this, SMALL_SECTION)), kInt64Size); | |
2522 } | |
2523 | |
2524 | |
2525 ConstantPoolArray::WeakObjectState ConstantPoolArray::get_weak_object_state() { | |
2526 uint32_t small_layout_2 = READ_UINT32_FIELD(this, kSmallLayout2Offset); | |
2527 return WeakObjectStateField::decode(small_layout_2); | |
2528 } | |
2529 | |
2530 | |
2531 void ConstantPoolArray::set_weak_object_state( | |
2532 ConstantPoolArray::WeakObjectState state) { | |
2533 uint32_t small_layout_2 = READ_UINT32_FIELD(this, kSmallLayout2Offset); | |
2534 small_layout_2 = WeakObjectStateField::update(small_layout_2, state); | |
2535 WRITE_INT32_FIELD(this, kSmallLayout2Offset, small_layout_2); | |
2536 } | |
2537 | |
2538 | |
2539 int ConstantPoolArray::first_index(Type type, LayoutSection section) { | |
2540 int index = 0; | |
2541 if (section == EXTENDED_SECTION) { | |
2542 DCHECK(is_extended_layout()); | |
2543 index += first_extended_section_index(); | |
2544 } | |
2545 | |
2546 for (Type type_iter = FIRST_TYPE; type_iter < type; | |
2547 type_iter = next_type(type_iter)) { | |
2548 index += number_of_entries(type_iter, section); | |
2549 } | |
2550 | |
2551 return index; | |
2552 } | |
2553 | |
2554 | |
2555 int ConstantPoolArray::last_index(Type type, LayoutSection section) { | |
2556 return first_index(type, section) + number_of_entries(type, section) - 1; | |
2557 } | |
2558 | |
2559 | |
2560 int ConstantPoolArray::number_of_entries(Type type, LayoutSection section) { | |
2561 if (section == SMALL_SECTION) { | |
2562 uint32_t small_layout_1 = READ_UINT32_FIELD(this, kSmallLayout1Offset); | |
2563 uint32_t small_layout_2 = READ_UINT32_FIELD(this, kSmallLayout2Offset); | |
2564 switch (type) { | |
2565 case INT64: | |
2566 return Int64CountField::decode(small_layout_1); | |
2567 case CODE_PTR: | |
2568 return CodePtrCountField::decode(small_layout_1); | |
2569 case HEAP_PTR: | |
2570 return HeapPtrCountField::decode(small_layout_1); | |
2571 case INT32: | |
2572 return Int32CountField::decode(small_layout_2); | |
2573 default: | |
2574 UNREACHABLE(); | |
2575 return 0; | |
2576 } | |
2577 } else { | |
2578 DCHECK(section == EXTENDED_SECTION && is_extended_layout()); | |
2579 int offset = get_extended_section_header_offset(); | |
2580 switch (type) { | |
2581 case INT64: | |
2582 offset += kExtendedInt64CountOffset; | |
2583 break; | |
2584 case CODE_PTR: | |
2585 offset += kExtendedCodePtrCountOffset; | |
2586 break; | |
2587 case HEAP_PTR: | |
2588 offset += kExtendedHeapPtrCountOffset; | |
2589 break; | |
2590 case INT32: | |
2591 offset += kExtendedInt32CountOffset; | |
2592 break; | |
2593 default: | |
2594 UNREACHABLE(); | |
2595 } | |
2596 return READ_INT_FIELD(this, offset); | |
2597 } | |
2598 } | |
2599 | |
2600 | |
2601 bool ConstantPoolArray::offset_is_type(int offset, Type type) { | |
2602 return (offset >= OffsetOfElementAt(first_index(type, SMALL_SECTION)) && | |
2603 offset <= OffsetOfElementAt(last_index(type, SMALL_SECTION))) || | |
2604 (is_extended_layout() && | |
2605 offset >= OffsetOfElementAt(first_index(type, EXTENDED_SECTION)) && | |
2606 offset <= OffsetOfElementAt(last_index(type, EXTENDED_SECTION))); | |
2607 } | |
2608 | |
2609 | |
2610 ConstantPoolArray::Type ConstantPoolArray::get_type(int index) { | |
2611 LayoutSection section; | |
2612 if (is_extended_layout() && index >= first_extended_section_index()) { | |
2613 section = EXTENDED_SECTION; | |
2614 } else { | |
2615 section = SMALL_SECTION; | |
2616 } | |
2617 | |
2618 Type type = FIRST_TYPE; | |
2619 while (index > last_index(type, section)) { | |
2620 type = next_type(type); | |
2621 } | |
2622 DCHECK(type <= LAST_TYPE); | |
2623 return type; | |
2624 } | |
2625 | |
2626 | |
2627 int64_t ConstantPoolArray::get_int64_entry(int index) { | |
2628 DCHECK(map() == GetHeap()->constant_pool_array_map()); | |
2629 DCHECK(get_type(index) == INT64); | |
2630 return READ_INT64_FIELD(this, OffsetOfElementAt(index)); | |
2631 } | |
2632 | |
2633 | |
2634 double ConstantPoolArray::get_int64_entry_as_double(int index) { | |
2635 STATIC_ASSERT(kDoubleSize == kInt64Size); | |
2636 DCHECK(map() == GetHeap()->constant_pool_array_map()); | |
2637 DCHECK(get_type(index) == INT64); | |
2638 return READ_DOUBLE_FIELD(this, OffsetOfElementAt(index)); | |
2639 } | |
2640 | |
2641 | |
2642 Address ConstantPoolArray::get_code_ptr_entry(int index) { | |
2643 DCHECK(map() == GetHeap()->constant_pool_array_map()); | |
2644 DCHECK(get_type(index) == CODE_PTR); | |
2645 return reinterpret_cast<Address>(READ_FIELD(this, OffsetOfElementAt(index))); | |
2646 } | |
2647 | |
2648 | |
2649 Object* ConstantPoolArray::get_heap_ptr_entry(int index) { | |
2650 DCHECK(map() == GetHeap()->constant_pool_array_map()); | |
2651 DCHECK(get_type(index) == HEAP_PTR); | |
2652 return READ_FIELD(this, OffsetOfElementAt(index)); | |
2653 } | |
2654 | |
2655 | |
2656 int32_t ConstantPoolArray::get_int32_entry(int index) { | |
2657 DCHECK(map() == GetHeap()->constant_pool_array_map()); | |
2658 DCHECK(get_type(index) == INT32); | |
2659 return READ_INT32_FIELD(this, OffsetOfElementAt(index)); | |
2660 } | |
2661 | |
2662 | |
2663 void ConstantPoolArray::set(int index, int64_t value) { | |
2664 DCHECK(map() == GetHeap()->constant_pool_array_map()); | |
2665 DCHECK(get_type(index) == INT64); | |
2666 WRITE_INT64_FIELD(this, OffsetOfElementAt(index), value); | |
2667 } | |
2668 | |
2669 | |
2670 void ConstantPoolArray::set(int index, double value) { | |
2671 STATIC_ASSERT(kDoubleSize == kInt64Size); | |
2672 DCHECK(map() == GetHeap()->constant_pool_array_map()); | |
2673 DCHECK(get_type(index) == INT64); | |
2674 WRITE_DOUBLE_FIELD(this, OffsetOfElementAt(index), value); | |
2675 } | |
2676 | |
2677 | |
2678 void ConstantPoolArray::set(int index, Address value) { | |
2679 DCHECK(map() == GetHeap()->constant_pool_array_map()); | |
2680 DCHECK(get_type(index) == CODE_PTR); | |
2681 WRITE_FIELD(this, OffsetOfElementAt(index), reinterpret_cast<Object*>(value)); | |
2682 } | |
2683 | |
2684 | |
2685 void ConstantPoolArray::set(int index, Object* value) { | |
2686 DCHECK(map() == GetHeap()->constant_pool_array_map()); | |
2687 DCHECK(!GetHeap()->InNewSpace(value)); | |
2688 DCHECK(get_type(index) == HEAP_PTR); | |
2689 WRITE_FIELD(this, OffsetOfElementAt(index), value); | |
2690 WRITE_BARRIER(GetHeap(), this, OffsetOfElementAt(index), value); | |
2691 } | |
2692 | |
2693 | |
2694 void ConstantPoolArray::set(int index, int32_t value) { | |
2695 DCHECK(map() == GetHeap()->constant_pool_array_map()); | |
2696 DCHECK(get_type(index) == INT32); | |
2697 WRITE_INT32_FIELD(this, OffsetOfElementAt(index), value); | |
2698 } | |
2699 | |
2700 | |
2701 void ConstantPoolArray::set_at_offset(int offset, int32_t value) { | |
2702 DCHECK(map() == GetHeap()->constant_pool_array_map()); | |
2703 DCHECK(offset_is_type(offset, INT32)); | |
2704 WRITE_INT32_FIELD(this, offset, value); | |
2705 } | |
2706 | |
2707 | |
2708 void ConstantPoolArray::set_at_offset(int offset, int64_t value) { | |
2709 DCHECK(map() == GetHeap()->constant_pool_array_map()); | |
2710 DCHECK(offset_is_type(offset, INT64)); | |
2711 WRITE_INT64_FIELD(this, offset, value); | |
2712 } | |
2713 | |
2714 | |
2715 void ConstantPoolArray::set_at_offset(int offset, double value) { | |
2716 DCHECK(map() == GetHeap()->constant_pool_array_map()); | |
2717 DCHECK(offset_is_type(offset, INT64)); | |
2718 WRITE_DOUBLE_FIELD(this, offset, value); | |
2719 } | |
2720 | |
2721 | |
2722 void ConstantPoolArray::set_at_offset(int offset, Address value) { | |
2723 DCHECK(map() == GetHeap()->constant_pool_array_map()); | |
2724 DCHECK(offset_is_type(offset, CODE_PTR)); | |
2725 WRITE_FIELD(this, offset, reinterpret_cast<Object*>(value)); | |
2726 WRITE_BARRIER(GetHeap(), this, offset, reinterpret_cast<Object*>(value)); | |
2727 } | |
2728 | |
2729 | |
2730 void ConstantPoolArray::set_at_offset(int offset, Object* value) { | |
2731 DCHECK(map() == GetHeap()->constant_pool_array_map()); | |
2732 DCHECK(!GetHeap()->InNewSpace(value)); | |
2733 DCHECK(offset_is_type(offset, HEAP_PTR)); | |
2734 WRITE_FIELD(this, offset, value); | |
2735 WRITE_BARRIER(GetHeap(), this, offset, value); | |
2736 } | |
2737 | |
2738 | |
2739 void ConstantPoolArray::Init(const NumberOfEntries& small) { | |
2740 uint32_t small_layout_1 = | |
2741 Int64CountField::encode(small.count_of(INT64)) | | |
2742 CodePtrCountField::encode(small.count_of(CODE_PTR)) | | |
2743 HeapPtrCountField::encode(small.count_of(HEAP_PTR)) | | |
2744 IsExtendedField::encode(false); | |
2745 uint32_t small_layout_2 = | |
2746 Int32CountField::encode(small.count_of(INT32)) | | |
2747 TotalCountField::encode(small.total_count()) | | |
2748 WeakObjectStateField::encode(NO_WEAK_OBJECTS); | |
2749 WRITE_UINT32_FIELD(this, kSmallLayout1Offset, small_layout_1); | |
2750 WRITE_UINT32_FIELD(this, kSmallLayout2Offset, small_layout_2); | |
2751 if (kHeaderSize != kFirstEntryOffset) { | |
2752 DCHECK(kFirstEntryOffset - kHeaderSize == kInt32Size); | |
2753 WRITE_UINT32_FIELD(this, kHeaderSize, 0); // Zero out header padding. | |
2754 } | |
2755 } | |
2756 | |
2757 | |
2758 void ConstantPoolArray::InitExtended(const NumberOfEntries& small, | |
2759 const NumberOfEntries& extended) { | |
2760 // Initialize small layout fields first. | |
2761 Init(small); | |
2762 | |
2763 // Set is_extended_layout field. | |
2764 uint32_t small_layout_1 = READ_UINT32_FIELD(this, kSmallLayout1Offset); | |
2765 small_layout_1 = IsExtendedField::update(small_layout_1, true); | |
2766 WRITE_INT32_FIELD(this, kSmallLayout1Offset, small_layout_1); | |
2767 | |
2768 // Initialize the extended layout fields. | |
2769 int extended_header_offset = get_extended_section_header_offset(); | |
2770 WRITE_INT32_FIELD(this, extended_header_offset + kExtendedInt64CountOffset, | |
2771 extended.count_of(INT64)); | |
2772 WRITE_INT32_FIELD(this, extended_header_offset + kExtendedCodePtrCountOffset, | |
2773 extended.count_of(CODE_PTR)); | |
2774 WRITE_INT32_FIELD(this, extended_header_offset + kExtendedHeapPtrCountOffset, | |
2775 extended.count_of(HEAP_PTR)); | |
2776 WRITE_INT32_FIELD(this, extended_header_offset + kExtendedInt32CountOffset, | |
2777 extended.count_of(INT32)); | |
2778 } | |
2779 | |
2780 | |
2781 int ConstantPoolArray::size() { | |
2782 NumberOfEntries small(this, SMALL_SECTION); | |
2783 if (!is_extended_layout()) { | |
2784 return SizeFor(small); | |
2785 } else { | |
2786 NumberOfEntries extended(this, EXTENDED_SECTION); | |
2787 return SizeForExtended(small, extended); | |
2788 } | |
2789 } | |
2790 | |
2791 | |
2792 int ConstantPoolArray::length() { | |
2793 uint32_t small_layout_2 = READ_UINT32_FIELD(this, kSmallLayout2Offset); | |
2794 int length = TotalCountField::decode(small_layout_2); | |
2795 if (is_extended_layout()) { | |
2796 length += number_of_entries(INT64, EXTENDED_SECTION) + | |
2797 number_of_entries(CODE_PTR, EXTENDED_SECTION) + | |
2798 number_of_entries(HEAP_PTR, EXTENDED_SECTION) + | |
2799 number_of_entries(INT32, EXTENDED_SECTION); | |
2800 } | |
2801 return length; | |
2802 } | |
2803 | |
2804 | |
2805 WriteBarrierMode HeapObject::GetWriteBarrierMode( | 2421 WriteBarrierMode HeapObject::GetWriteBarrierMode( |
2806 const DisallowHeapAllocation& promise) { | 2422 const DisallowHeapAllocation& promise) { |
2807 Heap* heap = GetHeap(); | 2423 Heap* heap = GetHeap(); |
2808 if (heap->incremental_marking()->IsMarking()) return UPDATE_WRITE_BARRIER; | 2424 if (heap->incremental_marking()->IsMarking()) return UPDATE_WRITE_BARRIER; |
2809 if (heap->InNewSpace(this)) return SKIP_WRITE_BARRIER; | 2425 if (heap->InNewSpace(this)) return SKIP_WRITE_BARRIER; |
2810 return UPDATE_WRITE_BARRIER; | 2426 return UPDATE_WRITE_BARRIER; |
2811 } | 2427 } |
2812 | 2428 |
2813 | 2429 |
2814 bool HeapObject::NeedsToEnsureDoubleAlignment() { | 2430 bool HeapObject::NeedsToEnsureDoubleAlignment() { |
2815 #ifndef V8_HOST_ARCH_64_BIT | 2431 #ifndef V8_HOST_ARCH_64_BIT |
2816 return (IsFixedFloat64Array() || IsFixedDoubleArray() || | 2432 return (IsFixedFloat64Array() || IsFixedDoubleArray()) && |
2817 IsConstantPoolArray()) && | |
2818 FixedArrayBase::cast(this)->length() != 0; | 2433 FixedArrayBase::cast(this)->length() != 0; |
2819 #else | 2434 #else |
2820 return false; | 2435 return false; |
2821 #endif // V8_HOST_ARCH_64_BIT | 2436 #endif // V8_HOST_ARCH_64_BIT |
2822 } | 2437 } |
2823 | 2438 |
2824 | 2439 |
2825 void FixedArray::set(int index, | 2440 void FixedArray::set(int index, |
2826 Object* value, | 2441 Object* value, |
2827 WriteBarrierMode mode) { | 2442 WriteBarrierMode mode) { |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3323 | 2938 |
3324 | 2939 |
3325 CAST_ACCESSOR(AccessorInfo) | 2940 CAST_ACCESSOR(AccessorInfo) |
3326 CAST_ACCESSOR(ArrayList) | 2941 CAST_ACCESSOR(ArrayList) |
3327 CAST_ACCESSOR(ByteArray) | 2942 CAST_ACCESSOR(ByteArray) |
3328 CAST_ACCESSOR(Cell) | 2943 CAST_ACCESSOR(Cell) |
3329 CAST_ACCESSOR(Code) | 2944 CAST_ACCESSOR(Code) |
3330 CAST_ACCESSOR(CodeCacheHashTable) | 2945 CAST_ACCESSOR(CodeCacheHashTable) |
3331 CAST_ACCESSOR(CompilationCacheTable) | 2946 CAST_ACCESSOR(CompilationCacheTable) |
3332 CAST_ACCESSOR(ConsString) | 2947 CAST_ACCESSOR(ConsString) |
3333 CAST_ACCESSOR(ConstantPoolArray) | |
3334 CAST_ACCESSOR(DeoptimizationInputData) | 2948 CAST_ACCESSOR(DeoptimizationInputData) |
3335 CAST_ACCESSOR(DeoptimizationOutputData) | 2949 CAST_ACCESSOR(DeoptimizationOutputData) |
3336 CAST_ACCESSOR(DependentCode) | 2950 CAST_ACCESSOR(DependentCode) |
3337 CAST_ACCESSOR(DescriptorArray) | 2951 CAST_ACCESSOR(DescriptorArray) |
3338 CAST_ACCESSOR(ExternalArray) | 2952 CAST_ACCESSOR(ExternalArray) |
3339 CAST_ACCESSOR(ExternalOneByteString) | 2953 CAST_ACCESSOR(ExternalOneByteString) |
3340 CAST_ACCESSOR(ExternalFloat32Array) | 2954 CAST_ACCESSOR(ExternalFloat32Array) |
3341 CAST_ACCESSOR(ExternalFloat64Array) | 2955 CAST_ACCESSOR(ExternalFloat64Array) |
3342 CAST_ACCESSOR(ExternalInt16Array) | 2956 CAST_ACCESSOR(ExternalInt16Array) |
3343 CAST_ACCESSOR(ExternalInt32Array) | 2957 CAST_ACCESSOR(ExternalInt32Array) |
(...skipping 1167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4511 instance_type == INTERNALIZED_STRING_TYPE) { | 4125 instance_type == INTERNALIZED_STRING_TYPE) { |
4512 // Strings may get concurrently truncated, hence we have to access its | 4126 // Strings may get concurrently truncated, hence we have to access its |
4513 // length synchronized. | 4127 // length synchronized. |
4514 return SeqTwoByteString::SizeFor( | 4128 return SeqTwoByteString::SizeFor( |
4515 reinterpret_cast<SeqTwoByteString*>(this)->synchronized_length()); | 4129 reinterpret_cast<SeqTwoByteString*>(this)->synchronized_length()); |
4516 } | 4130 } |
4517 if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) { | 4131 if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) { |
4518 return FixedDoubleArray::SizeFor( | 4132 return FixedDoubleArray::SizeFor( |
4519 reinterpret_cast<FixedDoubleArray*>(this)->length()); | 4133 reinterpret_cast<FixedDoubleArray*>(this)->length()); |
4520 } | 4134 } |
4521 if (instance_type == CONSTANT_POOL_ARRAY_TYPE) { | |
4522 return reinterpret_cast<ConstantPoolArray*>(this)->size(); | |
4523 } | |
4524 if (instance_type >= FIRST_FIXED_TYPED_ARRAY_TYPE && | 4135 if (instance_type >= FIRST_FIXED_TYPED_ARRAY_TYPE && |
4525 instance_type <= LAST_FIXED_TYPED_ARRAY_TYPE) { | 4136 instance_type <= LAST_FIXED_TYPED_ARRAY_TYPE) { |
4526 return reinterpret_cast<FixedTypedArrayBase*>( | 4137 return reinterpret_cast<FixedTypedArrayBase*>( |
4527 this)->TypedArraySize(instance_type); | 4138 this)->TypedArraySize(instance_type); |
4528 } | 4139 } |
4529 DCHECK(instance_type == CODE_TYPE); | 4140 DCHECK(instance_type == CODE_TYPE); |
4530 return reinterpret_cast<Code*>(this)->CodeSize(); | 4141 return reinterpret_cast<Code*>(this)->CodeSize(); |
4531 } | 4142 } |
4532 | 4143 |
4533 | 4144 |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5118 bool Code::is_keyed_stub() { | 4729 bool Code::is_keyed_stub() { |
5119 return is_keyed_load_stub() || is_keyed_store_stub(); | 4730 return is_keyed_load_stub() || is_keyed_store_stub(); |
5120 } | 4731 } |
5121 | 4732 |
5122 | 4733 |
5123 bool Code::is_debug_stub() { | 4734 bool Code::is_debug_stub() { |
5124 return ic_state() == DEBUG_STUB; | 4735 return ic_state() == DEBUG_STUB; |
5125 } | 4736 } |
5126 | 4737 |
5127 | 4738 |
5128 ConstantPoolArray* Code::constant_pool() { | 4739 Address Code::constant_pool() { |
5129 return ConstantPoolArray::cast(READ_FIELD(this, kConstantPoolOffset)); | 4740 Address constant_pool = NULL; |
| 4741 if (FLAG_enable_embedded_constant_pool) { |
| 4742 int offset = constant_pool_offset(); |
| 4743 if (offset < instruction_size()) { |
| 4744 constant_pool = FIELD_ADDR(this, kHeaderSize + offset); |
| 4745 } |
| 4746 } |
| 4747 return constant_pool; |
5130 } | 4748 } |
5131 | 4749 |
5132 | 4750 |
5133 void Code::set_constant_pool(Object* value) { | |
5134 DCHECK(value->IsConstantPoolArray()); | |
5135 WRITE_FIELD(this, kConstantPoolOffset, value); | |
5136 WRITE_BARRIER(GetHeap(), this, kConstantPoolOffset, value); | |
5137 } | |
5138 | |
5139 | |
5140 Code::Flags Code::ComputeFlags(Kind kind, InlineCacheState ic_state, | 4751 Code::Flags Code::ComputeFlags(Kind kind, InlineCacheState ic_state, |
5141 ExtraICState extra_ic_state, StubType type, | 4752 ExtraICState extra_ic_state, StubType type, |
5142 CacheHolderFlag holder) { | 4753 CacheHolderFlag holder) { |
5143 // Compute the bit mask. | 4754 // Compute the bit mask. |
5144 unsigned int bits = KindField::encode(kind) | 4755 unsigned int bits = KindField::encode(kind) |
5145 | ICStateField::encode(ic_state) | 4756 | ICStateField::encode(ic_state) |
5146 | TypeField::encode(type) | 4757 | TypeField::encode(type) |
5147 | ExtraICStateField::encode(extra_ic_state) | 4758 | ExtraICStateField::encode(extra_ic_state) |
5148 | CacheHolderField::encode(holder); | 4759 | CacheHolderField::encode(holder); |
5149 return static_cast<Flags>(bits); | 4760 return static_cast<Flags>(bits); |
(...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6308 ACCESSORS(JSMessageObject, type, String, kTypeOffset) | 5919 ACCESSORS(JSMessageObject, type, String, kTypeOffset) |
6309 ACCESSORS(JSMessageObject, arguments, JSArray, kArgumentsOffset) | 5920 ACCESSORS(JSMessageObject, arguments, JSArray, kArgumentsOffset) |
6310 ACCESSORS(JSMessageObject, script, Object, kScriptOffset) | 5921 ACCESSORS(JSMessageObject, script, Object, kScriptOffset) |
6311 ACCESSORS(JSMessageObject, stack_frames, Object, kStackFramesOffset) | 5922 ACCESSORS(JSMessageObject, stack_frames, Object, kStackFramesOffset) |
6312 SMI_ACCESSORS(JSMessageObject, start_position, kStartPositionOffset) | 5923 SMI_ACCESSORS(JSMessageObject, start_position, kStartPositionOffset) |
6313 SMI_ACCESSORS(JSMessageObject, end_position, kEndPositionOffset) | 5924 SMI_ACCESSORS(JSMessageObject, end_position, kEndPositionOffset) |
6314 | 5925 |
6315 | 5926 |
6316 INT_ACCESSORS(Code, instruction_size, kInstructionSizeOffset) | 5927 INT_ACCESSORS(Code, instruction_size, kInstructionSizeOffset) |
6317 INT_ACCESSORS(Code, prologue_offset, kPrologueOffset) | 5928 INT_ACCESSORS(Code, prologue_offset, kPrologueOffset) |
| 5929 INT_ACCESSORS(Code, constant_pool_offset, kConstantPoolOffset) |
6318 ACCESSORS(Code, relocation_info, ByteArray, kRelocationInfoOffset) | 5930 ACCESSORS(Code, relocation_info, ByteArray, kRelocationInfoOffset) |
6319 ACCESSORS(Code, handler_table, FixedArray, kHandlerTableOffset) | 5931 ACCESSORS(Code, handler_table, FixedArray, kHandlerTableOffset) |
6320 ACCESSORS(Code, deoptimization_data, FixedArray, kDeoptimizationDataOffset) | 5932 ACCESSORS(Code, deoptimization_data, FixedArray, kDeoptimizationDataOffset) |
6321 ACCESSORS(Code, raw_type_feedback_info, Object, kTypeFeedbackInfoOffset) | 5933 ACCESSORS(Code, raw_type_feedback_info, Object, kTypeFeedbackInfoOffset) |
6322 ACCESSORS(Code, next_code_link, Object, kNextCodeLinkOffset) | 5934 ACCESSORS(Code, next_code_link, Object, kNextCodeLinkOffset) |
6323 | 5935 |
6324 | 5936 |
6325 void Code::WipeOutHeader() { | 5937 void Code::WipeOutHeader() { |
6326 WRITE_FIELD(this, kRelocationInfoOffset, NULL); | 5938 WRITE_FIELD(this, kRelocationInfoOffset, NULL); |
6327 WRITE_FIELD(this, kHandlerTableOffset, NULL); | 5939 WRITE_FIELD(this, kHandlerTableOffset, NULL); |
6328 WRITE_FIELD(this, kDeoptimizationDataOffset, NULL); | 5940 WRITE_FIELD(this, kDeoptimizationDataOffset, NULL); |
6329 WRITE_FIELD(this, kConstantPoolOffset, NULL); | |
6330 // Do not wipe out major/minor keys on a code stub or IC | 5941 // Do not wipe out major/minor keys on a code stub or IC |
6331 if (!READ_FIELD(this, kTypeFeedbackInfoOffset)->IsSmi()) { | 5942 if (!READ_FIELD(this, kTypeFeedbackInfoOffset)->IsSmi()) { |
6332 WRITE_FIELD(this, kTypeFeedbackInfoOffset, NULL); | 5943 WRITE_FIELD(this, kTypeFeedbackInfoOffset, NULL); |
6333 } | 5944 } |
6334 } | 5945 } |
6335 | 5946 |
6336 | 5947 |
6337 Object* Code::type_feedback_info() { | 5948 Object* Code::type_feedback_info() { |
6338 DCHECK(kind() == FUNCTION); | 5949 DCHECK(kind() == FUNCTION); |
6339 return raw_type_feedback_info(); | 5950 return raw_type_feedback_info(); |
(...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7599 #undef READ_SHORT_FIELD | 7210 #undef READ_SHORT_FIELD |
7600 #undef WRITE_SHORT_FIELD | 7211 #undef WRITE_SHORT_FIELD |
7601 #undef READ_BYTE_FIELD | 7212 #undef READ_BYTE_FIELD |
7602 #undef WRITE_BYTE_FIELD | 7213 #undef WRITE_BYTE_FIELD |
7603 #undef NOBARRIER_READ_BYTE_FIELD | 7214 #undef NOBARRIER_READ_BYTE_FIELD |
7604 #undef NOBARRIER_WRITE_BYTE_FIELD | 7215 #undef NOBARRIER_WRITE_BYTE_FIELD |
7605 | 7216 |
7606 } } // namespace v8::internal | 7217 } } // namespace v8::internal |
7607 | 7218 |
7608 #endif // V8_OBJECTS_INL_H_ | 7219 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |