| 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/heap/heap.h" | 5 #include "src/heap/heap.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/ast/context-slot-cache.h" | 9 #include "src/ast/context-slot-cache.h" |
| 10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
| (...skipping 2397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2408 set_empty_fixed_##type##_array(obj); \ | 2408 set_empty_fixed_##type##_array(obj); \ |
| 2409 } | 2409 } |
| 2410 | 2410 |
| 2411 TYPED_ARRAYS(ALLOCATE_EMPTY_FIXED_TYPED_ARRAY) | 2411 TYPED_ARRAYS(ALLOCATE_EMPTY_FIXED_TYPED_ARRAY) |
| 2412 #undef ALLOCATE_EMPTY_FIXED_TYPED_ARRAY | 2412 #undef ALLOCATE_EMPTY_FIXED_TYPED_ARRAY |
| 2413 } | 2413 } |
| 2414 DCHECK(!InNewSpace(empty_fixed_array())); | 2414 DCHECK(!InNewSpace(empty_fixed_array())); |
| 2415 return true; | 2415 return true; |
| 2416 } | 2416 } |
| 2417 | 2417 |
| 2418 | 2418 AllocationResult Heap::AllocateHeapNumber(MutableMode mode, |
| 2419 AllocationResult Heap::AllocateHeapNumber(double value, MutableMode mode, | |
| 2420 PretenureFlag pretenure) { | 2419 PretenureFlag pretenure) { |
| 2421 // Statically ensure that it is safe to allocate heap numbers in paged | 2420 // Statically ensure that it is safe to allocate heap numbers in paged |
| 2422 // spaces. | 2421 // spaces. |
| 2423 int size = HeapNumber::kSize; | 2422 int size = HeapNumber::kSize; |
| 2424 STATIC_ASSERT(HeapNumber::kSize <= kMaxRegularHeapObjectSize); | 2423 STATIC_ASSERT(HeapNumber::kSize <= kMaxRegularHeapObjectSize); |
| 2425 | 2424 |
| 2426 AllocationSpace space = SelectSpace(pretenure); | 2425 AllocationSpace space = SelectSpace(pretenure); |
| 2427 | 2426 |
| 2428 HeapObject* result = nullptr; | 2427 HeapObject* result = nullptr; |
| 2429 { | 2428 { |
| 2430 AllocationResult allocation = AllocateRaw(size, space, kDoubleUnaligned); | 2429 AllocationResult allocation = AllocateRaw(size, space, kDoubleUnaligned); |
| 2431 if (!allocation.To(&result)) return allocation; | 2430 if (!allocation.To(&result)) return allocation; |
| 2432 } | 2431 } |
| 2433 | 2432 |
| 2434 Map* map = mode == MUTABLE ? mutable_heap_number_map() : heap_number_map(); | 2433 Map* map = mode == MUTABLE ? mutable_heap_number_map() : heap_number_map(); |
| 2435 HeapObject::cast(result)->set_map_no_write_barrier(map); | 2434 HeapObject::cast(result)->set_map_no_write_barrier(map); |
| 2436 HeapNumber::cast(result)->set_value(value); | |
| 2437 return result; | 2435 return result; |
| 2438 } | 2436 } |
| 2439 | 2437 |
| 2440 #define SIMD_ALLOCATE_DEFINITION(TYPE, Type, type, lane_count, lane_type) \ | 2438 #define SIMD_ALLOCATE_DEFINITION(TYPE, Type, type, lane_count, lane_type) \ |
| 2441 AllocationResult Heap::Allocate##Type(lane_type lanes[lane_count], \ | 2439 AllocationResult Heap::Allocate##Type(lane_type lanes[lane_count], \ |
| 2442 PretenureFlag pretenure) { \ | 2440 PretenureFlag pretenure) { \ |
| 2443 int size = Type::kSize; \ | 2441 int size = Type::kSize; \ |
| 2444 STATIC_ASSERT(Type::kSize <= kMaxRegularHeapObjectSize); \ | 2442 STATIC_ASSERT(Type::kSize <= kMaxRegularHeapObjectSize); \ |
| 2445 \ | 2443 \ |
| 2446 AllocationSpace space = SelectSpace(pretenure); \ | 2444 AllocationSpace space = SelectSpace(pretenure); \ |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2593 void Heap::CreateInitialObjects() { | 2591 void Heap::CreateInitialObjects() { |
| 2594 HandleScope scope(isolate()); | 2592 HandleScope scope(isolate()); |
| 2595 Factory* factory = isolate()->factory(); | 2593 Factory* factory = isolate()->factory(); |
| 2596 | 2594 |
| 2597 // The -0 value must be set before NewNumber works. | 2595 // The -0 value must be set before NewNumber works. |
| 2598 set_minus_zero_value(*factory->NewHeapNumber(-0.0, IMMUTABLE, TENURED)); | 2596 set_minus_zero_value(*factory->NewHeapNumber(-0.0, IMMUTABLE, TENURED)); |
| 2599 DCHECK(std::signbit(minus_zero_value()->Number()) != 0); | 2597 DCHECK(std::signbit(minus_zero_value()->Number()) != 0); |
| 2600 | 2598 |
| 2601 set_nan_value(*factory->NewHeapNumber( | 2599 set_nan_value(*factory->NewHeapNumber( |
| 2602 std::numeric_limits<double>::quiet_NaN(), IMMUTABLE, TENURED)); | 2600 std::numeric_limits<double>::quiet_NaN(), IMMUTABLE, TENURED)); |
| 2603 set_hole_nan_value(*factory->NewHeapNumber(bit_cast<double>(kHoleNanInt64), | 2601 set_hole_nan_value( |
| 2604 IMMUTABLE, TENURED)); | 2602 *factory->NewHeapNumberFromBits(kHoleNanInt64, IMMUTABLE, TENURED)); |
| 2605 set_infinity_value(*factory->NewHeapNumber(V8_INFINITY, IMMUTABLE, TENURED)); | 2603 set_infinity_value(*factory->NewHeapNumber(V8_INFINITY, IMMUTABLE, TENURED)); |
| 2606 set_minus_infinity_value( | 2604 set_minus_infinity_value( |
| 2607 *factory->NewHeapNumber(-V8_INFINITY, IMMUTABLE, TENURED)); | 2605 *factory->NewHeapNumber(-V8_INFINITY, IMMUTABLE, TENURED)); |
| 2608 | 2606 |
| 2609 // Allocate initial string table. | 2607 // Allocate initial string table. |
| 2610 set_string_table(*StringTable::New(isolate(), kInitialStringTableSize)); | 2608 set_string_table(*StringTable::New(isolate(), kInitialStringTableSize)); |
| 2611 | 2609 |
| 2612 // Allocate | 2610 // Allocate |
| 2613 | 2611 |
| 2614 // Finish initializing oddballs after creating the string table. | 2612 // Finish initializing oddballs after creating the string table. |
| (...skipping 3993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6608 } | 6606 } |
| 6609 | 6607 |
| 6610 | 6608 |
| 6611 // static | 6609 // static |
| 6612 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6610 int Heap::GetStaticVisitorIdForMap(Map* map) { |
| 6613 return StaticVisitorBase::GetVisitorId(map); | 6611 return StaticVisitorBase::GetVisitorId(map); |
| 6614 } | 6612 } |
| 6615 | 6613 |
| 6616 } // namespace internal | 6614 } // namespace internal |
| 6617 } // namespace v8 | 6615 } // namespace v8 |
| OLD | NEW |