| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1010 obj = AllocateMap(FIXED_ARRAY_TYPE, HeapObject::kHeaderSize); | 1010 obj = AllocateMap(FIXED_ARRAY_TYPE, HeapObject::kHeaderSize); |
| 1011 if (obj->IsFailure()) return false; | 1011 if (obj->IsFailure()) return false; |
| 1012 hash_table_map_ = Map::cast(obj); | 1012 hash_table_map_ = Map::cast(obj); |
| 1013 | 1013 |
| 1014 obj = AllocateMap(FIXED_ARRAY_TYPE, HeapObject::kHeaderSize); | 1014 obj = AllocateMap(FIXED_ARRAY_TYPE, HeapObject::kHeaderSize); |
| 1015 if (obj->IsFailure()) return false; | 1015 if (obj->IsFailure()) return false; |
| 1016 context_map_ = Map::cast(obj); | 1016 context_map_ = Map::cast(obj); |
| 1017 | 1017 |
| 1018 obj = AllocateMap(FIXED_ARRAY_TYPE, HeapObject::kHeaderSize); | 1018 obj = AllocateMap(FIXED_ARRAY_TYPE, HeapObject::kHeaderSize); |
| 1019 if (obj->IsFailure()) return false; | 1019 if (obj->IsFailure()) return false; |
| 1020 catch_context_map_ = Map::cast(obj); |
| 1021 |
| 1022 obj = AllocateMap(FIXED_ARRAY_TYPE, HeapObject::kHeaderSize); |
| 1023 if (obj->IsFailure()) return false; |
| 1020 global_context_map_ = Map::cast(obj); | 1024 global_context_map_ = Map::cast(obj); |
| 1021 | 1025 |
| 1022 obj = AllocateMap(JS_FUNCTION_TYPE, JSFunction::kSize); | 1026 obj = AllocateMap(JS_FUNCTION_TYPE, JSFunction::kSize); |
| 1023 if (obj->IsFailure()) return false; | 1027 if (obj->IsFailure()) return false; |
| 1024 boilerplate_function_map_ = Map::cast(obj); | 1028 boilerplate_function_map_ = Map::cast(obj); |
| 1025 | 1029 |
| 1026 obj = AllocateMap(SHARED_FUNCTION_INFO_TYPE, SharedFunctionInfo::kSize); | 1030 obj = AllocateMap(SHARED_FUNCTION_INFO_TYPE, SharedFunctionInfo::kSize); |
| 1027 if (obj->IsFailure()) return false; | 1031 if (obj->IsFailure()) return false; |
| 1028 shared_function_info_map_ = Map::cast(obj); | 1032 shared_function_info_map_ = Map::cast(obj); |
| 1029 | 1033 |
| (...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1652 if (self_reference != NULL) { | 1656 if (self_reference != NULL) { |
| 1653 *self_reference = code; | 1657 *self_reference = code; |
| 1654 } | 1658 } |
| 1655 // Migrate generated code. | 1659 // Migrate generated code. |
| 1656 // The generated code can contain Object** values (typically from handles) | 1660 // The generated code can contain Object** values (typically from handles) |
| 1657 // that are dereferenced during the copy to point directly to the actual heap | 1661 // that are dereferenced during the copy to point directly to the actual heap |
| 1658 // objects. These pointers can include references to the code object itself, | 1662 // objects. These pointers can include references to the code object itself, |
| 1659 // through the self_reference parameter. | 1663 // through the self_reference parameter. |
| 1660 code->CopyFrom(desc); | 1664 code->CopyFrom(desc); |
| 1661 if (sinfo != NULL) sinfo->Serialize(code); // write scope info | 1665 if (sinfo != NULL) sinfo->Serialize(code); // write scope info |
| 1666 LOG(CodeAllocateEvent(code, desc.origin)); |
| 1662 | 1667 |
| 1663 #ifdef DEBUG | 1668 #ifdef DEBUG |
| 1664 code->Verify(); | 1669 code->Verify(); |
| 1665 #endif | 1670 #endif |
| 1666 return code; | 1671 return code; |
| 1667 } | 1672 } |
| 1668 | 1673 |
| 1669 | 1674 |
| 1670 Object* Heap::CopyCode(Code* code) { | 1675 Object* Heap::CopyCode(Code* code) { |
| 1671 // Allocate an object the same size as the code object. | 1676 // Allocate an object the same size as the code object. |
| (...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2380 context->set_previous(NULL); | 2385 context->set_previous(NULL); |
| 2381 context->set_extension(NULL); | 2386 context->set_extension(NULL); |
| 2382 context->set_global(function->context()->global()); | 2387 context->set_global(function->context()->global()); |
| 2383 ASSERT(!context->IsGlobalContext()); | 2388 ASSERT(!context->IsGlobalContext()); |
| 2384 ASSERT(context->is_function_context()); | 2389 ASSERT(context->is_function_context()); |
| 2385 ASSERT(result->IsContext()); | 2390 ASSERT(result->IsContext()); |
| 2386 return result; | 2391 return result; |
| 2387 } | 2392 } |
| 2388 | 2393 |
| 2389 | 2394 |
| 2390 Object* Heap::AllocateWithContext(Context* previous, JSObject* extension) { | 2395 Object* Heap::AllocateWithContext(Context* previous, |
| 2396 JSObject* extension, |
| 2397 bool is_catch_context) { |
| 2391 Object* result = Heap::AllocateFixedArray(Context::MIN_CONTEXT_SLOTS); | 2398 Object* result = Heap::AllocateFixedArray(Context::MIN_CONTEXT_SLOTS); |
| 2392 if (result->IsFailure()) return result; | 2399 if (result->IsFailure()) return result; |
| 2393 Context* context = reinterpret_cast<Context*>(result); | 2400 Context* context = reinterpret_cast<Context*>(result); |
| 2394 context->set_map(context_map()); | 2401 context->set_map(is_catch_context ? catch_context_map() : context_map()); |
| 2395 context->set_closure(previous->closure()); | 2402 context->set_closure(previous->closure()); |
| 2396 context->set_fcontext(previous->fcontext()); | 2403 context->set_fcontext(previous->fcontext()); |
| 2397 context->set_previous(previous); | 2404 context->set_previous(previous); |
| 2398 context->set_extension(extension); | 2405 context->set_extension(extension); |
| 2399 context->set_global(previous->global()); | 2406 context->set_global(previous->global()); |
| 2400 ASSERT(!context->IsGlobalContext()); | 2407 ASSERT(!context->IsGlobalContext()); |
| 2401 ASSERT(!context->is_function_context()); | 2408 ASSERT(!context->is_function_context()); |
| 2402 ASSERT(result->IsContext()); | 2409 ASSERT(result->IsContext()); |
| 2403 return result; | 2410 return result; |
| 2404 } | 2411 } |
| (...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3349 #ifdef DEBUG | 3356 #ifdef DEBUG |
| 3350 bool Heap::GarbageCollectionGreedyCheck() { | 3357 bool Heap::GarbageCollectionGreedyCheck() { |
| 3351 ASSERT(FLAG_gc_greedy); | 3358 ASSERT(FLAG_gc_greedy); |
| 3352 if (Bootstrapper::IsActive()) return true; | 3359 if (Bootstrapper::IsActive()) return true; |
| 3353 if (disallow_allocation_failure()) return true; | 3360 if (disallow_allocation_failure()) return true; |
| 3354 return CollectGarbage(0, NEW_SPACE); | 3361 return CollectGarbage(0, NEW_SPACE); |
| 3355 } | 3362 } |
| 3356 #endif | 3363 #endif |
| 3357 | 3364 |
| 3358 } } // namespace v8::internal | 3365 } } // namespace v8::internal |
| OLD | NEW |