Speed up native error check.
authorulan@chromium.org <ulan@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 12 Nov 2012 15:33:31 +0000 (15:33 +0000)
committerulan@chromium.org <ulan@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 12 Nov 2012 15:33:31 +0000 (15:33 +0000)
BUG=148757
TEST=largeObj test from the bug is 2x faster.
R=yangguo@chromium.org

Review URL: https://chromiumcodereview.appspot.com/11377100

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12938 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/api.cc

index 4820f9d57f385a1c1c49e6fbc2765c60128ca542..e86430776d4d8ca30bf27e348caae58830231e91 100644 (file)
@@ -2309,7 +2309,11 @@ static i::Object* LookupBuiltin(i::Isolate* isolate,
 static bool CheckConstructor(i::Isolate* isolate,
                              i::Handle<i::JSObject> obj,
                              const char* class_name) {
-  return obj->map()->constructor() == LookupBuiltin(isolate, class_name);
+  i::Object* constr = obj->map()->constructor();
+  if (!constr->IsJSFunction()) return false;
+  i::JSFunction* func = i::JSFunction::cast(constr);
+  return func->shared()->native() &&
+         constr == LookupBuiltin(isolate, class_name);
 }