Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(748)

Side by Side Diff: src/runtime.cc

Issue 653603002: Try to fix cross-script global scope (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/runtime.h ('k') | src/scopeinfo.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 <stdlib.h> 5 #include <stdlib.h>
6 #include <limits> 6 #include <limits>
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/accessors.h" 10 #include "src/accessors.h"
(...skipping 8891 matching lines...) Expand 10 before | Expand all | Expand 10 after
8902 HandleScope scope(isolate); 8902 HandleScope scope(isolate);
8903 ASSERT(args.length() == 2); 8903 ASSERT(args.length() == 2);
8904 8904
8905 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 8905 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
8906 CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 1); 8906 CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 1);
8907 Handle<Context> result = 8907 Handle<Context> result =
8908 isolate->factory()->NewGlobalContext(function, scope_info); 8908 isolate->factory()->NewGlobalContext(function, scope_info);
8909 8909
8910 ASSERT(function->context() == isolate->context()); 8910 ASSERT(function->context() == isolate->context());
8911 ASSERT(function->context()->global_object() == result->global_object()); 8911 ASSERT(function->context()->global_object() == result->global_object());
8912 result->global_object()->set_global_context(*result); 8912 GlobalObject* global = result->global_object();
8913 return *result; 8913 Context* first_global_context = global->global_context();
8914 if (first_global_context->IsNativeContext()) {
8915 // This is the first global context, insert directly.
8916 global->set_global_context(*result);
8917 return *result;
8918 } else {
8919 // Insert new context at the top of the chain of global contexts.
8920 Context* last_global_context = first_global_context;
8921 while (!last_global_context->previous()->IsNativeContext()) {
8922 last_global_context = last_global_context->previous();
8923 }
8924 result->set_previous(last_global_context->previous());
8925 last_global_context->set_previous(*result);
8926 return first_global_context;
8927 }
8914 } 8928 }
8915 8929
8916 8930
8917 RUNTIME_FUNCTION(Runtime_NewFunctionContext) { 8931 RUNTIME_FUNCTION(Runtime_NewFunctionContext) {
8918 HandleScope scope(isolate); 8932 HandleScope scope(isolate);
8919 ASSERT(args.length() == 1); 8933 ASSERT(args.length() == 1);
8920 8934
8921 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 8935 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
8922 int length = function->shared()->scope_info()->ContextLength(); 8936 int length = function->shared()->scope_info()->ContextLength();
8923 return *isolate->factory()->NewFunctionContext(length, function); 8937 return *isolate->factory()->NewFunctionContext(length, function);
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after
9778 } 9792 }
9779 done = true; 9793 done = true;
9780 } 9794 }
9781 } 9795 }
9782 return !exit_handled || tokens_match; 9796 return !exit_handled || tokens_match;
9783 } 9797 }
9784 9798
9785 9799
9786 RUNTIME_FUNCTION(Runtime_CompileString) { 9800 RUNTIME_FUNCTION(Runtime_CompileString) {
9787 HandleScope scope(isolate); 9801 HandleScope scope(isolate);
9788 ASSERT(args.length() == 2); 9802 ASSERT(args.length() == 3);
9789 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); 9803 CONVERT_ARG_HANDLE_CHECKED(String, source, 0);
9790 CONVERT_BOOLEAN_ARG_CHECKED(function_literal_only, 1); 9804 CONVERT_ARG_HANDLE_CHECKED(JSGlobalProxy, global_proxy, 1);
9805 CONVERT_BOOLEAN_ARG_CHECKED(function_literal_only, 2);
9791 9806
9792 // Extract native context. 9807 // Extract native context.
9793 Handle<Context> context(isolate->native_context()); 9808 Handle<Context> native_context(isolate->native_context());
9794 9809
9795 // Filter cross security context calls. 9810 // Filter cross security context calls.
9796 if (!TokensMatchForCompileString(isolate)) { 9811 if (!TokensMatchForCompileString(isolate)) {
9797 return isolate->heap()->undefined_value(); 9812 return isolate->heap()->undefined_value();
9798 } 9813 }
9799 9814
9800 // Check if native context allows code generation from 9815 // Check if native context allows code generation from
9801 // strings. Throw an exception if it doesn't. 9816 // strings. Throw an exception if it doesn't.
9802 if (context->allow_code_gen_from_strings()->IsFalse() && 9817 if (native_context->allow_code_gen_from_strings()->IsFalse() &&
9803 !CodeGenerationFromStringsAllowed(isolate, context)) { 9818 !CodeGenerationFromStringsAllowed(isolate, native_context)) {
9804 Handle<Object> error_message = 9819 Handle<Object> error_message =
9805 context->ErrorMessageForCodeGenerationFromStrings(); 9820 native_context->ErrorMessageForCodeGenerationFromStrings();
9806 return isolate->Throw(*isolate->factory()->NewEvalError( 9821 return isolate->Throw(*isolate->factory()->NewEvalError(
9807 "code_gen_from_strings", HandleVector<Object>(&error_message, 1))); 9822 "code_gen_from_strings", HandleVector<Object>(&error_message, 1)));
9808 } 9823 }
9809 9824
9810 // Compile source string in the native context. 9825 // Compile source string in the native context.
9811 ParseRestriction restriction = function_literal_only 9826 ParseRestriction restriction = function_literal_only
9812 ? ONLY_SINGLE_FUNCTION_LITERAL : NO_PARSE_RESTRICTION; 9827 ? ONLY_SINGLE_FUNCTION_LITERAL : NO_PARSE_RESTRICTION;
9828 //TODO: this is insecure, fix. Need to get the global context properly.
9829 Handle<GlobalObject> global(GlobalObject::cast(global_proxy->GetPrototype()));
9830 Handle<Context> context(global->global_context());
9813 Handle<JSFunction> fun; 9831 Handle<JSFunction> fun;
9814 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 9832 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
9815 isolate, fun, 9833 isolate, fun,
9816 Compiler::GetFunctionFromEval( 9834 Compiler::GetFunctionFromEval(
9817 source, context, SLOPPY, restriction, RelocInfo::kNoPosition)); 9835 source, context, SLOPPY, restriction, RelocInfo::kNoPosition));
9818 return *fun; 9836 return *fun;
9819 } 9837 }
9820 9838
9821 9839
9822 static ObjectPair CompileGlobalEval(Isolate* isolate, 9840 static ObjectPair CompileGlobalEval(Isolate* isolate,
(...skipping 1968 matching lines...) Expand 10 before | Expand all | Expand 10 after
11791 // Fill all context locals. 11809 // Fill all context locals.
11792 if (!ScopeInfo::CopyContextLocalsToScopeObject( 11810 if (!ScopeInfo::CopyContextLocalsToScopeObject(
11793 scope_info, context, block_scope)) { 11811 scope_info, context, block_scope)) {
11794 return MaybeHandle<JSObject>(); 11812 return MaybeHandle<JSObject>();
11795 } 11813 }
11796 11814
11797 return block_scope; 11815 return block_scope;
11798 } 11816 }
11799 11817
11800 11818
11819 // Create a plain JSObject which materializes the block scope for the specified
11820 // global context.
11821 MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeGlobalScope(
11822 Isolate* isolate,
11823 Handle<Context> context) {
11824 ASSERT(context->IsGlobalContext());
11825 Handle<ScopeInfo> scope_info(ScopeInfo::cast(context->extension()));
11826
11827 // Allocate and initialize a JSObject with all the arguments, stack locals
11828 // heap locals and extension properties of the debugged function.
11829 Handle<JSObject> global_scope =
11830 isolate->factory()->NewJSObject(isolate->object_function());
11831
11832 // Fill all context locals.
11833 if (!ScopeInfo::CopyContextLocalsToScopeObject(
11834 scope_info, context, global_scope)) {
11835 return MaybeHandle<JSObject>();
11836 }
11837
11838 return global_scope;
11839 }
11840
11841
11801 // Create a plain JSObject which materializes the module scope for the specified 11842 // Create a plain JSObject which materializes the module scope for the specified
11802 // module context. 11843 // module context.
11803 MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeModuleScope( 11844 MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeModuleScope(
11804 Isolate* isolate, 11845 Isolate* isolate,
11805 Handle<Context> context) { 11846 Handle<Context> context) {
11806 ASSERT(context->IsModuleContext()); 11847 ASSERT(context->IsModuleContext());
11807 Handle<ScopeInfo> scope_info(ScopeInfo::cast(context->extension())); 11848 Handle<ScopeInfo> scope_info(ScopeInfo::cast(context->extension()));
11808 11849
11809 // Allocate and initialize a JSObject with all the members of the debugged 11850 // Allocate and initialize a JSObject with all the members of the debugged
11810 // module. 11851 // module.
11811 Handle<JSObject> module_scope = 11852 Handle<JSObject> module_scope =
11812 isolate->factory()->NewJSObject(isolate->object_function()); 11853 isolate->factory()->NewJSObject(isolate->object_function());
11813 11854
11814 // Fill all context locals. 11855 // Fill all context locals.
11815 if (!ScopeInfo::CopyContextLocalsToScopeObject( 11856 if (!ScopeInfo::CopyContextLocalsToScopeObject(
11816 scope_info, context, module_scope)) { 11857 scope_info, context, module_scope)) {
11817 return MaybeHandle<JSObject>(); 11858 return MaybeHandle<JSObject>();
11818 } 11859 }
11819 11860
11820 return module_scope; 11861 return module_scope;
11821 } 11862 }
11822 11863
11823 11864
11824 // Iterate over the actual scopes visible from a stack frame or from a closure. 11865 // Iterate over the actual scopes visible from a stack frame or from a closure.
11825 // The iteration proceeds from the innermost visible nested scope outwards. 11866 // The iteration proceeds from the innermost visible nested scope outwards.
11826 // All scopes are backed by an actual context except the local scope, 11867 // All scopes are backed by an actual context except the local scope,
11827 // which is inserted "artificially" in the context chain. 11868 // which is inserted "artificially" in the context chain.
11828 class ScopeIterator { 11869 class ScopeIterator {
11829 public: 11870 public:
11871 // This type has to be matched by ScopeType in mirror-debugger.js
11830 enum ScopeType { 11872 enum ScopeType {
11831 ScopeTypeGlobal = 0, 11873 ScopeTypeNative,
11874 ScopeTypeGlobal,
11832 ScopeTypeLocal, 11875 ScopeTypeLocal,
11833 ScopeTypeWith, 11876 ScopeTypeWith,
11834 ScopeTypeClosure, 11877 ScopeTypeClosure,
11835 ScopeTypeCatch, 11878 ScopeTypeCatch,
11836 ScopeTypeBlock, 11879 ScopeTypeBlock,
11837 ScopeTypeModule 11880 ScopeTypeModule
11838 }; 11881 };
11839 11882
11840 ScopeIterator(Isolate* isolate, 11883 ScopeIterator(Isolate* isolate,
11841 JavaScriptFrame* frame, 11884 JavaScriptFrame* frame,
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
11949 ASSERT(!failed_); 11992 ASSERT(!failed_);
11950 return context_.is_null(); 11993 return context_.is_null();
11951 } 11994 }
11952 11995
11953 bool Failed() { return failed_; } 11996 bool Failed() { return failed_; }
11954 11997
11955 // Move to the next scope. 11998 // Move to the next scope.
11956 void Next() { 11999 void Next() {
11957 ASSERT(!failed_); 12000 ASSERT(!failed_);
11958 ScopeType scope_type = Type(); 12001 ScopeType scope_type = Type();
11959 if (scope_type == ScopeTypeGlobal) { 12002 if (scope_type == ScopeTypeNative) {
11960 // The global scope is always the last in the chain. 12003 // The native scope is always the last in the chain.
11961 ASSERT(context_->IsNativeContext()); 12004 ASSERT(context_->IsNativeContext());
11962 context_ = Handle<Context>(); 12005 context_ = Handle<Context>();
11963 return; 12006 return;
11964 } 12007 }
11965 if (nested_scope_chain_.is_empty()) { 12008 if (nested_scope_chain_.is_empty()) {
11966 context_ = Handle<Context>(context_->previous(), isolate_); 12009 context_ = Handle<Context>(context_->previous(), isolate_);
11967 } else { 12010 } else {
11968 if (nested_scope_chain_.last()->HasContext()) { 12011 if (nested_scope_chain_.last()->HasContext()) {
11969 ASSERT(context_->previous() != NULL); 12012 ASSERT(context_->previous() != NULL);
11970 context_ = Handle<Context>(context_->previous(), isolate_); 12013 context_ = Handle<Context>(context_->previous(), isolate_);
11971 } 12014 }
11972 nested_scope_chain_.RemoveLast(); 12015 nested_scope_chain_.RemoveLast();
11973 } 12016 }
11974 } 12017 }
11975 12018
11976 // Return the type of the current scope. 12019 // Return the type of the current scope.
11977 ScopeType Type() { 12020 ScopeType Type() {
11978 ASSERT(!failed_); 12021 ASSERT(!failed_);
11979 if (!nested_scope_chain_.is_empty()) { 12022 if (!nested_scope_chain_.is_empty()) {
11980 Handle<ScopeInfo> scope_info = nested_scope_chain_.last(); 12023 Handle<ScopeInfo> scope_info = nested_scope_chain_.last();
11981 switch (scope_info->scope_type()) { 12024 switch (scope_info->scope_type()) {
11982 case FUNCTION_SCOPE: 12025 case FUNCTION_SCOPE:
11983 ASSERT(context_->IsFunctionContext() || 12026 ASSERT(context_->IsFunctionContext() ||
11984 !scope_info->HasContext()); 12027 !scope_info->HasContext());
11985 return ScopeTypeLocal; 12028 return ScopeTypeLocal;
11986 case MODULE_SCOPE: 12029 case MODULE_SCOPE:
11987 ASSERT(context_->IsModuleContext()); 12030 ASSERT(context_->IsModuleContext());
11988 return ScopeTypeModule; 12031 return ScopeTypeModule;
11989 case GLOBAL_SCOPE: 12032 case GLOBAL_SCOPE:
11990 ASSERT(context_->IsNativeContext()); 12033 ASSERT(context_->IsNativeContext() || context_->IsGlobalContext());
12034 return
12035 context_->IsNativeContext() ? ScopeTypeNative : ScopeTypeGlobal;
12036 case SCRIPT_SCOPE:
12037 ASSERT(context_->IsGlobalContext());
11991 return ScopeTypeGlobal; 12038 return ScopeTypeGlobal;
11992 case WITH_SCOPE: 12039 case WITH_SCOPE:
11993 ASSERT(context_->IsWithContext()); 12040 ASSERT(context_->IsWithContext());
11994 return ScopeTypeWith; 12041 return ScopeTypeWith;
11995 case CATCH_SCOPE: 12042 case CATCH_SCOPE:
11996 ASSERT(context_->IsCatchContext()); 12043 ASSERT(context_->IsCatchContext());
11997 return ScopeTypeCatch; 12044 return ScopeTypeCatch;
11998 case BLOCK_SCOPE: 12045 case BLOCK_SCOPE:
11999 ASSERT(!scope_info->HasContext() || 12046 ASSERT(!scope_info->HasContext() ||
12000 context_->IsBlockContext()); 12047 context_->IsBlockContext());
12001 return ScopeTypeBlock; 12048 return ScopeTypeBlock;
12002 case EVAL_SCOPE: 12049 case EVAL_SCOPE:
12003 UNREACHABLE(); 12050 UNREACHABLE();
12004 } 12051 }
12005 } 12052 }
12006 if (context_->IsNativeContext()) { 12053 if (context_->IsNativeContext()) {
12007 ASSERT(context_->global_object()->IsGlobalObject()); 12054 ASSERT(context_->global_object()->IsGlobalObject());
12055 return ScopeTypeNative;
12056 }
12057 if (context_->IsGlobalContext()) {
12008 return ScopeTypeGlobal; 12058 return ScopeTypeGlobal;
12009 } 12059 }
12010 if (context_->IsFunctionContext()) { 12060 if (context_->IsFunctionContext()) {
12011 return ScopeTypeClosure; 12061 return ScopeTypeClosure;
12012 } 12062 }
12013 if (context_->IsCatchContext()) { 12063 if (context_->IsCatchContext()) {
12014 return ScopeTypeCatch; 12064 return ScopeTypeCatch;
12015 } 12065 }
12016 if (context_->IsBlockContext()) { 12066 if (context_->IsBlockContext()) {
12017 return ScopeTypeBlock; 12067 return ScopeTypeBlock;
12018 } 12068 }
12019 if (context_->IsModuleContext()) { 12069 if (context_->IsModuleContext()) {
12020 return ScopeTypeModule; 12070 return ScopeTypeModule;
12021 } 12071 }
12022 ASSERT(context_->IsWithContext()); 12072 ASSERT(context_->IsWithContext());
12023 return ScopeTypeWith; 12073 return ScopeTypeWith;
12024 } 12074 }
12025 12075
12026 // Return the JavaScript object with the content of the current scope. 12076 // Return the JavaScript object with the content of the current scope.
12027 MaybeHandle<JSObject> ScopeObject() { 12077 MaybeHandle<JSObject> ScopeObject() {
12028 ASSERT(!failed_); 12078 ASSERT(!failed_);
12029 switch (Type()) { 12079 switch (Type()) {
12080 case ScopeIterator::ScopeTypeNative:
12081 return Handle<JSObject>(CurrentContext()->global_object());
12030 case ScopeIterator::ScopeTypeGlobal: 12082 case ScopeIterator::ScopeTypeGlobal:
12031 return Handle<JSObject>(CurrentContext()->global_object()); 12083 return MaterializeGlobalScope(isolate_, CurrentContext());
12032 case ScopeIterator::ScopeTypeLocal: 12084 case ScopeIterator::ScopeTypeLocal:
12033 // Materialize the content of the local scope into a JSObject. 12085 // Materialize the content of the local scope into a JSObject.
12034 ASSERT(nested_scope_chain_.length() == 1); 12086 ASSERT(nested_scope_chain_.length() == 1);
12035 return MaterializeLocalScope(isolate_, frame_, inlined_jsframe_index_); 12087 return MaterializeLocalScope(isolate_, frame_, inlined_jsframe_index_);
12036 case ScopeIterator::ScopeTypeWith: 12088 case ScopeIterator::ScopeTypeWith:
12037 // Return the with object. 12089 // Return the with object.
12038 return Handle<JSObject>(JSObject::cast(CurrentContext()->extension())); 12090 return Handle<JSObject>(JSObject::cast(CurrentContext()->extension()));
12039 case ScopeIterator::ScopeTypeCatch: 12091 case ScopeIterator::ScopeTypeCatch:
12040 return MaterializeCatchScope(isolate_, CurrentContext()); 12092 return MaterializeCatchScope(isolate_, CurrentContext());
12041 case ScopeIterator::ScopeTypeClosure: 12093 case ScopeIterator::ScopeTypeClosure:
12042 // Materialize the content of the closure scope into a JSObject. 12094 // Materialize the content of the closure scope into a JSObject.
12043 return MaterializeClosure(isolate_, CurrentContext()); 12095 return MaterializeClosure(isolate_, CurrentContext());
12044 case ScopeIterator::ScopeTypeBlock: 12096 case ScopeIterator::ScopeTypeBlock:
12045 return MaterializeBlockScope(isolate_, CurrentContext()); 12097 return MaterializeBlockScope(isolate_, CurrentContext());
12046 case ScopeIterator::ScopeTypeModule: 12098 case ScopeIterator::ScopeTypeModule:
12047 return MaterializeModuleScope(isolate_, CurrentContext()); 12099 return MaterializeModuleScope(isolate_, CurrentContext());
12048 } 12100 }
12049 UNREACHABLE(); 12101 UNREACHABLE();
12050 return Handle<JSObject>(); 12102 return Handle<JSObject>();
12051 } 12103 }
12052 12104
12053 bool SetVariableValue(Handle<String> variable_name, 12105 bool SetVariableValue(Handle<String> variable_name,
12054 Handle<Object> new_value) { 12106 Handle<Object> new_value) {
12055 ASSERT(!failed_); 12107 ASSERT(!failed_);
12056 switch (Type()) { 12108 switch (Type()) {
12109 case ScopeIterator::ScopeTypeNative:
12110 break;
12057 case ScopeIterator::ScopeTypeGlobal: 12111 case ScopeIterator::ScopeTypeGlobal:
12112 // TODO(2399): should we implement it?
12058 break; 12113 break;
12059 case ScopeIterator::ScopeTypeLocal: 12114 case ScopeIterator::ScopeTypeLocal:
12060 return SetLocalVariableValue(isolate_, frame_, inlined_jsframe_index_, 12115 return SetLocalVariableValue(isolate_, frame_, inlined_jsframe_index_,
12061 variable_name, new_value); 12116 variable_name, new_value);
12062 case ScopeIterator::ScopeTypeWith: 12117 case ScopeIterator::ScopeTypeWith:
12063 break; 12118 break;
12064 case ScopeIterator::ScopeTypeCatch: 12119 case ScopeIterator::ScopeTypeCatch:
12065 return SetCatchVariableValue(isolate_, CurrentContext(), 12120 return SetCatchVariableValue(isolate_, CurrentContext(),
12066 variable_name, new_value); 12121 variable_name, new_value);
12067 case ScopeIterator::ScopeTypeClosure: 12122 case ScopeIterator::ScopeTypeClosure:
(...skipping 18 matching lines...) Expand all
12086 } else if (context_->IsFunctionContext()) { 12141 } else if (context_->IsFunctionContext()) {
12087 return Handle<ScopeInfo>(context_->closure()->shared()->scope_info()); 12142 return Handle<ScopeInfo>(context_->closure()->shared()->scope_info());
12088 } 12143 }
12089 return Handle<ScopeInfo>::null(); 12144 return Handle<ScopeInfo>::null();
12090 } 12145 }
12091 12146
12092 // Return the context for this scope. For the local context there might not 12147 // Return the context for this scope. For the local context there might not
12093 // be an actual context. 12148 // be an actual context.
12094 Handle<Context> CurrentContext() { 12149 Handle<Context> CurrentContext() {
12095 ASSERT(!failed_); 12150 ASSERT(!failed_);
12096 if (Type() == ScopeTypeGlobal || 12151 if (Type() == ScopeTypeNative || nested_scope_chain_.is_empty()) {
12097 nested_scope_chain_.is_empty()) {
12098 return context_; 12152 return context_;
12099 } else if (nested_scope_chain_.last()->HasContext()) { 12153 } else if (nested_scope_chain_.last()->HasContext()) {
12100 return context_; 12154 return context_;
12101 } else { 12155 } else {
12102 return Handle<Context>(); 12156 return Handle<Context>();
12103 } 12157 }
12104 } 12158 }
12105 12159
12106 #ifdef DEBUG 12160 #ifdef DEBUG
12107 // Debug print of the content of the current scope. 12161 // Debug print of the content of the current scope.
12108 void DebugPrint() { 12162 void DebugPrint() {
12109 OFStream os(stdout); 12163 OFStream os(stdout);
12110 ASSERT(!failed_); 12164 ASSERT(!failed_);
12111 switch (Type()) { 12165 switch (Type()) {
12166 case ScopeIterator::ScopeTypeNative:
12167 os << "Native:\n";
12168 CurrentContext()->Print(os);
12169 break;
12170
12112 case ScopeIterator::ScopeTypeGlobal: 12171 case ScopeIterator::ScopeTypeGlobal:
12113 os << "Global:\n"; 12172 os << "Global:\n";
12114 CurrentContext()->Print(os); 12173 CurrentContext()->Print(os);
12115 break; 12174 break;
12116 12175
12176 case ScopeIterator::ScopeTypeModule:
12177 os << "Module:\n";
12178 CurrentContext()->Print(os);
12179 break;
12180
12181 case ScopeIterator::ScopeTypeBlock:
12182 os << "Block:\n";
12183 CurrentContext()->Print(os);
12184 break;
12185
12117 case ScopeIterator::ScopeTypeLocal: { 12186 case ScopeIterator::ScopeTypeLocal: {
12118 os << "Local:\n"; 12187 os << "Local:\n";
12119 function_->shared()->scope_info()->Print(); 12188 function_->shared()->scope_info()->Print();
12120 if (!CurrentContext().is_null()) { 12189 if (!CurrentContext().is_null()) {
12121 CurrentContext()->Print(os); 12190 CurrentContext()->Print(os);
12122 if (CurrentContext()->has_extension()) { 12191 if (CurrentContext()->has_extension()) {
12123 Handle<Object> extension(CurrentContext()->extension(), isolate_); 12192 Handle<Object> extension(CurrentContext()->extension(), isolate_);
12124 if (extension->IsJSContextExtensionObject()) { 12193 if (extension->IsJSContextExtensionObject()) {
12125 extension->Print(os); 12194 extension->Print(os);
12126 } 12195 }
(...skipping 16 matching lines...) Expand all
12143 case ScopeIterator::ScopeTypeClosure: 12212 case ScopeIterator::ScopeTypeClosure:
12144 os << "Closure:\n"; 12213 os << "Closure:\n";
12145 CurrentContext()->Print(os); 12214 CurrentContext()->Print(os);
12146 if (CurrentContext()->has_extension()) { 12215 if (CurrentContext()->has_extension()) {
12147 Handle<Object> extension(CurrentContext()->extension(), isolate_); 12216 Handle<Object> extension(CurrentContext()->extension(), isolate_);
12148 if (extension->IsJSContextExtensionObject()) { 12217 if (extension->IsJSContextExtensionObject()) {
12149 extension->Print(os); 12218 extension->Print(os);
12150 } 12219 }
12151 } 12220 }
12152 break; 12221 break;
12153
12154 default:
12155 UNREACHABLE();
12156 } 12222 }
12157 PrintF("\n"); 12223 PrintF("\n");
12158 } 12224 }
12159 #endif 12225 #endif
12160 12226
12161 private: 12227 private:
12162 Isolate* isolate_; 12228 Isolate* isolate_;
12163 JavaScriptFrame* frame_; 12229 JavaScriptFrame* frame_;
12164 int inlined_jsframe_index_; 12230 int inlined_jsframe_index_;
12165 Handle<JSFunction> function_; 12231 Handle<JSFunction> function_;
(...skipping 2939 matching lines...) Expand 10 before | Expand all | Expand 10 after
15105 } 15171 }
15106 return NULL; 15172 return NULL;
15107 } 15173 }
15108 15174
15109 15175
15110 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { 15176 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) {
15111 return &(kIntrinsicFunctions[static_cast<int>(id)]); 15177 return &(kIntrinsicFunctions[static_cast<int>(id)]);
15112 } 15178 }
15113 15179
15114 } } // namespace v8::internal 15180 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | src/scopeinfo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698