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

Unified Diff: src/stub-cache.cc

Issue 142973005: Unify calling to GenerateFastApiCallBody before stubbing it (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: arm Created 6 years, 11 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/stub-cache.h ('k') | src/x64/stub-cache-x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/stub-cache.cc
diff --git a/src/stub-cache.cc b/src/stub-cache.cc
index 7cb02f6a241f97bbe24bdd4b3c4d61798a32244c..f8fc8d974c6332581bec11638008bfdb7ae3d8bc 100644
--- a/src/stub-cache.cc
+++ b/src/stub-cache.cc
@@ -1959,20 +1959,45 @@ CallOptimization::CallOptimization(Handle<JSFunction> function) {
}
-int CallOptimization::GetPrototypeDepthOfExpectedType(
+Handle<Map> CallOptimization::LookupHolderOfExpectedType(
+ Handle<JSObject> receiver,
Handle<JSObject> object,
- Handle<JSObject> holder) const {
+ Handle<JSObject> holder,
+ HolderLookup* holder_lookup) const {
ASSERT(is_simple_api_call());
- if (expected_receiver_type_.is_null()) return 0;
- int depth = 0;
+ ASSERT_EQ(kHolderNotFound, *holder_lookup);
+ *holder_lookup = kHolderIsReceiver;
+ Handle<Map> map_to_holder;
+ if (expected_receiver_type_.is_null()) {
+ // no expected type, load from receiver.
+ return map_to_holder;
+ }
+ // walk down the prototype chain to the object
+ while (!receiver.is_identical_to(object)) {
+ *holder_lookup = kHolderIsPrototypeOfMap;
+ map_to_holder = Handle<Map>(receiver->map());
+ receiver = Handle<JSObject>(JSObject::cast(map_to_holder->prototype()));
+ ASSERT(!expected_receiver_type_->IsTemplateFor(*map_to_holder));
+ }
+ // start looking for the holder
while (!object.is_identical_to(holder)) {
- if (expected_receiver_type_->IsTemplateFor(object->map())) return depth;
- object = Handle<JSObject>(JSObject::cast(object->GetPrototype()));
- if (!object->map()->is_hidden_prototype()) return kInvalidProtoDepth;
- ++depth;
+ Handle<Map> object_map(object->map());
+ if (expected_receiver_type_->IsTemplateFor(*object_map)) {
+ return map_to_holder;
+ }
+ if (!object_map->is_hidden_prototype()) {
+ *holder_lookup = kHolderNotFound;
+ return Handle<Map>::null();
+ }
+ *holder_lookup = kHolderIsPrototypeOfMap;
+ map_to_holder = object_map;
+ object = Handle<JSObject>(JSObject::cast(object_map->prototype()));
+ }
+ if (expected_receiver_type_->IsTemplateFor(holder->map())) {
+ return map_to_holder;
}
- if (expected_receiver_type_->IsTemplateFor(holder->map())) return depth;
- return kInvalidProtoDepth;
+ *holder_lookup = kHolderNotFound;
+ return Handle<Map>::null();
}
« no previous file with comments | « src/stub-cache.h ('k') | src/x64/stub-cache-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698