| 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 2513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2524 if (!maybe_obj->ToObject(&obj)) return false; | 2524 if (!maybe_obj->ToObject(&obj)) return false; |
| 2525 } | 2525 } |
| 2526 set_shared_function_info_map(Map::cast(obj)); | 2526 set_shared_function_info_map(Map::cast(obj)); |
| 2527 | 2527 |
| 2528 { MaybeObject* maybe_obj = AllocateMap(JS_MESSAGE_OBJECT_TYPE, | 2528 { MaybeObject* maybe_obj = AllocateMap(JS_MESSAGE_OBJECT_TYPE, |
| 2529 JSMessageObject::kSize); | 2529 JSMessageObject::kSize); |
| 2530 if (!maybe_obj->ToObject(&obj)) return false; | 2530 if (!maybe_obj->ToObject(&obj)) return false; |
| 2531 } | 2531 } |
| 2532 set_message_object_map(Map::cast(obj)); | 2532 set_message_object_map(Map::cast(obj)); |
| 2533 | 2533 |
| 2534 Map* external_map; |
| 2535 { MaybeObject* maybe_obj = |
| 2536 AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize + kPointerSize); |
| 2537 if (!maybe_obj->To(&external_map)) return false; |
| 2538 } |
| 2539 external_map->set_is_extensible(false); |
| 2540 set_external_map(external_map); |
| 2541 |
| 2534 ASSERT(!InNewSpace(empty_fixed_array())); | 2542 ASSERT(!InNewSpace(empty_fixed_array())); |
| 2535 return true; | 2543 return true; |
| 2536 } | 2544 } |
| 2537 | 2545 |
| 2538 | 2546 |
| 2539 MaybeObject* Heap::AllocateHeapNumber(double value, PretenureFlag pretenure) { | 2547 MaybeObject* Heap::AllocateHeapNumber(double value, PretenureFlag pretenure) { |
| 2540 // Statically ensure that it is safe to allocate heap numbers in paged | 2548 // Statically ensure that it is safe to allocate heap numbers in paged |
| 2541 // spaces. | 2549 // spaces. |
| 2542 STATIC_ASSERT(HeapNumber::kSize <= Page::kNonCodeObjectAreaSize); | 2550 STATIC_ASSERT(HeapNumber::kSize <= Page::kNonCodeObjectAreaSize); |
| 2543 AllocationSpace space = (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE; | 2551 AllocationSpace space = (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE; |
| (...skipping 2582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5126 | 5134 |
| 5127 MaybeObject* Heap::AllocateScopeInfo(int length) { | 5135 MaybeObject* Heap::AllocateScopeInfo(int length) { |
| 5128 FixedArray* scope_info; | 5136 FixedArray* scope_info; |
| 5129 MaybeObject* maybe_scope_info = AllocateFixedArray(length, TENURED); | 5137 MaybeObject* maybe_scope_info = AllocateFixedArray(length, TENURED); |
| 5130 if (!maybe_scope_info->To(&scope_info)) return maybe_scope_info; | 5138 if (!maybe_scope_info->To(&scope_info)) return maybe_scope_info; |
| 5131 scope_info->set_map_no_write_barrier(scope_info_map()); | 5139 scope_info->set_map_no_write_barrier(scope_info_map()); |
| 5132 return scope_info; | 5140 return scope_info; |
| 5133 } | 5141 } |
| 5134 | 5142 |
| 5135 | 5143 |
| 5144 MaybeObject* Heap::AllocateExternal(void* value) { |
| 5145 Foreign* foreign; |
| 5146 { MaybeObject* maybe_result = AllocateForeign(static_cast<Address>(value)); |
| 5147 if (!maybe_result->To(&foreign)) return maybe_result; |
| 5148 } |
| 5149 JSObject* external; |
| 5150 { MaybeObject* maybe_result = AllocateJSObjectFromMap(external_map()); |
| 5151 if (!maybe_result->To(&external)) return maybe_result; |
| 5152 } |
| 5153 external->SetInternalField(0, foreign); |
| 5154 return external; |
| 5155 } |
| 5156 |
| 5157 |
| 5136 MaybeObject* Heap::AllocateStruct(InstanceType type) { | 5158 MaybeObject* Heap::AllocateStruct(InstanceType type) { |
| 5137 Map* map; | 5159 Map* map; |
| 5138 switch (type) { | 5160 switch (type) { |
| 5139 #define MAKE_CASE(NAME, Name, name) \ | 5161 #define MAKE_CASE(NAME, Name, name) \ |
| 5140 case NAME##_TYPE: map = name##_map(); break; | 5162 case NAME##_TYPE: map = name##_map(); break; |
| 5141 STRUCT_LIST(MAKE_CASE) | 5163 STRUCT_LIST(MAKE_CASE) |
| 5142 #undef MAKE_CASE | 5164 #undef MAKE_CASE |
| 5143 default: | 5165 default: |
| 5144 UNREACHABLE(); | 5166 UNREACHABLE(); |
| 5145 return Failure::InternalError(); | 5167 return Failure::InternalError(); |
| (...skipping 2249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7395 static_cast<int>(object_sizes_last_time_[index])); | 7417 static_cast<int>(object_sizes_last_time_[index])); |
| 7396 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) | 7418 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) |
| 7397 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 7419 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
| 7398 | 7420 |
| 7399 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 7421 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
| 7400 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 7422 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
| 7401 ClearObjectStats(); | 7423 ClearObjectStats(); |
| 7402 } | 7424 } |
| 7403 | 7425 |
| 7404 } } // namespace v8::internal | 7426 } } // namespace v8::internal |
| OLD | NEW |