Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1003)

Unified Diff: src/runtime.cc

Issue 2918001: Move serialized scope info from Code object to SharedFunctionInfo. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/profile-generator.cc ('k') | src/scopeinfo.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
===================================================================
--- src/runtime.cc (revision 5039)
+++ src/runtime.cc (working copy)
@@ -1606,9 +1606,10 @@
if (!EnsureCompiled(shared, KEEP_EXCEPTION)) {
return Failure::Exception();
}
- // Set the code, formal parameter count, and the length of the target
- // function.
+ // Set the code, scope info, formal parameter count,
+ // and the length of the target function.
target->set_code(fun->code());
+ target->shared()->set_scope_info(shared->scope_info());
target->shared()->set_length(shared->length());
target->shared()->set_formal_parameter_count(
shared->formal_parameter_count());
@@ -6868,7 +6869,8 @@
ASSERT(args.length() == 1);
CONVERT_CHECKED(JSFunction, function, args[0]);
- int length = ScopeInfo<>::NumberOfContextSlots(function->code());
+ int length =
+ ScopeInfo<>::NumberOfContextSlots(function->shared()->scope_info());
Object* result = Heap::AllocateFunctionContext(length, function);
if (result->IsFailure()) return result;
@@ -8488,9 +8490,10 @@
// Check for constructor frame.
bool constructor = it.frame()->IsConstructor();
- // Get code and read scope info from it for local variable information.
- Handle<Code> code(it.frame()->code());
- ScopeInfo<> info(*code);
+ // Get scope info and read from it for local variable information.
+ Handle<JSFunction> function(JSFunction::cast(it.frame()->function()));
+ Handle<Object> scope_info(function->shared()->scope_info());
+ ScopeInfo<> info(*scope_info);
// Get the context.
Handle<Context> context(Context::cast(it.frame()->context()));
@@ -8518,7 +8521,8 @@
}
ASSERT(context->is_function_context());
locals->set(i * 2 + 1,
- context->get(ScopeInfo<>::ContextSlotIndex(*code, *name,
+ context->get(ScopeInfo<>::ContextSlotIndex(*scope_info,
+ *name,
NULL)));
}
}
@@ -8659,7 +8663,7 @@
// Copy all the context locals into an object used to materialize a scope.
-static void CopyContextLocalsToScopeObject(Handle<Code> code,
+static void CopyContextLocalsToScopeObject(Handle<SharedFunctionInfo> shared,
ScopeInfo<>& scope_info,
Handle<Context> context,
Handle<JSObject> scope_object) {
@@ -8668,7 +8672,7 @@
i < scope_info.number_of_context_slots();
i++) {
int context_index =
- ScopeInfo<>::ContextSlotIndex(*code,
+ ScopeInfo<>::ContextSlotIndex(shared->scope_info(),
*scope_info.context_slot_name(i),
NULL);
@@ -8686,8 +8690,8 @@
// frame.
static Handle<JSObject> MaterializeLocalScope(JavaScriptFrame* frame) {
Handle<JSFunction> function(JSFunction::cast(frame->function()));
- Handle<Code> code(function->code());
- ScopeInfo<> scope_info(*code);
+ Handle<SharedFunctionInfo> shared(function->shared());
+ ScopeInfo<> scope_info(shared->scope_info());
// Allocate and initialize a JSObject with all the arguments, stack locals
// heap locals and extension properties of the debugged function.
@@ -8710,7 +8714,7 @@
// Third fill all context locals.
Handle<Context> frame_context(Context::cast(frame->context()));
Handle<Context> function_context(frame_context->fcontext());
- CopyContextLocalsToScopeObject(code, scope_info,
+ CopyContextLocalsToScopeObject(shared, scope_info,
function_context, local_scope);
// Finally copy any properties from the function context extension. This will
@@ -8737,8 +8741,8 @@
static Handle<JSObject> MaterializeClosure(Handle<Context> context) {
ASSERT(context->is_function_context());
- Handle<Code> code(context->closure()->code());
- ScopeInfo<> scope_info(*code);
+ Handle<SharedFunctionInfo> shared(context->closure()->shared());
+ ScopeInfo<> scope_info(shared->scope_info());
// Allocate and initialize a JSObject with all the content of theis function
// closure.
@@ -8746,7 +8750,7 @@
// Check whether the arguments shadow object exists.
int arguments_shadow_index =
- ScopeInfo<>::ContextSlotIndex(*code,
+ ScopeInfo<>::ContextSlotIndex(shared->scope_info(),
Heap::arguments_shadow_symbol(),
NULL);
if (arguments_shadow_index >= 0) {
@@ -8762,7 +8766,7 @@
}
// Fill all context locals to the context extension.
- CopyContextLocalsToScopeObject(code, scope_info, context, closure_scope);
+ CopyContextLocalsToScopeObject(shared, scope_info, context, closure_scope);
// Finally copy any properties from the function context extension. This will
// be variables introduced by eval.
@@ -8811,8 +8815,8 @@
// created for evaluating top level code and it is not a real local scope.
// Checking for the existence of .result seems fragile, but the scope info
// saved with the code object does not otherwise have that information.
- Handle<Code> code(function_->code());
- int index = ScopeInfo<>::StackSlotIndex(*code, Heap::result_symbol());
+ int index = ScopeInfo<>::StackSlotIndex(function_->shared()->scope_info(),
+ Heap::result_symbol());
at_local_ = index < 0;
} else if (context_->is_function_context()) {
at_local_ = true;
@@ -8926,8 +8930,7 @@
case ScopeIterator::ScopeTypeLocal: {
PrintF("Local:\n");
- Handle<Code> code(function_->code());
- ScopeInfo<> scope_info(*code);
+ ScopeInfo<> scope_info(function_->shared()->scope_info());
scope_info.Print();
if (!CurrentContext().is_null()) {
CurrentContext()->Print();
@@ -9451,7 +9454,7 @@
// Runtime_DebugEvaluate.
static Handle<Object> GetArgumentsObject(JavaScriptFrame* frame,
Handle<JSFunction> function,
- Handle<Code> code,
+ Handle<Object> scope_info,
const ScopeInfo<>* sinfo,
Handle<Context> function_context) {
// Try to find the value of 'arguments' to pass as parameter. If it is not
@@ -9459,14 +9462,14 @@
// does not support eval) then create an 'arguments' object.
int index;
if (sinfo->number_of_stack_slots() > 0) {
- index = ScopeInfo<>::StackSlotIndex(*code, Heap::arguments_symbol());
+ index = ScopeInfo<>::StackSlotIndex(*scope_info, Heap::arguments_symbol());
if (index != -1) {
return Handle<Object>(frame->GetExpression(index));
}
}
if (sinfo->number_of_context_slots() > Context::MIN_CONTEXT_SLOTS) {
- index = ScopeInfo<>::ContextSlotIndex(*code, Heap::arguments_symbol(),
+ index = ScopeInfo<>::ContextSlotIndex(*scope_info, Heap::arguments_symbol(),
NULL);
if (index != -1) {
return Handle<Object>(function_context->get(index));
@@ -9518,8 +9521,8 @@
JavaScriptFrameIterator it(id);
JavaScriptFrame* frame = it.frame();
Handle<JSFunction> function(JSFunction::cast(frame->function()));
- Handle<Code> code(function->code());
- ScopeInfo<> sinfo(*code);
+ Handle<Object> scope_info(function->shared()->scope_info());
+ ScopeInfo<> sinfo(*scope_info);
// Traverse the saved contexts chain to find the active context for the
// selected frame.
@@ -9541,7 +9544,7 @@
Factory::NewFunction(Factory::empty_string(), Factory::undefined_value());
go_between->set_context(function->context());
#ifdef DEBUG
- ScopeInfo<> go_between_sinfo(go_between->shared()->code());
+ ScopeInfo<> go_between_sinfo(go_between->shared()->scope_info());
ASSERT(go_between_sinfo.number_of_parameters() == 0);
ASSERT(go_between_sinfo.number_of_context_slots() == 0);
#endif
@@ -9587,8 +9590,8 @@
&has_pending_exception);
if (has_pending_exception) return Failure::Exception();
- Handle<Object> arguments = GetArgumentsObject(frame, function, code, &sinfo,
- function_context);
+ Handle<Object> arguments = GetArgumentsObject(frame, function, scope_info,
+ &sinfo, function_context);
// Invoke the evaluation function and return the result.
const int argc = 2;
« no previous file with comments | « src/profile-generator.cc ('k') | src/scopeinfo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698