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