Restore info needed to register profile ticks in functions from

the snapshot.  Still needed: info to register profile ticks in
stubs.
Review URL: http://codereview.chromium.org/385035

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3272 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
erik.corry@gmail.com 2009-11-11 09:19:39 +00:00
parent 2252cc1bc9
commit 78a8f5973d
7 changed files with 46 additions and 19 deletions

View File

@ -315,7 +315,14 @@ Object* Accessors::ScriptGetLineEnds(Object* object, void*) {
HandleScope scope;
Handle<Script> script(Script::cast(JSValue::cast(object)->value()));
InitScriptLineEnds(script);
return script->line_ends();
if (script->line_ends_js_array()->IsUndefined()) {
Handle<FixedArray> line_ends_fixed_array(
FixedArray::cast(script->line_ends_fixed_array()));
Handle<FixedArray> copy = Factory::CopyFixedArray(line_ends_fixed_array);
Handle<JSArray> js_array = Factory::NewJSArrayWithElements(copy);
script->set_line_ends_js_array(*js_array);
}
return script->line_ends_js_array();
}

View File

@ -188,7 +188,8 @@ Handle<Script> Factory::NewScript(Handle<String> source) {
script->set_type(Smi::FromInt(Script::TYPE_NORMAL));
script->set_compilation_type(Smi::FromInt(Script::COMPILATION_TYPE_HOST));
script->set_wrapper(*wrapper);
script->set_line_ends(Heap::undefined_value());
script->set_line_ends_fixed_array(Heap::undefined_value());
script->set_line_ends_js_array(Heap::undefined_value());
script->set_eval_from_function(Heap::undefined_value());
script->set_eval_from_instructions_offset(Smi::FromInt(0));

View File

@ -427,12 +427,12 @@ Handle<JSValue> GetScriptWrapper(Handle<Script> script) {
// Init line_ends array with code positions of line ends inside script
// source.
void InitScriptLineEnds(Handle<Script> script) {
if (!script->line_ends()->IsUndefined()) return;
if (!script->line_ends_fixed_array()->IsUndefined()) return;
if (!script->source()->IsString()) {
ASSERT(script->source()->IsUndefined());
script->set_line_ends(*(Factory::NewJSArray(0)));
ASSERT(script->line_ends()->IsJSArray());
script->set_line_ends_fixed_array(*(Factory::NewFixedArray(0)));
ASSERT(script->line_ends_fixed_array()->IsFixedArray());
return;
}
@ -465,9 +465,8 @@ void InitScriptLineEnds(Handle<Script> script) {
}
ASSERT(array_index == line_count);
Handle<JSArray> object = Factory::NewJSArrayWithElements(array);
script->set_line_ends(*object);
ASSERT(script->line_ends()->IsJSArray());
script->set_line_ends_fixed_array(*array);
ASSERT(script->line_ends_fixed_array()->IsFixedArray());
}
@ -475,17 +474,18 @@ void InitScriptLineEnds(Handle<Script> script) {
int GetScriptLineNumber(Handle<Script> script, int code_pos) {
InitScriptLineEnds(script);
AssertNoAllocation no_allocation;
JSArray* line_ends_array = JSArray::cast(script->line_ends());
const int line_ends_len = (Smi::cast(line_ends_array->length()))->value();
FixedArray* line_ends_array =
FixedArray::cast(script->line_ends_fixed_array());
const int line_ends_len = line_ends_array->length();
int line = -1;
if (line_ends_len > 0 &&
code_pos <= (Smi::cast(line_ends_array->GetElement(0)))->value()) {
code_pos <= (Smi::cast(line_ends_array->get(0)))->value()) {
line = 0;
} else {
for (int i = 1; i < line_ends_len; ++i) {
if ((Smi::cast(line_ends_array->GetElement(i - 1)))->value() < code_pos &&
code_pos <= (Smi::cast(line_ends_array->GetElement(i)))->value()) {
if ((Smi::cast(line_ends_array->get(i - 1)))->value() < code_pos &&
code_pos <= (Smi::cast(line_ends_array->get(i)))->value()) {
line = i;
break;
}

View File

@ -1140,7 +1140,8 @@ void Script::ScriptVerify() {
VerifyPointer(data());
VerifyPointer(wrapper());
type()->SmiVerify();
VerifyPointer(line_ends());
VerifyPointer(line_ends_fixed_array());
VerifyPointer(line_ends_js_array());
VerifyPointer(id());
}

View File

@ -2441,7 +2441,8 @@ ACCESSORS(Script, context_data, Object, kContextOffset)
ACCESSORS(Script, wrapper, Proxy, kWrapperOffset)
ACCESSORS(Script, type, Smi, kTypeOffset)
ACCESSORS(Script, compilation_type, Smi, kCompilationTypeOffset)
ACCESSORS(Script, line_ends, Object, kLineEndsOffset)
ACCESSORS(Script, line_ends_fixed_array, Object, kLineEndsFixedArrayOffset)
ACCESSORS(Script, line_ends_js_array, Object, kLineEndsJSArrayOffset)
ACCESSORS(Script, eval_from_function, Object, kEvalFromFunctionOffset)
ACCESSORS(Script, eval_from_instructions_offset, Smi,
kEvalFrominstructionsOffsetOffset)

View File

@ -3156,8 +3156,11 @@ class Script: public Struct {
// [compilation]: how the the script was compiled.
DECL_ACCESSORS(compilation_type, Smi)
// [line_ends]: array of line ends positions.
DECL_ACCESSORS(line_ends, Object)
// [line_ends]: FixedArray of line ends positions.
DECL_ACCESSORS(line_ends_fixed_array, Object)
// [line_ends]: JSArray of line ends positions.
DECL_ACCESSORS(line_ends_js_array, Object)
// [eval_from_function]: for eval scripts the funcion from which eval was
// called.
@ -3187,8 +3190,16 @@ class Script: public Struct {
static const int kWrapperOffset = kContextOffset + kPointerSize;
static const int kTypeOffset = kWrapperOffset + kPointerSize;
static const int kCompilationTypeOffset = kTypeOffset + kPointerSize;
static const int kLineEndsOffset = kCompilationTypeOffset + kPointerSize;
static const int kIdOffset = kLineEndsOffset + kPointerSize;
// We have the line ends array both in FixedArray form and in JSArray form.
// The FixedArray form is useful when we don't have a context and so can't
// create a JSArray. The JSArray form is useful when we want to see the
// array from JS code (e.g. debug-delay.js) which cannot handle unboxed
// FixedArray objects.
static const int kLineEndsFixedArrayOffset =
kCompilationTypeOffset + kPointerSize;
static const int kLineEndsJSArrayOffset =
kLineEndsFixedArrayOffset + kPointerSize;
static const int kIdOffset = kLineEndsJSArrayOffset + kPointerSize;
static const int kEvalFromFunctionOffset = kIdOffset + kPointerSize;
static const int kEvalFrominstructionsOffsetOffset =
kEvalFromFunctionOffset + kPointerSize;

View File

@ -33,6 +33,7 @@
#include "simulator.h"
#include "stub-cache.h"
#include "oprofile-agent.h"
#include "log.h"
namespace v8 {
namespace internal {
@ -114,6 +115,11 @@ bool V8::Initialize(GenericDeserializer *des) {
OProfileAgent::Initialize();
if (FLAG_log_code) {
HandleScope scope;
Logger::LogCompiledFunctions();
}
return true;
}