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

Side by Side Diff: src/runtime.cc

Issue 11227: Fixing wrong reference to this in eval. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years, 1 month 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/v8natives.js » ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 3943 matching lines...) Expand 10 before | Expand all | Expand 10 after
3954 // Check for eval() invocations that cross environments. Use the 3954 // Check for eval() invocations that cross environments. Use the
3955 // context from the stack if evaluating in current environment. 3955 // context from the stack if evaluating in current environment.
3956 Handle<Context> target = Top::global_context(); 3956 Handle<Context> target = Top::global_context();
3957 if (caller->global_context() == *target) return *caller; 3957 if (caller->global_context() == *target) return *caller;
3958 3958
3959 // Otherwise, use the global context from the other environment. 3959 // Otherwise, use the global context from the other environment.
3960 return *target; 3960 return *target;
3961 } 3961 }
3962 3962
3963 3963
3964 static Object* Runtime_EvalReceiver(Arguments args) {
3965 ASSERT(args.length() == 1);
3966 StackFrameLocator locator;
3967 JavaScriptFrame* frame = locator.FindJavaScriptFrame(1);
3968 // Fetch the caller context from the frame.
3969 Context* caller = Context::cast(frame->context());
3970
3971 // Check for eval() invocations that cross environments. Use the
3972 // top frames receiver if evaluating in current environment.
3973 Context* global_context = Top::context()->global()->global_context();
3974 if (caller->global_context() == global_context) {
3975 return frame->receiver();
3976 }
3977
3978 // Otherwise use the given argument (the global object of the
3979 // receiving context).
3980 return args[0];
3981 }
3982
3983
3964 static Object* Runtime_GlobalReceiver(Arguments args) { 3984 static Object* Runtime_GlobalReceiver(Arguments args) {
3965 ASSERT(args.length() == 1); 3985 ASSERT(args.length() == 1);
3966 Object* global = args[0]; 3986 Object* global = args[0];
3967 if (!global->IsJSGlobalObject()) return Heap::null_value(); 3987 if (!global->IsJSGlobalObject()) return Heap::null_value();
3968 return JSGlobalObject::cast(global)->global_receiver(); 3988 return JSGlobalObject::cast(global)->global_receiver();
3969 } 3989 }
3970 3990
3971 3991
3972 static Object* Runtime_CompileString(Arguments args) { 3992 static Object* Runtime_CompileString(Arguments args) {
3973 HandleScope scope; 3993 HandleScope scope;
(...skipping 1878 matching lines...) Expand 10 before | Expand all | Expand 10 after
5852 } else { 5872 } else {
5853 // Handle last resort GC and make sure to allow future allocations 5873 // Handle last resort GC and make sure to allow future allocations
5854 // to grow the heap without causing GCs (if possible). 5874 // to grow the heap without causing GCs (if possible).
5855 Counters::gc_last_resort_from_js.Increment(); 5875 Counters::gc_last_resort_from_js.Increment();
5856 Heap::CollectAllGarbage(); 5876 Heap::CollectAllGarbage();
5857 } 5877 }
5858 } 5878 }
5859 5879
5860 5880
5861 } } // namespace v8::internal 5881 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | src/v8natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698