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

Unified Diff: src/accessors.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 | « BUILD.gn ('k') | src/api.cc » ('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 aeea430704d9f9956d7d9044fe51788a33be9996..cc755d98e9df74667c58cffab9da97a59ebb3795 100644
--- a/src/accessors.cc
+++ b/src/accessors.cc
@@ -15,6 +15,7 @@
#include "src/isolate.h"
#include "src/list-inl.h"
#include "src/property-details.h"
+#include "src/prototype-iterator.h"
namespace v8 {
namespace internal {
@@ -67,8 +68,9 @@ Handle<ExecutableAccessorInfo> Accessors::CloneAccessor(
template <class C>
static C* FindInstanceOf(Isolate* isolate, Object* obj) {
- for (Object* cur = obj; !cur->IsNull(); cur = cur->GetPrototype(isolate)) {
- if (Is<C>(cur)) return C::cast(cur);
+ for (PrototypeIterator<STORE_AS_POINTER, TYPE_BASED_WALK, END_AT_NULL_VALUE>
+ iter(isolate, obj); !iter.IsAtEnd(); iter.Advance()) {
+ if (Is<C>(iter.GetCurrent())) return C::cast(iter.GetCurrent());
}
return NULL;
}
@@ -774,8 +776,8 @@ static Handle<Object> GetFunctionPrototype(Isolate* isolate,
JSFunction* function_raw = FindInstanceOf<JSFunction>(isolate, *receiver);
if (function_raw == NULL) return isolate->factory()->undefined_value();
while (!function_raw->should_have_prototype()) {
- function_raw = FindInstanceOf<JSFunction>(isolate,
- function_raw->GetPrototype());
+ function_raw = FindInstanceOf<JSFunction>(
+ isolate, SAFE_GET_PROTOTYPE_FAST(function_raw));
// There has to be one because we hit the getter.
ASSERT(function_raw != NULL);
}
« no previous file with comments | « BUILD.gn ('k') | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698