| 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() || IsFixedTypedArrayBase() || | 145   return IsFixedArray() || IsFixedDoubleArray() || IsConstantPoolArray() || | 
| 146          IsExternalArray(); | 146          IsFixedTypedArrayBase() || 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 554 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 711 TYPE_CHECKER(JSMap, JS_MAP_TYPE) | 711 TYPE_CHECKER(JSMap, JS_MAP_TYPE) | 
| 712 TYPE_CHECKER(JSSetIterator, JS_SET_ITERATOR_TYPE) | 712 TYPE_CHECKER(JSSetIterator, JS_SET_ITERATOR_TYPE) | 
| 713 TYPE_CHECKER(JSMapIterator, JS_MAP_ITERATOR_TYPE) | 713 TYPE_CHECKER(JSMapIterator, JS_MAP_ITERATOR_TYPE) | 
| 714 TYPE_CHECKER(JSWeakMap, JS_WEAK_MAP_TYPE) | 714 TYPE_CHECKER(JSWeakMap, JS_WEAK_MAP_TYPE) | 
| 715 TYPE_CHECKER(JSWeakSet, JS_WEAK_SET_TYPE) | 715 TYPE_CHECKER(JSWeakSet, JS_WEAK_SET_TYPE) | 
| 716 TYPE_CHECKER(JSContextExtensionObject, JS_CONTEXT_EXTENSION_OBJECT_TYPE) | 716 TYPE_CHECKER(JSContextExtensionObject, JS_CONTEXT_EXTENSION_OBJECT_TYPE) | 
| 717 TYPE_CHECKER(Map, MAP_TYPE) | 717 TYPE_CHECKER(Map, MAP_TYPE) | 
| 718 TYPE_CHECKER(FixedArray, FIXED_ARRAY_TYPE) | 718 TYPE_CHECKER(FixedArray, FIXED_ARRAY_TYPE) | 
| 719 TYPE_CHECKER(FixedDoubleArray, FIXED_DOUBLE_ARRAY_TYPE) | 719 TYPE_CHECKER(FixedDoubleArray, FIXED_DOUBLE_ARRAY_TYPE) | 
| 720 TYPE_CHECKER(WeakFixedArray, FIXED_ARRAY_TYPE) | 720 TYPE_CHECKER(WeakFixedArray, FIXED_ARRAY_TYPE) | 
|  | 721 TYPE_CHECKER(ConstantPoolArray, CONSTANT_POOL_ARRAY_TYPE) | 
| 721 | 722 | 
| 722 | 723 | 
| 723 bool Object::IsJSWeakCollection() const { | 724 bool Object::IsJSWeakCollection() const { | 
| 724   return IsJSWeakMap() || IsJSWeakSet(); | 725   return IsJSWeakMap() || IsJSWeakSet(); | 
| 725 } | 726 } | 
| 726 | 727 | 
| 727 | 728 | 
| 728 bool Object::IsDescriptorArray() const { | 729 bool Object::IsDescriptorArray() const { | 
| 729   return IsFixedArray(); | 730   return IsFixedArray(); | 
| 730 } | 731 } | 
| (...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1528     if (type == SYMBOL_TYPE) { | 1529     if (type == SYMBOL_TYPE) { | 
| 1529       return false; | 1530       return false; | 
| 1530     } | 1531     } | 
| 1531     DCHECK(type < FIRST_NONSTRING_TYPE); | 1532     DCHECK(type < FIRST_NONSTRING_TYPE); | 
| 1532     // There are four string representations: sequential strings, external | 1533     // There are four string representations: sequential strings, external | 
| 1533     // strings, cons strings, and sliced strings. | 1534     // strings, cons strings, and sliced strings. | 
| 1534     // Only the former two contain raw values and no heap pointers (besides the | 1535     // Only the former two contain raw values and no heap pointers (besides the | 
| 1535     // map-word). | 1536     // map-word). | 
| 1536     return ((type & kIsIndirectStringMask) != kIsIndirectStringTag); | 1537     return ((type & kIsIndirectStringMask) != kIsIndirectStringTag); | 
| 1537   } | 1538   } | 
|  | 1539   // The ConstantPoolArray contains heap pointers, but also raw values. | 
|  | 1540   if (type == CONSTANT_POOL_ARRAY_TYPE) return true; | 
| 1538   return (type <= LAST_DATA_TYPE); | 1541   return (type <= LAST_DATA_TYPE); | 
| 1539 } | 1542 } | 
| 1540 | 1543 | 
| 1541 | 1544 | 
| 1542 void HeapObject::IteratePointers(ObjectVisitor* v, int start, int end) { | 1545 void HeapObject::IteratePointers(ObjectVisitor* v, int start, int end) { | 
| 1543   v->VisitPointers(reinterpret_cast<Object**>(FIELD_ADDR(this, start)), | 1546   v->VisitPointers(reinterpret_cast<Object**>(FIELD_ADDR(this, start)), | 
| 1544                    reinterpret_cast<Object**>(FIELD_ADDR(this, end))); | 1547                    reinterpret_cast<Object**>(FIELD_ADDR(this, end))); | 
| 1545 } | 1548 } | 
| 1546 | 1549 | 
| 1547 | 1550 | 
| (...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2410 } | 2413 } | 
| 2411 | 2414 | 
| 2412 | 2415 | 
| 2413 void ArrayList::Clear(int index, Object* undefined) { | 2416 void ArrayList::Clear(int index, Object* undefined) { | 
| 2414   DCHECK(undefined->IsUndefined()); | 2417   DCHECK(undefined->IsUndefined()); | 
| 2415   FixedArray::cast(this) | 2418   FixedArray::cast(this) | 
| 2416       ->set(kFirstIndex + index, undefined, SKIP_WRITE_BARRIER); | 2419       ->set(kFirstIndex + index, undefined, SKIP_WRITE_BARRIER); | 
| 2417 } | 2420 } | 
| 2418 | 2421 | 
| 2419 | 2422 | 
|  | 2423 void ConstantPoolArray::NumberOfEntries::increment(Type type) { | 
|  | 2424   DCHECK(type < NUMBER_OF_TYPES); | 
|  | 2425   element_counts_[type]++; | 
|  | 2426 } | 
|  | 2427 | 
|  | 2428 | 
|  | 2429 int ConstantPoolArray::NumberOfEntries::equals( | 
|  | 2430     const ConstantPoolArray::NumberOfEntries& other) const { | 
|  | 2431   for (int i = 0; i < NUMBER_OF_TYPES; i++) { | 
|  | 2432     if (element_counts_[i] != other.element_counts_[i]) return false; | 
|  | 2433   } | 
|  | 2434   return true; | 
|  | 2435 } | 
|  | 2436 | 
|  | 2437 | 
|  | 2438 bool ConstantPoolArray::NumberOfEntries::is_empty() const { | 
|  | 2439   return total_count() == 0; | 
|  | 2440 } | 
|  | 2441 | 
|  | 2442 | 
|  | 2443 int ConstantPoolArray::NumberOfEntries::count_of(Type type) const { | 
|  | 2444   DCHECK(type < NUMBER_OF_TYPES); | 
|  | 2445   return element_counts_[type]; | 
|  | 2446 } | 
|  | 2447 | 
|  | 2448 | 
|  | 2449 int ConstantPoolArray::NumberOfEntries::base_of(Type type) const { | 
|  | 2450   int base = 0; | 
|  | 2451   DCHECK(type < NUMBER_OF_TYPES); | 
|  | 2452   for (int i = 0; i < type; i++) { | 
|  | 2453     base += element_counts_[i]; | 
|  | 2454   } | 
|  | 2455   return base; | 
|  | 2456 } | 
|  | 2457 | 
|  | 2458 | 
|  | 2459 int ConstantPoolArray::NumberOfEntries::total_count() const { | 
|  | 2460   int count = 0; | 
|  | 2461   for (int i = 0; i < NUMBER_OF_TYPES; i++) { | 
|  | 2462     count += element_counts_[i]; | 
|  | 2463   } | 
|  | 2464   return count; | 
|  | 2465 } | 
|  | 2466 | 
|  | 2467 | 
|  | 2468 int ConstantPoolArray::NumberOfEntries::are_in_range(int min, int max) const { | 
|  | 2469   for (int i = FIRST_TYPE; i < NUMBER_OF_TYPES; i++) { | 
|  | 2470     if (element_counts_[i] < min || element_counts_[i] > max) { | 
|  | 2471       return false; | 
|  | 2472     } | 
|  | 2473   } | 
|  | 2474   return true; | 
|  | 2475 } | 
|  | 2476 | 
|  | 2477 | 
|  | 2478 int ConstantPoolArray::Iterator::next_index() { | 
|  | 2479   DCHECK(!is_finished()); | 
|  | 2480   int ret = next_index_++; | 
|  | 2481   update_section(); | 
|  | 2482   return ret; | 
|  | 2483 } | 
|  | 2484 | 
|  | 2485 | 
|  | 2486 bool ConstantPoolArray::Iterator::is_finished() { | 
|  | 2487   return next_index_ > array_->last_index(type_, final_section_); | 
|  | 2488 } | 
|  | 2489 | 
|  | 2490 | 
|  | 2491 void ConstantPoolArray::Iterator::update_section() { | 
|  | 2492   if (next_index_ > array_->last_index(type_, current_section_) && | 
|  | 2493       current_section_ != final_section_) { | 
|  | 2494     DCHECK(final_section_ == EXTENDED_SECTION); | 
|  | 2495     current_section_ = EXTENDED_SECTION; | 
|  | 2496     next_index_ = array_->first_index(type_, EXTENDED_SECTION); | 
|  | 2497   } | 
|  | 2498 } | 
|  | 2499 | 
|  | 2500 | 
|  | 2501 bool ConstantPoolArray::is_extended_layout() { | 
|  | 2502   uint32_t small_layout_1 = READ_UINT32_FIELD(this, kSmallLayout1Offset); | 
|  | 2503   return IsExtendedField::decode(small_layout_1); | 
|  | 2504 } | 
|  | 2505 | 
|  | 2506 | 
|  | 2507 ConstantPoolArray::LayoutSection ConstantPoolArray::final_section() { | 
|  | 2508   return is_extended_layout() ? EXTENDED_SECTION : SMALL_SECTION; | 
|  | 2509 } | 
|  | 2510 | 
|  | 2511 | 
|  | 2512 int ConstantPoolArray::first_extended_section_index() { | 
|  | 2513   DCHECK(is_extended_layout()); | 
|  | 2514   uint32_t small_layout_2 = READ_UINT32_FIELD(this, kSmallLayout2Offset); | 
|  | 2515   return TotalCountField::decode(small_layout_2); | 
|  | 2516 } | 
|  | 2517 | 
|  | 2518 | 
|  | 2519 int ConstantPoolArray::get_extended_section_header_offset() { | 
|  | 2520   return RoundUp(SizeFor(NumberOfEntries(this, SMALL_SECTION)), kInt64Size); | 
|  | 2521 } | 
|  | 2522 | 
|  | 2523 | 
|  | 2524 ConstantPoolArray::WeakObjectState ConstantPoolArray::get_weak_object_state() { | 
|  | 2525   uint32_t small_layout_2 = READ_UINT32_FIELD(this, kSmallLayout2Offset); | 
|  | 2526   return WeakObjectStateField::decode(small_layout_2); | 
|  | 2527 } | 
|  | 2528 | 
|  | 2529 | 
|  | 2530 void ConstantPoolArray::set_weak_object_state( | 
|  | 2531       ConstantPoolArray::WeakObjectState state) { | 
|  | 2532   uint32_t small_layout_2 = READ_UINT32_FIELD(this, kSmallLayout2Offset); | 
|  | 2533   small_layout_2 = WeakObjectStateField::update(small_layout_2, state); | 
|  | 2534   WRITE_INT32_FIELD(this, kSmallLayout2Offset, small_layout_2); | 
|  | 2535 } | 
|  | 2536 | 
|  | 2537 | 
|  | 2538 int ConstantPoolArray::first_index(Type type, LayoutSection section) { | 
|  | 2539   int index = 0; | 
|  | 2540   if (section == EXTENDED_SECTION) { | 
|  | 2541     DCHECK(is_extended_layout()); | 
|  | 2542     index += first_extended_section_index(); | 
|  | 2543   } | 
|  | 2544 | 
|  | 2545   for (Type type_iter = FIRST_TYPE; type_iter < type; | 
|  | 2546        type_iter = next_type(type_iter)) { | 
|  | 2547     index += number_of_entries(type_iter, section); | 
|  | 2548   } | 
|  | 2549 | 
|  | 2550   return index; | 
|  | 2551 } | 
|  | 2552 | 
|  | 2553 | 
|  | 2554 int ConstantPoolArray::last_index(Type type, LayoutSection section) { | 
|  | 2555   return first_index(type, section) + number_of_entries(type, section) - 1; | 
|  | 2556 } | 
|  | 2557 | 
|  | 2558 | 
|  | 2559 int ConstantPoolArray::number_of_entries(Type type, LayoutSection section) { | 
|  | 2560   if (section == SMALL_SECTION) { | 
|  | 2561     uint32_t small_layout_1 = READ_UINT32_FIELD(this, kSmallLayout1Offset); | 
|  | 2562     uint32_t small_layout_2 = READ_UINT32_FIELD(this, kSmallLayout2Offset); | 
|  | 2563     switch (type) { | 
|  | 2564       case INT64: | 
|  | 2565         return Int64CountField::decode(small_layout_1); | 
|  | 2566       case CODE_PTR: | 
|  | 2567         return CodePtrCountField::decode(small_layout_1); | 
|  | 2568       case HEAP_PTR: | 
|  | 2569         return HeapPtrCountField::decode(small_layout_1); | 
|  | 2570       case INT32: | 
|  | 2571         return Int32CountField::decode(small_layout_2); | 
|  | 2572       default: | 
|  | 2573         UNREACHABLE(); | 
|  | 2574         return 0; | 
|  | 2575     } | 
|  | 2576   } else { | 
|  | 2577     DCHECK(section == EXTENDED_SECTION && is_extended_layout()); | 
|  | 2578     int offset = get_extended_section_header_offset(); | 
|  | 2579     switch (type) { | 
|  | 2580       case INT64: | 
|  | 2581         offset += kExtendedInt64CountOffset; | 
|  | 2582         break; | 
|  | 2583       case CODE_PTR: | 
|  | 2584         offset += kExtendedCodePtrCountOffset; | 
|  | 2585         break; | 
|  | 2586       case HEAP_PTR: | 
|  | 2587         offset += kExtendedHeapPtrCountOffset; | 
|  | 2588         break; | 
|  | 2589       case INT32: | 
|  | 2590         offset += kExtendedInt32CountOffset; | 
|  | 2591         break; | 
|  | 2592       default: | 
|  | 2593         UNREACHABLE(); | 
|  | 2594     } | 
|  | 2595     return READ_INT_FIELD(this, offset); | 
|  | 2596   } | 
|  | 2597 } | 
|  | 2598 | 
|  | 2599 | 
|  | 2600 bool ConstantPoolArray::offset_is_type(int offset, Type type) { | 
|  | 2601   return (offset >= OffsetOfElementAt(first_index(type, SMALL_SECTION)) && | 
|  | 2602           offset <= OffsetOfElementAt(last_index(type, SMALL_SECTION))) || | 
|  | 2603          (is_extended_layout() && | 
|  | 2604           offset >= OffsetOfElementAt(first_index(type, EXTENDED_SECTION)) && | 
|  | 2605           offset <= OffsetOfElementAt(last_index(type, EXTENDED_SECTION))); | 
|  | 2606 } | 
|  | 2607 | 
|  | 2608 | 
|  | 2609 ConstantPoolArray::Type ConstantPoolArray::get_type(int index) { | 
|  | 2610   LayoutSection section; | 
|  | 2611   if (is_extended_layout() && index >= first_extended_section_index()) { | 
|  | 2612     section = EXTENDED_SECTION; | 
|  | 2613   } else { | 
|  | 2614     section = SMALL_SECTION; | 
|  | 2615   } | 
|  | 2616 | 
|  | 2617   Type type = FIRST_TYPE; | 
|  | 2618   while (index > last_index(type, section)) { | 
|  | 2619     type = next_type(type); | 
|  | 2620   } | 
|  | 2621   DCHECK(type <= LAST_TYPE); | 
|  | 2622   return type; | 
|  | 2623 } | 
|  | 2624 | 
|  | 2625 | 
|  | 2626 int64_t ConstantPoolArray::get_int64_entry(int index) { | 
|  | 2627   DCHECK(map() == GetHeap()->constant_pool_array_map()); | 
|  | 2628   DCHECK(get_type(index) == INT64); | 
|  | 2629   return READ_INT64_FIELD(this, OffsetOfElementAt(index)); | 
|  | 2630 } | 
|  | 2631 | 
|  | 2632 | 
|  | 2633 double ConstantPoolArray::get_int64_entry_as_double(int index) { | 
|  | 2634   STATIC_ASSERT(kDoubleSize == kInt64Size); | 
|  | 2635   DCHECK(map() == GetHeap()->constant_pool_array_map()); | 
|  | 2636   DCHECK(get_type(index) == INT64); | 
|  | 2637   return READ_DOUBLE_FIELD(this, OffsetOfElementAt(index)); | 
|  | 2638 } | 
|  | 2639 | 
|  | 2640 | 
|  | 2641 Address ConstantPoolArray::get_code_ptr_entry(int index) { | 
|  | 2642   DCHECK(map() == GetHeap()->constant_pool_array_map()); | 
|  | 2643   DCHECK(get_type(index) == CODE_PTR); | 
|  | 2644   return reinterpret_cast<Address>(READ_FIELD(this, OffsetOfElementAt(index))); | 
|  | 2645 } | 
|  | 2646 | 
|  | 2647 | 
|  | 2648 Object* ConstantPoolArray::get_heap_ptr_entry(int index) { | 
|  | 2649   DCHECK(map() == GetHeap()->constant_pool_array_map()); | 
|  | 2650   DCHECK(get_type(index) == HEAP_PTR); | 
|  | 2651   return READ_FIELD(this, OffsetOfElementAt(index)); | 
|  | 2652 } | 
|  | 2653 | 
|  | 2654 | 
|  | 2655 int32_t ConstantPoolArray::get_int32_entry(int index) { | 
|  | 2656   DCHECK(map() == GetHeap()->constant_pool_array_map()); | 
|  | 2657   DCHECK(get_type(index) == INT32); | 
|  | 2658   return READ_INT32_FIELD(this, OffsetOfElementAt(index)); | 
|  | 2659 } | 
|  | 2660 | 
|  | 2661 | 
|  | 2662 void ConstantPoolArray::set(int index, int64_t value) { | 
|  | 2663   DCHECK(map() == GetHeap()->constant_pool_array_map()); | 
|  | 2664   DCHECK(get_type(index) == INT64); | 
|  | 2665   WRITE_INT64_FIELD(this, OffsetOfElementAt(index), value); | 
|  | 2666 } | 
|  | 2667 | 
|  | 2668 | 
|  | 2669 void ConstantPoolArray::set(int index, double value) { | 
|  | 2670   STATIC_ASSERT(kDoubleSize == kInt64Size); | 
|  | 2671   DCHECK(map() == GetHeap()->constant_pool_array_map()); | 
|  | 2672   DCHECK(get_type(index) == INT64); | 
|  | 2673   WRITE_DOUBLE_FIELD(this, OffsetOfElementAt(index), value); | 
|  | 2674 } | 
|  | 2675 | 
|  | 2676 | 
|  | 2677 void ConstantPoolArray::set(int index, Address value) { | 
|  | 2678   DCHECK(map() == GetHeap()->constant_pool_array_map()); | 
|  | 2679   DCHECK(get_type(index) == CODE_PTR); | 
|  | 2680   WRITE_FIELD(this, OffsetOfElementAt(index), reinterpret_cast<Object*>(value)); | 
|  | 2681 } | 
|  | 2682 | 
|  | 2683 | 
|  | 2684 void ConstantPoolArray::set(int index, Object* value) { | 
|  | 2685   DCHECK(map() == GetHeap()->constant_pool_array_map()); | 
|  | 2686   DCHECK(!GetHeap()->InNewSpace(value)); | 
|  | 2687   DCHECK(get_type(index) == HEAP_PTR); | 
|  | 2688   WRITE_FIELD(this, OffsetOfElementAt(index), value); | 
|  | 2689   WRITE_BARRIER(GetHeap(), this, OffsetOfElementAt(index), value); | 
|  | 2690 } | 
|  | 2691 | 
|  | 2692 | 
|  | 2693 void ConstantPoolArray::set(int index, int32_t value) { | 
|  | 2694   DCHECK(map() == GetHeap()->constant_pool_array_map()); | 
|  | 2695   DCHECK(get_type(index) == INT32); | 
|  | 2696   WRITE_INT32_FIELD(this, OffsetOfElementAt(index), value); | 
|  | 2697 } | 
|  | 2698 | 
|  | 2699 | 
|  | 2700 void ConstantPoolArray::set_at_offset(int offset, int32_t value) { | 
|  | 2701   DCHECK(map() == GetHeap()->constant_pool_array_map()); | 
|  | 2702   DCHECK(offset_is_type(offset, INT32)); | 
|  | 2703   WRITE_INT32_FIELD(this, offset, value); | 
|  | 2704 } | 
|  | 2705 | 
|  | 2706 | 
|  | 2707 void ConstantPoolArray::set_at_offset(int offset, int64_t value) { | 
|  | 2708   DCHECK(map() == GetHeap()->constant_pool_array_map()); | 
|  | 2709   DCHECK(offset_is_type(offset, INT64)); | 
|  | 2710   WRITE_INT64_FIELD(this, offset, value); | 
|  | 2711 } | 
|  | 2712 | 
|  | 2713 | 
|  | 2714 void ConstantPoolArray::set_at_offset(int offset, double value) { | 
|  | 2715   DCHECK(map() == GetHeap()->constant_pool_array_map()); | 
|  | 2716   DCHECK(offset_is_type(offset, INT64)); | 
|  | 2717   WRITE_DOUBLE_FIELD(this, offset, value); | 
|  | 2718 } | 
|  | 2719 | 
|  | 2720 | 
|  | 2721 void ConstantPoolArray::set_at_offset(int offset, Address value) { | 
|  | 2722   DCHECK(map() == GetHeap()->constant_pool_array_map()); | 
|  | 2723   DCHECK(offset_is_type(offset, CODE_PTR)); | 
|  | 2724   WRITE_FIELD(this, offset, reinterpret_cast<Object*>(value)); | 
|  | 2725   WRITE_BARRIER(GetHeap(), this, offset, reinterpret_cast<Object*>(value)); | 
|  | 2726 } | 
|  | 2727 | 
|  | 2728 | 
|  | 2729 void ConstantPoolArray::set_at_offset(int offset, Object* value) { | 
|  | 2730   DCHECK(map() == GetHeap()->constant_pool_array_map()); | 
|  | 2731   DCHECK(!GetHeap()->InNewSpace(value)); | 
|  | 2732   DCHECK(offset_is_type(offset, HEAP_PTR)); | 
|  | 2733   WRITE_FIELD(this, offset, value); | 
|  | 2734   WRITE_BARRIER(GetHeap(), this, offset, value); | 
|  | 2735 } | 
|  | 2736 | 
|  | 2737 | 
|  | 2738 void ConstantPoolArray::Init(const NumberOfEntries& small) { | 
|  | 2739   uint32_t small_layout_1 = | 
|  | 2740       Int64CountField::encode(small.count_of(INT64)) | | 
|  | 2741       CodePtrCountField::encode(small.count_of(CODE_PTR)) | | 
|  | 2742       HeapPtrCountField::encode(small.count_of(HEAP_PTR)) | | 
|  | 2743       IsExtendedField::encode(false); | 
|  | 2744   uint32_t small_layout_2 = | 
|  | 2745       Int32CountField::encode(small.count_of(INT32)) | | 
|  | 2746       TotalCountField::encode(small.total_count()) | | 
|  | 2747       WeakObjectStateField::encode(NO_WEAK_OBJECTS); | 
|  | 2748   WRITE_UINT32_FIELD(this, kSmallLayout1Offset, small_layout_1); | 
|  | 2749   WRITE_UINT32_FIELD(this, kSmallLayout2Offset, small_layout_2); | 
|  | 2750   if (kHeaderSize != kFirstEntryOffset) { | 
|  | 2751     DCHECK(kFirstEntryOffset - kHeaderSize == kInt32Size); | 
|  | 2752     WRITE_UINT32_FIELD(this, kHeaderSize, 0);  // Zero out header padding. | 
|  | 2753   } | 
|  | 2754 } | 
|  | 2755 | 
|  | 2756 | 
|  | 2757 void ConstantPoolArray::InitExtended(const NumberOfEntries& small, | 
|  | 2758                                      const NumberOfEntries& extended) { | 
|  | 2759   // Initialize small layout fields first. | 
|  | 2760   Init(small); | 
|  | 2761 | 
|  | 2762   // Set is_extended_layout field. | 
|  | 2763   uint32_t small_layout_1 = READ_UINT32_FIELD(this, kSmallLayout1Offset); | 
|  | 2764   small_layout_1 = IsExtendedField::update(small_layout_1, true); | 
|  | 2765   WRITE_INT32_FIELD(this, kSmallLayout1Offset, small_layout_1); | 
|  | 2766 | 
|  | 2767   // Initialize the extended layout fields. | 
|  | 2768   int extended_header_offset = get_extended_section_header_offset(); | 
|  | 2769   WRITE_INT32_FIELD(this, extended_header_offset + kExtendedInt64CountOffset, | 
|  | 2770                     extended.count_of(INT64)); | 
|  | 2771   WRITE_INT32_FIELD(this, extended_header_offset + kExtendedCodePtrCountOffset, | 
|  | 2772                     extended.count_of(CODE_PTR)); | 
|  | 2773   WRITE_INT32_FIELD(this, extended_header_offset + kExtendedHeapPtrCountOffset, | 
|  | 2774                     extended.count_of(HEAP_PTR)); | 
|  | 2775   WRITE_INT32_FIELD(this, extended_header_offset + kExtendedInt32CountOffset, | 
|  | 2776                     extended.count_of(INT32)); | 
|  | 2777 } | 
|  | 2778 | 
|  | 2779 | 
|  | 2780 int ConstantPoolArray::size() { | 
|  | 2781   NumberOfEntries small(this, SMALL_SECTION); | 
|  | 2782   if (!is_extended_layout()) { | 
|  | 2783     return SizeFor(small); | 
|  | 2784   } else { | 
|  | 2785     NumberOfEntries extended(this, EXTENDED_SECTION); | 
|  | 2786     return SizeForExtended(small, extended); | 
|  | 2787   } | 
|  | 2788 } | 
|  | 2789 | 
|  | 2790 | 
|  | 2791 int ConstantPoolArray::length() { | 
|  | 2792   uint32_t small_layout_2 = READ_UINT32_FIELD(this, kSmallLayout2Offset); | 
|  | 2793   int length = TotalCountField::decode(small_layout_2); | 
|  | 2794   if (is_extended_layout()) { | 
|  | 2795     length += number_of_entries(INT64, EXTENDED_SECTION) + | 
|  | 2796               number_of_entries(CODE_PTR, EXTENDED_SECTION) + | 
|  | 2797               number_of_entries(HEAP_PTR, EXTENDED_SECTION) + | 
|  | 2798               number_of_entries(INT32, EXTENDED_SECTION); | 
|  | 2799   } | 
|  | 2800   return length; | 
|  | 2801 } | 
|  | 2802 | 
|  | 2803 | 
| 2420 WriteBarrierMode HeapObject::GetWriteBarrierMode( | 2804 WriteBarrierMode HeapObject::GetWriteBarrierMode( | 
| 2421     const DisallowHeapAllocation& promise) { | 2805     const DisallowHeapAllocation& promise) { | 
| 2422   Heap* heap = GetHeap(); | 2806   Heap* heap = GetHeap(); | 
| 2423   if (heap->incremental_marking()->IsMarking()) return UPDATE_WRITE_BARRIER; | 2807   if (heap->incremental_marking()->IsMarking()) return UPDATE_WRITE_BARRIER; | 
| 2424   if (heap->InNewSpace(this)) return SKIP_WRITE_BARRIER; | 2808   if (heap->InNewSpace(this)) return SKIP_WRITE_BARRIER; | 
| 2425   return UPDATE_WRITE_BARRIER; | 2809   return UPDATE_WRITE_BARRIER; | 
| 2426 } | 2810 } | 
| 2427 | 2811 | 
| 2428 | 2812 | 
| 2429 AllocationAlignment HeapObject::RequiredAlignment() { | 2813 AllocationAlignment HeapObject::RequiredAlignment() { | 
| 2430 #ifdef V8_HOST_ARCH_32_BIT | 2814 #ifdef V8_HOST_ARCH_32_BIT | 
| 2431   if ((IsFixedFloat64Array() || IsFixedDoubleArray()) && | 2815   if ((IsFixedFloat64Array() || IsFixedDoubleArray() || | 
|  | 2816        IsConstantPoolArray()) && | 
| 2432       FixedArrayBase::cast(this)->length() != 0) { | 2817       FixedArrayBase::cast(this)->length() != 0) { | 
| 2433     return kDoubleAligned; | 2818     return kDoubleAligned; | 
| 2434   } | 2819   } | 
| 2435   if (IsHeapNumber()) return kDoubleUnaligned; | 2820   if (IsHeapNumber()) return kDoubleUnaligned; | 
| 2436 #endif  // V8_HOST_ARCH_32_BIT | 2821 #endif  // V8_HOST_ARCH_32_BIT | 
| 2437   return kWordAligned; | 2822   return kWordAligned; | 
| 2438 } | 2823 } | 
| 2439 | 2824 | 
| 2440 | 2825 | 
| 2441 void FixedArray::set(int index, | 2826 void FixedArray::set(int index, | 
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2945 | 3330 | 
| 2946 | 3331 | 
| 2947 CAST_ACCESSOR(AccessorInfo) | 3332 CAST_ACCESSOR(AccessorInfo) | 
| 2948 CAST_ACCESSOR(ArrayList) | 3333 CAST_ACCESSOR(ArrayList) | 
| 2949 CAST_ACCESSOR(ByteArray) | 3334 CAST_ACCESSOR(ByteArray) | 
| 2950 CAST_ACCESSOR(Cell) | 3335 CAST_ACCESSOR(Cell) | 
| 2951 CAST_ACCESSOR(Code) | 3336 CAST_ACCESSOR(Code) | 
| 2952 CAST_ACCESSOR(CodeCacheHashTable) | 3337 CAST_ACCESSOR(CodeCacheHashTable) | 
| 2953 CAST_ACCESSOR(CompilationCacheTable) | 3338 CAST_ACCESSOR(CompilationCacheTable) | 
| 2954 CAST_ACCESSOR(ConsString) | 3339 CAST_ACCESSOR(ConsString) | 
|  | 3340 CAST_ACCESSOR(ConstantPoolArray) | 
| 2955 CAST_ACCESSOR(DeoptimizationInputData) | 3341 CAST_ACCESSOR(DeoptimizationInputData) | 
| 2956 CAST_ACCESSOR(DeoptimizationOutputData) | 3342 CAST_ACCESSOR(DeoptimizationOutputData) | 
| 2957 CAST_ACCESSOR(DependentCode) | 3343 CAST_ACCESSOR(DependentCode) | 
| 2958 CAST_ACCESSOR(DescriptorArray) | 3344 CAST_ACCESSOR(DescriptorArray) | 
| 2959 CAST_ACCESSOR(ExternalArray) | 3345 CAST_ACCESSOR(ExternalArray) | 
| 2960 CAST_ACCESSOR(ExternalOneByteString) | 3346 CAST_ACCESSOR(ExternalOneByteString) | 
| 2961 CAST_ACCESSOR(ExternalFloat32Array) | 3347 CAST_ACCESSOR(ExternalFloat32Array) | 
| 2962 CAST_ACCESSOR(ExternalFloat64Array) | 3348 CAST_ACCESSOR(ExternalFloat64Array) | 
| 2963 CAST_ACCESSOR(ExternalInt16Array) | 3349 CAST_ACCESSOR(ExternalInt16Array) | 
| 2964 CAST_ACCESSOR(ExternalInt32Array) | 3350 CAST_ACCESSOR(ExternalInt32Array) | 
| (...skipping 1169 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4134       instance_type == INTERNALIZED_STRING_TYPE) { | 4520       instance_type == INTERNALIZED_STRING_TYPE) { | 
| 4135     // Strings may get concurrently truncated, hence we have to access its | 4521     // Strings may get concurrently truncated, hence we have to access its | 
| 4136     // length synchronized. | 4522     // length synchronized. | 
| 4137     return SeqTwoByteString::SizeFor( | 4523     return SeqTwoByteString::SizeFor( | 
| 4138         reinterpret_cast<SeqTwoByteString*>(this)->synchronized_length()); | 4524         reinterpret_cast<SeqTwoByteString*>(this)->synchronized_length()); | 
| 4139   } | 4525   } | 
| 4140   if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) { | 4526   if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) { | 
| 4141     return FixedDoubleArray::SizeFor( | 4527     return FixedDoubleArray::SizeFor( | 
| 4142         reinterpret_cast<FixedDoubleArray*>(this)->length()); | 4528         reinterpret_cast<FixedDoubleArray*>(this)->length()); | 
| 4143   } | 4529   } | 
|  | 4530   if (instance_type == CONSTANT_POOL_ARRAY_TYPE) { | 
|  | 4531     return reinterpret_cast<ConstantPoolArray*>(this)->size(); | 
|  | 4532   } | 
| 4144   if (instance_type >= FIRST_FIXED_TYPED_ARRAY_TYPE && | 4533   if (instance_type >= FIRST_FIXED_TYPED_ARRAY_TYPE && | 
| 4145       instance_type <= LAST_FIXED_TYPED_ARRAY_TYPE) { | 4534       instance_type <= LAST_FIXED_TYPED_ARRAY_TYPE) { | 
| 4146     return reinterpret_cast<FixedTypedArrayBase*>( | 4535     return reinterpret_cast<FixedTypedArrayBase*>( | 
| 4147         this)->TypedArraySize(instance_type); | 4536         this)->TypedArraySize(instance_type); | 
| 4148   } | 4537   } | 
| 4149   DCHECK(instance_type == CODE_TYPE); | 4538   DCHECK(instance_type == CODE_TYPE); | 
| 4150   return reinterpret_cast<Code*>(this)->CodeSize(); | 4539   return reinterpret_cast<Code*>(this)->CodeSize(); | 
| 4151 } | 4540 } | 
| 4152 | 4541 | 
| 4153 | 4542 | 
| (...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4736 bool Code::is_keyed_stub() { | 5125 bool Code::is_keyed_stub() { | 
| 4737   return is_keyed_load_stub() || is_keyed_store_stub(); | 5126   return is_keyed_load_stub() || is_keyed_store_stub(); | 
| 4738 } | 5127 } | 
| 4739 | 5128 | 
| 4740 | 5129 | 
| 4741 bool Code::is_debug_stub() { | 5130 bool Code::is_debug_stub() { | 
| 4742   return ic_state() == DEBUG_STUB; | 5131   return ic_state() == DEBUG_STUB; | 
| 4743 } | 5132 } | 
| 4744 | 5133 | 
| 4745 | 5134 | 
| 4746 Address Code::constant_pool() { | 5135 ConstantPoolArray* Code::constant_pool() { | 
| 4747   Address constant_pool = NULL; | 5136   return ConstantPoolArray::cast(READ_FIELD(this, kConstantPoolOffset)); | 
| 4748   if (FLAG_enable_embedded_constant_pool) { |  | 
| 4749     int offset = constant_pool_offset(); |  | 
| 4750     if (offset < instruction_size()) { |  | 
| 4751       constant_pool = FIELD_ADDR(this, kHeaderSize + offset); |  | 
| 4752     } |  | 
| 4753   } |  | 
| 4754   return constant_pool; |  | 
| 4755 } | 5137 } | 
| 4756 | 5138 | 
| 4757 | 5139 | 
|  | 5140 void Code::set_constant_pool(Object* value) { | 
|  | 5141   DCHECK(value->IsConstantPoolArray()); | 
|  | 5142   WRITE_FIELD(this, kConstantPoolOffset, value); | 
|  | 5143   WRITE_BARRIER(GetHeap(), this, kConstantPoolOffset, value); | 
|  | 5144 } | 
|  | 5145 | 
|  | 5146 | 
| 4758 Code::Flags Code::ComputeFlags(Kind kind, InlineCacheState ic_state, | 5147 Code::Flags Code::ComputeFlags(Kind kind, InlineCacheState ic_state, | 
| 4759                                ExtraICState extra_ic_state, StubType type, | 5148                                ExtraICState extra_ic_state, StubType type, | 
| 4760                                CacheHolderFlag holder) { | 5149                                CacheHolderFlag holder) { | 
| 4761   // Compute the bit mask. | 5150   // Compute the bit mask. | 
| 4762   unsigned int bits = KindField::encode(kind) | 5151   unsigned int bits = KindField::encode(kind) | 
| 4763       | ICStateField::encode(ic_state) | 5152       | ICStateField::encode(ic_state) | 
| 4764       | TypeField::encode(type) | 5153       | TypeField::encode(type) | 
| 4765       | ExtraICStateField::encode(extra_ic_state) | 5154       | ExtraICStateField::encode(extra_ic_state) | 
| 4766       | CacheHolderField::encode(holder); | 5155       | CacheHolderField::encode(holder); | 
| 4767   return static_cast<Flags>(bits); | 5156   return static_cast<Flags>(bits); | 
| (...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 5922 SMI_ACCESSORS(JSMessageObject, type, kTypeOffset) | 6311 SMI_ACCESSORS(JSMessageObject, type, kTypeOffset) | 
| 5923 ACCESSORS(JSMessageObject, argument, Object, kArgumentsOffset) | 6312 ACCESSORS(JSMessageObject, argument, Object, kArgumentsOffset) | 
| 5924 ACCESSORS(JSMessageObject, script, Object, kScriptOffset) | 6313 ACCESSORS(JSMessageObject, script, Object, kScriptOffset) | 
| 5925 ACCESSORS(JSMessageObject, stack_frames, Object, kStackFramesOffset) | 6314 ACCESSORS(JSMessageObject, stack_frames, Object, kStackFramesOffset) | 
| 5926 SMI_ACCESSORS(JSMessageObject, start_position, kStartPositionOffset) | 6315 SMI_ACCESSORS(JSMessageObject, start_position, kStartPositionOffset) | 
| 5927 SMI_ACCESSORS(JSMessageObject, end_position, kEndPositionOffset) | 6316 SMI_ACCESSORS(JSMessageObject, end_position, kEndPositionOffset) | 
| 5928 | 6317 | 
| 5929 | 6318 | 
| 5930 INT_ACCESSORS(Code, instruction_size, kInstructionSizeOffset) | 6319 INT_ACCESSORS(Code, instruction_size, kInstructionSizeOffset) | 
| 5931 INT_ACCESSORS(Code, prologue_offset, kPrologueOffset) | 6320 INT_ACCESSORS(Code, prologue_offset, kPrologueOffset) | 
| 5932 INT_ACCESSORS(Code, constant_pool_offset, kConstantPoolOffset) |  | 
| 5933 ACCESSORS(Code, relocation_info, ByteArray, kRelocationInfoOffset) | 6321 ACCESSORS(Code, relocation_info, ByteArray, kRelocationInfoOffset) | 
| 5934 ACCESSORS(Code, handler_table, FixedArray, kHandlerTableOffset) | 6322 ACCESSORS(Code, handler_table, FixedArray, kHandlerTableOffset) | 
| 5935 ACCESSORS(Code, deoptimization_data, FixedArray, kDeoptimizationDataOffset) | 6323 ACCESSORS(Code, deoptimization_data, FixedArray, kDeoptimizationDataOffset) | 
| 5936 ACCESSORS(Code, raw_type_feedback_info, Object, kTypeFeedbackInfoOffset) | 6324 ACCESSORS(Code, raw_type_feedback_info, Object, kTypeFeedbackInfoOffset) | 
| 5937 ACCESSORS(Code, next_code_link, Object, kNextCodeLinkOffset) | 6325 ACCESSORS(Code, next_code_link, Object, kNextCodeLinkOffset) | 
| 5938 | 6326 | 
| 5939 | 6327 | 
| 5940 void Code::WipeOutHeader() { | 6328 void Code::WipeOutHeader() { | 
| 5941   WRITE_FIELD(this, kRelocationInfoOffset, NULL); | 6329   WRITE_FIELD(this, kRelocationInfoOffset, NULL); | 
| 5942   WRITE_FIELD(this, kHandlerTableOffset, NULL); | 6330   WRITE_FIELD(this, kHandlerTableOffset, NULL); | 
| 5943   WRITE_FIELD(this, kDeoptimizationDataOffset, NULL); | 6331   WRITE_FIELD(this, kDeoptimizationDataOffset, NULL); | 
|  | 6332   WRITE_FIELD(this, kConstantPoolOffset, NULL); | 
| 5944   // Do not wipe out major/minor keys on a code stub or IC | 6333   // Do not wipe out major/minor keys on a code stub or IC | 
| 5945   if (!READ_FIELD(this, kTypeFeedbackInfoOffset)->IsSmi()) { | 6334   if (!READ_FIELD(this, kTypeFeedbackInfoOffset)->IsSmi()) { | 
| 5946     WRITE_FIELD(this, kTypeFeedbackInfoOffset, NULL); | 6335     WRITE_FIELD(this, kTypeFeedbackInfoOffset, NULL); | 
| 5947   } | 6336   } | 
| 5948 } | 6337 } | 
| 5949 | 6338 | 
| 5950 | 6339 | 
| 5951 Object* Code::type_feedback_info() { | 6340 Object* Code::type_feedback_info() { | 
| 5952   DCHECK(kind() == FUNCTION); | 6341   DCHECK(kind() == FUNCTION); | 
| 5953   return raw_type_feedback_info(); | 6342   return raw_type_feedback_info(); | 
| (...skipping 1372 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 7326 #undef READ_SHORT_FIELD | 7715 #undef READ_SHORT_FIELD | 
| 7327 #undef WRITE_SHORT_FIELD | 7716 #undef WRITE_SHORT_FIELD | 
| 7328 #undef READ_BYTE_FIELD | 7717 #undef READ_BYTE_FIELD | 
| 7329 #undef WRITE_BYTE_FIELD | 7718 #undef WRITE_BYTE_FIELD | 
| 7330 #undef NOBARRIER_READ_BYTE_FIELD | 7719 #undef NOBARRIER_READ_BYTE_FIELD | 
| 7331 #undef NOBARRIER_WRITE_BYTE_FIELD | 7720 #undef NOBARRIER_WRITE_BYTE_FIELD | 
| 7332 | 7721 | 
| 7333 } }  // namespace v8::internal | 7722 } }  // namespace v8::internal | 
| 7334 | 7723 | 
| 7335 #endif  // V8_OBJECTS_INL_H_ | 7724 #endif  // V8_OBJECTS_INL_H_ | 
| OLD | NEW | 
|---|