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

Unified Diff: src/runtime.cc

Issue 5733001: Introduce additional context to evaluate operations (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: merge Created 10 years 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
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index af40e983b9a480e4d0ce6993764b1c6ef7888fc1..66cd37fb0ba66c1c538081e6f9520054967b606f 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -9682,7 +9682,7 @@ static MaybeObject* Runtime_DebugEvaluate(Arguments args) {
// Check the execution state and decode arguments frame and source to be
// evaluated.
- ASSERT(args.length() == 4);
+ ASSERT(args.length() == 5);
Object* check_result;
{ MaybeObject* maybe_check_result = Runtime_CheckExecutionState(args);
if (!maybe_check_result->ToObject(&check_result)) {
@@ -9692,6 +9692,7 @@ static MaybeObject* Runtime_DebugEvaluate(Arguments args) {
CONVERT_CHECKED(Smi, wrapped_id, args[1]);
CONVERT_ARG_CHECKED(String, source, 2);
CONVERT_BOOLEAN_CHECKED(disable_break, args[3]);
+ Handle<Object> additional_context(args[4]);
// Handle the processing of break.
DisableBreak disable_break_save(disable_break);
@@ -9742,6 +9743,11 @@ static MaybeObject* Runtime_DebugEvaluate(Arguments args) {
Handle<Context> function_context(frame_context->fcontext());
context = CopyWithContextChain(frame_context, context);
+ if (additional_context->IsJSObject()) {
+ context = Factory::NewWithContext(context,
+ Handle<JSObject>::cast(additional_context), false);
+ }
+
// Wrap the evaluation statement in a new function compiled in the newly
// created context. The function has one parameter which has to be called
// 'arguments'. This it to have access to what would have been 'arguments' in
@@ -9796,7 +9802,7 @@ static MaybeObject* Runtime_DebugEvaluateGlobal(Arguments args) {
// Check the execution state and decode arguments frame and source to be
// evaluated.
- ASSERT(args.length() == 3);
+ ASSERT(args.length() == 4);
Object* check_result;
{ MaybeObject* maybe_check_result = Runtime_CheckExecutionState(args);
if (!maybe_check_result->ToObject(&check_result)) {
@@ -9805,6 +9811,7 @@ static MaybeObject* Runtime_DebugEvaluateGlobal(Arguments args) {
}
CONVERT_ARG_CHECKED(String, source, 1);
CONVERT_BOOLEAN_CHECKED(disable_break, args[2]);
+ Handle<Object> additional_context(args[3]);
// Handle the processing of break.
DisableBreak disable_break_save(disable_break);
@@ -9823,11 +9830,24 @@ static MaybeObject* Runtime_DebugEvaluateGlobal(Arguments args) {
// debugger was invoked.
Handle<Context> context = Top::global_context();
+ bool is_global = true;
+
+ if (additional_context->IsJSObject()) {
Søren Thygesen Gjesse 2010/12/13 08:37:14 4 char indent.
Peter Rybin 2010/12/14 00:02:52 Done.
+ // Create a function context first, than put 'with' context on top of it.
+ Handle<JSFunction> go_between = Factory::NewFunction(
+ Factory::empty_string(), Factory::undefined_value());
+ go_between->set_context(*context);
+ context = Factory::NewFunctionContext(Context::MIN_CONTEXT_SLOTS,
Søren Thygesen Gjesse 2010/12/13 08:37:14 I suggest splitting this line either after the '='
Peter Rybin 2010/12/14 00:02:52 Done.
+ go_between);
+ context->set_extension(JSObject::cast(*additional_context));
+ is_global = false;
+ }
+
// Compile the source to be evaluated.
Handle<SharedFunctionInfo> shared =
Compiler::CompileEval(source,
context,
- true);
+ is_global);
if (shared.is_null()) return Failure::Exception();
Handle<JSFunction> compiled_function =
Handle<JSFunction>(Factory::NewFunctionFromSharedFunctionInfo(shared,

Powered by Google App Engine
This is Rietveld 408576698