OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/arguments.h" | 8 #include "src/arguments.h" |
9 #include "src/debug.h" | 9 #include "src/debug.h" |
10 #include "src/deoptimizer.h" | 10 #include "src/deoptimizer.h" |
(...skipping 2025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2036 Handle<String> arguments_str = isolate->factory()->arguments_string(); | 2036 Handle<String> arguments_str = isolate->factory()->arguments_string(); |
2037 RETURN_ON_EXCEPTION(isolate, Runtime::DefineObjectProperty( | 2037 RETURN_ON_EXCEPTION(isolate, Runtime::DefineObjectProperty( |
2038 target, arguments_str, arguments, NONE), | 2038 target, arguments_str, arguments, NONE), |
2039 JSObject); | 2039 JSObject); |
2040 return target; | 2040 return target; |
2041 } | 2041 } |
2042 | 2042 |
2043 | 2043 |
2044 // Compile and evaluate source for the given context. | 2044 // Compile and evaluate source for the given context. |
2045 static MaybeHandle<Object> DebugEvaluate(Isolate* isolate, | 2045 static MaybeHandle<Object> DebugEvaluate(Isolate* isolate, |
| 2046 Handle<SharedFunctionInfo> outer_info, |
2046 Handle<Context> context, | 2047 Handle<Context> context, |
2047 Handle<Object> context_extension, | 2048 Handle<Object> context_extension, |
2048 Handle<Object> receiver, | 2049 Handle<Object> receiver, |
2049 Handle<String> source) { | 2050 Handle<String> source) { |
2050 if (context_extension->IsJSObject()) { | 2051 if (context_extension->IsJSObject()) { |
2051 Handle<JSObject> extension = Handle<JSObject>::cast(context_extension); | 2052 Handle<JSObject> extension = Handle<JSObject>::cast(context_extension); |
2052 Handle<JSFunction> closure(context->closure(), isolate); | 2053 Handle<JSFunction> closure(context->closure(), isolate); |
2053 context = isolate->factory()->NewWithContext(closure, context, extension); | 2054 context = isolate->factory()->NewWithContext(closure, context, extension); |
2054 } | 2055 } |
2055 | 2056 |
2056 Handle<JSFunction> eval_fun; | 2057 Handle<JSFunction> eval_fun; |
2057 ASSIGN_RETURN_ON_EXCEPTION( | 2058 ASSIGN_RETURN_ON_EXCEPTION(isolate, eval_fun, |
2058 isolate, eval_fun, Compiler::GetFunctionFromEval(source, context, SLOPPY, | 2059 Compiler::GetFunctionFromEval( |
2059 NO_PARSE_RESTRICTION, | 2060 source, outer_info, context, SLOPPY, |
2060 RelocInfo::kNoPosition), | 2061 NO_PARSE_RESTRICTION, RelocInfo::kNoPosition), |
2061 Object); | 2062 Object); |
2062 | 2063 |
2063 Handle<Object> result; | 2064 Handle<Object> result; |
2064 ASSIGN_RETURN_ON_EXCEPTION( | 2065 ASSIGN_RETURN_ON_EXCEPTION( |
2065 isolate, result, Execution::Call(isolate, eval_fun, receiver, 0, NULL), | 2066 isolate, result, Execution::Call(isolate, eval_fun, receiver, 0, NULL), |
2066 Object); | 2067 Object); |
2067 | 2068 |
2068 // Skip the global proxy as it has no properties and always delegates to the | 2069 // Skip the global proxy as it has no properties and always delegates to the |
2069 // real global object. | 2070 // real global object. |
2070 if (result->IsJSGlobalProxy()) { | 2071 if (result->IsJSGlobalProxy()) { |
2071 PrototypeIterator iter(isolate, result); | 2072 PrototypeIterator iter(isolate, result); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2111 | 2112 |
2112 // Handle the processing of break. | 2113 // Handle the processing of break. |
2113 DisableBreak disable_break_scope(isolate->debug(), disable_break); | 2114 DisableBreak disable_break_scope(isolate->debug(), disable_break); |
2114 | 2115 |
2115 // Get the frame where the debugging is performed. | 2116 // Get the frame where the debugging is performed. |
2116 StackFrame::Id id = UnwrapFrameId(wrapped_id); | 2117 StackFrame::Id id = UnwrapFrameId(wrapped_id); |
2117 JavaScriptFrameIterator it(isolate, id); | 2118 JavaScriptFrameIterator it(isolate, id); |
2118 JavaScriptFrame* frame = it.frame(); | 2119 JavaScriptFrame* frame = it.frame(); |
2119 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate); | 2120 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate); |
2120 Handle<JSFunction> function(JSFunction::cast(frame_inspector.GetFunction())); | 2121 Handle<JSFunction> function(JSFunction::cast(frame_inspector.GetFunction())); |
| 2122 Handle<SharedFunctionInfo> outer_info(function->shared()); |
2121 | 2123 |
2122 // Traverse the saved contexts chain to find the active context for the | 2124 // Traverse the saved contexts chain to find the active context for the |
2123 // selected frame. | 2125 // selected frame. |
2124 SaveContext* save = FindSavedContextForFrame(isolate, frame); | 2126 SaveContext* save = FindSavedContextForFrame(isolate, frame); |
2125 | 2127 |
2126 SaveContext savex(isolate); | 2128 SaveContext savex(isolate); |
2127 isolate->set_context(*(save->context())); | 2129 isolate->set_context(*(save->context())); |
2128 | 2130 |
2129 // Materialize stack locals and the arguments object. | 2131 // Materialize stack locals and the arguments object. |
2130 Handle<JSObject> materialized = NewJSObjectWithNullProto(isolate); | 2132 Handle<JSObject> materialized = NewJSObjectWithNullProto(isolate); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2170 function, function_context, materialized); | 2172 function, function_context, materialized); |
2171 | 2173 |
2172 if (inner_context.is_null()) { | 2174 if (inner_context.is_null()) { |
2173 // No inner context. The with-context is now inner-most. | 2175 // No inner context. The with-context is now inner-most. |
2174 eval_context = materialized_context; | 2176 eval_context = materialized_context; |
2175 } else { | 2177 } else { |
2176 inner_context->set_previous(*materialized_context); | 2178 inner_context->set_previous(*materialized_context); |
2177 } | 2179 } |
2178 | 2180 |
2179 Handle<Object> receiver(frame->receiver(), isolate); | 2181 Handle<Object> receiver(frame->receiver(), isolate); |
2180 MaybeHandle<Object> maybe_result = | 2182 MaybeHandle<Object> maybe_result = DebugEvaluate( |
2181 DebugEvaluate(isolate, eval_context, context_extension, receiver, source); | 2183 isolate, outer_info, eval_context, context_extension, receiver, source); |
2182 | 2184 |
2183 // Remove with-context if it was inserted in between. | 2185 // Remove with-context if it was inserted in between. |
2184 if (!inner_context.is_null()) inner_context->set_previous(*function_context); | 2186 if (!inner_context.is_null()) inner_context->set_previous(*function_context); |
2185 | 2187 |
2186 Handle<Object> result; | 2188 Handle<Object> result; |
2187 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, maybe_result); | 2189 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, maybe_result); |
2188 | 2190 |
2189 // Write back potential changes to materialized stack locals to the stack. | 2191 // Write back potential changes to materialized stack locals to the stack. |
2190 UpdateStackLocalsFromMaterializedObject(isolate, materialized, function, | 2192 UpdateStackLocalsFromMaterializedObject(isolate, materialized, function, |
2191 frame, inlined_jsframe_index); | 2193 frame, inlined_jsframe_index); |
(...skipping 25 matching lines...) Expand all Loading... |
2217 top = top->prev(); | 2219 top = top->prev(); |
2218 } | 2220 } |
2219 if (top != NULL) { | 2221 if (top != NULL) { |
2220 isolate->set_context(*top->context()); | 2222 isolate->set_context(*top->context()); |
2221 } | 2223 } |
2222 | 2224 |
2223 // Get the native context now set to the top context from before the | 2225 // Get the native context now set to the top context from before the |
2224 // debugger was invoked. | 2226 // debugger was invoked. |
2225 Handle<Context> context = isolate->native_context(); | 2227 Handle<Context> context = isolate->native_context(); |
2226 Handle<JSObject> receiver(context->global_proxy()); | 2228 Handle<JSObject> receiver(context->global_proxy()); |
| 2229 Handle<SharedFunctionInfo> outer_info(context->closure()->shared(), isolate); |
2227 Handle<Object> result; | 2230 Handle<Object> result; |
2228 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 2231 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
2229 isolate, result, | 2232 isolate, result, DebugEvaluate(isolate, outer_info, context, |
2230 DebugEvaluate(isolate, context, context_extension, receiver, source)); | 2233 context_extension, receiver, source)); |
2231 return *result; | 2234 return *result; |
2232 } | 2235 } |
2233 | 2236 |
2234 | 2237 |
2235 RUNTIME_FUNCTION(Runtime_DebugGetLoadedScripts) { | 2238 RUNTIME_FUNCTION(Runtime_DebugGetLoadedScripts) { |
2236 HandleScope scope(isolate); | 2239 HandleScope scope(isolate); |
2237 DCHECK(args.length() == 0); | 2240 DCHECK(args.length() == 0); |
2238 | 2241 |
2239 // Fill the script objects. | 2242 // Fill the script objects. |
2240 Handle<FixedArray> instances = isolate->debug()->GetLoadedScripts(); | 2243 Handle<FixedArray> instances = isolate->debug()->GetLoadedScripts(); |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2736 return Smi::FromInt(isolate->debug()->is_active()); | 2739 return Smi::FromInt(isolate->debug()->is_active()); |
2737 } | 2740 } |
2738 | 2741 |
2739 | 2742 |
2740 RUNTIME_FUNCTION(RuntimeReference_DebugBreakInOptimizedCode) { | 2743 RUNTIME_FUNCTION(RuntimeReference_DebugBreakInOptimizedCode) { |
2741 UNIMPLEMENTED(); | 2744 UNIMPLEMENTED(); |
2742 return NULL; | 2745 return NULL; |
2743 } | 2746 } |
2744 } | 2747 } |
2745 } // namespace v8::internal | 2748 } // namespace v8::internal |
OLD | NEW |