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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/base/once.h" | 9 #include "src/base/once.h" |
10 #include "src/base/utils/random-number-generator.h" | 10 #include "src/base/utils/random-number-generator.h" |
(...skipping 2510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2521 } | 2521 } |
2522 | 2522 |
2523 #define ALLOCATE_VARSIZE_MAP(instance_type, field_name) \ | 2523 #define ALLOCATE_VARSIZE_MAP(instance_type, field_name) \ |
2524 ALLOCATE_MAP(instance_type, kVariableSizeSentinel, field_name) | 2524 ALLOCATE_MAP(instance_type, kVariableSizeSentinel, field_name) |
2525 | 2525 |
2526 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, fixed_cow_array) | 2526 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, fixed_cow_array) |
2527 ASSERT(fixed_array_map() != fixed_cow_array_map()); | 2527 ASSERT(fixed_array_map() != fixed_cow_array_map()); |
2528 | 2528 |
2529 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, scope_info) | 2529 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, scope_info) |
2530 ALLOCATE_MAP(HEAP_NUMBER_TYPE, HeapNumber::kSize, heap_number) | 2530 ALLOCATE_MAP(HEAP_NUMBER_TYPE, HeapNumber::kSize, heap_number) |
| 2531 ALLOCATE_MAP( |
| 2532 MUTABLE_HEAP_NUMBER_TYPE, HeapNumber::kSize, mutable_heap_number) |
2531 ALLOCATE_MAP(SYMBOL_TYPE, Symbol::kSize, symbol) | 2533 ALLOCATE_MAP(SYMBOL_TYPE, Symbol::kSize, symbol) |
2532 ALLOCATE_MAP(FOREIGN_TYPE, Foreign::kSize, foreign) | 2534 ALLOCATE_MAP(FOREIGN_TYPE, Foreign::kSize, foreign) |
2533 | 2535 |
2534 ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, the_hole); | 2536 ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, the_hole); |
2535 ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, boolean); | 2537 ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, boolean); |
2536 ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, uninitialized); | 2538 ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, uninitialized); |
2537 ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, arguments_marker); | 2539 ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, arguments_marker); |
2538 ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, no_interceptor_result_sentinel); | 2540 ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, no_interceptor_result_sentinel); |
2539 ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, exception); | 2541 ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, exception); |
2540 ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, termination_exception); | 2542 ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, termination_exception); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2645 | 2647 |
2646 TYPED_ARRAYS(ALLOCATE_EMPTY_FIXED_TYPED_ARRAY) | 2648 TYPED_ARRAYS(ALLOCATE_EMPTY_FIXED_TYPED_ARRAY) |
2647 #undef ALLOCATE_EMPTY_FIXED_TYPED_ARRAY | 2649 #undef ALLOCATE_EMPTY_FIXED_TYPED_ARRAY |
2648 } | 2650 } |
2649 ASSERT(!InNewSpace(empty_fixed_array())); | 2651 ASSERT(!InNewSpace(empty_fixed_array())); |
2650 return true; | 2652 return true; |
2651 } | 2653 } |
2652 | 2654 |
2653 | 2655 |
2654 AllocationResult Heap::AllocateHeapNumber(double value, | 2656 AllocationResult Heap::AllocateHeapNumber(double value, |
| 2657 MutableMode mode, |
2655 PretenureFlag pretenure) { | 2658 PretenureFlag pretenure) { |
2656 // Statically ensure that it is safe to allocate heap numbers in paged | 2659 // Statically ensure that it is safe to allocate heap numbers in paged |
2657 // spaces. | 2660 // spaces. |
2658 int size = HeapNumber::kSize; | 2661 int size = HeapNumber::kSize; |
2659 STATIC_ASSERT(HeapNumber::kSize <= Page::kMaxRegularHeapObjectSize); | 2662 STATIC_ASSERT(HeapNumber::kSize <= Page::kMaxRegularHeapObjectSize); |
2660 | 2663 |
2661 AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, pretenure); | 2664 AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, pretenure); |
2662 | 2665 |
2663 HeapObject* result; | 2666 HeapObject* result; |
2664 { AllocationResult allocation = AllocateRaw(size, space, OLD_DATA_SPACE); | 2667 { AllocationResult allocation = AllocateRaw(size, space, OLD_DATA_SPACE); |
2665 if (!allocation.To(&result)) return allocation; | 2668 if (!allocation.To(&result)) return allocation; |
2666 } | 2669 } |
2667 | 2670 |
2668 result->set_map_no_write_barrier(heap_number_map()); | 2671 Map* map = mode == MUTABLE ? mutable_heap_number_map() : heap_number_map(); |
| 2672 HeapObject::cast(result)->set_map_no_write_barrier(map); |
2669 HeapNumber::cast(result)->set_value(value); | 2673 HeapNumber::cast(result)->set_value(value); |
2670 return result; | 2674 return result; |
2671 } | 2675 } |
2672 | 2676 |
2673 | 2677 |
2674 AllocationResult Heap::AllocateCell(Object* value) { | 2678 AllocationResult Heap::AllocateCell(Object* value) { |
2675 int size = Cell::kSize; | 2679 int size = Cell::kSize; |
2676 STATIC_ASSERT(Cell::kSize <= Page::kMaxRegularHeapObjectSize); | 2680 STATIC_ASSERT(Cell::kSize <= Page::kMaxRegularHeapObjectSize); |
2677 | 2681 |
2678 HeapObject* result; | 2682 HeapObject* result; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2764 // To workaround the problem, make separate functions without inlining. | 2768 // To workaround the problem, make separate functions without inlining. |
2765 Heap::CreateJSEntryStub(); | 2769 Heap::CreateJSEntryStub(); |
2766 Heap::CreateJSConstructEntryStub(); | 2770 Heap::CreateJSConstructEntryStub(); |
2767 } | 2771 } |
2768 | 2772 |
2769 | 2773 |
2770 void Heap::CreateInitialObjects() { | 2774 void Heap::CreateInitialObjects() { |
2771 HandleScope scope(isolate()); | 2775 HandleScope scope(isolate()); |
2772 Factory* factory = isolate()->factory(); | 2776 Factory* factory = isolate()->factory(); |
2773 | 2777 |
2774 // The -0 value must be set before NumberFromDouble works. | 2778 // The -0 value must be set before NewNumber works. |
2775 set_minus_zero_value(*factory->NewHeapNumber(-0.0, TENURED)); | 2779 set_minus_zero_value(*factory->NewHeapNumber(-0.0, IMMUTABLE, TENURED)); |
2776 ASSERT(std::signbit(minus_zero_value()->Number()) != 0); | 2780 ASSERT(std::signbit(minus_zero_value()->Number()) != 0); |
2777 | 2781 |
2778 set_nan_value(*factory->NewHeapNumber(base::OS::nan_value(), TENURED)); | 2782 set_nan_value( |
2779 set_infinity_value(*factory->NewHeapNumber(V8_INFINITY, TENURED)); | 2783 *factory->NewHeapNumber(base::OS::nan_value(), IMMUTABLE, TENURED)); |
| 2784 set_infinity_value(*factory->NewHeapNumber(V8_INFINITY, IMMUTABLE, TENURED)); |
2780 | 2785 |
2781 // The hole has not been created yet, but we want to put something | 2786 // The hole has not been created yet, but we want to put something |
2782 // predictable in the gaps in the string table, so lets make that Smi zero. | 2787 // predictable in the gaps in the string table, so lets make that Smi zero. |
2783 set_the_hole_value(reinterpret_cast<Oddball*>(Smi::FromInt(0))); | 2788 set_the_hole_value(reinterpret_cast<Oddball*>(Smi::FromInt(0))); |
2784 | 2789 |
2785 // Allocate initial string table. | 2790 // Allocate initial string table. |
2786 set_string_table(*StringTable::New(isolate(), kInitialStringTableSize)); | 2791 set_string_table(*StringTable::New(isolate(), kInitialStringTableSize)); |
2787 | 2792 |
2788 // Finish initializing oddballs after creating the string table. | 2793 // Finish initializing oddballs after creating the string table. |
2789 Oddball::Initialize(isolate(), | 2794 Oddball::Initialize(isolate(), |
(...skipping 3653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6443 static_cast<int>(object_sizes_last_time_[index])); | 6448 static_cast<int>(object_sizes_last_time_[index])); |
6444 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 6449 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
6445 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 6450 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
6446 | 6451 |
6447 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 6452 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
6448 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 6453 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
6449 ClearObjectStats(); | 6454 ClearObjectStats(); |
6450 } | 6455 } |
6451 | 6456 |
6452 } } // namespace v8::internal | 6457 } } // namespace v8::internal |
OLD | NEW |