Commit bc4156ca authored by danno@chromium.org's avatar danno@chromium.org

Refactor platform-specific code for determining shared stub for keyed load/stores.

R=ager@chromium.org
BUG=none
TEST=none

Review URL: http://codereview.chromium.org/7044083

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8253 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 870ef6bd
......@@ -3121,15 +3121,8 @@ MaybeObject* KeyedLoadStubCompiler::CompileLoadElement(Map* receiver_map) {
// -- r0 : key
// -- r1 : receiver
// -----------------------------------
MaybeObject* maybe_stub;
if (receiver_map->has_fast_elements()) {
maybe_stub = KeyedLoadFastElementStub().TryGetCode();
} else {
ASSERT(receiver_map->has_external_array_elements());
JSObject::ElementsKind elements_kind = receiver_map->elements_kind();
maybe_stub = KeyedLoadExternalArrayStub(elements_kind).TryGetCode();
}
Code* stub;
MaybeObject* maybe_stub = ComputeSharedKeyedLoadElementStub(receiver_map);
if (!maybe_stub->To(&stub)) return maybe_stub;
__ DispatchMap(r1,
r2,
......@@ -3213,8 +3206,7 @@ MaybeObject* KeyedStoreStubCompiler::CompileStoreField(JSObject* object,
}
MaybeObject* KeyedStoreStubCompiler::CompileStoreElement(
Map* receiver_map) {
MaybeObject* KeyedStoreStubCompiler::CompileStoreElement(Map* receiver_map) {
// ----------- S t a t e -------------
// -- r0 : value
// -- r1 : key
......@@ -3222,16 +3214,8 @@ MaybeObject* KeyedStoreStubCompiler::CompileStoreElement(
// -- lr : return address
// -- r3 : scratch
// -----------------------------------
MaybeObject* maybe_stub;
if (receiver_map->has_fast_elements()) {
bool is_js_array = receiver_map->instance_type() == JS_ARRAY_TYPE;
maybe_stub = KeyedStoreFastElementStub(is_js_array).TryGetCode();
} else {
ASSERT(receiver_map->has_external_array_elements());
JSObject::ElementsKind elements_kind = receiver_map->elements_kind();
maybe_stub = KeyedStoreExternalArrayStub(elements_kind).TryGetCode();
}
Code* stub;
MaybeObject* maybe_stub = ComputeSharedKeyedStoreElementStub(receiver_map);
if (!maybe_stub->To(&stub)) return maybe_stub;
__ DispatchMap(r2,
r3,
......
......@@ -2699,24 +2699,15 @@ MaybeObject* KeyedStoreStubCompiler::CompileStoreField(JSObject* object,
}
MaybeObject* KeyedStoreStubCompiler::CompileStoreElement(
Map* receiver_map) {
MaybeObject* KeyedStoreStubCompiler::CompileStoreElement(Map* receiver_map) {
// ----------- S t a t e -------------
// -- eax : value
// -- ecx : key
// -- edx : receiver
// -- esp[0] : return address
// -----------------------------------
MaybeObject* maybe_stub;
if (receiver_map->has_fast_elements()) {
bool is_js_array = receiver_map->instance_type() == JS_ARRAY_TYPE;
maybe_stub = KeyedStoreFastElementStub(is_js_array).TryGetCode();
} else {
ASSERT(receiver_map->has_external_array_elements());
JSObject::ElementsKind elements_kind = receiver_map->elements_kind();
maybe_stub = KeyedStoreExternalArrayStub(elements_kind).TryGetCode();
}
Code* stub;
MaybeObject* maybe_stub = ComputeSharedKeyedStoreElementStub(receiver_map);
if (!maybe_stub->To(&stub)) return maybe_stub;
__ DispatchMap(edx,
Handle<Map>(receiver_map),
......@@ -3175,15 +3166,8 @@ MaybeObject* KeyedLoadStubCompiler::CompileLoadElement(Map* receiver_map) {
// -- edx : receiver
// -- esp[0] : return address
// -----------------------------------
MaybeObject* maybe_stub;
if (receiver_map->has_fast_elements()) {
maybe_stub = KeyedLoadFastElementStub().TryGetCode();
} else {
ASSERT(receiver_map->has_external_array_elements());
JSObject::ElementsKind elements_kind = receiver_map->elements_kind();
maybe_stub = KeyedLoadExternalArrayStub(elements_kind).TryGetCode();
}
Code* stub;
MaybeObject* maybe_stub = ComputeSharedKeyedLoadElementStub(receiver_map);
if (!maybe_stub->To(&stub)) return maybe_stub;
__ DispatchMap(edx,
Handle<Map>(receiver_map),
......
......@@ -29,6 +29,7 @@
#include "api.h"
#include "arguments.h"
#include "code-stubs.h"
#include "gdb-jit.h"
#include "ic-inl.h"
#include "stub-cache.h"
......@@ -502,12 +503,13 @@ MaybeObject* StubCache::ComputeKeyedLoadOrStoreElement(
if (!maybe_code->IsUndefined()) return Code::cast(maybe_code);
MaybeObject* maybe_new_code = NULL;
Map* receiver_map = receiver->map();
if (is_store) {
KeyedStoreStubCompiler compiler(strict_mode);
maybe_new_code = compiler.CompileStoreElement(receiver->map());
maybe_new_code = compiler.CompileStoreElement(receiver_map);
} else {
KeyedLoadStubCompiler compiler;
maybe_new_code = compiler.CompileLoadElement(receiver->map());
maybe_new_code = compiler.CompileLoadElement(receiver_map);
}
Code* code;
if (!maybe_new_code->To(&code)) return maybe_new_code;
......@@ -1645,6 +1647,21 @@ MaybeObject* KeyedLoadStubCompiler::GetCode(PropertyType type,
}
MaybeObject* KeyedLoadStubCompiler::ComputeSharedKeyedLoadElementStub(
Map* receiver_map) {
MaybeObject* maybe_stub = NULL;
if (receiver_map->has_fast_elements()) {
maybe_stub = KeyedLoadFastElementStub().TryGetCode();
} else if (receiver_map->has_external_array_elements()) {
JSObject::ElementsKind elements_kind = receiver_map->elements_kind();
maybe_stub = KeyedLoadExternalArrayStub(elements_kind).TryGetCode();
} else {
UNREACHABLE();
}
return maybe_stub;
}
MaybeObject* StoreStubCompiler::GetCode(PropertyType type, String* name) {
Code::Flags flags = Code::ComputeMonomorphicFlags(
Code::STORE_IC, type, strict_mode_);
......@@ -1681,6 +1698,22 @@ MaybeObject* KeyedStoreStubCompiler::GetCode(PropertyType type,
}
MaybeObject* KeyedStoreStubCompiler::ComputeSharedKeyedStoreElementStub(
Map* receiver_map) {
MaybeObject* maybe_stub = NULL;
if (receiver_map->has_fast_elements()) {
bool is_js_array = receiver_map->instance_type() == JS_ARRAY_TYPE;
maybe_stub = KeyedStoreFastElementStub(is_js_array).TryGetCode();
} else if (receiver_map->has_external_array_elements()) {
JSObject::ElementsKind elements_kind = receiver_map->elements_kind();
maybe_stub = KeyedStoreExternalArrayStub(elements_kind).TryGetCode();
} else {
UNREACHABLE();
}
return maybe_stub;
}
CallStubCompiler::CallStubCompiler(int argc,
InLoopFlag in_loop,
Code::Kind kind,
......
......@@ -661,6 +661,8 @@ class KeyedLoadStubCompiler: public StubCompiler {
MaybeObject* GetCode(PropertyType type,
String* name,
InlineCacheState state = MONOMORPHIC);
MaybeObject* ComputeSharedKeyedLoadElementStub(Map* receiver_map);
};
......@@ -718,6 +720,8 @@ class KeyedStoreStubCompiler: public StubCompiler {
String* name,
InlineCacheState state = MONOMORPHIC);
MaybeObject* ComputeSharedKeyedStoreElementStub(Map* receiver_map);
StrictModeFlag strict_mode_;
};
......
......@@ -2530,24 +2530,15 @@ MaybeObject* KeyedStoreStubCompiler::CompileStoreField(JSObject* object,
}
MaybeObject* KeyedStoreStubCompiler::CompileStoreElement(
Map* receiver_map) {
MaybeObject* KeyedStoreStubCompiler::CompileStoreElement(Map* receiver_map) {
// ----------- S t a t e -------------
// -- rax : value
// -- rcx : key
// -- rdx : receiver
// -- rsp[0] : return address
// -----------------------------------
MaybeObject* maybe_stub;
if (receiver_map->has_fast_elements()) {
bool is_js_array = receiver_map->instance_type() == JS_ARRAY_TYPE;
maybe_stub = KeyedStoreFastElementStub(is_js_array).TryGetCode();
} else {
ASSERT(receiver_map->has_external_array_elements());
JSObject::ElementsKind elements_kind = receiver_map->elements_kind();
maybe_stub = KeyedStoreExternalArrayStub(elements_kind).TryGetCode();
}
Code* stub;
MaybeObject* maybe_stub = ComputeSharedKeyedStoreElementStub(receiver_map);
if (!maybe_stub->To(&stub)) return maybe_stub;
__ DispatchMap(rdx,
Handle<Map>(receiver_map),
......@@ -3002,15 +2993,8 @@ MaybeObject* KeyedLoadStubCompiler::CompileLoadElement(Map* receiver_map) {
// -- rdx : receiver
// -- rsp[0] : return address
// -----------------------------------
MaybeObject* maybe_stub;
if (receiver_map->has_fast_elements()) {
maybe_stub = KeyedLoadFastElementStub().TryGetCode();
} else {
ASSERT(receiver_map->has_external_array_elements());
JSObject::ElementsKind elements_kind = receiver_map->elements_kind();
maybe_stub = KeyedLoadExternalArrayStub(elements_kind).TryGetCode();
}
Code* stub;
MaybeObject* maybe_stub = ComputeSharedKeyedLoadElementStub(receiver_map);
if (!maybe_stub->To(&stub)) return maybe_stub;
__ DispatchMap(rdx,
Handle<Map>(receiver_map),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment