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 2560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2571 if (!maybe_obj->ToObject(&obj)) return false; | 2571 if (!maybe_obj->ToObject(&obj)) return false; |
2572 } | 2572 } |
2573 set_shared_function_info_map(Map::cast(obj)); | 2573 set_shared_function_info_map(Map::cast(obj)); |
2574 | 2574 |
2575 { MaybeObject* maybe_obj = AllocateMap(JS_MESSAGE_OBJECT_TYPE, | 2575 { MaybeObject* maybe_obj = AllocateMap(JS_MESSAGE_OBJECT_TYPE, |
2576 JSMessageObject::kSize); | 2576 JSMessageObject::kSize); |
2577 if (!maybe_obj->ToObject(&obj)) return false; | 2577 if (!maybe_obj->ToObject(&obj)) return false; |
2578 } | 2578 } |
2579 set_message_object_map(Map::cast(obj)); | 2579 set_message_object_map(Map::cast(obj)); |
2580 | 2580 |
2581 Map* external_map; | |
2582 { MaybeObject* maybe_obj = | |
2583 AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize + kPointerSize); | |
2584 if (!maybe_obj->To(&external_map)) return false; | |
2585 } | |
2586 external_map->set_is_extensible(false); | |
2587 set_external_map(external_map); | |
2588 | |
2589 ASSERT(!InNewSpace(empty_fixed_array())); | 2581 ASSERT(!InNewSpace(empty_fixed_array())); |
2590 return true; | 2582 return true; |
2591 } | 2583 } |
2592 | 2584 |
2593 | 2585 |
2594 MaybeObject* Heap::AllocateHeapNumber(double value, PretenureFlag pretenure) { | 2586 MaybeObject* Heap::AllocateHeapNumber(double value, PretenureFlag pretenure) { |
2595 // Statically ensure that it is safe to allocate heap numbers in paged | 2587 // Statically ensure that it is safe to allocate heap numbers in paged |
2596 // spaces. | 2588 // spaces. |
2597 STATIC_ASSERT(HeapNumber::kSize <= Page::kNonCodeObjectAreaSize); | 2589 STATIC_ASSERT(HeapNumber::kSize <= Page::kNonCodeObjectAreaSize); |
2598 AllocationSpace space = (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE; | 2590 AllocationSpace space = (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE; |
(...skipping 2619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5218 | 5210 |
5219 MaybeObject* Heap::AllocateScopeInfo(int length) { | 5211 MaybeObject* Heap::AllocateScopeInfo(int length) { |
5220 FixedArray* scope_info; | 5212 FixedArray* scope_info; |
5221 MaybeObject* maybe_scope_info = AllocateFixedArray(length, TENURED); | 5213 MaybeObject* maybe_scope_info = AllocateFixedArray(length, TENURED); |
5222 if (!maybe_scope_info->To(&scope_info)) return maybe_scope_info; | 5214 if (!maybe_scope_info->To(&scope_info)) return maybe_scope_info; |
5223 scope_info->set_map_no_write_barrier(scope_info_map()); | 5215 scope_info->set_map_no_write_barrier(scope_info_map()); |
5224 return scope_info; | 5216 return scope_info; |
5225 } | 5217 } |
5226 | 5218 |
5227 | 5219 |
5228 MaybeObject* Heap::AllocateExternal(void* value) { | |
5229 Foreign* foreign; | |
5230 { MaybeObject* maybe_result = AllocateForeign(static_cast<Address>(value)); | |
5231 if (!maybe_result->To(&foreign)) return maybe_result; | |
5232 } | |
5233 JSObject* external; | |
5234 { MaybeObject* maybe_result = AllocateJSObjectFromMap(external_map()); | |
5235 if (!maybe_result->To(&external)) return maybe_result; | |
5236 } | |
5237 external->SetInternalField(0, foreign); | |
5238 return external; | |
5239 } | |
5240 | |
5241 | |
5242 MaybeObject* Heap::AllocateStruct(InstanceType type) { | 5220 MaybeObject* Heap::AllocateStruct(InstanceType type) { |
5243 Map* map; | 5221 Map* map; |
5244 switch (type) { | 5222 switch (type) { |
5245 #define MAKE_CASE(NAME, Name, name) \ | 5223 #define MAKE_CASE(NAME, Name, name) \ |
5246 case NAME##_TYPE: map = name##_map(); break; | 5224 case NAME##_TYPE: map = name##_map(); break; |
5247 STRUCT_LIST(MAKE_CASE) | 5225 STRUCT_LIST(MAKE_CASE) |
5248 #undef MAKE_CASE | 5226 #undef MAKE_CASE |
5249 default: | 5227 default: |
5250 UNREACHABLE(); | 5228 UNREACHABLE(); |
5251 return Failure::InternalError(); | 5229 return Failure::InternalError(); |
(...skipping 2249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7501 static_cast<int>(object_sizes_last_time_[index])); | 7479 static_cast<int>(object_sizes_last_time_[index])); |
7502 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) | 7480 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) |
7503 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 7481 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
7504 | 7482 |
7505 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 7483 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
7506 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 7484 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
7507 ClearObjectStats(); | 7485 ClearObjectStats(); |
7508 } | 7486 } |
7509 | 7487 |
7510 } } // namespace v8::internal | 7488 } } // namespace v8::internal |
OLD | NEW |