Use correct LookupIterator in CallSite::GetMethodName.
authoryangguo <yangguo@chromium.org>
Tue, 30 Jun 2015 16:27:49 +0000 (09:27 -0700)
committerCommit bot <commit-bot@chromium.org>
Tue, 30 Jun 2015 16:28:07 +0000 (16:28 +0000)
R=verwaest@chromium.org
BUG=chromium:505370
LOG=N

Review URL: https://codereview.chromium.org/1218023002

Cr-Commit-Position: refs/heads/master@{#29385}

src/messages.cc
test/mjsunit/regress/regress-crbug-505370.js [new file with mode: 0644]

index a69df04..5e050bd 100644 (file)
@@ -175,10 +175,11 @@ Handle<Object> CallSite::GetScriptNameOrSourceUrl(Isolate* isolate) {
 }
 
 
-bool CheckMethodName(Handle<JSObject> obj, Handle<Name> name,
+bool CheckMethodName(Isolate* isolate, Handle<JSObject> obj, Handle<Name> name,
                      Handle<JSFunction> fun,
                      LookupIterator::Configuration config) {
-  LookupIterator iter(obj, name, config);
+  LookupIterator iter =
+      LookupIterator::PropertyOrElement(isolate, obj, name, config);
   if (iter.state() == LookupIterator::DATA) {
     return iter.GetDataValue().is_identical_to(fun);
   } else if (iter.state() == LookupIterator::ACCESSOR) {
@@ -203,7 +204,7 @@ Handle<Object> CallSite::GetMethodName(Isolate* isolate) {
   Handle<Object> function_name(fun_->shared()->name(), isolate);
   if (function_name->IsName()) {
     Handle<Name> name = Handle<Name>::cast(function_name);
-    if (CheckMethodName(obj, name, fun_,
+    if (CheckMethodName(isolate, obj, name, fun_,
                         LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR))
       return name;
   }
@@ -222,7 +223,7 @@ Handle<Object> CallSite::GetMethodName(Isolate* isolate) {
       HandleScope inner_scope(isolate);
       if (!keys->get(i)->IsName()) continue;
       Handle<Name> name_key(Name::cast(keys->get(i)), isolate);
-      if (!CheckMethodName(current_obj, name_key, fun_,
+      if (!CheckMethodName(isolate, current_obj, name_key, fun_,
                            LookupIterator::OWN_SKIP_INTERCEPTOR))
         continue;
       // Return null in case of duplicates to avoid confusion.
diff --git a/test/mjsunit/regress/regress-crbug-505370.js b/test/mjsunit/regress/regress-crbug-505370.js
new file mode 100644 (file)
index 0000000..f67d82b
--- /dev/null
@@ -0,0 +1,22 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var o = {
+  get 0() { reference_error;  },
+  get length() { return 1; }
+};
+
+var method_name;
+
+try {
+  o[0];
+} catch (e) {
+  thrown = true;
+  Error.prepareStackTrace = function(exception, frames) { return frames; };
+  var frames = e.stack;
+  Error.prepareStackTrace = undefined;
+  method_name = frames[0].getMethodName();
+}
+
+assertEquals("0", method_name);