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

Unified Diff: src/accessors.cc

Issue 6713059: Function.caller when caller is a strict function. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/messages.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/accessors.cc
diff --git a/src/accessors.cc b/src/accessors.cc
index 7326aed4ca8fa2777be46717c760c38d45a31d17..af344d1a631598f9e44ebd1b591d8e666ebdce4f 100644
--- a/src/accessors.cc
+++ b/src/accessors.cc
@@ -827,6 +827,19 @@ const AccessorDescriptor Accessors::FunctionArguments = {
//
+static MaybeObject* CheckNonStrictCallerOrThrow(
+ Isolate* isolate,
+ JSFunction* caller) {
+ DisableAssertNoAllocation enable_allocation;
+ if (caller->shared()->strict_mode()) {
+ return isolate->Throw(
+ *isolate->factory()->NewTypeError("strict_caller",
+ HandleVector<Object>(NULL, 0)));
+ }
+ return caller;
+}
+
+
MaybeObject* Accessors::FunctionGetCaller(Object* object, void*) {
Isolate* isolate = Isolate::Current();
HandleScope scope(isolate);
@@ -847,14 +860,14 @@ MaybeObject* Accessors::FunctionGetCaller(Object* object, void*) {
// frames, e.g. frames for scripts not functions.
if (i > 0) {
ASSERT(!functions[i - 1]->shared()->is_toplevel());
- return functions[i - 1];
+ return CheckNonStrictCallerOrThrow(isolate, functions[i - 1]);
} else {
for (it.Advance(); !it.done(); it.Advance()) {
frame = it.frame();
functions.Rewind(0);
frame->GetFunctions(&functions);
if (!functions.last()->shared()->is_toplevel()) {
- return functions.last();
+ return CheckNonStrictCallerOrThrow(isolate, functions.last());
}
ASSERT(functions.length() == 1);
}
« no previous file with comments | « no previous file | src/messages.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698