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