| 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 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 TYPE_CHECKER(JSMap, JS_MAP_TYPE) | 712 TYPE_CHECKER(JSMap, JS_MAP_TYPE) |
| 713 TYPE_CHECKER(JSSetIterator, JS_SET_ITERATOR_TYPE) | 713 TYPE_CHECKER(JSSetIterator, JS_SET_ITERATOR_TYPE) |
| 714 TYPE_CHECKER(JSMapIterator, JS_MAP_ITERATOR_TYPE) | 714 TYPE_CHECKER(JSMapIterator, JS_MAP_ITERATOR_TYPE) |
| 715 TYPE_CHECKER(JSWeakMap, JS_WEAK_MAP_TYPE) | 715 TYPE_CHECKER(JSWeakMap, JS_WEAK_MAP_TYPE) |
| 716 TYPE_CHECKER(JSWeakSet, JS_WEAK_SET_TYPE) | 716 TYPE_CHECKER(JSWeakSet, JS_WEAK_SET_TYPE) |
| 717 TYPE_CHECKER(JSContextExtensionObject, JS_CONTEXT_EXTENSION_OBJECT_TYPE) | 717 TYPE_CHECKER(JSContextExtensionObject, JS_CONTEXT_EXTENSION_OBJECT_TYPE) |
| 718 TYPE_CHECKER(Map, MAP_TYPE) | 718 TYPE_CHECKER(Map, MAP_TYPE) |
| 719 TYPE_CHECKER(FixedArray, FIXED_ARRAY_TYPE) | 719 TYPE_CHECKER(FixedArray, FIXED_ARRAY_TYPE) |
| 720 TYPE_CHECKER(FixedDoubleArray, FIXED_DOUBLE_ARRAY_TYPE) | 720 TYPE_CHECKER(FixedDoubleArray, FIXED_DOUBLE_ARRAY_TYPE) |
| 721 TYPE_CHECKER(WeakFixedArray, FIXED_ARRAY_TYPE) | 721 TYPE_CHECKER(WeakFixedArray, FIXED_ARRAY_TYPE) |
| 722 TYPE_CHECKER(ConstantPoolArray, CONSTANT_POOL_ARRAY_TYPE) | |
| 723 | 722 |
| 724 | 723 |
| 725 bool Object::IsJSWeakCollection() const { | 724 bool Object::IsJSWeakCollection() const { |
| 726 return IsJSWeakMap() || IsJSWeakSet(); | 725 return IsJSWeakMap() || IsJSWeakSet(); |
| 727 } | 726 } |
| 728 | 727 |
| 729 | 728 |
| 730 bool Object::IsDescriptorArray() const { | 729 bool Object::IsDescriptorArray() const { |
| 731 return IsFixedArray(); | 730 return IsFixedArray(); |
| 732 } | 731 } |
| (...skipping 803 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 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2444 } | 2441 } |
| 2445 | 2442 |
| 2446 | 2443 |
| 2447 void ArrayList::Clear(int index, Object* undefined) { | 2444 void ArrayList::Clear(int index, Object* undefined) { |
| 2448 DCHECK(undefined->IsUndefined()); | 2445 DCHECK(undefined->IsUndefined()); |
| 2449 FixedArray::cast(this) | 2446 FixedArray::cast(this) |
| 2450 ->set(kFirstIndex + index, undefined, SKIP_WRITE_BARRIER); | 2447 ->set(kFirstIndex + index, undefined, SKIP_WRITE_BARRIER); |
| 2451 } | 2448 } |
| 2452 | 2449 |
| 2453 | 2450 |
| 2454 void ConstantPoolArray::NumberOfEntries::increment(Type type) { | |
| 2455 DCHECK(type < NUMBER_OF_TYPES); | |
| 2456 element_counts_[type]++; | |
| 2457 } | |
| 2458 | |
| 2459 | |
| 2460 int ConstantPoolArray::NumberOfEntries::equals( | |
| 2461 const ConstantPoolArray::NumberOfEntries& other) const { | |
| 2462 for (int i = 0; i < NUMBER_OF_TYPES; i++) { | |
| 2463 if (element_counts_[i] != other.element_counts_[i]) return false; | |
| 2464 } | |
| 2465 return true; | |
| 2466 } | |
| 2467 | |
| 2468 | |
| 2469 bool ConstantPoolArray::NumberOfEntries::is_empty() const { | |
| 2470 return total_count() == 0; | |
| 2471 } | |
| 2472 | |
| 2473 | |
| 2474 int ConstantPoolArray::NumberOfEntries::count_of(Type type) const { | |
| 2475 DCHECK(type < NUMBER_OF_TYPES); | |
| 2476 return element_counts_[type]; | |
| 2477 } | |
| 2478 | |
| 2479 | |
| 2480 int ConstantPoolArray::NumberOfEntries::base_of(Type type) const { | |
| 2481 int base = 0; | |
| 2482 DCHECK(type < NUMBER_OF_TYPES); | |
| 2483 for (int i = 0; i < type; i++) { | |
| 2484 base += element_counts_[i]; | |
| 2485 } | |
| 2486 return base; | |
| 2487 } | |
| 2488 | |
| 2489 | |
| 2490 int ConstantPoolArray::NumberOfEntries::total_count() const { | |
| 2491 int count = 0; | |
| 2492 for (int i = 0; i < NUMBER_OF_TYPES; i++) { | |
| 2493 count += element_counts_[i]; | |
| 2494 } | |
| 2495 return count; | |
| 2496 } | |
| 2497 | |
| 2498 | |
| 2499 int ConstantPoolArray::NumberOfEntries::are_in_range(int min, int max) const { | |
| 2500 for (int i = FIRST_TYPE; i < NUMBER_OF_TYPES; i++) { | |
| 2501 if (element_counts_[i] < min || element_counts_[i] > max) { | |
| 2502 return false; | |
| 2503 } | |
| 2504 } | |
| 2505 return true; | |
| 2506 } | |
| 2507 | |
| 2508 | |
| 2509 int ConstantPoolArray::Iterator::next_index() { | |
| 2510 DCHECK(!is_finished()); | |
| 2511 int ret = next_index_++; | |
| 2512 update_section(); | |
| 2513 return ret; | |
| 2514 } | |
| 2515 | |
| 2516 | |
| 2517 bool ConstantPoolArray::Iterator::is_finished() { | |
| 2518 return next_index_ > array_->last_index(type_, final_section_); | |
| 2519 } | |
| 2520 | |
| 2521 | |
| 2522 void ConstantPoolArray::Iterator::update_section() { | |
| 2523 if (next_index_ > array_->last_index(type_, current_section_) && | |
| 2524 current_section_ != final_section_) { | |
| 2525 DCHECK(final_section_ == EXTENDED_SECTION); | |
| 2526 current_section_ = EXTENDED_SECTION; | |
| 2527 next_index_ = array_->first_index(type_, EXTENDED_SECTION); | |
| 2528 } | |
| 2529 } | |
| 2530 | |
| 2531 | |
| 2532 bool ConstantPoolArray::is_extended_layout() { | |
| 2533 uint32_t small_layout_1 = READ_UINT32_FIELD(this, kSmallLayout1Offset); | |
| 2534 return IsExtendedField::decode(small_layout_1); | |
| 2535 } | |
| 2536 | |
| 2537 | |
| 2538 ConstantPoolArray::LayoutSection ConstantPoolArray::final_section() { | |
| 2539 return is_extended_layout() ? EXTENDED_SECTION : SMALL_SECTION; | |
| 2540 } | |
| 2541 | |
| 2542 | |
| 2543 int ConstantPoolArray::first_extended_section_index() { | |
| 2544 DCHECK(is_extended_layout()); | |
| 2545 uint32_t small_layout_2 = READ_UINT32_FIELD(this, kSmallLayout2Offset); | |
| 2546 return TotalCountField::decode(small_layout_2); | |
| 2547 } | |
| 2548 | |
| 2549 | |
| 2550 int ConstantPoolArray::get_extended_section_header_offset() { | |
| 2551 return RoundUp(SizeFor(NumberOfEntries(this, SMALL_SECTION)), kInt64Size); | |
| 2552 } | |
| 2553 | |
| 2554 | |
| 2555 ConstantPoolArray::WeakObjectState ConstantPoolArray::get_weak_object_state() { | |
| 2556 uint32_t small_layout_2 = READ_UINT32_FIELD(this, kSmallLayout2Offset); | |
| 2557 return WeakObjectStateField::decode(small_layout_2); | |
| 2558 } | |
| 2559 | |
| 2560 | |
| 2561 void ConstantPoolArray::set_weak_object_state( | |
| 2562 ConstantPoolArray::WeakObjectState state) { | |
| 2563 uint32_t small_layout_2 = READ_UINT32_FIELD(this, kSmallLayout2Offset); | |
| 2564 small_layout_2 = WeakObjectStateField::update(small_layout_2, state); | |
| 2565 WRITE_INT32_FIELD(this, kSmallLayout2Offset, small_layout_2); | |
| 2566 } | |
| 2567 | |
| 2568 | |
| 2569 int ConstantPoolArray::first_index(Type type, LayoutSection section) { | |
| 2570 int index = 0; | |
| 2571 if (section == EXTENDED_SECTION) { | |
| 2572 DCHECK(is_extended_layout()); | |
| 2573 index += first_extended_section_index(); | |
| 2574 } | |
| 2575 | |
| 2576 for (Type type_iter = FIRST_TYPE; type_iter < type; | |
| 2577 type_iter = next_type(type_iter)) { | |
| 2578 index += number_of_entries(type_iter, section); | |
| 2579 } | |
| 2580 | |
| 2581 return index; | |
| 2582 } | |
| 2583 | |
| 2584 | |
| 2585 int ConstantPoolArray::last_index(Type type, LayoutSection section) { | |
| 2586 return first_index(type, section) + number_of_entries(type, section) - 1; | |
| 2587 } | |
| 2588 | |
| 2589 | |
| 2590 int ConstantPoolArray::number_of_entries(Type type, LayoutSection section) { | |
| 2591 if (section == SMALL_SECTION) { | |
| 2592 uint32_t small_layout_1 = READ_UINT32_FIELD(this, kSmallLayout1Offset); | |
| 2593 uint32_t small_layout_2 = READ_UINT32_FIELD(this, kSmallLayout2Offset); | |
| 2594 switch (type) { | |
| 2595 case INT64: | |
| 2596 return Int64CountField::decode(small_layout_1); | |
| 2597 case CODE_PTR: | |
| 2598 return CodePtrCountField::decode(small_layout_1); | |
| 2599 case HEAP_PTR: | |
| 2600 return HeapPtrCountField::decode(small_layout_1); | |
| 2601 case INT32: | |
| 2602 return Int32CountField::decode(small_layout_2); | |
| 2603 default: | |
| 2604 UNREACHABLE(); | |
| 2605 return 0; | |
| 2606 } | |
| 2607 } else { | |
| 2608 DCHECK(section == EXTENDED_SECTION && is_extended_layout()); | |
| 2609 int offset = get_extended_section_header_offset(); | |
| 2610 switch (type) { | |
| 2611 case INT64: | |
| 2612 offset += kExtendedInt64CountOffset; | |
| 2613 break; | |
| 2614 case CODE_PTR: | |
| 2615 offset += kExtendedCodePtrCountOffset; | |
| 2616 break; | |
| 2617 case HEAP_PTR: | |
| 2618 offset += kExtendedHeapPtrCountOffset; | |
| 2619 break; | |
| 2620 case INT32: | |
| 2621 offset += kExtendedInt32CountOffset; | |
| 2622 break; | |
| 2623 default: | |
| 2624 UNREACHABLE(); | |
| 2625 } | |
| 2626 return READ_INT_FIELD(this, offset); | |
| 2627 } | |
| 2628 } | |
| 2629 | |
| 2630 | |
| 2631 bool ConstantPoolArray::offset_is_type(int offset, Type type) { | |
| 2632 return (offset >= OffsetOfElementAt(first_index(type, SMALL_SECTION)) && | |
| 2633 offset <= OffsetOfElementAt(last_index(type, SMALL_SECTION))) || | |
| 2634 (is_extended_layout() && | |
| 2635 offset >= OffsetOfElementAt(first_index(type, EXTENDED_SECTION)) && | |
| 2636 offset <= OffsetOfElementAt(last_index(type, EXTENDED_SECTION))); | |
| 2637 } | |
| 2638 | |
| 2639 | |
| 2640 ConstantPoolArray::Type ConstantPoolArray::get_type(int index) { | |
| 2641 LayoutSection section; | |
| 2642 if (is_extended_layout() && index >= first_extended_section_index()) { | |
| 2643 section = EXTENDED_SECTION; | |
| 2644 } else { | |
| 2645 section = SMALL_SECTION; | |
| 2646 } | |
| 2647 | |
| 2648 Type type = FIRST_TYPE; | |
| 2649 while (index > last_index(type, section)) { | |
| 2650 type = next_type(type); | |
| 2651 } | |
| 2652 DCHECK(type <= LAST_TYPE); | |
| 2653 return type; | |
| 2654 } | |
| 2655 | |
| 2656 | |
| 2657 int64_t ConstantPoolArray::get_int64_entry(int index) { | |
| 2658 DCHECK(map() == GetHeap()->constant_pool_array_map()); | |
| 2659 DCHECK(get_type(index) == INT64); | |
| 2660 return READ_INT64_FIELD(this, OffsetOfElementAt(index)); | |
| 2661 } | |
| 2662 | |
| 2663 | |
| 2664 double ConstantPoolArray::get_int64_entry_as_double(int index) { | |
| 2665 STATIC_ASSERT(kDoubleSize == kInt64Size); | |
| 2666 DCHECK(map() == GetHeap()->constant_pool_array_map()); | |
| 2667 DCHECK(get_type(index) == INT64); | |
| 2668 return READ_DOUBLE_FIELD(this, OffsetOfElementAt(index)); | |
| 2669 } | |
| 2670 | |
| 2671 | |
| 2672 Address ConstantPoolArray::get_code_ptr_entry(int index) { | |
| 2673 DCHECK(map() == GetHeap()->constant_pool_array_map()); | |
| 2674 DCHECK(get_type(index) == CODE_PTR); | |
| 2675 return reinterpret_cast<Address>(READ_FIELD(this, OffsetOfElementAt(index))); | |
| 2676 } | |
| 2677 | |
| 2678 | |
| 2679 Object* ConstantPoolArray::get_heap_ptr_entry(int index) { | |
| 2680 DCHECK(map() == GetHeap()->constant_pool_array_map()); | |
| 2681 DCHECK(get_type(index) == HEAP_PTR); | |
| 2682 return READ_FIELD(this, OffsetOfElementAt(index)); | |
| 2683 } | |
| 2684 | |
| 2685 | |
| 2686 int32_t ConstantPoolArray::get_int32_entry(int index) { | |
| 2687 DCHECK(map() == GetHeap()->constant_pool_array_map()); | |
| 2688 DCHECK(get_type(index) == INT32); | |
| 2689 return READ_INT32_FIELD(this, OffsetOfElementAt(index)); | |
| 2690 } | |
| 2691 | |
| 2692 | |
| 2693 void ConstantPoolArray::set(int index, int64_t value) { | |
| 2694 DCHECK(map() == GetHeap()->constant_pool_array_map()); | |
| 2695 DCHECK(get_type(index) == INT64); | |
| 2696 WRITE_INT64_FIELD(this, OffsetOfElementAt(index), value); | |
| 2697 } | |
| 2698 | |
| 2699 | |
| 2700 void ConstantPoolArray::set(int index, double value) { | |
| 2701 STATIC_ASSERT(kDoubleSize == kInt64Size); | |
| 2702 DCHECK(map() == GetHeap()->constant_pool_array_map()); | |
| 2703 DCHECK(get_type(index) == INT64); | |
| 2704 WRITE_DOUBLE_FIELD(this, OffsetOfElementAt(index), value); | |
| 2705 } | |
| 2706 | |
| 2707 | |
| 2708 void ConstantPoolArray::set(int index, Address value) { | |
| 2709 DCHECK(map() == GetHeap()->constant_pool_array_map()); | |
| 2710 DCHECK(get_type(index) == CODE_PTR); | |
| 2711 WRITE_FIELD(this, OffsetOfElementAt(index), reinterpret_cast<Object*>(value)); | |
| 2712 } | |
| 2713 | |
| 2714 | |
| 2715 void ConstantPoolArray::set(int index, Object* value) { | |
| 2716 DCHECK(map() == GetHeap()->constant_pool_array_map()); | |
| 2717 DCHECK(!GetHeap()->InNewSpace(value)); | |
| 2718 DCHECK(get_type(index) == HEAP_PTR); | |
| 2719 WRITE_FIELD(this, OffsetOfElementAt(index), value); | |
| 2720 WRITE_BARRIER(GetHeap(), this, OffsetOfElementAt(index), value); | |
| 2721 } | |
| 2722 | |
| 2723 | |
| 2724 void ConstantPoolArray::set(int index, int32_t value) { | |
| 2725 DCHECK(map() == GetHeap()->constant_pool_array_map()); | |
| 2726 DCHECK(get_type(index) == INT32); | |
| 2727 WRITE_INT32_FIELD(this, OffsetOfElementAt(index), value); | |
| 2728 } | |
| 2729 | |
| 2730 | |
| 2731 void ConstantPoolArray::set_at_offset(int offset, int32_t value) { | |
| 2732 DCHECK(map() == GetHeap()->constant_pool_array_map()); | |
| 2733 DCHECK(offset_is_type(offset, INT32)); | |
| 2734 WRITE_INT32_FIELD(this, offset, value); | |
| 2735 } | |
| 2736 | |
| 2737 | |
| 2738 void ConstantPoolArray::set_at_offset(int offset, int64_t value) { | |
| 2739 DCHECK(map() == GetHeap()->constant_pool_array_map()); | |
| 2740 DCHECK(offset_is_type(offset, INT64)); | |
| 2741 WRITE_INT64_FIELD(this, offset, value); | |
| 2742 } | |
| 2743 | |
| 2744 | |
| 2745 void ConstantPoolArray::set_at_offset(int offset, double value) { | |
| 2746 DCHECK(map() == GetHeap()->constant_pool_array_map()); | |
| 2747 DCHECK(offset_is_type(offset, INT64)); | |
| 2748 WRITE_DOUBLE_FIELD(this, offset, value); | |
| 2749 } | |
| 2750 | |
| 2751 | |
| 2752 void ConstantPoolArray::set_at_offset(int offset, Address value) { | |
| 2753 DCHECK(map() == GetHeap()->constant_pool_array_map()); | |
| 2754 DCHECK(offset_is_type(offset, CODE_PTR)); | |
| 2755 WRITE_FIELD(this, offset, reinterpret_cast<Object*>(value)); | |
| 2756 WRITE_BARRIER(GetHeap(), this, offset, reinterpret_cast<Object*>(value)); | |
| 2757 } | |
| 2758 | |
| 2759 | |
| 2760 void ConstantPoolArray::set_at_offset(int offset, Object* value) { | |
| 2761 DCHECK(map() == GetHeap()->constant_pool_array_map()); | |
| 2762 DCHECK(!GetHeap()->InNewSpace(value)); | |
| 2763 DCHECK(offset_is_type(offset, HEAP_PTR)); | |
| 2764 WRITE_FIELD(this, offset, value); | |
| 2765 WRITE_BARRIER(GetHeap(), this, offset, value); | |
| 2766 } | |
| 2767 | |
| 2768 | |
| 2769 void ConstantPoolArray::Init(const NumberOfEntries& small) { | |
| 2770 uint32_t small_layout_1 = | |
| 2771 Int64CountField::encode(small.count_of(INT64)) | | |
| 2772 CodePtrCountField::encode(small.count_of(CODE_PTR)) | | |
| 2773 HeapPtrCountField::encode(small.count_of(HEAP_PTR)) | | |
| 2774 IsExtendedField::encode(false); | |
| 2775 uint32_t small_layout_2 = | |
| 2776 Int32CountField::encode(small.count_of(INT32)) | | |
| 2777 TotalCountField::encode(small.total_count()) | | |
| 2778 WeakObjectStateField::encode(NO_WEAK_OBJECTS); | |
| 2779 WRITE_UINT32_FIELD(this, kSmallLayout1Offset, small_layout_1); | |
| 2780 WRITE_UINT32_FIELD(this, kSmallLayout2Offset, small_layout_2); | |
| 2781 if (kHeaderSize != kFirstEntryOffset) { | |
| 2782 DCHECK(kFirstEntryOffset - kHeaderSize == kInt32Size); | |
| 2783 WRITE_UINT32_FIELD(this, kHeaderSize, 0); // Zero out header padding. | |
| 2784 } | |
| 2785 } | |
| 2786 | |
| 2787 | |
| 2788 void ConstantPoolArray::InitExtended(const NumberOfEntries& small, | |
| 2789 const NumberOfEntries& extended) { | |
| 2790 // Initialize small layout fields first. | |
| 2791 Init(small); | |
| 2792 | |
| 2793 // Set is_extended_layout field. | |
| 2794 uint32_t small_layout_1 = READ_UINT32_FIELD(this, kSmallLayout1Offset); | |
| 2795 small_layout_1 = IsExtendedField::update(small_layout_1, true); | |
| 2796 WRITE_INT32_FIELD(this, kSmallLayout1Offset, small_layout_1); | |
| 2797 | |
| 2798 // Initialize the extended layout fields. | |
| 2799 int extended_header_offset = get_extended_section_header_offset(); | |
| 2800 WRITE_INT32_FIELD(this, extended_header_offset + kExtendedInt64CountOffset, | |
| 2801 extended.count_of(INT64)); | |
| 2802 WRITE_INT32_FIELD(this, extended_header_offset + kExtendedCodePtrCountOffset, | |
| 2803 extended.count_of(CODE_PTR)); | |
| 2804 WRITE_INT32_FIELD(this, extended_header_offset + kExtendedHeapPtrCountOffset, | |
| 2805 extended.count_of(HEAP_PTR)); | |
| 2806 WRITE_INT32_FIELD(this, extended_header_offset + kExtendedInt32CountOffset, | |
| 2807 extended.count_of(INT32)); | |
| 2808 } | |
| 2809 | |
| 2810 | |
| 2811 int ConstantPoolArray::size() { | |
| 2812 NumberOfEntries small(this, SMALL_SECTION); | |
| 2813 if (!is_extended_layout()) { | |
| 2814 return SizeFor(small); | |
| 2815 } else { | |
| 2816 NumberOfEntries extended(this, EXTENDED_SECTION); | |
| 2817 return SizeForExtended(small, extended); | |
| 2818 } | |
| 2819 } | |
| 2820 | |
| 2821 | |
| 2822 int ConstantPoolArray::length() { | |
| 2823 uint32_t small_layout_2 = READ_UINT32_FIELD(this, kSmallLayout2Offset); | |
| 2824 int length = TotalCountField::decode(small_layout_2); | |
| 2825 if (is_extended_layout()) { | |
| 2826 length += number_of_entries(INT64, EXTENDED_SECTION) + | |
| 2827 number_of_entries(CODE_PTR, EXTENDED_SECTION) + | |
| 2828 number_of_entries(HEAP_PTR, EXTENDED_SECTION) + | |
| 2829 number_of_entries(INT32, EXTENDED_SECTION); | |
| 2830 } | |
| 2831 return length; | |
| 2832 } | |
| 2833 | |
| 2834 | |
| 2835 WriteBarrierMode HeapObject::GetWriteBarrierMode( | 2451 WriteBarrierMode HeapObject::GetWriteBarrierMode( |
| 2836 const DisallowHeapAllocation& promise) { | 2452 const DisallowHeapAllocation& promise) { |
| 2837 Heap* heap = GetHeap(); | 2453 Heap* heap = GetHeap(); |
| 2838 if (heap->incremental_marking()->IsMarking()) return UPDATE_WRITE_BARRIER; | 2454 if (heap->incremental_marking()->IsMarking()) return UPDATE_WRITE_BARRIER; |
| 2839 if (heap->InNewSpace(this)) return SKIP_WRITE_BARRIER; | 2455 if (heap->InNewSpace(this)) return SKIP_WRITE_BARRIER; |
| 2840 return UPDATE_WRITE_BARRIER; | 2456 return UPDATE_WRITE_BARRIER; |
| 2841 } | 2457 } |
| 2842 | 2458 |
| 2843 | 2459 |
| 2844 AllocationAlignment HeapObject::RequiredAlignment() { | 2460 AllocationAlignment HeapObject::RequiredAlignment() { |
| 2845 #ifdef V8_HOST_ARCH_32_BIT | 2461 #ifdef V8_HOST_ARCH_32_BIT |
| 2846 if ((IsFixedFloat64Array() || IsFixedDoubleArray() || | 2462 if ((IsFixedFloat64Array() || IsFixedDoubleArray()) && |
| 2847 IsConstantPoolArray()) && | |
| 2848 FixedArrayBase::cast(this)->length() != 0) { | 2463 FixedArrayBase::cast(this)->length() != 0) { |
| 2849 return kDoubleAligned; | 2464 return kDoubleAligned; |
| 2850 } | 2465 } |
| 2851 if (IsHeapNumber()) return kDoubleUnaligned; | 2466 if (IsHeapNumber()) return kDoubleUnaligned; |
| 2852 if (IsFloat32x4()) return kSimd128Unaligned; | 2467 if (IsFloat32x4()) return kSimd128Unaligned; |
| 2853 #endif // V8_HOST_ARCH_32_BIT | 2468 #endif // V8_HOST_ARCH_32_BIT |
| 2854 return kWordAligned; | 2469 return kWordAligned; |
| 2855 } | 2470 } |
| 2856 | 2471 |
| 2857 | 2472 |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3362 | 2977 |
| 3363 | 2978 |
| 3364 CAST_ACCESSOR(AccessorInfo) | 2979 CAST_ACCESSOR(AccessorInfo) |
| 3365 CAST_ACCESSOR(ArrayList) | 2980 CAST_ACCESSOR(ArrayList) |
| 3366 CAST_ACCESSOR(ByteArray) | 2981 CAST_ACCESSOR(ByteArray) |
| 3367 CAST_ACCESSOR(Cell) | 2982 CAST_ACCESSOR(Cell) |
| 3368 CAST_ACCESSOR(Code) | 2983 CAST_ACCESSOR(Code) |
| 3369 CAST_ACCESSOR(CodeCacheHashTable) | 2984 CAST_ACCESSOR(CodeCacheHashTable) |
| 3370 CAST_ACCESSOR(CompilationCacheTable) | 2985 CAST_ACCESSOR(CompilationCacheTable) |
| 3371 CAST_ACCESSOR(ConsString) | 2986 CAST_ACCESSOR(ConsString) |
| 3372 CAST_ACCESSOR(ConstantPoolArray) | |
| 3373 CAST_ACCESSOR(DeoptimizationInputData) | 2987 CAST_ACCESSOR(DeoptimizationInputData) |
| 3374 CAST_ACCESSOR(DeoptimizationOutputData) | 2988 CAST_ACCESSOR(DeoptimizationOutputData) |
| 3375 CAST_ACCESSOR(DependentCode) | 2989 CAST_ACCESSOR(DependentCode) |
| 3376 CAST_ACCESSOR(DescriptorArray) | 2990 CAST_ACCESSOR(DescriptorArray) |
| 3377 CAST_ACCESSOR(ExternalArray) | 2991 CAST_ACCESSOR(ExternalArray) |
| 3378 CAST_ACCESSOR(ExternalOneByteString) | 2992 CAST_ACCESSOR(ExternalOneByteString) |
| 3379 CAST_ACCESSOR(ExternalFloat32Array) | 2993 CAST_ACCESSOR(ExternalFloat32Array) |
| 3380 CAST_ACCESSOR(ExternalFloat64Array) | 2994 CAST_ACCESSOR(ExternalFloat64Array) |
| 3381 CAST_ACCESSOR(ExternalInt16Array) | 2995 CAST_ACCESSOR(ExternalInt16Array) |
| 3382 CAST_ACCESSOR(ExternalInt32Array) | 2996 CAST_ACCESSOR(ExternalInt32Array) |
| (...skipping 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4553 instance_type == INTERNALIZED_STRING_TYPE) { | 4167 instance_type == INTERNALIZED_STRING_TYPE) { |
| 4554 // Strings may get concurrently truncated, hence we have to access its | 4168 // Strings may get concurrently truncated, hence we have to access its |
| 4555 // length synchronized. | 4169 // length synchronized. |
| 4556 return SeqTwoByteString::SizeFor( | 4170 return SeqTwoByteString::SizeFor( |
| 4557 reinterpret_cast<SeqTwoByteString*>(this)->synchronized_length()); | 4171 reinterpret_cast<SeqTwoByteString*>(this)->synchronized_length()); |
| 4558 } | 4172 } |
| 4559 if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) { | 4173 if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) { |
| 4560 return FixedDoubleArray::SizeFor( | 4174 return FixedDoubleArray::SizeFor( |
| 4561 reinterpret_cast<FixedDoubleArray*>(this)->length()); | 4175 reinterpret_cast<FixedDoubleArray*>(this)->length()); |
| 4562 } | 4176 } |
| 4563 if (instance_type == CONSTANT_POOL_ARRAY_TYPE) { | |
| 4564 return reinterpret_cast<ConstantPoolArray*>(this)->size(); | |
| 4565 } | |
| 4566 if (instance_type >= FIRST_FIXED_TYPED_ARRAY_TYPE && | 4177 if (instance_type >= FIRST_FIXED_TYPED_ARRAY_TYPE && |
| 4567 instance_type <= LAST_FIXED_TYPED_ARRAY_TYPE) { | 4178 instance_type <= LAST_FIXED_TYPED_ARRAY_TYPE) { |
| 4568 return reinterpret_cast<FixedTypedArrayBase*>( | 4179 return reinterpret_cast<FixedTypedArrayBase*>( |
| 4569 this)->TypedArraySize(instance_type); | 4180 this)->TypedArraySize(instance_type); |
| 4570 } | 4181 } |
| 4571 DCHECK(instance_type == CODE_TYPE); | 4182 DCHECK(instance_type == CODE_TYPE); |
| 4572 return reinterpret_cast<Code*>(this)->CodeSize(); | 4183 return reinterpret_cast<Code*>(this)->CodeSize(); |
| 4573 } | 4184 } |
| 4574 | 4185 |
| 4575 | 4186 |
| (...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5158 bool Code::is_keyed_stub() { | 4769 bool Code::is_keyed_stub() { |
| 5159 return is_keyed_load_stub() || is_keyed_store_stub(); | 4770 return is_keyed_load_stub() || is_keyed_store_stub(); |
| 5160 } | 4771 } |
| 5161 | 4772 |
| 5162 | 4773 |
| 5163 bool Code::is_debug_stub() { | 4774 bool Code::is_debug_stub() { |
| 5164 return ic_state() == DEBUG_STUB; | 4775 return ic_state() == DEBUG_STUB; |
| 5165 } | 4776 } |
| 5166 | 4777 |
| 5167 | 4778 |
| 5168 ConstantPoolArray* Code::constant_pool() { | 4779 Address Code::constant_pool() { |
| 5169 return ConstantPoolArray::cast(READ_FIELD(this, kConstantPoolOffset)); | 4780 Address constant_pool = NULL; |
| 4781 if (FLAG_enable_embedded_constant_pool) { |
| 4782 int offset = constant_pool_offset(); |
| 4783 if (offset < instruction_size()) { |
| 4784 constant_pool = FIELD_ADDR(this, kHeaderSize + offset); |
| 4785 } |
| 4786 } |
| 4787 return constant_pool; |
| 5170 } | 4788 } |
| 5171 | 4789 |
| 5172 | 4790 |
| 5173 void Code::set_constant_pool(Object* value) { | |
| 5174 DCHECK(value->IsConstantPoolArray()); | |
| 5175 WRITE_FIELD(this, kConstantPoolOffset, value); | |
| 5176 WRITE_BARRIER(GetHeap(), this, kConstantPoolOffset, value); | |
| 5177 } | |
| 5178 | |
| 5179 | |
| 5180 Code::Flags Code::ComputeFlags(Kind kind, InlineCacheState ic_state, | 4791 Code::Flags Code::ComputeFlags(Kind kind, InlineCacheState ic_state, |
| 5181 ExtraICState extra_ic_state, StubType type, | 4792 ExtraICState extra_ic_state, StubType type, |
| 5182 CacheHolderFlag holder) { | 4793 CacheHolderFlag holder) { |
| 5183 // Compute the bit mask. | 4794 // Compute the bit mask. |
| 5184 unsigned int bits = KindField::encode(kind) | 4795 unsigned int bits = KindField::encode(kind) |
| 5185 | ICStateField::encode(ic_state) | 4796 | ICStateField::encode(ic_state) |
| 5186 | TypeField::encode(type) | 4797 | TypeField::encode(type) |
| 5187 | ExtraICStateField::encode(extra_ic_state) | 4798 | ExtraICStateField::encode(extra_ic_state) |
| 5188 | CacheHolderField::encode(holder); | 4799 | CacheHolderField::encode(holder); |
| 5189 return static_cast<Flags>(bits); | 4800 return static_cast<Flags>(bits); |
| (...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6344 SMI_ACCESSORS(JSMessageObject, type, kTypeOffset) | 5955 SMI_ACCESSORS(JSMessageObject, type, kTypeOffset) |
| 6345 ACCESSORS(JSMessageObject, argument, Object, kArgumentsOffset) | 5956 ACCESSORS(JSMessageObject, argument, Object, kArgumentsOffset) |
| 6346 ACCESSORS(JSMessageObject, script, Object, kScriptOffset) | 5957 ACCESSORS(JSMessageObject, script, Object, kScriptOffset) |
| 6347 ACCESSORS(JSMessageObject, stack_frames, Object, kStackFramesOffset) | 5958 ACCESSORS(JSMessageObject, stack_frames, Object, kStackFramesOffset) |
| 6348 SMI_ACCESSORS(JSMessageObject, start_position, kStartPositionOffset) | 5959 SMI_ACCESSORS(JSMessageObject, start_position, kStartPositionOffset) |
| 6349 SMI_ACCESSORS(JSMessageObject, end_position, kEndPositionOffset) | 5960 SMI_ACCESSORS(JSMessageObject, end_position, kEndPositionOffset) |
| 6350 | 5961 |
| 6351 | 5962 |
| 6352 INT_ACCESSORS(Code, instruction_size, kInstructionSizeOffset) | 5963 INT_ACCESSORS(Code, instruction_size, kInstructionSizeOffset) |
| 6353 INT_ACCESSORS(Code, prologue_offset, kPrologueOffset) | 5964 INT_ACCESSORS(Code, prologue_offset, kPrologueOffset) |
| 5965 INT_ACCESSORS(Code, constant_pool_offset, kConstantPoolOffset) |
| 6354 ACCESSORS(Code, relocation_info, ByteArray, kRelocationInfoOffset) | 5966 ACCESSORS(Code, relocation_info, ByteArray, kRelocationInfoOffset) |
| 6355 ACCESSORS(Code, handler_table, FixedArray, kHandlerTableOffset) | 5967 ACCESSORS(Code, handler_table, FixedArray, kHandlerTableOffset) |
| 6356 ACCESSORS(Code, deoptimization_data, FixedArray, kDeoptimizationDataOffset) | 5968 ACCESSORS(Code, deoptimization_data, FixedArray, kDeoptimizationDataOffset) |
| 6357 ACCESSORS(Code, raw_type_feedback_info, Object, kTypeFeedbackInfoOffset) | 5969 ACCESSORS(Code, raw_type_feedback_info, Object, kTypeFeedbackInfoOffset) |
| 6358 ACCESSORS(Code, next_code_link, Object, kNextCodeLinkOffset) | 5970 ACCESSORS(Code, next_code_link, Object, kNextCodeLinkOffset) |
| 6359 | 5971 |
| 6360 | 5972 |
| 6361 void Code::WipeOutHeader() { | 5973 void Code::WipeOutHeader() { |
| 6362 WRITE_FIELD(this, kRelocationInfoOffset, NULL); | 5974 WRITE_FIELD(this, kRelocationInfoOffset, NULL); |
| 6363 WRITE_FIELD(this, kHandlerTableOffset, NULL); | 5975 WRITE_FIELD(this, kHandlerTableOffset, NULL); |
| 6364 WRITE_FIELD(this, kDeoptimizationDataOffset, NULL); | 5976 WRITE_FIELD(this, kDeoptimizationDataOffset, NULL); |
| 6365 WRITE_FIELD(this, kConstantPoolOffset, NULL); | |
| 6366 // Do not wipe out major/minor keys on a code stub or IC | 5977 // Do not wipe out major/minor keys on a code stub or IC |
| 6367 if (!READ_FIELD(this, kTypeFeedbackInfoOffset)->IsSmi()) { | 5978 if (!READ_FIELD(this, kTypeFeedbackInfoOffset)->IsSmi()) { |
| 6368 WRITE_FIELD(this, kTypeFeedbackInfoOffset, NULL); | 5979 WRITE_FIELD(this, kTypeFeedbackInfoOffset, NULL); |
| 6369 } | 5980 } |
| 6370 } | 5981 } |
| 6371 | 5982 |
| 6372 | 5983 |
| 6373 Object* Code::type_feedback_info() { | 5984 Object* Code::type_feedback_info() { |
| 6374 DCHECK(kind() == FUNCTION); | 5985 DCHECK(kind() == FUNCTION); |
| 6375 return raw_type_feedback_info(); | 5986 return raw_type_feedback_info(); |
| (...skipping 1372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7748 #undef READ_SHORT_FIELD | 7359 #undef READ_SHORT_FIELD |
| 7749 #undef WRITE_SHORT_FIELD | 7360 #undef WRITE_SHORT_FIELD |
| 7750 #undef READ_BYTE_FIELD | 7361 #undef READ_BYTE_FIELD |
| 7751 #undef WRITE_BYTE_FIELD | 7362 #undef WRITE_BYTE_FIELD |
| 7752 #undef NOBARRIER_READ_BYTE_FIELD | 7363 #undef NOBARRIER_READ_BYTE_FIELD |
| 7753 #undef NOBARRIER_WRITE_BYTE_FIELD | 7364 #undef NOBARRIER_WRITE_BYTE_FIELD |
| 7754 | 7365 |
| 7755 } } // namespace v8::internal | 7366 } } // namespace v8::internal |
| 7756 | 7367 |
| 7757 #endif // V8_OBJECTS_INL_H_ | 7368 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |