| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 sweeping_time_(0.0), | 134 sweeping_time_(0.0), |
| 135 store_buffer_(this), | 135 store_buffer_(this), |
| 136 marking_(this), | 136 marking_(this), |
| 137 incremental_marking_(this), | 137 incremental_marking_(this), |
| 138 number_idle_notifications_(0), | 138 number_idle_notifications_(0), |
| 139 last_idle_notification_gc_count_(0), | 139 last_idle_notification_gc_count_(0), |
| 140 last_idle_notification_gc_count_init_(false), | 140 last_idle_notification_gc_count_init_(false), |
| 141 mark_sweeps_since_idle_round_started_(0), | 141 mark_sweeps_since_idle_round_started_(0), |
| 142 gc_count_at_last_idle_gc_(0), | 142 gc_count_at_last_idle_gc_(0), |
| 143 scavenges_since_last_idle_round_(kIdleScavengeThreshold), | 143 scavenges_since_last_idle_round_(kIdleScavengeThreshold), |
| 144 full_codegen_bytes_generated_(0), |
| 145 crankshaft_codegen_bytes_generated_(0), |
| 144 gcs_since_last_deopt_(0), | 146 gcs_since_last_deopt_(0), |
| 145 #ifdef VERIFY_HEAP | 147 #ifdef VERIFY_HEAP |
| 146 no_weak_object_verification_scope_depth_(0), | 148 no_weak_object_verification_scope_depth_(0), |
| 147 #endif | 149 #endif |
| 148 promotion_queue_(this), | 150 promotion_queue_(this), |
| 149 configured_(false), | 151 configured_(false), |
| 150 chunks_queued_for_free_(NULL), | 152 chunks_queued_for_free_(NULL), |
| 151 relocation_mutex_(NULL) { | 153 relocation_mutex_(NULL) { |
| 152 // Allow build-time customization of the max semispace size. Building | 154 // Allow build-time customization of the max semispace size. Building |
| 153 // V8 with snapshots and a non-default max semispace size is much | 155 // V8 with snapshots and a non-default max semispace size is much |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 | 443 |
| 442 #ifdef DEBUG | 444 #ifdef DEBUG |
| 443 ASSERT(!AllowHeapAllocation::IsAllowed() && gc_state_ == NOT_IN_GC); | 445 ASSERT(!AllowHeapAllocation::IsAllowed() && gc_state_ == NOT_IN_GC); |
| 444 | 446 |
| 445 if (FLAG_gc_verbose) Print(); | 447 if (FLAG_gc_verbose) Print(); |
| 446 | 448 |
| 447 ReportStatisticsBeforeGC(); | 449 ReportStatisticsBeforeGC(); |
| 448 #endif // DEBUG | 450 #endif // DEBUG |
| 449 | 451 |
| 450 store_buffer()->GCPrologue(); | 452 store_buffer()->GCPrologue(); |
| 453 |
| 454 if (FLAG_concurrent_osr) { |
| 455 isolate()->optimizing_compiler_thread()->AgeBufferedOsrJobs(); |
| 456 } |
| 451 } | 457 } |
| 452 | 458 |
| 453 | 459 |
| 454 intptr_t Heap::SizeOfObjects() { | 460 intptr_t Heap::SizeOfObjects() { |
| 455 intptr_t total = 0; | 461 intptr_t total = 0; |
| 456 AllSpaces spaces(this); | 462 AllSpaces spaces(this); |
| 457 for (Space* space = spaces.next(); space != NULL; space = spaces.next()) { | 463 for (Space* space = spaces.next(); space != NULL; space = spaces.next()) { |
| 458 total += space->SizeOfObjects(); | 464 total += space->SizeOfObjects(); |
| 459 } | 465 } |
| 460 return total; | 466 return total; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 } | 507 } |
| 502 | 508 |
| 503 isolate_->counters()->alive_after_last_gc()->Set( | 509 isolate_->counters()->alive_after_last_gc()->Set( |
| 504 static_cast<int>(SizeOfObjects())); | 510 static_cast<int>(SizeOfObjects())); |
| 505 | 511 |
| 506 isolate_->counters()->string_table_capacity()->Set( | 512 isolate_->counters()->string_table_capacity()->Set( |
| 507 string_table()->Capacity()); | 513 string_table()->Capacity()); |
| 508 isolate_->counters()->number_of_symbols()->Set( | 514 isolate_->counters()->number_of_symbols()->Set( |
| 509 string_table()->NumberOfElements()); | 515 string_table()->NumberOfElements()); |
| 510 | 516 |
| 517 if (full_codegen_bytes_generated_ + crankshaft_codegen_bytes_generated_ > 0) { |
| 518 isolate_->counters()->codegen_fraction_crankshaft()->AddSample( |
| 519 static_cast<int>((crankshaft_codegen_bytes_generated_ * 100.0) / |
| 520 (crankshaft_codegen_bytes_generated_ |
| 521 + full_codegen_bytes_generated_))); |
| 522 } |
| 523 |
| 511 if (CommittedMemory() > 0) { | 524 if (CommittedMemory() > 0) { |
| 512 isolate_->counters()->external_fragmentation_total()->AddSample( | 525 isolate_->counters()->external_fragmentation_total()->AddSample( |
| 513 static_cast<int>(100 - (SizeOfObjects() * 100.0) / CommittedMemory())); | 526 static_cast<int>(100 - (SizeOfObjects() * 100.0) / CommittedMemory())); |
| 514 | 527 |
| 528 isolate_->counters()->heap_fraction_new_space()-> |
| 529 AddSample(static_cast<int>( |
| 530 (new_space()->CommittedMemory() * 100.0) / CommittedMemory())); |
| 531 isolate_->counters()->heap_fraction_old_pointer_space()->AddSample( |
| 532 static_cast<int>( |
| 533 (old_pointer_space()->CommittedMemory() * 100.0) / |
| 534 CommittedMemory())); |
| 535 isolate_->counters()->heap_fraction_old_data_space()->AddSample( |
| 536 static_cast<int>( |
| 537 (old_data_space()->CommittedMemory() * 100.0) / |
| 538 CommittedMemory())); |
| 539 isolate_->counters()->heap_fraction_code_space()-> |
| 540 AddSample(static_cast<int>( |
| 541 (code_space()->CommittedMemory() * 100.0) / CommittedMemory())); |
| 515 isolate_->counters()->heap_fraction_map_space()->AddSample( | 542 isolate_->counters()->heap_fraction_map_space()->AddSample( |
| 516 static_cast<int>( | 543 static_cast<int>( |
| 517 (map_space()->CommittedMemory() * 100.0) / CommittedMemory())); | 544 (map_space()->CommittedMemory() * 100.0) / CommittedMemory())); |
| 518 isolate_->counters()->heap_fraction_cell_space()->AddSample( | 545 isolate_->counters()->heap_fraction_cell_space()->AddSample( |
| 519 static_cast<int>( | 546 static_cast<int>( |
| 520 (cell_space()->CommittedMemory() * 100.0) / CommittedMemory())); | 547 (cell_space()->CommittedMemory() * 100.0) / CommittedMemory())); |
| 521 isolate_->counters()->heap_fraction_property_cell_space()-> | 548 isolate_->counters()->heap_fraction_property_cell_space()-> |
| 522 AddSample(static_cast<int>( | 549 AddSample(static_cast<int>( |
| 523 (property_cell_space()->CommittedMemory() * 100.0) / | 550 (property_cell_space()->CommittedMemory() * 100.0) / |
| 524 CommittedMemory())); | 551 CommittedMemory())); |
| 552 isolate_->counters()->heap_fraction_lo_space()-> |
| 553 AddSample(static_cast<int>( |
| 554 (lo_space()->CommittedMemory() * 100.0) / CommittedMemory())); |
| 525 | 555 |
| 526 isolate_->counters()->heap_sample_total_committed()->AddSample( | 556 isolate_->counters()->heap_sample_total_committed()->AddSample( |
| 527 static_cast<int>(CommittedMemory() / KB)); | 557 static_cast<int>(CommittedMemory() / KB)); |
| 528 isolate_->counters()->heap_sample_total_used()->AddSample( | 558 isolate_->counters()->heap_sample_total_used()->AddSample( |
| 529 static_cast<int>(SizeOfObjects() / KB)); | 559 static_cast<int>(SizeOfObjects() / KB)); |
| 530 isolate_->counters()->heap_sample_map_space_committed()->AddSample( | 560 isolate_->counters()->heap_sample_map_space_committed()->AddSample( |
| 531 static_cast<int>(map_space()->CommittedMemory() / KB)); | 561 static_cast<int>(map_space()->CommittedMemory() / KB)); |
| 532 isolate_->counters()->heap_sample_cell_space_committed()->AddSample( | 562 isolate_->counters()->heap_sample_cell_space_committed()->AddSample( |
| 533 static_cast<int>(cell_space()->CommittedMemory() / KB)); | 563 static_cast<int>(cell_space()->CommittedMemory() / KB)); |
| 534 isolate_->counters()-> | 564 isolate_->counters()-> |
| 535 heap_sample_property_cell_space_committed()-> | 565 heap_sample_property_cell_space_committed()-> |
| 536 AddSample(static_cast<int>( | 566 AddSample(static_cast<int>( |
| 537 property_cell_space()->CommittedMemory() / KB)); | 567 property_cell_space()->CommittedMemory() / KB)); |
| 568 isolate_->counters()->heap_sample_code_space_committed()->AddSample( |
| 569 static_cast<int>(code_space()->CommittedMemory() / KB)); |
| 538 } | 570 } |
| 539 | 571 |
| 540 #define UPDATE_COUNTERS_FOR_SPACE(space) \ | 572 #define UPDATE_COUNTERS_FOR_SPACE(space) \ |
| 541 isolate_->counters()->space##_bytes_available()->Set( \ | 573 isolate_->counters()->space##_bytes_available()->Set( \ |
| 542 static_cast<int>(space()->Available())); \ | 574 static_cast<int>(space()->Available())); \ |
| 543 isolate_->counters()->space##_bytes_committed()->Set( \ | 575 isolate_->counters()->space##_bytes_committed()->Set( \ |
| 544 static_cast<int>(space()->CommittedMemory())); \ | 576 static_cast<int>(space()->CommittedMemory())); \ |
| 545 isolate_->counters()->space##_bytes_used()->Set( \ | 577 isolate_->counters()->space##_bytes_used()->Set( \ |
| 546 static_cast<int>(space()->SizeOfObjects())); | 578 static_cast<int>(space()->SizeOfObjects())); |
| 547 #define UPDATE_FRAGMENTATION_FOR_SPACE(space) \ | 579 #define UPDATE_FRAGMENTATION_FOR_SPACE(space) \ |
| (...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1950 | 1982 |
| 1951 // Take another spin if there are now unswept objects in new space | 1983 // Take another spin if there are now unswept objects in new space |
| 1952 // (there are currently no more unswept promoted objects). | 1984 // (there are currently no more unswept promoted objects). |
| 1953 } while (new_space_front != new_space_.top()); | 1985 } while (new_space_front != new_space_.top()); |
| 1954 | 1986 |
| 1955 return new_space_front; | 1987 return new_space_front; |
| 1956 } | 1988 } |
| 1957 | 1989 |
| 1958 | 1990 |
| 1959 STATIC_ASSERT((FixedDoubleArray::kHeaderSize & kDoubleAlignmentMask) == 0); | 1991 STATIC_ASSERT((FixedDoubleArray::kHeaderSize & kDoubleAlignmentMask) == 0); |
| 1992 STATIC_ASSERT((ConstantPoolArray::kHeaderSize & kDoubleAlignmentMask) == 0); |
| 1960 | 1993 |
| 1961 | 1994 |
| 1962 INLINE(static HeapObject* EnsureDoubleAligned(Heap* heap, | 1995 INLINE(static HeapObject* EnsureDoubleAligned(Heap* heap, |
| 1963 HeapObject* object, | 1996 HeapObject* object, |
| 1964 int size)); | 1997 int size)); |
| 1965 | 1998 |
| 1966 static HeapObject* EnsureDoubleAligned(Heap* heap, | 1999 static HeapObject* EnsureDoubleAligned(Heap* heap, |
| 1967 HeapObject* object, | 2000 HeapObject* object, |
| 1968 int size) { | 2001 int size) { |
| 1969 if ((OffsetFrom(object->address()) & kDoubleAlignmentMask) != 0) { | 2002 if ((OffsetFrom(object->address()) & kDoubleAlignmentMask) != 0) { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2094 int size)) { | 2127 int size)) { |
| 2095 // Copy the content of source to target. | 2128 // Copy the content of source to target. |
| 2096 heap->CopyBlock(target->address(), source->address(), size); | 2129 heap->CopyBlock(target->address(), source->address(), size); |
| 2097 | 2130 |
| 2098 // Set the forwarding address. | 2131 // Set the forwarding address. |
| 2099 source->set_map_word(MapWord::FromForwardingAddress(target)); | 2132 source->set_map_word(MapWord::FromForwardingAddress(target)); |
| 2100 | 2133 |
| 2101 if (logging_and_profiling_mode == LOGGING_AND_PROFILING_ENABLED) { | 2134 if (logging_and_profiling_mode == LOGGING_AND_PROFILING_ENABLED) { |
| 2102 // Update NewSpace stats if necessary. | 2135 // Update NewSpace stats if necessary. |
| 2103 RecordCopiedObject(heap, target); | 2136 RecordCopiedObject(heap, target); |
| 2104 HEAP_PROFILE(heap, ObjectMoveEvent(source->address(), target->address())); | |
| 2105 Isolate* isolate = heap->isolate(); | 2137 Isolate* isolate = heap->isolate(); |
| 2138 HeapProfiler* heap_profiler = isolate->heap_profiler(); |
| 2139 if (heap_profiler->is_profiling()) { |
| 2140 heap_profiler->ObjectMoveEvent(source->address(), target->address(), |
| 2141 size); |
| 2142 } |
| 2106 if (isolate->logger()->is_logging_code_events() || | 2143 if (isolate->logger()->is_logging_code_events() || |
| 2107 isolate->cpu_profiler()->is_profiling()) { | 2144 isolate->cpu_profiler()->is_profiling()) { |
| 2108 if (target->IsSharedFunctionInfo()) { | 2145 if (target->IsSharedFunctionInfo()) { |
| 2109 PROFILE(isolate, SharedFunctionInfoMoveEvent( | 2146 PROFILE(isolate, SharedFunctionInfoMoveEvent( |
| 2110 source->address(), target->address())); | 2147 source->address(), target->address())); |
| 2111 } | 2148 } |
| 2112 } | 2149 } |
| 2113 } | 2150 } |
| 2114 | 2151 |
| 2115 if (marks_handling == TRANSFER_MARKS) { | 2152 if (marks_handling == TRANSFER_MARKS) { |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2392 MapWord first_word = object->map_word(); | 2429 MapWord first_word = object->map_word(); |
| 2393 SLOW_ASSERT(!first_word.IsForwardingAddress()); | 2430 SLOW_ASSERT(!first_word.IsForwardingAddress()); |
| 2394 Map* map = first_word.ToMap(); | 2431 Map* map = first_word.ToMap(); |
| 2395 map->GetHeap()->DoScavengeObject(map, p, object); | 2432 map->GetHeap()->DoScavengeObject(map, p, object); |
| 2396 } | 2433 } |
| 2397 | 2434 |
| 2398 | 2435 |
| 2399 MaybeObject* Heap::AllocatePartialMap(InstanceType instance_type, | 2436 MaybeObject* Heap::AllocatePartialMap(InstanceType instance_type, |
| 2400 int instance_size) { | 2437 int instance_size) { |
| 2401 Object* result; | 2438 Object* result; |
| 2402 MaybeObject* maybe_result = AllocateRawMap(); | 2439 MaybeObject* maybe_result = AllocateRaw(Map::kSize, MAP_SPACE, MAP_SPACE); |
| 2403 if (!maybe_result->ToObject(&result)) return maybe_result; | 2440 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 2404 | 2441 |
| 2405 // Map::cast cannot be used due to uninitialized map field. | 2442 // Map::cast cannot be used due to uninitialized map field. |
| 2406 reinterpret_cast<Map*>(result)->set_map(raw_unchecked_meta_map()); | 2443 reinterpret_cast<Map*>(result)->set_map(raw_unchecked_meta_map()); |
| 2407 reinterpret_cast<Map*>(result)->set_instance_type(instance_type); | 2444 reinterpret_cast<Map*>(result)->set_instance_type(instance_type); |
| 2408 reinterpret_cast<Map*>(result)->set_instance_size(instance_size); | 2445 reinterpret_cast<Map*>(result)->set_instance_size(instance_size); |
| 2409 reinterpret_cast<Map*>(result)->set_visitor_id( | 2446 reinterpret_cast<Map*>(result)->set_visitor_id( |
| 2410 StaticVisitorBase::GetVisitorId(instance_type, instance_size)); | 2447 StaticVisitorBase::GetVisitorId(instance_type, instance_size)); |
| 2411 reinterpret_cast<Map*>(result)->set_inobject_properties(0); | 2448 reinterpret_cast<Map*>(result)->set_inobject_properties(0); |
| 2412 reinterpret_cast<Map*>(result)->set_pre_allocated_property_fields(0); | 2449 reinterpret_cast<Map*>(result)->set_pre_allocated_property_fields(0); |
| 2413 reinterpret_cast<Map*>(result)->set_unused_property_fields(0); | 2450 reinterpret_cast<Map*>(result)->set_unused_property_fields(0); |
| 2414 reinterpret_cast<Map*>(result)->set_bit_field(0); | 2451 reinterpret_cast<Map*>(result)->set_bit_field(0); |
| 2415 reinterpret_cast<Map*>(result)->set_bit_field2(0); | 2452 reinterpret_cast<Map*>(result)->set_bit_field2(0); |
| 2416 int bit_field3 = Map::EnumLengthBits::encode(Map::kInvalidEnumCache) | | 2453 int bit_field3 = Map::EnumLengthBits::encode(Map::kInvalidEnumCache) | |
| 2417 Map::OwnsDescriptors::encode(true); | 2454 Map::OwnsDescriptors::encode(true); |
| 2418 reinterpret_cast<Map*>(result)->set_bit_field3(bit_field3); | 2455 reinterpret_cast<Map*>(result)->set_bit_field3(bit_field3); |
| 2419 return result; | 2456 return result; |
| 2420 } | 2457 } |
| 2421 | 2458 |
| 2422 | 2459 |
| 2423 MaybeObject* Heap::AllocateMap(InstanceType instance_type, | 2460 MaybeObject* Heap::AllocateMap(InstanceType instance_type, |
| 2424 int instance_size, | 2461 int instance_size, |
| 2425 ElementsKind elements_kind) { | 2462 ElementsKind elements_kind) { |
| 2426 Object* result; | 2463 Object* result; |
| 2427 MaybeObject* maybe_result = AllocateRawMap(); | 2464 MaybeObject* maybe_result = AllocateRaw(Map::kSize, MAP_SPACE, MAP_SPACE); |
| 2428 if (!maybe_result->To(&result)) return maybe_result; | 2465 if (!maybe_result->To(&result)) return maybe_result; |
| 2429 | 2466 |
| 2430 Map* map = reinterpret_cast<Map*>(result); | 2467 Map* map = reinterpret_cast<Map*>(result); |
| 2431 map->set_map_no_write_barrier(meta_map()); | 2468 map->set_map_no_write_barrier(meta_map()); |
| 2432 map->set_instance_type(instance_type); | 2469 map->set_instance_type(instance_type); |
| 2433 map->set_visitor_id( | 2470 map->set_visitor_id( |
| 2434 StaticVisitorBase::GetVisitorId(instance_type, instance_size)); | 2471 StaticVisitorBase::GetVisitorId(instance_type, instance_size)); |
| 2435 map->set_prototype(null_value(), SKIP_WRITE_BARRIER); | 2472 map->set_prototype(null_value(), SKIP_WRITE_BARRIER); |
| 2436 map->set_constructor(null_value(), SKIP_WRITE_BARRIER); | 2473 map->set_constructor(null_value(), SKIP_WRITE_BARRIER); |
| 2437 map->set_instance_size(instance_size); | 2474 map->set_instance_size(instance_size); |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2650 set_undetectable_ascii_string_map(Map::cast(obj)); | 2687 set_undetectable_ascii_string_map(Map::cast(obj)); |
| 2651 Map::cast(obj)->set_is_undetectable(); | 2688 Map::cast(obj)->set_is_undetectable(); |
| 2652 | 2689 |
| 2653 { MaybeObject* maybe_obj = | 2690 { MaybeObject* maybe_obj = |
| 2654 AllocateMap(FIXED_DOUBLE_ARRAY_TYPE, kVariableSizeSentinel); | 2691 AllocateMap(FIXED_DOUBLE_ARRAY_TYPE, kVariableSizeSentinel); |
| 2655 if (!maybe_obj->ToObject(&obj)) return false; | 2692 if (!maybe_obj->ToObject(&obj)) return false; |
| 2656 } | 2693 } |
| 2657 set_fixed_double_array_map(Map::cast(obj)); | 2694 set_fixed_double_array_map(Map::cast(obj)); |
| 2658 | 2695 |
| 2659 { MaybeObject* maybe_obj = | 2696 { MaybeObject* maybe_obj = |
| 2697 AllocateMap(CONSTANT_POOL_ARRAY_TYPE, kVariableSizeSentinel); |
| 2698 if (!maybe_obj->ToObject(&obj)) return false; |
| 2699 } |
| 2700 set_constant_pool_array_map(Map::cast(obj)); |
| 2701 |
| 2702 { MaybeObject* maybe_obj = |
| 2660 AllocateMap(BYTE_ARRAY_TYPE, kVariableSizeSentinel); | 2703 AllocateMap(BYTE_ARRAY_TYPE, kVariableSizeSentinel); |
| 2661 if (!maybe_obj->ToObject(&obj)) return false; | 2704 if (!maybe_obj->ToObject(&obj)) return false; |
| 2662 } | 2705 } |
| 2663 set_byte_array_map(Map::cast(obj)); | 2706 set_byte_array_map(Map::cast(obj)); |
| 2664 | 2707 |
| 2665 { MaybeObject* maybe_obj = | 2708 { MaybeObject* maybe_obj = |
| 2666 AllocateMap(FREE_SPACE_TYPE, kVariableSizeSentinel); | 2709 AllocateMap(FREE_SPACE_TYPE, kVariableSizeSentinel); |
| 2667 if (!maybe_obj->ToObject(&obj)) return false; | 2710 if (!maybe_obj->ToObject(&obj)) return false; |
| 2668 } | 2711 } |
| 2669 set_free_space_map(Map::cast(obj)); | 2712 set_free_space_map(Map::cast(obj)); |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2903 if (!maybe_result->ToObject(&result)) return maybe_result; | 2946 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 2904 } | 2947 } |
| 2905 | 2948 |
| 2906 HeapObject::cast(result)->set_map_no_write_barrier(heap_number_map()); | 2949 HeapObject::cast(result)->set_map_no_write_barrier(heap_number_map()); |
| 2907 HeapNumber::cast(result)->set_value(value); | 2950 HeapNumber::cast(result)->set_value(value); |
| 2908 return result; | 2951 return result; |
| 2909 } | 2952 } |
| 2910 | 2953 |
| 2911 | 2954 |
| 2912 MaybeObject* Heap::AllocateCell(Object* value) { | 2955 MaybeObject* Heap::AllocateCell(Object* value) { |
| 2956 int size = Cell::kSize; |
| 2957 STATIC_ASSERT(Cell::kSize <= Page::kNonCodeObjectAreaSize); |
| 2958 |
| 2913 Object* result; | 2959 Object* result; |
| 2914 { MaybeObject* maybe_result = AllocateRawCell(); | 2960 { MaybeObject* maybe_result = AllocateRaw(size, CELL_SPACE, CELL_SPACE); |
| 2915 if (!maybe_result->ToObject(&result)) return maybe_result; | 2961 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 2916 } | 2962 } |
| 2917 HeapObject::cast(result)->set_map_no_write_barrier(cell_map()); | 2963 HeapObject::cast(result)->set_map_no_write_barrier(cell_map()); |
| 2918 Cell::cast(result)->set_value(value); | 2964 Cell::cast(result)->set_value(value); |
| 2919 return result; | 2965 return result; |
| 2920 } | 2966 } |
| 2921 | 2967 |
| 2922 | 2968 |
| 2923 MaybeObject* Heap::AllocatePropertyCell(Object* value) { | 2969 MaybeObject* Heap::AllocatePropertyCell() { |
| 2970 int size = PropertyCell::kSize; |
| 2971 STATIC_ASSERT(PropertyCell::kSize <= Page::kNonCodeObjectAreaSize); |
| 2972 |
| 2924 Object* result; | 2973 Object* result; |
| 2925 MaybeObject* maybe_result = AllocateRawPropertyCell(); | 2974 MaybeObject* maybe_result = |
| 2975 AllocateRaw(size, PROPERTY_CELL_SPACE, PROPERTY_CELL_SPACE); |
| 2926 if (!maybe_result->ToObject(&result)) return maybe_result; | 2976 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 2927 | 2977 |
| 2928 HeapObject::cast(result)->set_map_no_write_barrier( | 2978 HeapObject::cast(result)->set_map_no_write_barrier( |
| 2929 global_property_cell_map()); | 2979 global_property_cell_map()); |
| 2930 PropertyCell* cell = PropertyCell::cast(result); | 2980 PropertyCell* cell = PropertyCell::cast(result); |
| 2931 cell->set_dependent_code(DependentCode::cast(empty_fixed_array()), | 2981 cell->set_dependent_code(DependentCode::cast(empty_fixed_array()), |
| 2932 SKIP_WRITE_BARRIER); | 2982 SKIP_WRITE_BARRIER); |
| 2933 cell->set_value(value); | 2983 cell->set_value(the_hole_value()); |
| 2934 cell->set_type(Type::None()); | 2984 cell->set_type(Type::None()); |
| 2935 maybe_result = cell->SetValueInferType(value); | |
| 2936 if (maybe_result->IsFailure()) return maybe_result; | |
| 2937 return result; | 2985 return result; |
| 2938 } | 2986 } |
| 2939 | 2987 |
| 2940 | 2988 |
| 2941 MaybeObject* Heap::AllocateBox(Object* value, PretenureFlag pretenure) { | 2989 MaybeObject* Heap::AllocateBox(Object* value, PretenureFlag pretenure) { |
| 2942 Box* result; | 2990 Box* result; |
| 2943 MaybeObject* maybe_result = AllocateStruct(BOX_TYPE); | 2991 MaybeObject* maybe_result = AllocateStruct(BOX_TYPE); |
| 2944 if (!maybe_result->To(&result)) return maybe_result; | 2992 if (!maybe_result->To(&result)) return maybe_result; |
| 2945 result->set_value(value); | 2993 result->set_value(value); |
| 2946 return result; | 2994 return result; |
| (...skipping 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4097 external_pointer); | 4145 external_pointer); |
| 4098 | 4146 |
| 4099 return result; | 4147 return result; |
| 4100 } | 4148 } |
| 4101 | 4149 |
| 4102 | 4150 |
| 4103 MaybeObject* Heap::CreateCode(const CodeDesc& desc, | 4151 MaybeObject* Heap::CreateCode(const CodeDesc& desc, |
| 4104 Code::Flags flags, | 4152 Code::Flags flags, |
| 4105 Handle<Object> self_reference, | 4153 Handle<Object> self_reference, |
| 4106 bool immovable, | 4154 bool immovable, |
| 4107 bool crankshafted) { | 4155 bool crankshafted, |
| 4156 int prologue_offset) { |
| 4108 // Allocate ByteArray before the Code object, so that we do not risk | 4157 // Allocate ByteArray before the Code object, so that we do not risk |
| 4109 // leaving uninitialized Code object (and breaking the heap). | 4158 // leaving uninitialized Code object (and breaking the heap). |
| 4110 ByteArray* reloc_info; | 4159 ByteArray* reloc_info; |
| 4111 MaybeObject* maybe_reloc_info = AllocateByteArray(desc.reloc_size, TENURED); | 4160 MaybeObject* maybe_reloc_info = AllocateByteArray(desc.reloc_size, TENURED); |
| 4112 if (!maybe_reloc_info->To(&reloc_info)) return maybe_reloc_info; | 4161 if (!maybe_reloc_info->To(&reloc_info)) return maybe_reloc_info; |
| 4113 | 4162 |
| 4114 // Compute size. | 4163 // Compute size. |
| 4115 int body_size = RoundUp(desc.instr_size, kObjectAlignment); | 4164 int body_size = RoundUp(desc.instr_size, kObjectAlignment); |
| 4116 int obj_size = Code::SizeFor(body_size); | 4165 int obj_size = Code::SizeFor(body_size); |
| 4117 ASSERT(IsAligned(static_cast<intptr_t>(obj_size), kCodeAlignment)); | 4166 ASSERT(IsAligned(static_cast<intptr_t>(obj_size), kCodeAlignment)); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 4147 code->set_flags(flags); | 4196 code->set_flags(flags); |
| 4148 if (code->is_call_stub() || code->is_keyed_call_stub()) { | 4197 if (code->is_call_stub() || code->is_keyed_call_stub()) { |
| 4149 code->set_check_type(RECEIVER_MAP_CHECK); | 4198 code->set_check_type(RECEIVER_MAP_CHECK); |
| 4150 } | 4199 } |
| 4151 code->set_is_crankshafted(crankshafted); | 4200 code->set_is_crankshafted(crankshafted); |
| 4152 code->set_deoptimization_data(empty_fixed_array(), SKIP_WRITE_BARRIER); | 4201 code->set_deoptimization_data(empty_fixed_array(), SKIP_WRITE_BARRIER); |
| 4153 code->InitializeTypeFeedbackInfoNoWriteBarrier(undefined_value()); | 4202 code->InitializeTypeFeedbackInfoNoWriteBarrier(undefined_value()); |
| 4154 code->set_handler_table(empty_fixed_array(), SKIP_WRITE_BARRIER); | 4203 code->set_handler_table(empty_fixed_array(), SKIP_WRITE_BARRIER); |
| 4155 code->set_gc_metadata(Smi::FromInt(0)); | 4204 code->set_gc_metadata(Smi::FromInt(0)); |
| 4156 code->set_ic_age(global_ic_age_); | 4205 code->set_ic_age(global_ic_age_); |
| 4157 code->set_prologue_offset(kPrologueOffsetNotSet); | 4206 code->set_prologue_offset(prologue_offset); |
| 4158 if (code->kind() == Code::OPTIMIZED_FUNCTION) { | 4207 if (code->kind() == Code::OPTIMIZED_FUNCTION) { |
| 4159 code->set_marked_for_deoptimization(false); | 4208 code->set_marked_for_deoptimization(false); |
| 4160 } | 4209 } |
| 4210 |
| 4211 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 4212 if (code->kind() == Code::FUNCTION) { |
| 4213 code->set_has_debug_break_slots( |
| 4214 isolate_->debugger()->IsDebuggerActive()); |
| 4215 } |
| 4216 #endif |
| 4217 |
| 4161 // Allow self references to created code object by patching the handle to | 4218 // Allow self references to created code object by patching the handle to |
| 4162 // point to the newly allocated Code object. | 4219 // point to the newly allocated Code object. |
| 4163 if (!self_reference.is_null()) { | 4220 if (!self_reference.is_null()) { |
| 4164 *(self_reference.location()) = code; | 4221 *(self_reference.location()) = code; |
| 4165 } | 4222 } |
| 4166 // Migrate generated code. | 4223 // Migrate generated code. |
| 4167 // The generated code can contain Object** values (typically from handles) | 4224 // The generated code can contain Object** values (typically from handles) |
| 4168 // that are dereferenced during the copy to point directly to the actual heap | 4225 // that are dereferenced during the copy to point directly to the actual heap |
| 4169 // objects. These pointers can include references to the code object itself, | 4226 // objects. These pointers can include references to the code object itself, |
| 4170 // through the self_reference parameter. | 4227 // through the self_reference parameter. |
| (...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4806 if (!maybe_result->To<JSFunctionProxy>(&result)) return maybe_result; | 4863 if (!maybe_result->To<JSFunctionProxy>(&result)) return maybe_result; |
| 4807 result->InitializeBody(map->instance_size(), Smi::FromInt(0)); | 4864 result->InitializeBody(map->instance_size(), Smi::FromInt(0)); |
| 4808 result->set_handler(handler); | 4865 result->set_handler(handler); |
| 4809 result->set_hash(undefined_value(), SKIP_WRITE_BARRIER); | 4866 result->set_hash(undefined_value(), SKIP_WRITE_BARRIER); |
| 4810 result->set_call_trap(call_trap); | 4867 result->set_call_trap(call_trap); |
| 4811 result->set_construct_trap(construct_trap); | 4868 result->set_construct_trap(construct_trap); |
| 4812 return result; | 4869 return result; |
| 4813 } | 4870 } |
| 4814 | 4871 |
| 4815 | 4872 |
| 4816 MaybeObject* Heap::AllocateGlobalObject(JSFunction* constructor) { | |
| 4817 ASSERT(constructor->has_initial_map()); | |
| 4818 Map* map = constructor->initial_map(); | |
| 4819 ASSERT(map->is_dictionary_map()); | |
| 4820 | |
| 4821 // Make sure no field properties are described in the initial map. | |
| 4822 // This guarantees us that normalizing the properties does not | |
| 4823 // require us to change property values to PropertyCells. | |
| 4824 ASSERT(map->NextFreePropertyIndex() == 0); | |
| 4825 | |
| 4826 // Make sure we don't have a ton of pre-allocated slots in the | |
| 4827 // global objects. They will be unused once we normalize the object. | |
| 4828 ASSERT(map->unused_property_fields() == 0); | |
| 4829 ASSERT(map->inobject_properties() == 0); | |
| 4830 | |
| 4831 // Initial size of the backing store to avoid resize of the storage during | |
| 4832 // bootstrapping. The size differs between the JS global object ad the | |
| 4833 // builtins object. | |
| 4834 int initial_size = map->instance_type() == JS_GLOBAL_OBJECT_TYPE ? 64 : 512; | |
| 4835 | |
| 4836 // Allocate a dictionary object for backing storage. | |
| 4837 NameDictionary* dictionary; | |
| 4838 MaybeObject* maybe_dictionary = | |
| 4839 NameDictionary::Allocate( | |
| 4840 this, | |
| 4841 map->NumberOfOwnDescriptors() * 2 + initial_size); | |
| 4842 if (!maybe_dictionary->To(&dictionary)) return maybe_dictionary; | |
| 4843 | |
| 4844 // The global object might be created from an object template with accessors. | |
| 4845 // Fill these accessors into the dictionary. | |
| 4846 DescriptorArray* descs = map->instance_descriptors(); | |
| 4847 for (int i = 0; i < map->NumberOfOwnDescriptors(); i++) { | |
| 4848 PropertyDetails details = descs->GetDetails(i); | |
| 4849 ASSERT(details.type() == CALLBACKS); // Only accessors are expected. | |
| 4850 PropertyDetails d = PropertyDetails(details.attributes(), CALLBACKS, i + 1); | |
| 4851 Object* value = descs->GetCallbacksObject(i); | |
| 4852 MaybeObject* maybe_value = AllocatePropertyCell(value); | |
| 4853 if (!maybe_value->ToObject(&value)) return maybe_value; | |
| 4854 | |
| 4855 MaybeObject* maybe_added = dictionary->Add(descs->GetKey(i), value, d); | |
| 4856 if (!maybe_added->To(&dictionary)) return maybe_added; | |
| 4857 } | |
| 4858 | |
| 4859 // Allocate the global object and initialize it with the backing store. | |
| 4860 JSObject* global; | |
| 4861 MaybeObject* maybe_global = Allocate(map, OLD_POINTER_SPACE); | |
| 4862 if (!maybe_global->To(&global)) return maybe_global; | |
| 4863 | |
| 4864 InitializeJSObjectFromMap(global, dictionary, map); | |
| 4865 | |
| 4866 // Create a new map for the global object. | |
| 4867 Map* new_map; | |
| 4868 MaybeObject* maybe_map = map->CopyDropDescriptors(); | |
| 4869 if (!maybe_map->To(&new_map)) return maybe_map; | |
| 4870 new_map->set_dictionary_map(true); | |
| 4871 | |
| 4872 // Set up the global object as a normalized object. | |
| 4873 global->set_map(new_map); | |
| 4874 global->set_properties(dictionary); | |
| 4875 | |
| 4876 // Make sure result is a global object with properties in dictionary. | |
| 4877 ASSERT(global->IsGlobalObject()); | |
| 4878 ASSERT(!global->HasFastProperties()); | |
| 4879 return global; | |
| 4880 } | |
| 4881 | |
| 4882 | |
| 4883 MaybeObject* Heap::CopyJSObject(JSObject* source, AllocationSite* site) { | 4873 MaybeObject* Heap::CopyJSObject(JSObject* source, AllocationSite* site) { |
| 4884 // Never used to copy functions. If functions need to be copied we | 4874 // Never used to copy functions. If functions need to be copied we |
| 4885 // have to be careful to clear the literals array. | 4875 // have to be careful to clear the literals array. |
| 4886 SLOW_ASSERT(!source->IsJSFunction()); | 4876 SLOW_ASSERT(!source->IsJSFunction()); |
| 4887 | 4877 |
| 4888 // Make the clone. | 4878 // Make the clone. |
| 4889 Map* map = source->map(); | 4879 Map* map = source->map(); |
| 4890 int object_size = map->instance_size(); | 4880 int object_size = map->instance_size(); |
| 4891 Object* clone; | 4881 Object* clone; |
| 4892 | 4882 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4925 CopyBlock(HeapObject::cast(clone)->address(), | 4915 CopyBlock(HeapObject::cast(clone)->address(), |
| 4926 source->address(), | 4916 source->address(), |
| 4927 object_size); | 4917 object_size); |
| 4928 | 4918 |
| 4929 if (site != NULL) { | 4919 if (site != NULL) { |
| 4930 AllocationMemento* alloc_memento = reinterpret_cast<AllocationMemento*>( | 4920 AllocationMemento* alloc_memento = reinterpret_cast<AllocationMemento*>( |
| 4931 reinterpret_cast<Address>(clone) + object_size); | 4921 reinterpret_cast<Address>(clone) + object_size); |
| 4932 alloc_memento->set_map_no_write_barrier(allocation_memento_map()); | 4922 alloc_memento->set_map_no_write_barrier(allocation_memento_map()); |
| 4933 ASSERT(site->map() == allocation_site_map()); | 4923 ASSERT(site->map() == allocation_site_map()); |
| 4934 alloc_memento->set_allocation_site(site, SKIP_WRITE_BARRIER); | 4924 alloc_memento->set_allocation_site(site, SKIP_WRITE_BARRIER); |
| 4925 HeapProfiler* profiler = isolate()->heap_profiler(); |
| 4926 if (profiler->is_tracking_allocations()) { |
| 4927 profiler->UpdateObjectSizeEvent(HeapObject::cast(clone)->address(), |
| 4928 object_size); |
| 4929 profiler->NewObjectEvent(alloc_memento->address(), |
| 4930 AllocationMemento::kSize); |
| 4931 } |
| 4935 } | 4932 } |
| 4936 } | 4933 } |
| 4937 | 4934 |
| 4938 SLOW_ASSERT( | 4935 SLOW_ASSERT( |
| 4939 JSObject::cast(clone)->GetElementsKind() == source->GetElementsKind()); | 4936 JSObject::cast(clone)->GetElementsKind() == source->GetElementsKind()); |
| 4940 FixedArrayBase* elements = FixedArrayBase::cast(source->elements()); | 4937 FixedArrayBase* elements = FixedArrayBase::cast(source->elements()); |
| 4941 FixedArray* properties = FixedArray::cast(source->properties()); | 4938 FixedArray* properties = FixedArray::cast(source->properties()); |
| 4942 // Update elements if necessary. | 4939 // Update elements if necessary. |
| 4943 if (elements->length() > 0) { | 4940 if (elements->length() > 0) { |
| 4944 Object* elem; | 4941 Object* elem; |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5374 HeapObject* dst = HeapObject::cast(obj); | 5371 HeapObject* dst = HeapObject::cast(obj); |
| 5375 dst->set_map_no_write_barrier(map); | 5372 dst->set_map_no_write_barrier(map); |
| 5376 CopyBlock( | 5373 CopyBlock( |
| 5377 dst->address() + FixedDoubleArray::kLengthOffset, | 5374 dst->address() + FixedDoubleArray::kLengthOffset, |
| 5378 src->address() + FixedDoubleArray::kLengthOffset, | 5375 src->address() + FixedDoubleArray::kLengthOffset, |
| 5379 FixedDoubleArray::SizeFor(len) - FixedDoubleArray::kLengthOffset); | 5376 FixedDoubleArray::SizeFor(len) - FixedDoubleArray::kLengthOffset); |
| 5380 return obj; | 5377 return obj; |
| 5381 } | 5378 } |
| 5382 | 5379 |
| 5383 | 5380 |
| 5381 MaybeObject* Heap::CopyConstantPoolArrayWithMap(ConstantPoolArray* src, |
| 5382 Map* map) { |
| 5383 int int64_entries = src->count_of_int64_entries(); |
| 5384 int ptr_entries = src->count_of_ptr_entries(); |
| 5385 int int32_entries = src->count_of_int32_entries(); |
| 5386 Object* obj; |
| 5387 { MaybeObject* maybe_obj = |
| 5388 AllocateConstantPoolArray(int64_entries, ptr_entries, int32_entries); |
| 5389 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 5390 } |
| 5391 HeapObject* dst = HeapObject::cast(obj); |
| 5392 dst->set_map_no_write_barrier(map); |
| 5393 CopyBlock( |
| 5394 dst->address() + ConstantPoolArray::kLengthOffset, |
| 5395 src->address() + ConstantPoolArray::kLengthOffset, |
| 5396 ConstantPoolArray::SizeFor(int64_entries, ptr_entries, int32_entries) |
| 5397 - ConstantPoolArray::kLengthOffset); |
| 5398 return obj; |
| 5399 } |
| 5400 |
| 5401 |
| 5384 MaybeObject* Heap::AllocateRawFixedArray(int length, PretenureFlag pretenure) { | 5402 MaybeObject* Heap::AllocateRawFixedArray(int length, PretenureFlag pretenure) { |
| 5385 if (length < 0 || length > FixedArray::kMaxLength) { | 5403 if (length < 0 || length > FixedArray::kMaxLength) { |
| 5386 return Failure::OutOfMemoryException(0xe); | 5404 return Failure::OutOfMemoryException(0xe); |
| 5387 } | 5405 } |
| 5388 int size = FixedArray::SizeFor(length); | 5406 int size = FixedArray::SizeFor(length); |
| 5389 AllocationSpace space = SelectSpace(size, OLD_POINTER_SPACE, pretenure); | 5407 AllocationSpace space = SelectSpace(size, OLD_POINTER_SPACE, pretenure); |
| 5390 | 5408 |
| 5391 return AllocateRaw(size, space, OLD_POINTER_SPACE); | 5409 return AllocateRaw(size, space, OLD_POINTER_SPACE); |
| 5392 } | 5410 } |
| 5393 | 5411 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5505 | 5523 |
| 5506 HeapObject* object; | 5524 HeapObject* object; |
| 5507 { MaybeObject* maybe_object = AllocateRaw(size, space, OLD_DATA_SPACE); | 5525 { MaybeObject* maybe_object = AllocateRaw(size, space, OLD_DATA_SPACE); |
| 5508 if (!maybe_object->To<HeapObject>(&object)) return maybe_object; | 5526 if (!maybe_object->To<HeapObject>(&object)) return maybe_object; |
| 5509 } | 5527 } |
| 5510 | 5528 |
| 5511 return EnsureDoubleAligned(this, object, size); | 5529 return EnsureDoubleAligned(this, object, size); |
| 5512 } | 5530 } |
| 5513 | 5531 |
| 5514 | 5532 |
| 5533 MaybeObject* Heap::AllocateConstantPoolArray(int number_of_int64_entries, |
| 5534 int number_of_ptr_entries, |
| 5535 int number_of_int32_entries) { |
| 5536 ASSERT(number_of_int64_entries > 0 || number_of_ptr_entries > 0 || |
| 5537 number_of_int32_entries > 0); |
| 5538 int size = ConstantPoolArray::SizeFor(number_of_int64_entries, |
| 5539 number_of_ptr_entries, |
| 5540 number_of_int32_entries); |
| 5541 #ifndef V8_HOST_ARCH_64_BIT |
| 5542 size += kPointerSize; |
| 5543 #endif |
| 5544 AllocationSpace space = SelectSpace(size, OLD_POINTER_SPACE, TENURED); |
| 5545 |
| 5546 HeapObject* object; |
| 5547 { MaybeObject* maybe_object = AllocateRaw(size, space, OLD_POINTER_SPACE); |
| 5548 if (!maybe_object->To<HeapObject>(&object)) return maybe_object; |
| 5549 } |
| 5550 object = EnsureDoubleAligned(this, object, size); |
| 5551 HeapObject::cast(object)->set_map_no_write_barrier(constant_pool_array_map()); |
| 5552 |
| 5553 ConstantPoolArray* constant_pool = |
| 5554 reinterpret_cast<ConstantPoolArray*>(object); |
| 5555 constant_pool->SetEntryCounts(number_of_int64_entries, |
| 5556 number_of_ptr_entries, |
| 5557 number_of_int32_entries); |
| 5558 MemsetPointer( |
| 5559 HeapObject::RawField( |
| 5560 constant_pool, |
| 5561 constant_pool->OffsetOfElementAt(constant_pool->first_ptr_index())), |
| 5562 undefined_value(), |
| 5563 number_of_ptr_entries); |
| 5564 return constant_pool; |
| 5565 } |
| 5566 |
| 5567 |
| 5515 MaybeObject* Heap::AllocateHashTable(int length, PretenureFlag pretenure) { | 5568 MaybeObject* Heap::AllocateHashTable(int length, PretenureFlag pretenure) { |
| 5516 Object* result; | 5569 Object* result; |
| 5517 { MaybeObject* maybe_result = AllocateFixedArray(length, pretenure); | 5570 { MaybeObject* maybe_result = AllocateFixedArray(length, pretenure); |
| 5518 if (!maybe_result->ToObject(&result)) return maybe_result; | 5571 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 5519 } | 5572 } |
| 5520 reinterpret_cast<HeapObject*>(result)->set_map_no_write_barrier( | 5573 reinterpret_cast<HeapObject*>(result)->set_map_no_write_barrier( |
| 5521 hash_table_map()); | 5574 hash_table_map()); |
| 5522 ASSERT(result->IsHashTable()); | 5575 ASSERT(result->IsHashTable()); |
| 5523 return result; | 5576 return result; |
| 5524 } | 5577 } |
| (...skipping 1359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6884 | 6937 |
| 6885 | 6938 |
| 6886 MaybeObject* Heap::AddWeakObjectToCodeDependency(Object* obj, | 6939 MaybeObject* Heap::AddWeakObjectToCodeDependency(Object* obj, |
| 6887 DependentCode* dep) { | 6940 DependentCode* dep) { |
| 6888 ASSERT(!InNewSpace(obj)); | 6941 ASSERT(!InNewSpace(obj)); |
| 6889 ASSERT(!InNewSpace(dep)); | 6942 ASSERT(!InNewSpace(dep)); |
| 6890 MaybeObject* maybe_obj = | 6943 MaybeObject* maybe_obj = |
| 6891 WeakHashTable::cast(weak_object_to_code_table_)->Put(obj, dep); | 6944 WeakHashTable::cast(weak_object_to_code_table_)->Put(obj, dep); |
| 6892 WeakHashTable* table; | 6945 WeakHashTable* table; |
| 6893 if (!maybe_obj->To(&table)) return maybe_obj; | 6946 if (!maybe_obj->To(&table)) return maybe_obj; |
| 6947 if (ShouldZapGarbage() && weak_object_to_code_table_ != table) { |
| 6948 WeakHashTable::cast(weak_object_to_code_table_)->Zap(the_hole_value()); |
| 6949 } |
| 6894 set_weak_object_to_code_table(table); | 6950 set_weak_object_to_code_table(table); |
| 6895 ASSERT_EQ(dep, WeakHashTable::cast(weak_object_to_code_table_)->Lookup(obj)); | 6951 ASSERT_EQ(dep, WeakHashTable::cast(weak_object_to_code_table_)->Lookup(obj)); |
| 6896 return weak_object_to_code_table_; | 6952 return weak_object_to_code_table_; |
| 6897 } | 6953 } |
| 6898 | 6954 |
| 6899 | 6955 |
| 6900 DependentCode* Heap::LookupWeakObjectToCodeDependency(Object* obj) { | 6956 DependentCode* Heap::LookupWeakObjectToCodeDependency(Object* obj) { |
| 6901 Object* dep = WeakHashTable::cast(weak_object_to_code_table_)->Lookup(obj); | 6957 Object* dep = WeakHashTable::cast(weak_object_to_code_table_)->Lookup(obj); |
| 6902 if (dep->IsDependentCode()) return DependentCode::cast(dep); | 6958 if (dep->IsDependentCode()) return DependentCode::cast(dep); |
| 6903 return DependentCode::cast(empty_fixed_array()); | 6959 return DependentCode::cast(empty_fixed_array()); |
| (...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7886 counters->count_of_FIXED_ARRAY_##name()->Increment( \ | 7942 counters->count_of_FIXED_ARRAY_##name()->Increment( \ |
| 7887 static_cast<int>(object_counts_[index])); \ | 7943 static_cast<int>(object_counts_[index])); \ |
| 7888 counters->count_of_FIXED_ARRAY_##name()->Decrement( \ | 7944 counters->count_of_FIXED_ARRAY_##name()->Decrement( \ |
| 7889 static_cast<int>(object_counts_last_time_[index])); \ | 7945 static_cast<int>(object_counts_last_time_[index])); \ |
| 7890 counters->size_of_FIXED_ARRAY_##name()->Increment( \ | 7946 counters->size_of_FIXED_ARRAY_##name()->Increment( \ |
| 7891 static_cast<int>(object_sizes_[index])); \ | 7947 static_cast<int>(object_sizes_[index])); \ |
| 7892 counters->size_of_FIXED_ARRAY_##name()->Decrement( \ | 7948 counters->size_of_FIXED_ARRAY_##name()->Decrement( \ |
| 7893 static_cast<int>(object_sizes_last_time_[index])); | 7949 static_cast<int>(object_sizes_last_time_[index])); |
| 7894 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) | 7950 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) |
| 7895 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 7951 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
| 7952 #define ADJUST_LAST_TIME_OBJECT_COUNT(name) \ |
| 7953 index = FIRST_CODE_AGE_SUB_TYPE + Code::k##name##CodeAge; \ |
| 7954 counters->count_of_CODE_AGE_##name()->Increment( \ |
| 7955 static_cast<int>(object_counts_[index])); \ |
| 7956 counters->count_of_CODE_AGE_##name()->Decrement( \ |
| 7957 static_cast<int>(object_counts_last_time_[index])); \ |
| 7958 counters->size_of_CODE_AGE_##name()->Increment( \ |
| 7959 static_cast<int>(object_sizes_[index])); \ |
| 7960 counters->size_of_CODE_AGE_##name()->Decrement( \ |
| 7961 static_cast<int>(object_sizes_last_time_[index])); |
| 7962 CODE_AGE_LIST_WITH_NO_AGE(ADJUST_LAST_TIME_OBJECT_COUNT) |
| 7963 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
| 7896 | 7964 |
| 7897 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 7965 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
| 7898 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 7966 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
| 7899 ClearObjectStats(); | 7967 ClearObjectStats(); |
| 7900 } | 7968 } |
| 7901 | 7969 |
| 7902 | 7970 |
| 7903 Heap::RelocationLock::RelocationLock(Heap* heap) : heap_(heap) { | 7971 Heap::RelocationLock::RelocationLock(Heap* heap) : heap_(heap) { |
| 7904 if (FLAG_concurrent_recompilation) { | 7972 if (FLAG_concurrent_recompilation) { |
| 7905 heap_->relocation_mutex_->Lock(); | 7973 heap_->relocation_mutex_->Lock(); |
| 7906 #ifdef DEBUG | 7974 #ifdef DEBUG |
| 7907 heap_->relocation_mutex_locked_by_optimizer_thread_ = | 7975 heap_->relocation_mutex_locked_by_optimizer_thread_ = |
| 7908 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); | 7976 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); |
| 7909 #endif // DEBUG | 7977 #endif // DEBUG |
| 7910 } | 7978 } |
| 7911 } | 7979 } |
| 7912 | 7980 |
| 7913 } } // namespace v8::internal | 7981 } } // namespace v8::internal |
| OLD | NEW |