Cleanup polymorphic IC code to make use of ElementsKind information in maps.
Review URL: http://codereview.chromium.org/7283044 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8504 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
e6ec7808db
commit
3916da5f98
61
src/ic.cc
61
src/ic.cc
@ -1097,16 +1097,6 @@ void LoadIC::UpdateCaches(LookupResult* lookup,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
String* KeyedLoadIC::GetStubNameForCache(IC::State ic_state) {
|
|
||||||
if (ic_state == MONOMORPHIC) {
|
|
||||||
return isolate()->heap()->KeyedLoadElementMonomorphic_symbol();
|
|
||||||
} else {
|
|
||||||
ASSERT(ic_state == MEGAMORPHIC);
|
|
||||||
return isolate()->heap()->KeyedLoadElementPolymorphic_symbol();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
MaybeObject* KeyedLoadIC::GetFastElementStubWithoutMapCheck(
|
MaybeObject* KeyedLoadIC::GetFastElementStubWithoutMapCheck(
|
||||||
bool is_js_array) {
|
bool is_js_array) {
|
||||||
return KeyedLoadFastElementStub().TryGetCode();
|
return KeyedLoadFastElementStub().TryGetCode();
|
||||||
@ -1634,18 +1624,14 @@ MaybeObject* KeyedIC::ComputeStub(JSObject* receiver,
|
|||||||
StrictModeFlag strict_mode,
|
StrictModeFlag strict_mode,
|
||||||
Code* generic_stub) {
|
Code* generic_stub) {
|
||||||
State ic_state = target()->ic_state();
|
State ic_state = target()->ic_state();
|
||||||
Code* monomorphic_stub;
|
|
||||||
// Always compute the MONOMORPHIC stub, even if the MEGAMORPHIC stub ends up
|
|
||||||
// being used. This is necessary because the megamorphic stub needs to have
|
|
||||||
// access to more information than what is stored in the receiver map in some
|
|
||||||
// cases (external arrays need the array type from the MONOMORPHIC stub).
|
|
||||||
MaybeObject* maybe_stub = ComputeMonomorphicStub(receiver,
|
|
||||||
is_store,
|
|
||||||
strict_mode,
|
|
||||||
generic_stub);
|
|
||||||
if (!maybe_stub->To(&monomorphic_stub)) return maybe_stub;
|
|
||||||
|
|
||||||
if (ic_state == UNINITIALIZED || ic_state == PREMONOMORPHIC) {
|
if (ic_state == UNINITIALIZED || ic_state == PREMONOMORPHIC) {
|
||||||
|
Code* monomorphic_stub;
|
||||||
|
MaybeObject* maybe_stub = ComputeMonomorphicStub(receiver,
|
||||||
|
is_store,
|
||||||
|
strict_mode,
|
||||||
|
generic_stub);
|
||||||
|
if (!maybe_stub->To(&monomorphic_stub)) return maybe_stub;
|
||||||
|
|
||||||
return monomorphic_stub;
|
return monomorphic_stub;
|
||||||
}
|
}
|
||||||
ASSERT(target() != generic_stub);
|
ASSERT(target() != generic_stub);
|
||||||
@ -1696,9 +1682,9 @@ MaybeObject* KeyedIC::ComputeStub(JSObject* receiver,
|
|||||||
}
|
}
|
||||||
// Build the MEGAMORPHIC stub.
|
// Build the MEGAMORPHIC stub.
|
||||||
Code* stub;
|
Code* stub;
|
||||||
maybe_stub = ConstructMegamorphicStub(&target_receiver_maps,
|
MaybeObject* maybe_stub = ConstructMegamorphicStub(&target_receiver_maps,
|
||||||
&handler_ics,
|
&handler_ics,
|
||||||
strict_mode);
|
strict_mode);
|
||||||
if (!maybe_stub->To(&stub)) return maybe_stub;
|
if (!maybe_stub->To(&stub)) return maybe_stub;
|
||||||
MaybeObject* maybe_update = cache->Update(&target_receiver_maps, flags, stub);
|
MaybeObject* maybe_update = cache->Update(&target_receiver_maps, flags, stub);
|
||||||
if (maybe_update->IsFailure()) return maybe_update;
|
if (maybe_update->IsFailure()) return maybe_update;
|
||||||
@ -1714,22 +1700,7 @@ MaybeObject* KeyedIC::ComputeMonomorphicStubWithoutMapCheck(
|
|||||||
ASSERT(string_stub() != NULL);
|
ASSERT(string_stub() != NULL);
|
||||||
return string_stub();
|
return string_stub();
|
||||||
} else if (receiver_map->has_external_array_elements()) {
|
} else if (receiver_map->has_external_array_elements()) {
|
||||||
// Determine the array type from the default MONOMORPHIC already generated
|
return GetExternalArrayStubWithoutMapCheck(receiver_map->elements_kind());
|
||||||
// stub. There is no other way to determine the type of the external array
|
|
||||||
// directly from the receiver type.
|
|
||||||
Code::Kind kind = this->kind();
|
|
||||||
Code::Flags flags = Code::ComputeMonomorphicFlags(kind,
|
|
||||||
NORMAL,
|
|
||||||
strict_mode);
|
|
||||||
String* monomorphic_name = GetStubNameForCache(MONOMORPHIC);
|
|
||||||
Object* maybe_default_stub = receiver_map->FindInCodeCache(monomorphic_name,
|
|
||||||
flags);
|
|
||||||
if (maybe_default_stub->IsUndefined()) {
|
|
||||||
return generic_stub;
|
|
||||||
}
|
|
||||||
Code* default_stub = Code::cast(maybe_default_stub);
|
|
||||||
Map* first_map = default_stub->FindFirstMap();
|
|
||||||
return GetExternalArrayStubWithoutMapCheck(first_map->elements_kind());
|
|
||||||
} else if (receiver_map->has_fast_elements()) {
|
} else if (receiver_map->has_fast_elements()) {
|
||||||
bool is_js_array = receiver_map->instance_type() == JS_ARRAY_TYPE;
|
bool is_js_array = receiver_map->instance_type() == JS_ARRAY_TYPE;
|
||||||
return GetFastElementStubWithoutMapCheck(is_js_array);
|
return GetFastElementStubWithoutMapCheck(is_js_array);
|
||||||
@ -1758,16 +1729,6 @@ MaybeObject* KeyedIC::ComputeMonomorphicStub(JSObject* receiver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
String* KeyedStoreIC::GetStubNameForCache(IC::State ic_state) {
|
|
||||||
if (ic_state == MONOMORPHIC) {
|
|
||||||
return isolate()->heap()->KeyedStoreElementMonomorphic_symbol();
|
|
||||||
} else {
|
|
||||||
ASSERT(ic_state == MEGAMORPHIC);
|
|
||||||
return isolate()->heap()->KeyedStoreElementPolymorphic_symbol();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
MaybeObject* KeyedStoreIC::GetFastElementStubWithoutMapCheck(
|
MaybeObject* KeyedStoreIC::GetFastElementStubWithoutMapCheck(
|
||||||
bool is_js_array) {
|
bool is_js_array) {
|
||||||
return KeyedStoreFastElementStub(is_js_array).TryGetCode();
|
return KeyedStoreFastElementStub(is_js_array).TryGetCode();
|
||||||
|
6
src/ic.h
6
src/ic.h
@ -358,8 +358,6 @@ class KeyedIC: public IC {
|
|||||||
|
|
||||||
virtual Code::Kind kind() const = 0;
|
virtual Code::Kind kind() const = 0;
|
||||||
|
|
||||||
virtual String* GetStubNameForCache(IC::State ic_state) = 0;
|
|
||||||
|
|
||||||
MaybeObject* ComputeStub(JSObject* receiver,
|
MaybeObject* ComputeStub(JSObject* receiver,
|
||||||
bool is_store,
|
bool is_store,
|
||||||
StrictModeFlag strict_mode,
|
StrictModeFlag strict_mode,
|
||||||
@ -426,8 +424,6 @@ class KeyedLoadIC: public KeyedIC {
|
|||||||
protected:
|
protected:
|
||||||
virtual Code::Kind kind() const { return Code::KEYED_LOAD_IC; }
|
virtual Code::Kind kind() const { return Code::KEYED_LOAD_IC; }
|
||||||
|
|
||||||
virtual String* GetStubNameForCache(IC::State ic_state);
|
|
||||||
|
|
||||||
virtual MaybeObject* ConstructMegamorphicStub(
|
virtual MaybeObject* ConstructMegamorphicStub(
|
||||||
MapList* receiver_maps,
|
MapList* receiver_maps,
|
||||||
CodeList* targets,
|
CodeList* targets,
|
||||||
@ -581,8 +577,6 @@ class KeyedStoreIC: public KeyedIC {
|
|||||||
protected:
|
protected:
|
||||||
virtual Code::Kind kind() const { return Code::KEYED_STORE_IC; }
|
virtual Code::Kind kind() const { return Code::KEYED_STORE_IC; }
|
||||||
|
|
||||||
virtual String* GetStubNameForCache(IC::State ic_state);
|
|
||||||
|
|
||||||
virtual MaybeObject* ConstructMegamorphicStub(
|
virtual MaybeObject* ConstructMegamorphicStub(
|
||||||
MapList* receiver_maps,
|
MapList* receiver_maps,
|
||||||
CodeList* targets,
|
CodeList* targets,
|
||||||
|
Loading…
Reference in New Issue
Block a user