OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 12404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12415 // part has all the parameters and locals of the function on the stack frame | 12415 // part has all the parameters and locals of the function on the stack frame |
12416 // as well as a materialized arguments object. As this context replaces | 12416 // as well as a materialized arguments object. As this context replaces |
12417 // the context of the function on the stack frame a new (empty) function | 12417 // the context of the function on the stack frame a new (empty) function |
12418 // is created as well to be used as the closure for the context. | 12418 // is created as well to be used as the closure for the context. |
12419 // This closure as replacements for the one on the stack frame presenting | 12419 // This closure as replacements for the one on the stack frame presenting |
12420 // the same view of the values of parameters and local variables as if the | 12420 // the same view of the values of parameters and local variables as if the |
12421 // piece of JavaScript was evaluated at the point where the function on the | 12421 // piece of JavaScript was evaluated at the point where the function on the |
12422 // stack frame is currently stopped when we compile and run the (direct) eval. | 12422 // stack frame is currently stopped when we compile and run the (direct) eval. |
12423 // Returns array of | 12423 // Returns array of |
12424 // #0: evaluate result | 12424 // #0: evaluate result |
12425 // #1: local variables scope materizalized as object before evaluation | 12425 // #1: local variables materizalized again as object after evaluation, contain |
12426 // #2: local variables scope materizalized as object after evaluation | 12426 // original variable values as they remained on stack |
| 12427 // #2: local variables materizalized as object before evaluation (and possibly |
| 12428 // modified by expression having been executed) |
12427 // Since user expression only reaches (and modifies) copies of local variables, | 12429 // Since user expression only reaches (and modifies) copies of local variables, |
12428 // those copies are returned to the caller to allow tracking the changes and | 12430 // those copies are returned to the caller to allow tracking the changes and |
12429 // manually updating the actual variables. | 12431 // manually updating the actual variables. |
12430 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugEvaluate) { | 12432 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugEvaluate) { |
12431 HandleScope scope(isolate); | 12433 HandleScope scope(isolate); |
12432 | 12434 |
12433 // Check the execution state and decode arguments frame and source to be | 12435 // Check the execution state and decode arguments frame and source to be |
12434 // evaluated. | 12436 // evaluated. |
12435 ASSERT(args.length() == 6); | 12437 ASSERT(args.length() == 6); |
12436 Object* check_result; | 12438 Object* check_result; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12526 } | 12528 } |
12527 | 12529 |
12528 Handle<Object> receiver(frame->receiver(), isolate); | 12530 Handle<Object> receiver(frame->receiver(), isolate); |
12529 Object* evaluate_result_object; | 12531 Object* evaluate_result_object; |
12530 { MaybeObject* maybe_result = | 12532 { MaybeObject* maybe_result = |
12531 DebugEvaluate(isolate, context, context_extension, receiver, source); | 12533 DebugEvaluate(isolate, context, context_extension, receiver, source); |
12532 if (!maybe_result->ToObject(&evaluate_result_object)) return maybe_result; | 12534 if (!maybe_result->ToObject(&evaluate_result_object)) return maybe_result; |
12533 } | 12535 } |
12534 Handle<Object> evaluate_result(evaluate_result_object, isolate); | 12536 Handle<Object> evaluate_result(evaluate_result_object, isolate); |
12535 | 12537 |
12536 Handle<JSObject> local_scope_after = MaterializeLocalScopeWithFrameInspector( | 12538 Handle<JSObject> local_scope_control_copy = |
12537 isolate, frame, &frame_inspector); | 12539 MaterializeLocalScopeWithFrameInspector(isolate, frame, |
| 12540 &frame_inspector); |
12538 | 12541 |
12539 Handle<FixedArray> resultArray = | 12542 Handle<FixedArray> resultArray = isolate->factory()->NewFixedArray(3); |
12540 isolate->factory()->NewFixedArray(3); | |
12541 resultArray->set(0, *evaluate_result); | 12543 resultArray->set(0, *evaluate_result); |
| 12544 resultArray->set(1, *local_scope_control_copy); |
12542 resultArray->set(2, *local_scope); | 12545 resultArray->set(2, *local_scope); |
12543 resultArray->set(1, *local_scope_after); | |
12544 | 12546 |
12545 return *(isolate->factory()->NewJSArrayWithElements(resultArray)); | 12547 return *(isolate->factory()->NewJSArrayWithElements(resultArray)); |
12546 } | 12548 } |
12547 | 12549 |
12548 | 12550 |
12549 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugEvaluateGlobal) { | 12551 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugEvaluateGlobal) { |
12550 HandleScope scope(isolate); | 12552 HandleScope scope(isolate); |
12551 | 12553 |
12552 // Check the execution state and decode arguments frame and source to be | 12554 // Check the execution state and decode arguments frame and source to be |
12553 // evaluated. | 12555 // evaluated. |
(...skipping 1363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13917 // Handle last resort GC and make sure to allow future allocations | 13919 // Handle last resort GC and make sure to allow future allocations |
13918 // to grow the heap without causing GCs (if possible). | 13920 // to grow the heap without causing GCs (if possible). |
13919 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13921 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13920 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13922 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
13921 "Runtime::PerformGC"); | 13923 "Runtime::PerformGC"); |
13922 } | 13924 } |
13923 } | 13925 } |
13924 | 13926 |
13925 | 13927 |
13926 } } // namespace v8::internal | 13928 } } // namespace v8::internal |
OLD | NEW |