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 2479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2490 if (!maybe_obj->ToObject(&obj)) return false; | 2490 if (!maybe_obj->ToObject(&obj)) return false; |
2491 } | 2491 } |
2492 set_shared_function_info_map(Map::cast(obj)); | 2492 set_shared_function_info_map(Map::cast(obj)); |
2493 | 2493 |
2494 { MaybeObject* maybe_obj = AllocateMap(JS_MESSAGE_OBJECT_TYPE, | 2494 { MaybeObject* maybe_obj = AllocateMap(JS_MESSAGE_OBJECT_TYPE, |
2495 JSMessageObject::kSize); | 2495 JSMessageObject::kSize); |
2496 if (!maybe_obj->ToObject(&obj)) return false; | 2496 if (!maybe_obj->ToObject(&obj)) return false; |
2497 } | 2497 } |
2498 set_message_object_map(Map::cast(obj)); | 2498 set_message_object_map(Map::cast(obj)); |
2499 | 2499 |
| 2500 Map* external_map; |
| 2501 { MaybeObject* maybe_obj = |
| 2502 AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize + kPointerSize); |
| 2503 if (!maybe_obj->To(&external_map)) return false; |
| 2504 } |
| 2505 external_map->set_is_extensible(false); |
| 2506 set_external_map(external_map); |
| 2507 |
2500 ASSERT(!InNewSpace(empty_fixed_array())); | 2508 ASSERT(!InNewSpace(empty_fixed_array())); |
2501 return true; | 2509 return true; |
2502 } | 2510 } |
2503 | 2511 |
2504 | 2512 |
2505 MaybeObject* Heap::AllocateHeapNumber(double value, PretenureFlag pretenure) { | 2513 MaybeObject* Heap::AllocateHeapNumber(double value, PretenureFlag pretenure) { |
2506 // Statically ensure that it is safe to allocate heap numbers in paged | 2514 // Statically ensure that it is safe to allocate heap numbers in paged |
2507 // spaces. | 2515 // spaces. |
2508 STATIC_ASSERT(HeapNumber::kSize <= Page::kNonCodeObjectAreaSize); | 2516 STATIC_ASSERT(HeapNumber::kSize <= Page::kNonCodeObjectAreaSize); |
2509 AllocationSpace space = (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE; | 2517 AllocationSpace space = (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE; |
(...skipping 2582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5092 | 5100 |
5093 MaybeObject* Heap::AllocateScopeInfo(int length) { | 5101 MaybeObject* Heap::AllocateScopeInfo(int length) { |
5094 FixedArray* scope_info; | 5102 FixedArray* scope_info; |
5095 MaybeObject* maybe_scope_info = AllocateFixedArray(length, TENURED); | 5103 MaybeObject* maybe_scope_info = AllocateFixedArray(length, TENURED); |
5096 if (!maybe_scope_info->To(&scope_info)) return maybe_scope_info; | 5104 if (!maybe_scope_info->To(&scope_info)) return maybe_scope_info; |
5097 scope_info->set_map_no_write_barrier(scope_info_map()); | 5105 scope_info->set_map_no_write_barrier(scope_info_map()); |
5098 return scope_info; | 5106 return scope_info; |
5099 } | 5107 } |
5100 | 5108 |
5101 | 5109 |
| 5110 MaybeObject* Heap::AllocateExternal(void* value) { |
| 5111 Foreign* foreign; |
| 5112 { MaybeObject* maybe_result = AllocateForeign(static_cast<Address>(value)); |
| 5113 if (!maybe_result->To(&foreign)) return maybe_result; |
| 5114 } |
| 5115 JSObject* external; |
| 5116 { MaybeObject* maybe_result = AllocateJSObjectFromMap(external_map()); |
| 5117 if (!maybe_result->To(&external)) return maybe_result; |
| 5118 } |
| 5119 external->SetInternalField(0, foreign); |
| 5120 return external; |
| 5121 } |
| 5122 |
| 5123 |
5102 MaybeObject* Heap::AllocateStruct(InstanceType type) { | 5124 MaybeObject* Heap::AllocateStruct(InstanceType type) { |
5103 Map* map; | 5125 Map* map; |
5104 switch (type) { | 5126 switch (type) { |
5105 #define MAKE_CASE(NAME, Name, name) \ | 5127 #define MAKE_CASE(NAME, Name, name) \ |
5106 case NAME##_TYPE: map = name##_map(); break; | 5128 case NAME##_TYPE: map = name##_map(); break; |
5107 STRUCT_LIST(MAKE_CASE) | 5129 STRUCT_LIST(MAKE_CASE) |
5108 #undef MAKE_CASE | 5130 #undef MAKE_CASE |
5109 default: | 5131 default: |
5110 UNREACHABLE(); | 5132 UNREACHABLE(); |
5111 return Failure::InternalError(); | 5133 return Failure::InternalError(); |
(...skipping 2248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7360 static_cast<int>(object_sizes_last_time_[index])); | 7382 static_cast<int>(object_sizes_last_time_[index])); |
7361 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) | 7383 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) |
7362 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 7384 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
7363 | 7385 |
7364 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 7386 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
7365 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 7387 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
7366 ClearObjectStats(); | 7388 ClearObjectStats(); |
7367 } | 7389 } |
7368 | 7390 |
7369 } } // namespace v8::internal | 7391 } } // namespace v8::internal |
OLD | NEW |