From 9cd4196c557378db68313e9768db2191ea044803 Mon Sep 17 00:00:00 2001 From: "sgjesse@gmail.com" Date: Mon, 1 Sep 2008 10:15:45 +0000 Subject: [PATCH] Created a factory method for allocating the debug info object. The new method ensures that there are no allocations during the setup. This fixes test breakage on Linux in debug mode where allocation happened while the debug info object was not fully set up making verify heap unhappy. git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@70 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/debug.cc | 19 +------------------ src/factory.cc | 32 ++++++++++++++++++++++++++++++++ src/factory.h | 2 ++ 3 files changed, 35 insertions(+), 18 deletions(-) diff --git a/src/debug.cc b/src/debug.cc index 89fc7d8..7487cdc 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -1154,24 +1154,7 @@ bool Debug::EnsureDebugInfo(Handle shared) { if (!EnsureCompiled(shared)) return false; // Create the debug info object. - Handle debug_info = - Handle::cast(Factory::NewStruct(DEBUG_INFO_TYPE)); - - // Get the function original code. - Handle code(shared->code()); - - // Debug info contains function, a copy of the original code and the executing - // code. - debug_info->set_shared(*shared); - debug_info->set_original_code(*Factory::CopyCode(code)); - debug_info->set_code(*code); - - // Link debug info to function. - shared->set_debug_info(*debug_info); - - // Initially no active break points. - debug_info->set_break_points( - *Factory::NewFixedArray(Debug::kEstimatedNofBreakPointsInFunction)); + Handle debug_info = Factory::NewDebugInfo(shared); // Add debug info to the list. DebugInfoListNode* node = new DebugInfoListNode(*debug_info); diff --git a/src/factory.cc b/src/factory.cc index 8016965..39bc763 100644 --- a/src/factory.cc +++ b/src/factory.cc @@ -28,6 +28,7 @@ #include "v8.h" #include "api.h" +#include "debug.h" #include "execution.h" #include "factory.h" #include "macro-assembler.h" @@ -625,6 +626,37 @@ Handle Factory::ToObject(Handle object, } +Handle Factory::NewDebugInfo(Handle shared) { + // Get the original code of the function. + Handle code(shared->code()); + + // Create a copy of the code before allocating the debug info object to avoid + // allocation while setting up the debug info object. + Handle original_code(*Factory::CopyCode(code)); + + // Allocate initial fixed array for active break points before allocating the + // debug info object to avoid allocation while setting up the debug info + // object. + Handle break_points( + Factory::NewFixedArray(Debug::kEstimatedNofBreakPointsInFunction)); + + // Create and set up the debug info object. Debug info contains function, a + // copy of the original code, the executing code and initial fixed array for + // active break points. + Handle debug_info = + Handle::cast(Factory::NewStruct(DEBUG_INFO_TYPE)); + debug_info->set_shared(*shared); + debug_info->set_original_code(*original_code); + debug_info->set_code(*code); + debug_info->set_break_points(*break_points); + + // Link debug info to function. + shared->set_debug_info(*debug_info); + + return debug_info; +} + + Handle Factory::NewArgumentsObject(Handle callee, int length) { CALL_HEAP_FUNCTION(Heap::AllocateArgumentsObject(*callee, length), JSObject); diff --git a/src/factory.h b/src/factory.h index a0cd936..40e1305 100644 --- a/src/factory.h +++ b/src/factory.h @@ -289,6 +289,8 @@ class Factory : public AllStatic { uint32_t key, Handle value); + static Handle NewDebugInfo(Handle shared); + private: static Handle NewFunctionHelper(Handle name, Handle prototype); -- 2.7.4