Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(556)

Side by Side Diff: src/heap.cc

Issue 30023003: Remove specialized raw Cell and Map allocators. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed offline comments. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/heap.h ('k') | src/heap-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2418 matching lines...) Expand 10 before | Expand all | Expand 10 after
2429 MapWord first_word = object->map_word(); 2429 MapWord first_word = object->map_word();
2430 SLOW_ASSERT(!first_word.IsForwardingAddress()); 2430 SLOW_ASSERT(!first_word.IsForwardingAddress());
2431 Map* map = first_word.ToMap(); 2431 Map* map = first_word.ToMap();
2432 map->GetHeap()->DoScavengeObject(map, p, object); 2432 map->GetHeap()->DoScavengeObject(map, p, object);
2433 } 2433 }
2434 2434
2435 2435
2436 MaybeObject* Heap::AllocatePartialMap(InstanceType instance_type, 2436 MaybeObject* Heap::AllocatePartialMap(InstanceType instance_type,
2437 int instance_size) { 2437 int instance_size) {
2438 Object* result; 2438 Object* result;
2439 MaybeObject* maybe_result = AllocateRawMap(); 2439 MaybeObject* maybe_result = AllocateRaw(Map::kSize, MAP_SPACE, MAP_SPACE);
2440 if (!maybe_result->ToObject(&result)) return maybe_result; 2440 if (!maybe_result->ToObject(&result)) return maybe_result;
2441 2441
2442 // Map::cast cannot be used due to uninitialized map field. 2442 // Map::cast cannot be used due to uninitialized map field.
2443 reinterpret_cast<Map*>(result)->set_map(raw_unchecked_meta_map()); 2443 reinterpret_cast<Map*>(result)->set_map(raw_unchecked_meta_map());
2444 reinterpret_cast<Map*>(result)->set_instance_type(instance_type); 2444 reinterpret_cast<Map*>(result)->set_instance_type(instance_type);
2445 reinterpret_cast<Map*>(result)->set_instance_size(instance_size); 2445 reinterpret_cast<Map*>(result)->set_instance_size(instance_size);
2446 reinterpret_cast<Map*>(result)->set_visitor_id( 2446 reinterpret_cast<Map*>(result)->set_visitor_id(
2447 StaticVisitorBase::GetVisitorId(instance_type, instance_size)); 2447 StaticVisitorBase::GetVisitorId(instance_type, instance_size));
2448 reinterpret_cast<Map*>(result)->set_inobject_properties(0); 2448 reinterpret_cast<Map*>(result)->set_inobject_properties(0);
2449 reinterpret_cast<Map*>(result)->set_pre_allocated_property_fields(0); 2449 reinterpret_cast<Map*>(result)->set_pre_allocated_property_fields(0);
2450 reinterpret_cast<Map*>(result)->set_unused_property_fields(0); 2450 reinterpret_cast<Map*>(result)->set_unused_property_fields(0);
2451 reinterpret_cast<Map*>(result)->set_bit_field(0); 2451 reinterpret_cast<Map*>(result)->set_bit_field(0);
2452 reinterpret_cast<Map*>(result)->set_bit_field2(0); 2452 reinterpret_cast<Map*>(result)->set_bit_field2(0);
2453 int bit_field3 = Map::EnumLengthBits::encode(Map::kInvalidEnumCache) | 2453 int bit_field3 = Map::EnumLengthBits::encode(Map::kInvalidEnumCache) |
2454 Map::OwnsDescriptors::encode(true); 2454 Map::OwnsDescriptors::encode(true);
2455 reinterpret_cast<Map*>(result)->set_bit_field3(bit_field3); 2455 reinterpret_cast<Map*>(result)->set_bit_field3(bit_field3);
2456 return result; 2456 return result;
2457 } 2457 }
2458 2458
2459 2459
2460 MaybeObject* Heap::AllocateMap(InstanceType instance_type, 2460 MaybeObject* Heap::AllocateMap(InstanceType instance_type,
2461 int instance_size, 2461 int instance_size,
2462 ElementsKind elements_kind) { 2462 ElementsKind elements_kind) {
2463 Object* result; 2463 Object* result;
2464 MaybeObject* maybe_result = AllocateRawMap(); 2464 MaybeObject* maybe_result = AllocateRaw(Map::kSize, MAP_SPACE, MAP_SPACE);
2465 if (!maybe_result->To(&result)) return maybe_result; 2465 if (!maybe_result->To(&result)) return maybe_result;
2466 2466
2467 Map* map = reinterpret_cast<Map*>(result); 2467 Map* map = reinterpret_cast<Map*>(result);
2468 map->set_map_no_write_barrier(meta_map()); 2468 map->set_map_no_write_barrier(meta_map());
2469 map->set_instance_type(instance_type); 2469 map->set_instance_type(instance_type);
2470 map->set_visitor_id( 2470 map->set_visitor_id(
2471 StaticVisitorBase::GetVisitorId(instance_type, instance_size)); 2471 StaticVisitorBase::GetVisitorId(instance_type, instance_size));
2472 map->set_prototype(null_value(), SKIP_WRITE_BARRIER); 2472 map->set_prototype(null_value(), SKIP_WRITE_BARRIER);
2473 map->set_constructor(null_value(), SKIP_WRITE_BARRIER); 2473 map->set_constructor(null_value(), SKIP_WRITE_BARRIER);
2474 map->set_instance_size(instance_size); 2474 map->set_instance_size(instance_size);
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
2946 if (!maybe_result->ToObject(&result)) return maybe_result; 2946 if (!maybe_result->ToObject(&result)) return maybe_result;
2947 } 2947 }
2948 2948
2949 HeapObject::cast(result)->set_map_no_write_barrier(heap_number_map()); 2949 HeapObject::cast(result)->set_map_no_write_barrier(heap_number_map());
2950 HeapNumber::cast(result)->set_value(value); 2950 HeapNumber::cast(result)->set_value(value);
2951 return result; 2951 return result;
2952 } 2952 }
2953 2953
2954 2954
2955 MaybeObject* Heap::AllocateCell(Object* value) { 2955 MaybeObject* Heap::AllocateCell(Object* value) {
2956 int size = Cell::kSize;
2957 STATIC_ASSERT(Cell::kSize <= Page::kNonCodeObjectAreaSize);
2958
2956 Object* result; 2959 Object* result;
2957 { MaybeObject* maybe_result = AllocateRawCell(); 2960 { MaybeObject* maybe_result = AllocateRaw(size, CELL_SPACE, CELL_SPACE);
2958 if (!maybe_result->ToObject(&result)) return maybe_result; 2961 if (!maybe_result->ToObject(&result)) return maybe_result;
2959 } 2962 }
2960 HeapObject::cast(result)->set_map_no_write_barrier(cell_map()); 2963 HeapObject::cast(result)->set_map_no_write_barrier(cell_map());
2961 Cell::cast(result)->set_value(value); 2964 Cell::cast(result)->set_value(value);
2962 return result; 2965 return result;
2963 } 2966 }
2964 2967
2965 2968
2966 MaybeObject* Heap::AllocatePropertyCell() { 2969 MaybeObject* Heap::AllocatePropertyCell() {
2970 int size = PropertyCell::kSize;
2971 STATIC_ASSERT(PropertyCell::kSize <= Page::kNonCodeObjectAreaSize);
2972
2967 Object* result; 2973 Object* result;
2968 MaybeObject* maybe_result = AllocateRawPropertyCell(); 2974 MaybeObject* maybe_result =
2975 AllocateRaw(size, PROPERTY_CELL_SPACE, PROPERTY_CELL_SPACE);
2969 if (!maybe_result->ToObject(&result)) return maybe_result; 2976 if (!maybe_result->ToObject(&result)) return maybe_result;
2970 2977
2971 HeapObject::cast(result)->set_map_no_write_barrier( 2978 HeapObject::cast(result)->set_map_no_write_barrier(
2972 global_property_cell_map()); 2979 global_property_cell_map());
2973 PropertyCell* cell = PropertyCell::cast(result); 2980 PropertyCell* cell = PropertyCell::cast(result);
2974 cell->set_dependent_code(DependentCode::cast(empty_fixed_array()), 2981 cell->set_dependent_code(DependentCode::cast(empty_fixed_array()),
2975 SKIP_WRITE_BARRIER); 2982 SKIP_WRITE_BARRIER);
2976 cell->set_value(the_hole_value()); 2983 cell->set_value(the_hole_value());
2977 cell->set_type(Type::None()); 2984 cell->set_type(Type::None());
2978 return result; 2985 return result;
(...skipping 4981 matching lines...) Expand 10 before | Expand all | Expand 10 after
7960 if (FLAG_concurrent_recompilation) { 7967 if (FLAG_concurrent_recompilation) {
7961 heap_->relocation_mutex_->Lock(); 7968 heap_->relocation_mutex_->Lock();
7962 #ifdef DEBUG 7969 #ifdef DEBUG
7963 heap_->relocation_mutex_locked_by_optimizer_thread_ = 7970 heap_->relocation_mutex_locked_by_optimizer_thread_ =
7964 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); 7971 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread();
7965 #endif // DEBUG 7972 #endif // DEBUG
7966 } 7973 }
7967 } 7974 }
7968 7975
7969 } } // namespace v8::internal 7976 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.h ('k') | src/heap-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698