Commit 9cd4196c authored by sgjesse@gmail.com's avatar sgjesse@gmail.com

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
parent e5e85a88
...@@ -1154,24 +1154,7 @@ bool Debug::EnsureDebugInfo(Handle<SharedFunctionInfo> shared) { ...@@ -1154,24 +1154,7 @@ bool Debug::EnsureDebugInfo(Handle<SharedFunctionInfo> shared) {
if (!EnsureCompiled(shared)) return false; if (!EnsureCompiled(shared)) return false;
// Create the debug info object. // Create the debug info object.
Handle<DebugInfo> debug_info = Handle<DebugInfo> debug_info = Factory::NewDebugInfo(shared);
Handle<DebugInfo>::cast(Factory::NewStruct(DEBUG_INFO_TYPE));
// Get the function original code.
Handle<Code> 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));
// Add debug info to the list. // Add debug info to the list.
DebugInfoListNode* node = new DebugInfoListNode(*debug_info); DebugInfoListNode* node = new DebugInfoListNode(*debug_info);
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "v8.h" #include "v8.h"
#include "api.h" #include "api.h"
#include "debug.h"
#include "execution.h" #include "execution.h"
#include "factory.h" #include "factory.h"
#include "macro-assembler.h" #include "macro-assembler.h"
...@@ -625,6 +626,37 @@ Handle<Object> Factory::ToObject(Handle<Object> object, ...@@ -625,6 +626,37 @@ Handle<Object> Factory::ToObject(Handle<Object> object,
} }
Handle<DebugInfo> Factory::NewDebugInfo(Handle<SharedFunctionInfo> shared) {
// Get the original code of the function.
Handle<Code> 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<Code> 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<FixedArray> 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<DebugInfo> debug_info =
Handle<DebugInfo>::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<JSObject> Factory::NewArgumentsObject(Handle<Object> callee, Handle<JSObject> Factory::NewArgumentsObject(Handle<Object> callee,
int length) { int length) {
CALL_HEAP_FUNCTION(Heap::AllocateArgumentsObject(*callee, length), JSObject); CALL_HEAP_FUNCTION(Heap::AllocateArgumentsObject(*callee, length), JSObject);
......
...@@ -289,6 +289,8 @@ class Factory : public AllStatic { ...@@ -289,6 +289,8 @@ class Factory : public AllStatic {
uint32_t key, uint32_t key,
Handle<Object> value); Handle<Object> value);
static Handle<DebugInfo> NewDebugInfo(Handle<SharedFunctionInfo> shared);
private: private:
static Handle<JSFunction> NewFunctionHelper(Handle<String> name, static Handle<JSFunction> NewFunctionHelper(Handle<String> name,
Handle<Object> prototype); Handle<Object> prototype);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment