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 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
794 isolate, target, key, value, SLOPPY), | 794 isolate, target, key, value, SLOPPY), |
795 JSObject); | 795 JSObject); |
796 } | 796 } |
797 } | 797 } |
798 } | 798 } |
799 | 799 |
800 return target; | 800 return target; |
801 } | 801 } |
802 | 802 |
803 | 803 |
804 MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeScriptScope( | |
805 Handle<GlobalObject> global) { | |
806 Isolate* isolate = global->GetIsolate(); | |
807 Handle<ScriptContextTable> script_contexts( | |
808 global->native_context()->script_context_table()); | |
809 | |
810 Handle<JSObject> script_scope = | |
811 isolate->factory()->NewJSObject(isolate->object_function()); | |
812 | |
813 for (int context_index = 0; context_index < script_contexts->used(); | |
814 context_index++) { | |
815 Handle<Context> context = | |
816 ScriptContextTable::GetContext(script_contexts, context_index); | |
817 Handle<ScopeInfo> scope_info(ScopeInfo::cast(context->extension())); | |
818 if (!ScopeInfo::CopyContextLocalsToScopeObject(scope_info, context, | |
819 script_scope)) { | |
820 return MaybeHandle<JSObject>(); | |
821 } | |
822 } | |
823 return script_scope; | |
824 } | |
825 | |
826 | |
804 MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeLocalScope( | 827 MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeLocalScope( |
805 Isolate* isolate, JavaScriptFrame* frame, int inlined_jsframe_index) { | 828 Isolate* isolate, JavaScriptFrame* frame, int inlined_jsframe_index) { |
806 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate); | 829 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate); |
807 Handle<JSFunction> function(JSFunction::cast(frame_inspector.GetFunction())); | 830 Handle<JSFunction> function(JSFunction::cast(frame_inspector.GetFunction())); |
808 | 831 |
809 Handle<JSObject> local_scope = | 832 Handle<JSObject> local_scope = |
810 isolate->factory()->NewJSObject(isolate->object_function()); | 833 isolate->factory()->NewJSObject(isolate->object_function()); |
811 ASSIGN_RETURN_ON_EXCEPTION( | 834 ASSIGN_RETURN_ON_EXCEPTION( |
812 isolate, local_scope, | 835 isolate, local_scope, |
813 MaterializeStackLocalsWithFrameInspector(isolate, local_scope, function, | 836 MaterializeStackLocalsWithFrameInspector(isolate, local_scope, function, |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
990 Handle<String> variable_name, | 1013 Handle<String> variable_name, |
991 Handle<Object> new_value) { | 1014 Handle<Object> new_value) { |
992 DCHECK(block_context->IsBlockContext()); | 1015 DCHECK(block_context->IsBlockContext()); |
993 Handle<ScopeInfo> scope_info(ScopeInfo::cast(block_context->extension())); | 1016 Handle<ScopeInfo> scope_info(ScopeInfo::cast(block_context->extension())); |
994 | 1017 |
995 return SetContextLocalValue(block_context->GetIsolate(), scope_info, | 1018 return SetContextLocalValue(block_context->GetIsolate(), scope_info, |
996 block_context, variable_name, new_value); | 1019 block_context, variable_name, new_value); |
997 } | 1020 } |
998 | 1021 |
999 | 1022 |
1023 static bool SetScriptVariableValue(Handle<Context> context, | |
1024 Handle<String> variable_name, | |
1025 Handle<Object> new_value) { | |
1026 Handle<ScriptContextTable> script_contexts( | |
1027 context->global_object()->native_context()->script_context_table()); | |
1028 ScriptContextTable::LookupResult lookup_result; | |
1029 if (ScriptContextTable::Lookup(script_contexts, variable_name, | |
1030 &lookup_result)) { | |
1031 Handle<Context> script_context = ScriptContextTable::GetContext( | |
1032 script_contexts, lookup_result.context_index); | |
1033 script_context->set(lookup_result.slot_index, *new_value); | |
1034 return true; | |
1035 } | |
1036 | |
1037 return false; | |
1038 } | |
1039 | |
1040 | |
1000 // Create a plain JSObject which materializes the scope for the specified | 1041 // Create a plain JSObject which materializes the scope for the specified |
1001 // catch context. | 1042 // catch context. |
1002 MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeCatchScope( | 1043 MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeCatchScope( |
1003 Isolate* isolate, Handle<Context> context) { | 1044 Isolate* isolate, Handle<Context> context) { |
1004 DCHECK(context->IsCatchContext()); | 1045 DCHECK(context->IsCatchContext()); |
1005 Handle<String> name(String::cast(context->extension())); | 1046 Handle<String> name(String::cast(context->extension())); |
1006 Handle<Object> thrown_object(context->get(Context::THROWN_OBJECT_INDEX), | 1047 Handle<Object> thrown_object(context->get(Context::THROWN_OBJECT_INDEX), |
1007 isolate); | 1048 isolate); |
1008 Handle<JSObject> catch_scope = | 1049 Handle<JSObject> catch_scope = |
1009 isolate->factory()->NewJSObject(isolate->object_function()); | 1050 isolate->factory()->NewJSObject(isolate->object_function()); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1077 // which is inserted "artificially" in the context chain. | 1118 // which is inserted "artificially" in the context chain. |
1078 class ScopeIterator { | 1119 class ScopeIterator { |
1079 public: | 1120 public: |
1080 enum ScopeType { | 1121 enum ScopeType { |
1081 ScopeTypeGlobal = 0, | 1122 ScopeTypeGlobal = 0, |
1082 ScopeTypeLocal, | 1123 ScopeTypeLocal, |
1083 ScopeTypeWith, | 1124 ScopeTypeWith, |
1084 ScopeTypeClosure, | 1125 ScopeTypeClosure, |
1085 ScopeTypeCatch, | 1126 ScopeTypeCatch, |
1086 ScopeTypeBlock, | 1127 ScopeTypeBlock, |
1128 ScopeTypeScript, | |
1087 ScopeTypeModule | 1129 ScopeTypeModule |
1088 }; | 1130 }; |
1089 | 1131 |
1090 ScopeIterator(Isolate* isolate, JavaScriptFrame* frame, | 1132 ScopeIterator(Isolate* isolate, JavaScriptFrame* frame, |
1091 int inlined_jsframe_index, bool ignore_nested_scopes = false) | 1133 int inlined_jsframe_index, bool ignore_nested_scopes = false) |
1092 : isolate_(isolate), | 1134 : isolate_(isolate), |
1093 frame_(frame), | 1135 frame_(frame), |
1094 inlined_jsframe_index_(inlined_jsframe_index), | 1136 inlined_jsframe_index_(inlined_jsframe_index), |
1095 function_(frame->function()), | 1137 function_(frame->function()), |
1096 context_(Context::cast(frame->context())), | 1138 context_(Context::cast(frame->context())), |
1097 nested_scope_chain_(4), | 1139 nested_scope_chain_(4), |
1140 seen_script_scope_(false), | |
1098 failed_(false) { | 1141 failed_(false) { |
1099 // Catch the case when the debugger stops in an internal function. | 1142 // Catch the case when the debugger stops in an internal function. |
1100 Handle<SharedFunctionInfo> shared_info(function_->shared()); | 1143 Handle<SharedFunctionInfo> shared_info(function_->shared()); |
1101 Handle<ScopeInfo> scope_info(shared_info->scope_info()); | 1144 Handle<ScopeInfo> scope_info(shared_info->scope_info()); |
1102 if (shared_info->script() == isolate->heap()->undefined_value()) { | 1145 if (shared_info->script() == isolate->heap()->undefined_value()) { |
1103 while (context_->closure() == *function_) { | 1146 while (context_->closure() == *function_) { |
1104 context_ = Handle<Context>(context_->previous(), isolate_); | 1147 context_ = Handle<Context>(context_->previous(), isolate_); |
1105 } | 1148 } |
1106 return; | 1149 return; |
1107 } | 1150 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1179 } | 1222 } |
1180 } | 1223 } |
1181 } | 1224 } |
1182 | 1225 |
1183 ScopeIterator(Isolate* isolate, Handle<JSFunction> function) | 1226 ScopeIterator(Isolate* isolate, Handle<JSFunction> function) |
1184 : isolate_(isolate), | 1227 : isolate_(isolate), |
1185 frame_(NULL), | 1228 frame_(NULL), |
1186 inlined_jsframe_index_(0), | 1229 inlined_jsframe_index_(0), |
1187 function_(function), | 1230 function_(function), |
1188 context_(function->context()), | 1231 context_(function->context()), |
1232 seen_script_scope_(false), | |
1189 failed_(false) { | 1233 failed_(false) { |
1190 if (function->IsBuiltin()) { | 1234 if (function->IsBuiltin()) { |
1191 context_ = Handle<Context>(); | 1235 context_ = Handle<Context>(); |
1192 } | 1236 } |
1193 } | 1237 } |
1194 | 1238 |
1195 // More scopes? | 1239 // More scopes? |
1196 bool Done() { | 1240 bool Done() { |
1197 DCHECK(!failed_); | 1241 DCHECK(!failed_); |
1198 return context_.is_null(); | 1242 return context_.is_null(); |
1199 } | 1243 } |
1200 | 1244 |
1201 bool Failed() { return failed_; } | 1245 bool Failed() { return failed_; } |
1202 | 1246 |
1203 // Move to the next scope. | 1247 // Move to the next scope. |
1204 void Next() { | 1248 void Next() { |
1205 DCHECK(!failed_); | 1249 DCHECK(!failed_); |
1206 ScopeType scope_type = Type(); | 1250 ScopeType scope_type = Type(); |
1207 if (scope_type == ScopeTypeGlobal) { | 1251 if (scope_type == ScopeTypeGlobal) { |
1208 // The global scope is always the last in the chain. | 1252 // The global scope is always the last in the chain. |
1209 DCHECK(context_->IsNativeContext()); | 1253 DCHECK(context_->IsNativeContext()); |
1210 context_ = Handle<Context>(); | 1254 context_ = Handle<Context>(); |
1211 return; | 1255 return; |
1212 } | 1256 } |
1257 seen_script_scope_ = scope_type == ScopeTypeScript; | |
aandrey
2014/11/14 19:50:41
can it change now from true to false?
maybe:
if
Dmitry Lomov (no reviews)
2014/11/14 20:29:11
No it actually cannot since it is always Native af
| |
1213 if (nested_scope_chain_.is_empty()) { | 1258 if (nested_scope_chain_.is_empty()) { |
1214 context_ = Handle<Context>(context_->previous(), isolate_); | 1259 if (scope_type == ScopeTypeScript) { |
1260 if (context_->IsScriptContext()) { | |
1261 context_ = Handle<Context>(context_->previous(), isolate_); | |
1262 } | |
1263 CHECK(context_->IsNativeContext()); | |
1264 } else { | |
1265 context_ = Handle<Context>(context_->previous(), isolate_); | |
1266 } | |
1215 } else { | 1267 } else { |
1216 if (nested_scope_chain_.last()->HasContext()) { | 1268 if (nested_scope_chain_.last()->HasContext()) { |
1217 DCHECK(context_->previous() != NULL); | 1269 DCHECK(context_->previous() != NULL); |
1218 context_ = Handle<Context>(context_->previous(), isolate_); | 1270 context_ = Handle<Context>(context_->previous(), isolate_); |
1219 } | 1271 } |
1220 nested_scope_chain_.RemoveLast(); | 1272 nested_scope_chain_.RemoveLast(); |
1221 } | 1273 } |
1222 } | 1274 } |
1223 | 1275 |
1224 // Return the type of the current scope. | 1276 // Return the type of the current scope. |
1225 ScopeType Type() { | 1277 ScopeType Type() { |
1226 DCHECK(!failed_); | 1278 DCHECK(!failed_); |
1227 if (!nested_scope_chain_.is_empty()) { | 1279 if (!nested_scope_chain_.is_empty()) { |
1228 Handle<ScopeInfo> scope_info = nested_scope_chain_.last(); | 1280 Handle<ScopeInfo> scope_info = nested_scope_chain_.last(); |
1229 switch (scope_info->scope_type()) { | 1281 switch (scope_info->scope_type()) { |
1230 case FUNCTION_SCOPE: | 1282 case FUNCTION_SCOPE: |
1231 case ARROW_SCOPE: | 1283 case ARROW_SCOPE: |
1232 DCHECK(context_->IsFunctionContext() || !scope_info->HasContext()); | 1284 DCHECK(context_->IsFunctionContext() || !scope_info->HasContext()); |
1233 return ScopeTypeLocal; | 1285 return ScopeTypeLocal; |
1234 case MODULE_SCOPE: | 1286 case MODULE_SCOPE: |
1235 DCHECK(context_->IsModuleContext()); | 1287 DCHECK(context_->IsModuleContext()); |
1236 return ScopeTypeModule; | 1288 return ScopeTypeModule; |
1237 case SCRIPT_SCOPE: | 1289 case SCRIPT_SCOPE: |
1238 DCHECK(context_->IsNativeContext()); | 1290 DCHECK(context_->IsScriptContext() || context_->IsNativeContext()); |
1239 return ScopeTypeGlobal; | 1291 return ScopeTypeScript; |
1240 case WITH_SCOPE: | 1292 case WITH_SCOPE: |
1241 DCHECK(context_->IsWithContext()); | 1293 DCHECK(context_->IsWithContext()); |
1242 return ScopeTypeWith; | 1294 return ScopeTypeWith; |
1243 case CATCH_SCOPE: | 1295 case CATCH_SCOPE: |
1244 DCHECK(context_->IsCatchContext()); | 1296 DCHECK(context_->IsCatchContext()); |
1245 return ScopeTypeCatch; | 1297 return ScopeTypeCatch; |
1246 case BLOCK_SCOPE: | 1298 case BLOCK_SCOPE: |
1247 DCHECK(!scope_info->HasContext() || context_->IsBlockContext()); | 1299 DCHECK(!scope_info->HasContext() || context_->IsBlockContext()); |
1248 return ScopeTypeBlock; | 1300 return ScopeTypeBlock; |
1249 case EVAL_SCOPE: | 1301 case EVAL_SCOPE: |
1250 UNREACHABLE(); | 1302 UNREACHABLE(); |
1251 } | 1303 } |
1252 } | 1304 } |
1253 if (context_->IsNativeContext()) { | 1305 if (context_->IsNativeContext()) { |
1254 DCHECK(context_->global_object()->IsGlobalObject()); | 1306 DCHECK(context_->global_object()->IsGlobalObject()); |
1255 return ScopeTypeGlobal; | 1307 // If we are at the native context and have not yet seen script scope, |
1308 // fake it. | |
1309 return seen_script_scope_ ? ScopeTypeGlobal : ScopeTypeScript; | |
1256 } | 1310 } |
1257 if (context_->IsFunctionContext()) { | 1311 if (context_->IsFunctionContext()) { |
1258 return ScopeTypeClosure; | 1312 return ScopeTypeClosure; |
1259 } | 1313 } |
1260 if (context_->IsCatchContext()) { | 1314 if (context_->IsCatchContext()) { |
1261 return ScopeTypeCatch; | 1315 return ScopeTypeCatch; |
1262 } | 1316 } |
1263 if (context_->IsBlockContext()) { | 1317 if (context_->IsBlockContext()) { |
1264 return ScopeTypeBlock; | 1318 return ScopeTypeBlock; |
1265 } | 1319 } |
1266 if (context_->IsModuleContext()) { | 1320 if (context_->IsModuleContext()) { |
1267 return ScopeTypeModule; | 1321 return ScopeTypeModule; |
1268 } | 1322 } |
1323 if (context_->IsScriptContext()) { | |
1324 return ScopeTypeScript; | |
1325 } | |
1269 DCHECK(context_->IsWithContext()); | 1326 DCHECK(context_->IsWithContext()); |
1270 return ScopeTypeWith; | 1327 return ScopeTypeWith; |
1271 } | 1328 } |
1272 | 1329 |
1273 // Return the JavaScript object with the content of the current scope. | 1330 // Return the JavaScript object with the content of the current scope. |
1274 MaybeHandle<JSObject> ScopeObject() { | 1331 MaybeHandle<JSObject> ScopeObject() { |
1275 DCHECK(!failed_); | 1332 DCHECK(!failed_); |
1276 switch (Type()) { | 1333 switch (Type()) { |
1277 case ScopeIterator::ScopeTypeGlobal: | 1334 case ScopeIterator::ScopeTypeGlobal: |
1278 return Handle<JSObject>(CurrentContext()->global_object()); | 1335 return Handle<JSObject>(CurrentContext()->global_object()); |
1336 case ScopeIterator::ScopeTypeScript: | |
1337 return MaterializeScriptScope( | |
1338 Handle<GlobalObject>(CurrentContext()->global_object())); | |
1279 case ScopeIterator::ScopeTypeLocal: | 1339 case ScopeIterator::ScopeTypeLocal: |
1280 // Materialize the content of the local scope into a JSObject. | 1340 // Materialize the content of the local scope into a JSObject. |
1281 DCHECK(nested_scope_chain_.length() == 1); | 1341 DCHECK(nested_scope_chain_.length() == 1); |
1282 return MaterializeLocalScope(isolate_, frame_, inlined_jsframe_index_); | 1342 return MaterializeLocalScope(isolate_, frame_, inlined_jsframe_index_); |
1283 case ScopeIterator::ScopeTypeWith: | 1343 case ScopeIterator::ScopeTypeWith: |
1284 // Return the with object. | 1344 // Return the with object. |
1285 return Handle<JSObject>(JSObject::cast(CurrentContext()->extension())); | 1345 return Handle<JSObject>(JSObject::cast(CurrentContext()->extension())); |
1286 case ScopeIterator::ScopeTypeCatch: | 1346 case ScopeIterator::ScopeTypeCatch: |
1287 return MaterializeCatchScope(isolate_, CurrentContext()); | 1347 return MaterializeCatchScope(isolate_, CurrentContext()); |
1288 case ScopeIterator::ScopeTypeClosure: | 1348 case ScopeIterator::ScopeTypeClosure: |
(...skipping 18 matching lines...) Expand all Loading... | |
1307 return SetLocalVariableValue(isolate_, frame_, inlined_jsframe_index_, | 1367 return SetLocalVariableValue(isolate_, frame_, inlined_jsframe_index_, |
1308 variable_name, new_value); | 1368 variable_name, new_value); |
1309 case ScopeIterator::ScopeTypeWith: | 1369 case ScopeIterator::ScopeTypeWith: |
1310 break; | 1370 break; |
1311 case ScopeIterator::ScopeTypeCatch: | 1371 case ScopeIterator::ScopeTypeCatch: |
1312 return SetCatchVariableValue(isolate_, CurrentContext(), variable_name, | 1372 return SetCatchVariableValue(isolate_, CurrentContext(), variable_name, |
1313 new_value); | 1373 new_value); |
1314 case ScopeIterator::ScopeTypeClosure: | 1374 case ScopeIterator::ScopeTypeClosure: |
1315 return SetClosureVariableValue(isolate_, CurrentContext(), | 1375 return SetClosureVariableValue(isolate_, CurrentContext(), |
1316 variable_name, new_value); | 1376 variable_name, new_value); |
1377 case ScopeIterator::ScopeTypeScript: | |
1378 return SetScriptVariableValue(CurrentContext(), variable_name, | |
1379 new_value); | |
1317 case ScopeIterator::ScopeTypeBlock: | 1380 case ScopeIterator::ScopeTypeBlock: |
1318 return SetBlockContextVariableValue(CurrentContext(), variable_name, | 1381 return SetBlockContextVariableValue(CurrentContext(), variable_name, |
1319 new_value); | 1382 new_value); |
1320 case ScopeIterator::ScopeTypeModule: | 1383 case ScopeIterator::ScopeTypeModule: |
1321 // TODO(2399): should we implement it? | 1384 // TODO(2399): should we implement it? |
1322 break; | 1385 break; |
1323 } | 1386 } |
1324 return false; | 1387 return false; |
1325 } | 1388 } |
1326 | 1389 |
1327 Handle<ScopeInfo> CurrentScopeInfo() { | 1390 Handle<ScopeInfo> CurrentScopeInfo() { |
1328 DCHECK(!failed_); | 1391 DCHECK(!failed_); |
1329 if (!nested_scope_chain_.is_empty()) { | 1392 if (!nested_scope_chain_.is_empty()) { |
1330 return nested_scope_chain_.last(); | 1393 return nested_scope_chain_.last(); |
1331 } else if (context_->IsBlockContext()) { | 1394 } else if (context_->IsBlockContext()) { |
1332 return Handle<ScopeInfo>(ScopeInfo::cast(context_->extension())); | 1395 return Handle<ScopeInfo>(ScopeInfo::cast(context_->extension())); |
1333 } else if (context_->IsFunctionContext()) { | 1396 } else if (context_->IsFunctionContext()) { |
1334 return Handle<ScopeInfo>(context_->closure()->shared()->scope_info()); | 1397 return Handle<ScopeInfo>(context_->closure()->shared()->scope_info()); |
1335 } | 1398 } |
1336 return Handle<ScopeInfo>::null(); | 1399 return Handle<ScopeInfo>::null(); |
1337 } | 1400 } |
1338 | 1401 |
1339 // Return the context for this scope. For the local context there might not | 1402 // Return the context for this scope. For the local context there might not |
1340 // be an actual context. | 1403 // be an actual context. |
1341 Handle<Context> CurrentContext() { | 1404 Handle<Context> CurrentContext() { |
1342 DCHECK(!failed_); | 1405 DCHECK(!failed_); |
1343 if (Type() == ScopeTypeGlobal || nested_scope_chain_.is_empty()) { | 1406 if (Type() == ScopeTypeGlobal || Type() == ScopeTypeScript || |
1407 nested_scope_chain_.is_empty()) { | |
1344 return context_; | 1408 return context_; |
1345 } else if (nested_scope_chain_.last()->HasContext()) { | 1409 } else if (nested_scope_chain_.last()->HasContext()) { |
1346 return context_; | 1410 return context_; |
1347 } else { | 1411 } else { |
1348 return Handle<Context>(); | 1412 return Handle<Context>(); |
1349 } | 1413 } |
1350 } | 1414 } |
1351 | 1415 |
1352 #ifdef DEBUG | 1416 #ifdef DEBUG |
1353 // Debug print of the content of the current scope. | 1417 // Debug print of the content of the current scope. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1390 os << "Closure:\n"; | 1454 os << "Closure:\n"; |
1391 CurrentContext()->Print(os); | 1455 CurrentContext()->Print(os); |
1392 if (CurrentContext()->has_extension()) { | 1456 if (CurrentContext()->has_extension()) { |
1393 Handle<Object> extension(CurrentContext()->extension(), isolate_); | 1457 Handle<Object> extension(CurrentContext()->extension(), isolate_); |
1394 if (extension->IsJSContextExtensionObject()) { | 1458 if (extension->IsJSContextExtensionObject()) { |
1395 extension->Print(os); | 1459 extension->Print(os); |
1396 } | 1460 } |
1397 } | 1461 } |
1398 break; | 1462 break; |
1399 | 1463 |
1464 case ScopeIterator::ScopeTypeScript: | |
1465 os << "Script:\n"; | |
1466 CurrentContext() | |
1467 ->global_object() | |
1468 ->native_context() | |
1469 ->script_context_table() | |
1470 ->Print(os); | |
1471 break; | |
1472 | |
1400 default: | 1473 default: |
1401 UNREACHABLE(); | 1474 UNREACHABLE(); |
1402 } | 1475 } |
1403 PrintF("\n"); | 1476 PrintF("\n"); |
1404 } | 1477 } |
1405 #endif | 1478 #endif |
1406 | 1479 |
1407 private: | 1480 private: |
1408 Isolate* isolate_; | 1481 Isolate* isolate_; |
1409 JavaScriptFrame* frame_; | 1482 JavaScriptFrame* frame_; |
1410 int inlined_jsframe_index_; | 1483 int inlined_jsframe_index_; |
1411 Handle<JSFunction> function_; | 1484 Handle<JSFunction> function_; |
1412 Handle<Context> context_; | 1485 Handle<Context> context_; |
1413 List<Handle<ScopeInfo> > nested_scope_chain_; | 1486 List<Handle<ScopeInfo> > nested_scope_chain_; |
1487 bool seen_script_scope_; | |
1414 bool failed_; | 1488 bool failed_; |
1415 | 1489 |
1416 void RetrieveScopeChain(Scope* scope, | 1490 void RetrieveScopeChain(Scope* scope, |
1417 Handle<SharedFunctionInfo> shared_info) { | 1491 Handle<SharedFunctionInfo> shared_info) { |
1418 if (scope != NULL) { | 1492 if (scope != NULL) { |
1419 int source_position = shared_info->code()->SourcePosition(frame_->pc()); | 1493 int source_position = shared_info->code()->SourcePosition(frame_->pc()); |
1420 scope->GetNestedScopeChain(&nested_scope_chain_, source_position); | 1494 scope->GetNestedScopeChain(&nested_scope_chain_, source_position); |
1421 } else { | 1495 } else { |
1422 // A failed reparse indicates that the preparser has diverged from the | 1496 // A failed reparse indicates that the preparser has diverged from the |
1423 // parser or that the preparse data given to the initial parse has been | 1497 // parser or that the preparse data given to the initial parse has been |
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2168 // uses this temporary context chain. | 2242 // uses this temporary context chain. |
2169 | 2243 |
2170 Handle<Context> eval_context(Context::cast(frame_inspector.GetContext())); | 2244 Handle<Context> eval_context(Context::cast(frame_inspector.GetContext())); |
2171 DCHECK(!eval_context.is_null()); | 2245 DCHECK(!eval_context.is_null()); |
2172 Handle<Context> function_context = eval_context; | 2246 Handle<Context> function_context = eval_context; |
2173 Handle<Context> outer_context(function->context(), isolate); | 2247 Handle<Context> outer_context(function->context(), isolate); |
2174 Handle<Context> inner_context; | 2248 Handle<Context> inner_context; |
2175 // We iterate to find the function's context. If the function has no | 2249 // We iterate to find the function's context. If the function has no |
2176 // context-allocated variables, we iterate until we hit the outer context. | 2250 // context-allocated variables, we iterate until we hit the outer context. |
2177 while (!function_context->IsFunctionContext() && | 2251 while (!function_context->IsFunctionContext() && |
2252 !function_context->IsScriptContext() && | |
2178 !function_context.is_identical_to(outer_context)) { | 2253 !function_context.is_identical_to(outer_context)) { |
2179 inner_context = function_context; | 2254 inner_context = function_context; |
2180 function_context = Handle<Context>(function_context->previous(), isolate); | 2255 function_context = Handle<Context>(function_context->previous(), isolate); |
2181 } | 2256 } |
2182 | 2257 |
2183 Handle<Context> materialized_context = isolate->factory()->NewWithContext( | 2258 Handle<Context> materialized_context = isolate->factory()->NewWithContext( |
2184 function, function_context, materialized); | 2259 function, function_context, materialized); |
2185 | 2260 |
2186 if (inner_context.is_null()) { | 2261 if (inner_context.is_null()) { |
2187 // No inner context. The with-context is now inner-most. | 2262 // No inner context. The with-context is now inner-most. |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2733 return Smi::FromInt(isolate->debug()->is_active()); | 2808 return Smi::FromInt(isolate->debug()->is_active()); |
2734 } | 2809 } |
2735 | 2810 |
2736 | 2811 |
2737 RUNTIME_FUNCTION(RuntimeReference_DebugBreakInOptimizedCode) { | 2812 RUNTIME_FUNCTION(RuntimeReference_DebugBreakInOptimizedCode) { |
2738 UNIMPLEMENTED(); | 2813 UNIMPLEMENTED(); |
2739 return NULL; | 2814 return NULL; |
2740 } | 2815 } |
2741 } | 2816 } |
2742 } // namespace v8::internal | 2817 } // namespace v8::internal |
OLD | NEW |