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

Side by Side Diff: src/api.cc

Issue 11377100: Speed up native error check. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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 | « no previous file | no next file » | 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 // 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 2291 matching lines...) Expand 10 before | Expand all | Expand 10 after
2302 i::Handle<i::String> symbol = 2302 i::Handle<i::String> symbol =
2303 isolate->factory()->LookupAsciiSymbol(builtin_name); 2303 isolate->factory()->LookupAsciiSymbol(builtin_name);
2304 i::Handle<i::JSBuiltinsObject> builtins = isolate->js_builtins_object(); 2304 i::Handle<i::JSBuiltinsObject> builtins = isolate->js_builtins_object();
2305 return builtins->GetPropertyNoExceptionThrown(*symbol); 2305 return builtins->GetPropertyNoExceptionThrown(*symbol);
2306 } 2306 }
2307 2307
2308 2308
2309 static bool CheckConstructor(i::Isolate* isolate, 2309 static bool CheckConstructor(i::Isolate* isolate,
2310 i::Handle<i::JSObject> obj, 2310 i::Handle<i::JSObject> obj,
2311 const char* class_name) { 2311 const char* class_name) {
2312 return obj->map()->constructor() == LookupBuiltin(isolate, class_name); 2312 i::Object* constr = obj->map()->constructor();
2313 if (!constr->IsJSFunction()) return false;
2314 i::JSFunction* func = i::JSFunction::cast(constr);
2315 return func->shared()->native() &&
2316 constr == LookupBuiltin(isolate, class_name);
2313 } 2317 }
2314 2318
2315 2319
2316 bool Value::IsNativeError() const { 2320 bool Value::IsNativeError() const {
2317 i::Isolate* isolate = i::Isolate::Current(); 2321 i::Isolate* isolate = i::Isolate::Current();
2318 if (IsDeadCheck(isolate, "v8::Value::IsNativeError()")) return false; 2322 if (IsDeadCheck(isolate, "v8::Value::IsNativeError()")) return false;
2319 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2323 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2320 if (obj->IsJSObject()) { 2324 if (obj->IsJSObject()) {
2321 i::Handle<i::JSObject> js_obj(i::JSObject::cast(*obj)); 2325 i::Handle<i::JSObject> js_obj(i::JSObject::cast(*obj));
2322 return CheckConstructor(isolate, js_obj, "$Error") || 2326 return CheckConstructor(isolate, js_obj, "$Error") ||
(...skipping 4355 matching lines...) Expand 10 before | Expand all | Expand 10 after
6678 6682
6679 v->VisitPointers(blocks_.first(), first_block_limit_); 6683 v->VisitPointers(blocks_.first(), first_block_limit_);
6680 6684
6681 for (int i = 1; i < blocks_.length(); i++) { 6685 for (int i = 1; i < blocks_.length(); i++) {
6682 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); 6686 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]);
6683 } 6687 }
6684 } 6688 }
6685 6689
6686 6690
6687 } } // namespace v8::internal 6691 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698