Reviewers: Toon Verwaest,
Description:
Unify LookupIterator::GetRoot and Objects::GetRootMap
BUG=none
R=verwa...@chromium.org
LOG=n
Please review this at https://codereview.chromium.org/388193002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+17, -29 lines):
M src/lookup.cc
M src/objects.h
M src/objects.cc
M src/prototype.h
Index: src/lookup.cc
diff --git a/src/lookup.cc b/src/lookup.cc
index
5391640ac1f1f1a3e7dc4f6f831b2c6724b039c2..a2f36ed840b5e4c04a2c3a1433f386458d92d8d5
100644
--- a/src/lookup.cc
+++ b/src/lookup.cc
@@ -20,23 +20,9 @@ void LookupIterator::Next() {
Handle<JSReceiver> LookupIterator::GetRoot() const {
- Handle<Object> receiver = GetReceiver();
- if (receiver->IsJSReceiver()) return Handle<JSReceiver>::cast(receiver);
- Context* native_context = isolate_->context()->native_context();
- JSFunction* function;
- if (receiver->IsNumber()) {
- function = native_context->number_function();
- } else if (receiver->IsString()) {
- function = native_context->string_function();
- } else if (receiver->IsSymbol()) {
- function = native_context->symbol_function();
- } else if (receiver->IsBoolean()) {
- function = native_context->boolean_function();
- } else {
- UNREACHABLE();
- function = NULL;
- }
- return handle(JSReceiver::cast(function->instance_prototype()));
+ HeapObject* root = GetReceiver()->GetRoot(isolate_);
+ CHECK(!root->IsNull());
+ return handle(JSReceiver::cast(root), isolate_);
}
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index
27636585b1c736aac37384ee1d82a5a8e22ef4d3..dce876c371127fa2dfdcb3ee3999a69d8679d4b4
100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -854,11 +854,11 @@ MaybeHandle<Object>
Object::GetElementWithReceiver(Isolate* isolate,
}
-Map* Object::GetRootMap(Isolate* isolate) {
+HeapObject* Object::GetRoot(Isolate* isolate) {
DisallowHeapAllocation no_alloc;
if (IsSmi()) {
Context* context = isolate->context()->native_context();
- return context->number_function()->initial_map();
+ return context->number_function();
}
HeapObject* heap_object = HeapObject::cast(this);
@@ -866,23 +866,23 @@ Map* Object::GetRootMap(Isolate* isolate) {
// The object is either a number, a string, a boolean,
// a real JS object, or a Harmony proxy.
if (heap_object->IsJSReceiver()) {
- return heap_object->map();
+ return heap_object;
}
Context* context = isolate->context()->native_context();
if (heap_object->IsHeapNumber()) {
- return context->number_function()->initial_map();
+ return context->number_function();
}
if (heap_object->IsString()) {
- return context->string_function()->initial_map();
+ return context->string_function();
}
if (heap_object->IsSymbol()) {
- return context->symbol_function()->initial_map();
+ return context->symbol_function();
}
if (heap_object->IsBoolean()) {
- return context->boolean_function()->initial_map();
+ return context->boolean_function();
}
- return isolate->heap()->null_value()->map();
+ return isolate->heap()->null_value();
}
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index
d742b237c52b6f510f73c8ebda3654732c53d981..ef7acc86a4b4216a510c9876f2429895a6a4c4a5
100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -1570,10 +1570,11 @@ class Object {
#endif
private:
+ friend class LookupIterator;
friend class PrototypeIterator;
- // Return the map of the root of object's prototype chain.
- Map* GetRootMap(Isolate* isolate);
+ // Return the the root of object's prototype chain.
+ HeapObject* GetRoot(Isolate* isolate);
DISALLOW_IMPLICIT_CONSTRUCTORS(Object);
};
Index: src/prototype.h
diff --git a/src/prototype.h b/src/prototype.h
index
aebdcbc067ef1ed7d65432597826029e63650532..64ea35026affed37c943e370011707b9b1fe50ad
100644
--- a/src/prototype.h
+++ b/src/prototype.h
@@ -78,9 +78,10 @@ class PrototypeIterator {
if (!did_jump_to_prototype_chain_) {
did_jump_to_prototype_chain_ = true;
if (handle_.is_null()) {
- object_ = object_->GetRootMap(isolate_)->prototype();
+ object_ = object_->GetRoot(isolate_)->map()->prototype();
} else {
- handle_ = handle(handle_->GetRootMap(isolate_)->prototype(),
isolate_);
+ handle_ =
+ handle(handle_->GetRoot(isolate_)->map()->prototype(),
isolate_);
}
} else {
if (handle_.is_null()) {
--
--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.