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

Unified Diff: src/api.cc

Issue 348313002: Introduce a PrototypeIterator template and use it all over the place (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebase Created 6 years, 6 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 | « src/accessors.cc ('k') | src/builtins.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index f076bdb481ff2348dcf49c586c9ef6c1dec13e1c..651205bf11199a150230715355acecc2fc8ea1b4 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -37,6 +37,7 @@
#include "src/profile-generator-inl.h"
#include "src/property.h"
#include "src/property-details.h"
+#include "src/prototype-iterator.h"
#include "src/runtime.h"
#include "src/runtime-profiler.h"
#include "src/scanner-character-streams.h"
@@ -3164,7 +3165,7 @@ Local<Value> v8::Object::GetPrototype() {
ON_BAILOUT(isolate, "v8::Object::GetPrototype()", return Local<v8::Value>());
ENTER_V8(isolate);
i::Handle<i::Object> self = Utils::OpenHandle(this);
- i::Handle<i::Object> result(self->GetPrototype(isolate), isolate);
+ i::Handle<i::Object> result(SAFE_GET_PROTOTYPE(isolate, *self), isolate);
return Utils::ToLocal(result);
}
@@ -3196,12 +3197,15 @@ Local<Object> v8::Object::FindInstanceInPrototypeChain(
ENTER_V8(isolate);
i::JSObject* object = *Utils::OpenHandle(this);
i::FunctionTemplateInfo* tmpl_info = *Utils::OpenHandle(*tmpl);
- while (!tmpl_info->IsTemplateFor(object)) {
- i::Object* prototype = object->GetPrototype();
- if (!prototype->IsJSObject()) return Local<Object>();
- object = i::JSObject::cast(prototype);
+ for (i::PrototypeIterator<i::STORE_AS_POINTER, i::MAP_BASED_WALK,
+ i::END_AT_NULL_VALUE> iter(object);
+ !iter.IsAtEnd(); iter.Advance()) {
+ if (tmpl_info->IsTemplateFor(iter.GetCurrent())) {
+ return Utils::ToLocal(
+ i::Handle<i::JSObject>(i::JSObject::cast(iter.GetCurrent())));
+ }
}
- return Utils::ToLocal(i::Handle<i::JSObject>(object));
+ return Local<Object>();
}
« no previous file with comments | « src/accessors.cc ('k') | src/builtins.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698