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/compiler.h" | 9 #include "src/compiler.h" |
10 #include "src/debug.h" | 10 #include "src/debug.h" |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 : frame_->LookupCode()->SourcePosition(frame_->pc()); | 522 : frame_->LookupCode()->SourcePosition(frame_->pc()); |
523 } | 523 } |
524 bool IsConstructor() { | 524 bool IsConstructor() { |
525 return is_optimized_ && !is_bottommost_ | 525 return is_optimized_ && !is_bottommost_ |
526 ? deoptimized_frame_->HasConstructStub() | 526 ? deoptimized_frame_->HasConstructStub() |
527 : frame_->IsConstructor(); | 527 : frame_->IsConstructor(); |
528 } | 528 } |
529 Object* GetContext() { | 529 Object* GetContext() { |
530 return is_optimized_ ? deoptimized_frame_->GetContext() : frame_->context(); | 530 return is_optimized_ ? deoptimized_frame_->GetContext() : frame_->context(); |
531 } | 531 } |
| 532 JavaScriptFrame* GetArgumentsFrame() { return frame_; } |
532 | 533 |
533 // To inspect all the provided arguments the frame might need to be | 534 // To inspect all the provided arguments the frame might need to be |
534 // replaced with the arguments frame. | 535 // replaced with the arguments frame. |
535 void SetArgumentsFrame(JavaScriptFrame* frame) { | 536 void SetArgumentsFrame(JavaScriptFrame* frame) { |
536 DCHECK(has_adapted_arguments_); | 537 DCHECK(has_adapted_arguments_); |
537 frame_ = frame; | 538 frame_ = frame; |
538 is_optimized_ = frame_->is_optimized(); | 539 is_optimized_ = frame_->is_optimized(); |
539 DCHECK(!is_optimized_); | 540 DCHECK(!is_optimized_); |
540 } | 541 } |
541 | 542 |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
952 | 953 |
953 MaterializeStackLocalsWithFrameInspector(isolate, target, scope_info, | 954 MaterializeStackLocalsWithFrameInspector(isolate, target, scope_info, |
954 frame_inspector); | 955 frame_inspector); |
955 } | 956 } |
956 | 957 |
957 | 958 |
958 static void UpdateStackLocalsFromMaterializedObject( | 959 static void UpdateStackLocalsFromMaterializedObject( |
959 Isolate* isolate, Handle<JSObject> target, Handle<ScopeInfo> scope_info, | 960 Isolate* isolate, Handle<JSObject> target, Handle<ScopeInfo> scope_info, |
960 JavaScriptFrame* frame, int inlined_jsframe_index) { | 961 JavaScriptFrame* frame, int inlined_jsframe_index) { |
961 if (inlined_jsframe_index != 0 || frame->is_optimized()) { | 962 if (inlined_jsframe_index != 0 || frame->is_optimized()) { |
962 // Optimized frames are not supported. | 963 // Optimized frames are not supported. Simply give up. |
963 // TODO(yangguo): make sure all code deoptimized when debugger is active | |
964 // and assert that this cannot happen. | |
965 return; | 964 return; |
966 } | 965 } |
967 | 966 |
968 // Parameters. | 967 // Parameters. |
969 for (int i = 0; i < scope_info->ParameterCount(); ++i) { | 968 for (int i = 0; i < scope_info->ParameterCount(); ++i) { |
970 // Shadowed parameters were not materialized. | 969 // Shadowed parameters were not materialized. |
971 Handle<String> name(scope_info->ParameterName(i)); | 970 Handle<String> name(scope_info->ParameterName(i)); |
972 if (ParameterIsShadowedByContextLocal(scope_info, name)) continue; | 971 if (ParameterIsShadowedByContextLocal(scope_info, name)) continue; |
973 | 972 |
974 DCHECK(!frame->GetParameter(i)->IsTheHole()); | 973 DCHECK(!frame->GetParameter(i)->IsTheHole()); |
(...skipping 12 matching lines...) Expand all Loading... |
987 Handle<Object> value = Object::GetPropertyOrElement( | 986 Handle<Object> value = Object::GetPropertyOrElement( |
988 target, handle(scope_info->StackLocalName(i), | 987 target, handle(scope_info->StackLocalName(i), |
989 isolate)).ToHandleChecked(); | 988 isolate)).ToHandleChecked(); |
990 frame->SetExpression(index, *value); | 989 frame->SetExpression(index, *value); |
991 } | 990 } |
992 } | 991 } |
993 | 992 |
994 | 993 |
995 MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeLocalContext( | 994 MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeLocalContext( |
996 Isolate* isolate, Handle<JSObject> target, Handle<JSFunction> function, | 995 Isolate* isolate, Handle<JSObject> target, Handle<JSFunction> function, |
997 JavaScriptFrame* frame) { | 996 Handle<Context> frame_context) { |
998 HandleScope scope(isolate); | 997 HandleScope scope(isolate); |
999 Handle<SharedFunctionInfo> shared(function->shared()); | 998 Handle<SharedFunctionInfo> shared(function->shared()); |
1000 Handle<ScopeInfo> scope_info(shared->scope_info()); | 999 Handle<ScopeInfo> scope_info(shared->scope_info()); |
1001 | 1000 |
1002 if (!scope_info->HasContext()) return target; | 1001 if (!scope_info->HasContext()) return target; |
1003 | 1002 |
1004 // Third fill all context locals. | 1003 // Third fill all context locals. |
1005 Handle<Context> frame_context(Context::cast(frame->context())); | |
1006 Handle<Context> function_context(frame_context->declaration_context()); | 1004 Handle<Context> function_context(frame_context->declaration_context()); |
1007 ScopeInfo::CopyContextLocalsToScopeObject(scope_info, function_context, | 1005 ScopeInfo::CopyContextLocalsToScopeObject(scope_info, function_context, |
1008 target); | 1006 target); |
1009 | 1007 |
1010 // Finally copy any properties from the function context extension. | 1008 // Finally copy any properties from the function context extension. |
1011 // These will be variables introduced by eval. | 1009 // These will be variables introduced by eval. |
1012 if (function_context->closure() == *function) { | 1010 if (function_context->closure() == *function) { |
1013 if (function_context->has_extension() && | 1011 if (function_context->has_extension() && |
1014 !function_context->IsNativeContext()) { | 1012 !function_context->IsNativeContext()) { |
1015 Handle<JSObject> ext(JSObject::cast(function_context->extension())); | 1013 Handle<JSObject> ext(JSObject::cast(function_context->extension())); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1051 ScriptContextTable::GetContext(script_contexts, context_index); | 1049 ScriptContextTable::GetContext(script_contexts, context_index); |
1052 Handle<ScopeInfo> scope_info(ScopeInfo::cast(context->extension())); | 1050 Handle<ScopeInfo> scope_info(ScopeInfo::cast(context->extension())); |
1053 ScopeInfo::CopyContextLocalsToScopeObject(scope_info, context, | 1051 ScopeInfo::CopyContextLocalsToScopeObject(scope_info, context, |
1054 script_scope); | 1052 script_scope); |
1055 } | 1053 } |
1056 return script_scope; | 1054 return script_scope; |
1057 } | 1055 } |
1058 | 1056 |
1059 | 1057 |
1060 MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeLocalScope( | 1058 MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeLocalScope( |
1061 Isolate* isolate, JavaScriptFrame* frame, int inlined_jsframe_index) { | 1059 Isolate* isolate, FrameInspector* frame_inspector) { |
1062 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate); | 1060 Handle<JSFunction> function(JSFunction::cast(frame_inspector->GetFunction())); |
1063 Handle<JSFunction> function(JSFunction::cast(frame_inspector.GetFunction())); | |
1064 | 1061 |
1065 Handle<JSObject> local_scope = | 1062 Handle<JSObject> local_scope = |
1066 isolate->factory()->NewJSObject(isolate->object_function()); | 1063 isolate->factory()->NewJSObject(isolate->object_function()); |
1067 MaterializeStackLocalsWithFrameInspector(isolate, local_scope, function, | 1064 MaterializeStackLocalsWithFrameInspector(isolate, local_scope, function, |
1068 &frame_inspector); | 1065 frame_inspector); |
1069 | 1066 |
1070 return MaterializeLocalContext(isolate, local_scope, function, frame); | 1067 Handle<Context> frame_context(Context::cast(frame_inspector->GetContext())); |
| 1068 |
| 1069 return MaterializeLocalContext(isolate, local_scope, function, frame_context); |
1071 } | 1070 } |
1072 | 1071 |
1073 | 1072 |
1074 // Set the context local variable value. | 1073 // Set the context local variable value. |
1075 static bool SetContextLocalValue(Isolate* isolate, Handle<ScopeInfo> scope_info, | 1074 static bool SetContextLocalValue(Isolate* isolate, Handle<ScopeInfo> scope_info, |
1076 Handle<Context> context, | 1075 Handle<Context> context, |
1077 Handle<String> variable_name, | 1076 Handle<String> variable_name, |
1078 Handle<Object> new_value) { | 1077 Handle<Object> new_value) { |
1079 for (int i = 0; i < scope_info->ContextLocalCount(); i++) { | 1078 for (int i = 0; i < scope_info->ContextLocalCount(); i++) { |
1080 Handle<String> next_name(scope_info->ContextLocalName(i)); | 1079 Handle<String> next_name(scope_info->ContextLocalName(i)); |
1081 if (String::Equals(variable_name, next_name)) { | 1080 if (String::Equals(variable_name, next_name)) { |
1082 VariableMode mode; | 1081 VariableMode mode; |
1083 VariableLocation location; | 1082 VariableLocation location; |
1084 InitializationFlag init_flag; | 1083 InitializationFlag init_flag; |
1085 MaybeAssignedFlag maybe_assigned_flag; | 1084 MaybeAssignedFlag maybe_assigned_flag; |
1086 int context_index = | 1085 int context_index = |
1087 ScopeInfo::ContextSlotIndex(scope_info, next_name, &mode, &location, | 1086 ScopeInfo::ContextSlotIndex(scope_info, next_name, &mode, &location, |
1088 &init_flag, &maybe_assigned_flag); | 1087 &init_flag, &maybe_assigned_flag); |
1089 context->set(context_index, *new_value); | 1088 context->set(context_index, *new_value); |
1090 return true; | 1089 return true; |
1091 } | 1090 } |
1092 } | 1091 } |
1093 | 1092 |
1094 return false; | 1093 return false; |
1095 } | 1094 } |
1096 | 1095 |
1097 | 1096 |
1098 static bool SetLocalVariableValue(Isolate* isolate, JavaScriptFrame* frame, | 1097 static bool SetLocalVariableValue(Isolate* isolate, JavaScriptFrame* frame, |
1099 int inlined_jsframe_index, | |
1100 Handle<String> variable_name, | 1098 Handle<String> variable_name, |
1101 Handle<Object> new_value) { | 1099 Handle<Object> new_value) { |
1102 if (inlined_jsframe_index != 0 || frame->is_optimized()) { | 1100 // Optimized frames are not supported. |
1103 // Optimized frames are not supported. | 1101 if (frame->is_optimized()) return false; |
1104 return false; | |
1105 } | |
1106 | 1102 |
1107 Handle<JSFunction> function(frame->function()); | 1103 Handle<JSFunction> function(frame->function()); |
1108 Handle<SharedFunctionInfo> shared(function->shared()); | 1104 Handle<SharedFunctionInfo> shared(function->shared()); |
1109 Handle<ScopeInfo> scope_info(shared->scope_info()); | 1105 Handle<ScopeInfo> scope_info(shared->scope_info()); |
1110 | 1106 |
1111 bool default_result = false; | 1107 bool default_result = false; |
1112 | 1108 |
1113 // Parameters. | 1109 // Parameters. |
1114 for (int i = 0; i < scope_info->ParameterCount(); ++i) { | 1110 for (int i = 0; i < scope_info->ParameterCount(); ++i) { |
1115 HandleScope scope(isolate); | 1111 HandleScope scope(isolate); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1304 context->set(Context::THROWN_OBJECT_INDEX, *new_value); | 1300 context->set(Context::THROWN_OBJECT_INDEX, *new_value); |
1305 return true; | 1301 return true; |
1306 } | 1302 } |
1307 | 1303 |
1308 | 1304 |
1309 // Create a plain JSObject which materializes the block scope for the specified | 1305 // Create a plain JSObject which materializes the block scope for the specified |
1310 // block context. | 1306 // block context. |
1311 static Handle<JSObject> MaterializeBlockScope(Isolate* isolate, | 1307 static Handle<JSObject> MaterializeBlockScope(Isolate* isolate, |
1312 Handle<ScopeInfo> scope_info, | 1308 Handle<ScopeInfo> scope_info, |
1313 Handle<Context> context, | 1309 Handle<Context> context, |
1314 JavaScriptFrame* frame, | 1310 FrameInspector* frame_inspector) { |
1315 int inlined_jsframe_index) { | |
1316 Handle<JSObject> block_scope = | 1311 Handle<JSObject> block_scope = |
1317 isolate->factory()->NewJSObject(isolate->object_function()); | 1312 isolate->factory()->NewJSObject(isolate->object_function()); |
1318 | 1313 |
1319 if (frame != nullptr) { | 1314 if (frame_inspector != nullptr) { |
1320 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate); | |
1321 MaterializeStackLocalsWithFrameInspector(isolate, block_scope, scope_info, | 1315 MaterializeStackLocalsWithFrameInspector(isolate, block_scope, scope_info, |
1322 &frame_inspector); | 1316 frame_inspector); |
1323 } | 1317 } |
1324 | 1318 |
1325 if (!context.is_null()) { | 1319 if (!context.is_null()) { |
1326 Handle<ScopeInfo> scope_info_from_context( | 1320 Handle<ScopeInfo> scope_info_from_context( |
1327 ScopeInfo::cast(context->extension())); | 1321 ScopeInfo::cast(context->extension())); |
1328 // Fill all context locals. | 1322 // Fill all context locals. |
1329 ScopeInfo::CopyContextLocalsToScopeObject(scope_info_from_context, context, | 1323 ScopeInfo::CopyContextLocalsToScopeObject(scope_info_from_context, context, |
1330 block_scope); | 1324 block_scope); |
1331 } | 1325 } |
1332 | 1326 |
(...skipping 30 matching lines...) Expand all Loading... |
1363 ScopeTypeGlobal = 0, | 1357 ScopeTypeGlobal = 0, |
1364 ScopeTypeLocal, | 1358 ScopeTypeLocal, |
1365 ScopeTypeWith, | 1359 ScopeTypeWith, |
1366 ScopeTypeClosure, | 1360 ScopeTypeClosure, |
1367 ScopeTypeCatch, | 1361 ScopeTypeCatch, |
1368 ScopeTypeBlock, | 1362 ScopeTypeBlock, |
1369 ScopeTypeScript, | 1363 ScopeTypeScript, |
1370 ScopeTypeModule | 1364 ScopeTypeModule |
1371 }; | 1365 }; |
1372 | 1366 |
1373 ScopeIterator(Isolate* isolate, JavaScriptFrame* frame, | 1367 ScopeIterator(Isolate* isolate, FrameInspector* frame_inspector, |
1374 int inlined_jsframe_index, bool ignore_nested_scopes = false) | 1368 bool ignore_nested_scopes = false) |
1375 : isolate_(isolate), | 1369 : isolate_(isolate), |
1376 frame_(frame), | 1370 frame_inspector_(frame_inspector), |
1377 inlined_jsframe_index_(inlined_jsframe_index), | |
1378 function_(frame->function()), | |
1379 context_(Context::cast(frame->context())), | |
1380 nested_scope_chain_(4), | 1371 nested_scope_chain_(4), |
1381 seen_script_scope_(false), | 1372 seen_script_scope_(false), |
1382 failed_(false) { | 1373 failed_(false) { |
| 1374 if (!frame_inspector->GetContext()->IsContext() || |
| 1375 !frame_inspector->GetFunction()->IsJSFunction()) { |
| 1376 // Optimized frame, context or function cannot be materialized. Give up. |
| 1377 return; |
| 1378 } |
| 1379 |
| 1380 context_ = Handle<Context>(Context::cast(frame_inspector->GetContext())); |
| 1381 |
1383 // Catch the case when the debugger stops in an internal function. | 1382 // Catch the case when the debugger stops in an internal function. |
1384 Handle<SharedFunctionInfo> shared_info(function_->shared()); | 1383 Handle<SharedFunctionInfo> shared_info(function()->shared()); |
1385 Handle<ScopeInfo> scope_info(shared_info->scope_info()); | 1384 Handle<ScopeInfo> scope_info(shared_info->scope_info()); |
1386 if (shared_info->script() == isolate->heap()->undefined_value()) { | 1385 if (shared_info->script() == isolate->heap()->undefined_value()) { |
1387 while (context_->closure() == *function_) { | 1386 while (context_->closure() == function()) { |
1388 context_ = Handle<Context>(context_->previous(), isolate_); | 1387 context_ = Handle<Context>(context_->previous(), isolate_); |
1389 } | 1388 } |
1390 return; | 1389 return; |
1391 } | 1390 } |
1392 | 1391 |
1393 // Currently it takes too much time to find nested scopes due to script | 1392 // Currently it takes too much time to find nested scopes due to script |
1394 // parsing. Sometimes we want to run the ScopeIterator as fast as possible | 1393 // parsing. Sometimes we want to run the ScopeIterator as fast as possible |
1395 // (for example, while collecting async call stacks on every | 1394 // (for example, while collecting async call stacks on every |
1396 // addEventListener call), even if we drop some nested scopes. | 1395 // addEventListener call), even if we drop some nested scopes. |
1397 // Later we may optimize getting the nested scopes (cache the result?) | 1396 // Later we may optimize getting the nested scopes (cache the result?) |
1398 // and include nested scopes into the "fast" iteration case as well. | 1397 // and include nested scopes into the "fast" iteration case as well. |
1399 | 1398 |
1400 if (!ignore_nested_scopes && !shared_info->debug_info()->IsUndefined()) { | 1399 if (!ignore_nested_scopes && !shared_info->debug_info()->IsUndefined()) { |
1401 // The source position at return is always the end of the function, | 1400 // The source position at return is always the end of the function, |
1402 // which is not consistent with the current scope chain. Therefore all | 1401 // which is not consistent with the current scope chain. Therefore all |
1403 // nested with, catch and block contexts are skipped, and we can only | 1402 // nested with, catch and block contexts are skipped, and we can only |
1404 // inspect the function scope. | 1403 // inspect the function scope. |
1405 // This can only happen if we set a break point inside right before the | 1404 // This can only happen if we set a break point inside right before the |
1406 // return, which requires a debug info to be available. | 1405 // return, which requires a debug info to be available. |
1407 Handle<DebugInfo> debug_info = Debug::GetDebugInfo(shared_info); | 1406 Handle<DebugInfo> debug_info = Debug::GetDebugInfo(shared_info); |
1408 | 1407 |
1409 // PC points to the instruction after the current one, possibly a break | 1408 // PC points to the instruction after the current one, possibly a break |
1410 // location as well. So the "- 1" to exclude it from the search. | 1409 // location as well. So the "- 1" to exclude it from the search. |
1411 Address call_pc = frame->pc() - 1; | 1410 Address call_pc = frame()->pc() - 1; |
1412 | 1411 |
1413 // Find the break point where execution has stopped. | 1412 // Find the break point where execution has stopped. |
1414 BreakLocation location = | 1413 BreakLocation location = |
1415 BreakLocation::FromAddress(debug_info, ALL_BREAK_LOCATIONS, call_pc); | 1414 BreakLocation::FromAddress(debug_info, ALL_BREAK_LOCATIONS, call_pc); |
1416 | 1415 |
1417 ignore_nested_scopes = location.IsReturn(); | 1416 ignore_nested_scopes = location.IsReturn(); |
1418 } | 1417 } |
1419 | 1418 |
1420 if (ignore_nested_scopes) { | 1419 if (ignore_nested_scopes) { |
1421 if (scope_info->HasContext()) { | 1420 if (scope_info->HasContext()) { |
1422 context_ = Handle<Context>(context_->declaration_context(), isolate_); | 1421 context_ = Handle<Context>(context_->declaration_context(), isolate_); |
1423 } else { | 1422 } else { |
1424 while (context_->closure() == *function_) { | 1423 while (context_->closure() == function()) { |
1425 context_ = Handle<Context>(context_->previous(), isolate_); | 1424 context_ = Handle<Context>(context_->previous(), isolate_); |
1426 } | 1425 } |
1427 } | 1426 } |
1428 if (scope_info->scope_type() == FUNCTION_SCOPE || | 1427 if (scope_info->scope_type() == FUNCTION_SCOPE || |
1429 scope_info->scope_type() == ARROW_SCOPE) { | 1428 scope_info->scope_type() == ARROW_SCOPE) { |
1430 nested_scope_chain_.Add(scope_info); | 1429 nested_scope_chain_.Add(scope_info); |
1431 } | 1430 } |
1432 } else { | 1431 } else { |
1433 // Reparse the code and analyze the scopes. | 1432 // Reparse the code and analyze the scopes. |
1434 Handle<Script> script(Script::cast(shared_info->script())); | 1433 Handle<Script> script(Script::cast(shared_info->script())); |
1435 Scope* scope = NULL; | 1434 Scope* scope = NULL; |
1436 | 1435 |
1437 // Check whether we are in global, eval or function code. | 1436 // Check whether we are in global, eval or function code. |
1438 Handle<ScopeInfo> scope_info(shared_info->scope_info()); | 1437 Handle<ScopeInfo> scope_info(shared_info->scope_info()); |
1439 Zone zone; | 1438 Zone zone; |
1440 if (scope_info->scope_type() != FUNCTION_SCOPE && | 1439 if (scope_info->scope_type() != FUNCTION_SCOPE && |
1441 scope_info->scope_type() != ARROW_SCOPE) { | 1440 scope_info->scope_type() != ARROW_SCOPE) { |
1442 // Global or eval code. | 1441 // Global or eval code. |
1443 ParseInfo info(&zone, script); | 1442 ParseInfo info(&zone, script); |
1444 if (scope_info->scope_type() == SCRIPT_SCOPE) { | 1443 if (scope_info->scope_type() == SCRIPT_SCOPE) { |
1445 info.set_global(); | 1444 info.set_global(); |
1446 } else { | 1445 } else { |
1447 DCHECK(scope_info->scope_type() == EVAL_SCOPE); | 1446 DCHECK(scope_info->scope_type() == EVAL_SCOPE); |
1448 info.set_eval(); | 1447 info.set_eval(); |
1449 info.set_context(Handle<Context>(function_->context())); | 1448 info.set_context(Handle<Context>(function()->context())); |
1450 } | 1449 } |
1451 if (Parser::ParseStatic(&info) && Scope::Analyze(&info)) { | 1450 if (Parser::ParseStatic(&info) && Scope::Analyze(&info)) { |
1452 scope = info.function()->scope(); | 1451 scope = info.function()->scope(); |
1453 } | 1452 } |
1454 RetrieveScopeChain(scope, shared_info); | 1453 RetrieveScopeChain(scope, shared_info); |
1455 } else { | 1454 } else { |
1456 // Function code | 1455 // Function code |
1457 ParseInfo info(&zone, function_); | 1456 ParseInfo info(&zone, Handle<JSFunction>(function())); |
1458 if (Parser::ParseStatic(&info) && Scope::Analyze(&info)) { | 1457 if (Parser::ParseStatic(&info) && Scope::Analyze(&info)) { |
1459 scope = info.function()->scope(); | 1458 scope = info.function()->scope(); |
1460 } | 1459 } |
1461 RetrieveScopeChain(scope, shared_info); | 1460 RetrieveScopeChain(scope, shared_info); |
1462 } | 1461 } |
1463 } | 1462 } |
1464 } | 1463 } |
1465 | 1464 |
1466 ScopeIterator(Isolate* isolate, Handle<JSFunction> function) | 1465 ScopeIterator(Isolate* isolate, Handle<JSFunction> function) |
1467 : isolate_(isolate), | 1466 : isolate_(isolate), |
1468 frame_(NULL), | 1467 frame_inspector_(NULL), |
1469 inlined_jsframe_index_(0), | |
1470 function_(function), | |
1471 context_(function->context()), | 1468 context_(function->context()), |
1472 seen_script_scope_(false), | 1469 seen_script_scope_(false), |
1473 failed_(false) { | 1470 failed_(false) { |
1474 if (function->IsBuiltin()) { | 1471 if (function->IsBuiltin()) context_ = Handle<Context>(); |
1475 context_ = Handle<Context>(); | |
1476 } | |
1477 } | 1472 } |
1478 | 1473 |
1479 // More scopes? | 1474 // More scopes? |
1480 bool Done() { | 1475 bool Done() { |
1481 DCHECK(!failed_); | 1476 DCHECK(!failed_); |
1482 return context_.is_null(); | 1477 return context_.is_null(); |
1483 } | 1478 } |
1484 | 1479 |
1485 bool Failed() { return failed_; } | 1480 bool Failed() { return failed_; } |
1486 | 1481 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1577 DCHECK(!failed_); | 1572 DCHECK(!failed_); |
1578 switch (Type()) { | 1573 switch (Type()) { |
1579 case ScopeIterator::ScopeTypeGlobal: | 1574 case ScopeIterator::ScopeTypeGlobal: |
1580 return Handle<JSObject>(CurrentContext()->global_object()); | 1575 return Handle<JSObject>(CurrentContext()->global_object()); |
1581 case ScopeIterator::ScopeTypeScript: | 1576 case ScopeIterator::ScopeTypeScript: |
1582 return MaterializeScriptScope( | 1577 return MaterializeScriptScope( |
1583 Handle<GlobalObject>(CurrentContext()->global_object())); | 1578 Handle<GlobalObject>(CurrentContext()->global_object())); |
1584 case ScopeIterator::ScopeTypeLocal: | 1579 case ScopeIterator::ScopeTypeLocal: |
1585 // Materialize the content of the local scope into a JSObject. | 1580 // Materialize the content of the local scope into a JSObject. |
1586 DCHECK(nested_scope_chain_.length() == 1); | 1581 DCHECK(nested_scope_chain_.length() == 1); |
1587 return MaterializeLocalScope(isolate_, frame_, inlined_jsframe_index_); | 1582 return MaterializeLocalScope(isolate_, frame_inspector_); |
1588 case ScopeIterator::ScopeTypeWith: | 1583 case ScopeIterator::ScopeTypeWith: |
1589 // Return the with object. | 1584 // Return the with object. |
1590 return Handle<JSObject>(JSObject::cast(CurrentContext()->extension())); | 1585 return Handle<JSObject>(JSObject::cast(CurrentContext()->extension())); |
1591 case ScopeIterator::ScopeTypeCatch: | 1586 case ScopeIterator::ScopeTypeCatch: |
1592 return MaterializeCatchScope(isolate_, CurrentContext()); | 1587 return MaterializeCatchScope(isolate_, CurrentContext()); |
1593 case ScopeIterator::ScopeTypeClosure: | 1588 case ScopeIterator::ScopeTypeClosure: |
1594 // Materialize the content of the closure scope into a JSObject. | 1589 // Materialize the content of the closure scope into a JSObject. |
1595 return MaterializeClosure(isolate_, CurrentContext()); | 1590 return MaterializeClosure(isolate_, CurrentContext()); |
1596 case ScopeIterator::ScopeTypeBlock: { | 1591 case ScopeIterator::ScopeTypeBlock: { |
1597 if (!nested_scope_chain_.is_empty()) { | 1592 if (!nested_scope_chain_.is_empty()) { |
1598 // this is a block scope on the stack. | 1593 // this is a block scope on the stack. |
1599 Handle<ScopeInfo> scope_info = nested_scope_chain_.last(); | 1594 Handle<ScopeInfo> scope_info = nested_scope_chain_.last(); |
1600 Handle<Context> context = scope_info->HasContext() | 1595 Handle<Context> context = scope_info->HasContext() |
1601 ? CurrentContext() | 1596 ? CurrentContext() |
1602 : Handle<Context>::null(); | 1597 : Handle<Context>::null(); |
1603 return MaterializeBlockScope(isolate_, scope_info, context, frame_, | 1598 return MaterializeBlockScope(isolate_, scope_info, context, |
1604 inlined_jsframe_index_); | 1599 frame_inspector_); |
1605 } else { | 1600 } else { |
1606 return MaterializeBlockScope(isolate_, Handle<ScopeInfo>::null(), | 1601 return MaterializeBlockScope(isolate_, Handle<ScopeInfo>::null(), |
1607 CurrentContext(), nullptr, 0); | 1602 CurrentContext(), nullptr); |
1608 } | 1603 } |
1609 } | 1604 } |
1610 case ScopeIterator::ScopeTypeModule: | 1605 case ScopeIterator::ScopeTypeModule: |
1611 return MaterializeModuleScope(isolate_, CurrentContext()); | 1606 return MaterializeModuleScope(isolate_, CurrentContext()); |
1612 } | 1607 } |
1613 UNREACHABLE(); | 1608 UNREACHABLE(); |
1614 return Handle<JSObject>(); | 1609 return Handle<JSObject>(); |
1615 } | 1610 } |
1616 | 1611 |
1617 bool HasContext() { | 1612 bool HasContext() { |
1618 ScopeType type = Type(); | 1613 ScopeType type = Type(); |
1619 if (type == ScopeTypeBlock || type == ScopeTypeLocal) { | 1614 if (type == ScopeTypeBlock || type == ScopeTypeLocal) { |
1620 if (!nested_scope_chain_.is_empty()) { | 1615 if (!nested_scope_chain_.is_empty()) { |
1621 return nested_scope_chain_.last()->HasContext(); | 1616 return nested_scope_chain_.last()->HasContext(); |
1622 } | 1617 } |
1623 } | 1618 } |
1624 return true; | 1619 return true; |
1625 } | 1620 } |
1626 | 1621 |
1627 bool SetVariableValue(Handle<String> variable_name, | 1622 bool SetVariableValue(Handle<String> variable_name, |
1628 Handle<Object> new_value) { | 1623 Handle<Object> new_value) { |
1629 DCHECK(!failed_); | 1624 DCHECK(!failed_); |
1630 switch (Type()) { | 1625 switch (Type()) { |
1631 case ScopeIterator::ScopeTypeGlobal: | 1626 case ScopeIterator::ScopeTypeGlobal: |
1632 break; | 1627 break; |
1633 case ScopeIterator::ScopeTypeLocal: | 1628 case ScopeIterator::ScopeTypeLocal: |
1634 return SetLocalVariableValue(isolate_, frame_, inlined_jsframe_index_, | 1629 return SetLocalVariableValue(isolate_, frame(), variable_name, |
1635 variable_name, new_value); | 1630 new_value); |
1636 case ScopeIterator::ScopeTypeWith: | 1631 case ScopeIterator::ScopeTypeWith: |
1637 break; | 1632 break; |
1638 case ScopeIterator::ScopeTypeCatch: | 1633 case ScopeIterator::ScopeTypeCatch: |
1639 return SetCatchVariableValue(isolate_, CurrentContext(), variable_name, | 1634 return SetCatchVariableValue(isolate_, CurrentContext(), variable_name, |
1640 new_value); | 1635 new_value); |
1641 case ScopeIterator::ScopeTypeClosure: | 1636 case ScopeIterator::ScopeTypeClosure: |
1642 return SetClosureVariableValue(isolate_, CurrentContext(), | 1637 return SetClosureVariableValue(isolate_, CurrentContext(), |
1643 variable_name, new_value); | 1638 variable_name, new_value); |
1644 case ScopeIterator::ScopeTypeScript: | 1639 case ScopeIterator::ScopeTypeScript: |
1645 return SetScriptVariableValue(CurrentContext(), variable_name, | 1640 return SetScriptVariableValue(CurrentContext(), variable_name, |
1646 new_value); | 1641 new_value); |
1647 case ScopeIterator::ScopeTypeBlock: | 1642 case ScopeIterator::ScopeTypeBlock: |
1648 return SetBlockVariableValue( | 1643 return SetBlockVariableValue( |
1649 isolate_, HasContext() ? CurrentContext() : Handle<Context>::null(), | 1644 isolate_, HasContext() ? CurrentContext() : Handle<Context>::null(), |
1650 CurrentScopeInfo(), frame_, variable_name, new_value); | 1645 CurrentScopeInfo(), frame(), variable_name, new_value); |
1651 case ScopeIterator::ScopeTypeModule: | 1646 case ScopeIterator::ScopeTypeModule: |
1652 // TODO(2399): should we implement it? | 1647 // TODO(2399): should we implement it? |
1653 break; | 1648 break; |
1654 } | 1649 } |
1655 return false; | 1650 return false; |
1656 } | 1651 } |
1657 | 1652 |
1658 Handle<ScopeInfo> CurrentScopeInfo() { | 1653 Handle<ScopeInfo> CurrentScopeInfo() { |
1659 DCHECK(!failed_); | 1654 DCHECK(!failed_); |
1660 if (!nested_scope_chain_.is_empty()) { | 1655 if (!nested_scope_chain_.is_empty()) { |
(...skipping 26 matching lines...) Expand all Loading... |
1687 OFStream os(stdout); | 1682 OFStream os(stdout); |
1688 DCHECK(!failed_); | 1683 DCHECK(!failed_); |
1689 switch (Type()) { | 1684 switch (Type()) { |
1690 case ScopeIterator::ScopeTypeGlobal: | 1685 case ScopeIterator::ScopeTypeGlobal: |
1691 os << "Global:\n"; | 1686 os << "Global:\n"; |
1692 CurrentContext()->Print(os); | 1687 CurrentContext()->Print(os); |
1693 break; | 1688 break; |
1694 | 1689 |
1695 case ScopeIterator::ScopeTypeLocal: { | 1690 case ScopeIterator::ScopeTypeLocal: { |
1696 os << "Local:\n"; | 1691 os << "Local:\n"; |
1697 function_->shared()->scope_info()->Print(); | 1692 function()->shared()->scope_info()->Print(); |
1698 if (!CurrentContext().is_null()) { | 1693 if (!CurrentContext().is_null()) { |
1699 CurrentContext()->Print(os); | 1694 CurrentContext()->Print(os); |
1700 if (CurrentContext()->has_extension()) { | 1695 if (CurrentContext()->has_extension()) { |
1701 Handle<Object> extension(CurrentContext()->extension(), isolate_); | 1696 Handle<Object> extension(CurrentContext()->extension(), isolate_); |
1702 if (extension->IsJSContextExtensionObject()) { | 1697 if (extension->IsJSContextExtensionObject()) { |
1703 extension->Print(os); | 1698 extension->Print(os); |
1704 } | 1699 } |
1705 } | 1700 } |
1706 } | 1701 } |
1707 break; | 1702 break; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1740 | 1735 |
1741 default: | 1736 default: |
1742 UNREACHABLE(); | 1737 UNREACHABLE(); |
1743 } | 1738 } |
1744 PrintF("\n"); | 1739 PrintF("\n"); |
1745 } | 1740 } |
1746 #endif | 1741 #endif |
1747 | 1742 |
1748 private: | 1743 private: |
1749 Isolate* isolate_; | 1744 Isolate* isolate_; |
1750 JavaScriptFrame* frame_; | 1745 FrameInspector* const frame_inspector_; |
1751 int inlined_jsframe_index_; | |
1752 Handle<JSFunction> function_; | |
1753 Handle<Context> context_; | 1746 Handle<Context> context_; |
1754 List<Handle<ScopeInfo> > nested_scope_chain_; | 1747 List<Handle<ScopeInfo> > nested_scope_chain_; |
1755 bool seen_script_scope_; | 1748 bool seen_script_scope_; |
1756 bool failed_; | 1749 bool failed_; |
1757 | 1750 |
| 1751 inline JavaScriptFrame* frame() { |
| 1752 return frame_inspector_->GetArgumentsFrame(); |
| 1753 } |
| 1754 |
| 1755 inline JSFunction* function() { |
| 1756 return JSFunction::cast(frame_inspector_->GetFunction()); |
| 1757 } |
| 1758 |
1758 void RetrieveScopeChain(Scope* scope, | 1759 void RetrieveScopeChain(Scope* scope, |
1759 Handle<SharedFunctionInfo> shared_info) { | 1760 Handle<SharedFunctionInfo> shared_info) { |
1760 if (scope != NULL) { | 1761 if (scope != NULL) { |
1761 int source_position = shared_info->code()->SourcePosition(frame_->pc()); | 1762 int source_position = frame_inspector_->GetSourcePosition(); |
1762 scope->GetNestedScopeChain(isolate_, &nested_scope_chain_, | 1763 scope->GetNestedScopeChain(isolate_, &nested_scope_chain_, |
1763 source_position); | 1764 source_position); |
1764 } else { | 1765 } else { |
1765 // A failed reparse indicates that the preparser has diverged from the | 1766 // A failed reparse indicates that the preparser has diverged from the |
1766 // parser or that the preparse data given to the initial parse has been | 1767 // parser or that the preparse data given to the initial parse has been |
1767 // faulty. We fail in debug mode but in release mode we only provide the | 1768 // faulty. We fail in debug mode but in release mode we only provide the |
1768 // information we get from the context chain but nothing about | 1769 // information we get from the context chain but nothing about |
1769 // completely stack allocated scopes or stack allocated locals. | 1770 // completely stack allocated scopes or stack allocated locals. |
1770 // Or it could be due to stack overflow. | 1771 // Or it could be due to stack overflow. |
1771 DCHECK(isolate_->has_pending_exception()); | 1772 DCHECK(isolate_->has_pending_exception()); |
(...skipping 10 matching lines...) Expand all Loading... |
1782 DCHECK(args.length() == 2); | 1783 DCHECK(args.length() == 2); |
1783 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 1784 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
1784 RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id)); | 1785 RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id)); |
1785 | 1786 |
1786 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); | 1787 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); |
1787 | 1788 |
1788 // Get the frame where the debugging is performed. | 1789 // Get the frame where the debugging is performed. |
1789 StackFrame::Id id = UnwrapFrameId(wrapped_id); | 1790 StackFrame::Id id = UnwrapFrameId(wrapped_id); |
1790 JavaScriptFrameIterator it(isolate, id); | 1791 JavaScriptFrameIterator it(isolate, id); |
1791 JavaScriptFrame* frame = it.frame(); | 1792 JavaScriptFrame* frame = it.frame(); |
| 1793 FrameInspector frame_inspector(frame, 0, isolate); |
1792 | 1794 |
1793 // Count the visible scopes. | 1795 // Count the visible scopes. |
1794 int n = 0; | 1796 int n = 0; |
1795 for (ScopeIterator it(isolate, frame, 0); !it.Done(); it.Next()) { | 1797 for (ScopeIterator it(isolate, &frame_inspector); !it.Done(); it.Next()) { |
1796 n++; | 1798 n++; |
1797 } | 1799 } |
1798 | 1800 |
1799 return Smi::FromInt(n); | 1801 return Smi::FromInt(n); |
1800 } | 1802 } |
1801 | 1803 |
1802 | 1804 |
1803 // Returns the list of step-in positions (text offset) in a function of the | 1805 // Returns the list of step-in positions (text offset) in a function of the |
1804 // stack frame in a range from the current debug break position to the end | 1806 // stack frame in a range from the current debug break position to the end |
1805 // of the corresponding statement. | 1807 // of the corresponding statement. |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1910 RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id)); | 1912 RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id)); |
1911 | 1913 |
1912 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); | 1914 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); |
1913 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); | 1915 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); |
1914 CONVERT_NUMBER_CHECKED(int, index, Int32, args[3]); | 1916 CONVERT_NUMBER_CHECKED(int, index, Int32, args[3]); |
1915 | 1917 |
1916 // Get the frame where the debugging is performed. | 1918 // Get the frame where the debugging is performed. |
1917 StackFrame::Id id = UnwrapFrameId(wrapped_id); | 1919 StackFrame::Id id = UnwrapFrameId(wrapped_id); |
1918 JavaScriptFrameIterator frame_it(isolate, id); | 1920 JavaScriptFrameIterator frame_it(isolate, id); |
1919 JavaScriptFrame* frame = frame_it.frame(); | 1921 JavaScriptFrame* frame = frame_it.frame(); |
| 1922 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate); |
1920 | 1923 |
1921 // Find the requested scope. | 1924 // Find the requested scope. |
1922 int n = 0; | 1925 int n = 0; |
1923 ScopeIterator it(isolate, frame, inlined_jsframe_index); | 1926 ScopeIterator it(isolate, &frame_inspector); |
1924 for (; !it.Done() && n < index; it.Next()) { | 1927 for (; !it.Done() && n < index; it.Next()) { |
1925 n++; | 1928 n++; |
1926 } | 1929 } |
1927 if (it.Done()) { | 1930 if (it.Done()) { |
1928 return isolate->heap()->undefined_value(); | 1931 return isolate->heap()->undefined_value(); |
1929 } | 1932 } |
1930 Handle<JSObject> details; | 1933 Handle<JSObject> details; |
1931 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, details, | 1934 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, details, |
1932 MaterializeScopeDetails(isolate, &it)); | 1935 MaterializeScopeDetails(isolate, &it)); |
1933 return *details; | 1936 return *details; |
(...skipping 21 matching lines...) Expand all Loading... |
1955 bool ignore_nested_scopes = false; | 1958 bool ignore_nested_scopes = false; |
1956 if (args.length() == 4) { | 1959 if (args.length() == 4) { |
1957 CONVERT_BOOLEAN_ARG_CHECKED(flag, 3); | 1960 CONVERT_BOOLEAN_ARG_CHECKED(flag, 3); |
1958 ignore_nested_scopes = flag; | 1961 ignore_nested_scopes = flag; |
1959 } | 1962 } |
1960 | 1963 |
1961 // Get the frame where the debugging is performed. | 1964 // Get the frame where the debugging is performed. |
1962 StackFrame::Id id = UnwrapFrameId(wrapped_id); | 1965 StackFrame::Id id = UnwrapFrameId(wrapped_id); |
1963 JavaScriptFrameIterator frame_it(isolate, id); | 1966 JavaScriptFrameIterator frame_it(isolate, id); |
1964 JavaScriptFrame* frame = frame_it.frame(); | 1967 JavaScriptFrame* frame = frame_it.frame(); |
| 1968 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate); |
1965 | 1969 |
1966 List<Handle<JSObject> > result(4); | 1970 List<Handle<JSObject> > result(4); |
1967 ScopeIterator it(isolate, frame, inlined_jsframe_index, ignore_nested_scopes); | 1971 ScopeIterator it(isolate, &frame_inspector, ignore_nested_scopes); |
1968 for (; !it.Done(); it.Next()) { | 1972 for (; !it.Done(); it.Next()) { |
1969 Handle<JSObject> details; | 1973 Handle<JSObject> details; |
1970 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, details, | 1974 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, details, |
1971 MaterializeScopeDetails(isolate, &it)); | 1975 MaterializeScopeDetails(isolate, &it)); |
1972 result.Add(details); | 1976 result.Add(details); |
1973 } | 1977 } |
1974 | 1978 |
1975 Handle<FixedArray> array = isolate->factory()->NewFixedArray(result.length()); | 1979 Handle<FixedArray> array = isolate->factory()->NewFixedArray(result.length()); |
1976 for (int i = 0; i < result.length(); ++i) { | 1980 for (int i = 0; i < result.length(); ++i) { |
1977 array->set(i, *result[i]); | 1981 array->set(i, *result[i]); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2058 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 2062 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
2059 RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id)); | 2063 RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id)); |
2060 | 2064 |
2061 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); | 2065 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); |
2062 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); | 2066 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); |
2063 | 2067 |
2064 // Get the frame where the debugging is performed. | 2068 // Get the frame where the debugging is performed. |
2065 StackFrame::Id id = UnwrapFrameId(wrapped_id); | 2069 StackFrame::Id id = UnwrapFrameId(wrapped_id); |
2066 JavaScriptFrameIterator frame_it(isolate, id); | 2070 JavaScriptFrameIterator frame_it(isolate, id); |
2067 JavaScriptFrame* frame = frame_it.frame(); | 2071 JavaScriptFrame* frame = frame_it.frame(); |
| 2072 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate); |
2068 | 2073 |
2069 ScopeIterator it(isolate, frame, inlined_jsframe_index); | 2074 ScopeIterator it(isolate, &frame_inspector); |
2070 res = SetScopeVariableValue(&it, index, variable_name, new_value); | 2075 res = SetScopeVariableValue(&it, index, variable_name, new_value); |
2071 } else { | 2076 } else { |
2072 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); | 2077 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); |
2073 ScopeIterator it(isolate, fun); | 2078 ScopeIterator it(isolate, fun); |
2074 res = SetScopeVariableValue(&it, index, variable_name, new_value); | 2079 res = SetScopeVariableValue(&it, index, variable_name, new_value); |
2075 } | 2080 } |
2076 | 2081 |
2077 return isolate->heap()->ToBoolean(res); | 2082 return isolate->heap()->ToBoolean(res); |
2078 } | 2083 } |
2079 | 2084 |
2080 | 2085 |
2081 RUNTIME_FUNCTION(Runtime_DebugPrintScopes) { | 2086 RUNTIME_FUNCTION(Runtime_DebugPrintScopes) { |
2082 HandleScope scope(isolate); | 2087 HandleScope scope(isolate); |
2083 DCHECK(args.length() == 0); | 2088 DCHECK(args.length() == 0); |
2084 | 2089 |
2085 #ifdef DEBUG | 2090 #ifdef DEBUG |
2086 // Print the scopes for the top frame. | 2091 // Print the scopes for the top frame. |
2087 StackFrameLocator locator(isolate); | 2092 StackFrameLocator locator(isolate); |
2088 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0); | 2093 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0); |
2089 for (ScopeIterator it(isolate, frame, 0); !it.Done(); it.Next()) { | 2094 FrameInspector frame_inspector(frame, 0, isolate); |
| 2095 |
| 2096 for (ScopeIterator it(isolate, &frame_inspector); !it.Done(); it.Next()) { |
2090 it.DebugPrint(); | 2097 it.DebugPrint(); |
2091 } | 2098 } |
2092 #endif | 2099 #endif |
2093 return isolate->heap()->undefined_value(); | 2100 return isolate->heap()->undefined_value(); |
2094 } | 2101 } |
2095 | 2102 |
2096 | 2103 |
2097 RUNTIME_FUNCTION(Runtime_GetThreadCount) { | 2104 RUNTIME_FUNCTION(Runtime_GetThreadCount) { |
2098 HandleScope scope(isolate); | 2105 HandleScope scope(isolate); |
2099 DCHECK(args.length() == 1); | 2106 DCHECK(args.length() == 1); |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2472 frame_(frame), | 2479 frame_(frame), |
2473 inlined_jsframe_index_(inlined_jsframe_index) { | 2480 inlined_jsframe_index_(inlined_jsframe_index) { |
2474 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate); | 2481 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate); |
2475 Handle<JSFunction> function = | 2482 Handle<JSFunction> function = |
2476 handle(JSFunction::cast(frame_inspector.GetFunction())); | 2483 handle(JSFunction::cast(frame_inspector.GetFunction())); |
2477 Handle<Context> outer_context = handle(function->context(), isolate); | 2484 Handle<Context> outer_context = handle(function->context(), isolate); |
2478 outer_info_ = handle(function->shared()); | 2485 outer_info_ = handle(function->shared()); |
2479 Handle<Context> inner_context; | 2486 Handle<Context> inner_context; |
2480 | 2487 |
2481 bool stop = false; | 2488 bool stop = false; |
2482 for (ScopeIterator it(isolate, frame, inlined_jsframe_index); | 2489 for (ScopeIterator it(isolate, &frame_inspector); |
2483 !it.Failed() && !it.Done() && !stop; it.Next()) { | 2490 !it.Failed() && !it.Done() && !stop; it.Next()) { |
2484 ScopeIterator::ScopeType scope_type = it.Type(); | 2491 ScopeIterator::ScopeType scope_type = it.Type(); |
2485 | 2492 |
2486 if (scope_type == ScopeIterator::ScopeTypeLocal) { | 2493 if (scope_type == ScopeIterator::ScopeTypeLocal) { |
2487 Handle<Context> parent_context = | 2494 Handle<Context> parent_context = |
2488 it.HasContext() ? it.CurrentContext() : outer_context; | 2495 it.HasContext() ? it.CurrentContext() : outer_context; |
2489 | 2496 |
2490 // The "this" binding, if any, can't be bound via "with". If we need | 2497 // The "this" binding, if any, can't be bound via "with". If we need |
2491 // to, add another node onto the outer context to bind "this". | 2498 // to, add another node onto the outer context to bind "this". |
2492 parent_context = | 2499 parent_context = |
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3218 return *isolate->factory()->undefined_value(); | 3225 return *isolate->factory()->undefined_value(); |
3219 } | 3226 } |
3220 | 3227 |
3221 | 3228 |
3222 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { | 3229 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { |
3223 UNIMPLEMENTED(); | 3230 UNIMPLEMENTED(); |
3224 return NULL; | 3231 return NULL; |
3225 } | 3232 } |
3226 } // namespace internal | 3233 } // namespace internal |
3227 } // namespace v8 | 3234 } // namespace v8 |
OLD | NEW |