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

Unified Diff: src/stub-cache.cc

Issue 6546036: Combine typed and pixel arrays. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix wrong external element call Created 9 years, 10 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
Index: src/stub-cache.cc
diff --git a/src/stub-cache.cc b/src/stub-cache.cc
index abb26d6ed423a6c231ae288baa37fa18bc498a86..f5f07bee27c9418b37b04fa388a872aa49f6ced3 100644
--- a/src/stub-cache.cc
+++ b/src/stub-cache.cc
@@ -467,33 +467,6 @@ MaybeObject* StubCache::ComputeKeyedLoadSpecialized(JSObject* receiver) {
}
-MaybeObject* StubCache::ComputeKeyedLoadPixelArray(JSObject* receiver) {
- // Using NORMAL as the PropertyType for array element loads is a misuse. The
- // generated stub always accesses fast elements, not slow-mode fields, but
- // some property type is required for the stub lookup. Note that overloading
- // the NORMAL PropertyType is only safe as long as no stubs are generated for
- // other keyed field loads. This is guaranteed to be the case since all field
- // keyed loads that are not array elements go through a generic builtin stub.
- Code::Flags flags =
- Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, NORMAL);
- String* name = Heap::KeyedLoadPixelArray_symbol();
- Object* code = receiver->map()->FindInCodeCache(name, flags);
- if (code->IsUndefined()) {
- KeyedLoadStubCompiler compiler;
- { MaybeObject* maybe_code = compiler.CompileLoadPixelArray(receiver);
- if (!maybe_code->ToObject(&code)) return maybe_code;
- }
- PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), 0));
- Object* result;
- { MaybeObject* maybe_result =
- receiver->UpdateMapCodeCache(name, Code::cast(code));
- if (!maybe_result->ToObject(&result)) return maybe_result;
- }
- }
- return code;
-}
-
-
MaybeObject* StubCache::ComputeStoreField(String* name,
JSObject* receiver,
int field_index,
@@ -542,33 +515,6 @@ MaybeObject* StubCache::ComputeKeyedStoreSpecialized(JSObject* receiver) {
}
-MaybeObject* StubCache::ComputeKeyedStorePixelArray(JSObject* receiver) {
- // Using NORMAL as the PropertyType for array element stores is a misuse. The
- // generated stub always accesses fast elements, not slow-mode fields, but
- // some property type is required for the stub lookup. Note that overloading
- // the NORMAL PropertyType is only safe as long as no stubs are generated for
- // other keyed field stores. This is guaranteed to be the case since all field
- // keyed stores that are not array elements go through a generic builtin stub.
- Code::Flags flags =
- Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, NORMAL);
- String* name = Heap::KeyedStorePixelArray_symbol();
- Object* code = receiver->map()->FindInCodeCache(name, flags);
- if (code->IsUndefined()) {
- KeyedStoreStubCompiler compiler;
- { MaybeObject* maybe_code = compiler.CompileStorePixelArray(receiver);
- if (!maybe_code->ToObject(&code)) return maybe_code;
- }
- PROFILE(CodeCreateEvent(Logger::KEYED_STORE_IC_TAG, Code::cast(code), 0));
- Object* result;
- { MaybeObject* maybe_result =
- receiver->UpdateMapCodeCache(name, Code::cast(code));
- if (!maybe_result->ToObject(&result)) return maybe_result;
- }
- }
- return code;
-}
-
-
namespace {
ExternalArrayType ElementsKindToExternalArrayType(JSObject::ElementsKind kind) {
@@ -587,12 +533,59 @@ ExternalArrayType ElementsKindToExternalArrayType(JSObject::ElementsKind kind) {
return kExternalUnsignedIntArray;
case JSObject::EXTERNAL_FLOAT_ELEMENTS:
return kExternalFloatArray;
+ case JSObject::EXTERNAL_PIXEL_ELEMENTS:
+ return kExternalPixelArray;
default:
UNREACHABLE();
return static_cast<ExternalArrayType>(0);
}
}
+String* ExternalArrayTypeToStubName(ExternalArrayType array_type,
+ bool is_store) {
+ if (is_store) {
+ switch (array_type) {
+ case kExternalByteArray:
+ return Heap::KeyedStoreExternalByteArray_symbol();
+ case kExternalUnsignedByteArray:
+ return Heap::KeyedStoreExternalUnsignedByteArray_symbol();
+ case kExternalShortArray:
+ return Heap::KeyedStoreExternalShortArray_symbol();
+ case kExternalUnsignedShortArray:
+ return Heap::KeyedStoreExternalUnsignedShortArray_symbol();
+ case kExternalIntArray:
+ return Heap::KeyedStoreExternalIntArray_symbol();
+ case kExternalUnsignedIntArray:
+ return Heap::KeyedStoreExternalUnsignedIntArray_symbol();
+ case kExternalPixelArray:
+ return Heap::KeyedStoreExternalPixelArray_symbol();
+ default:
+ UNREACHABLE();
+ return NULL;
+ }
+ } else {
+ switch (array_type) {
+ case kExternalByteArray:
+ return Heap::KeyedLoadExternalByteArray_symbol();
+ case kExternalUnsignedByteArray:
+ return Heap::KeyedLoadExternalUnsignedByteArray_symbol();
+ case kExternalShortArray:
+ return Heap::KeyedLoadExternalShortArray_symbol();
+ case kExternalUnsignedShortArray:
+ return Heap::KeyedLoadExternalUnsignedShortArray_symbol();
+ case kExternalIntArray:
+ return Heap::KeyedLoadExternalIntArray_symbol();
+ case kExternalUnsignedIntArray:
+ return Heap::KeyedLoadExternalUnsignedIntArray_symbol();
+ case kExternalPixelArray:
+ return Heap::KeyedLoadExternalPixelArray_symbol();
+ default:
+ UNREACHABLE();
+ return NULL;
+ }
+ }
+}
+
} // anonymous namespace
@@ -601,35 +594,33 @@ MaybeObject* StubCache::ComputeKeyedLoadOrStoreExternalArray(
bool is_store) {
Code::Flags flags =
Code::ComputeMonomorphicFlags(
- is_store ? Code::KEYED_STORE_IC : Code::KEYED_LOAD_IC,
+ is_store ? Code::KEYED_EXTERNAL_ARRAY_STORE_IC :
+ Code::KEYED_EXTERNAL_ARRAY_LOAD_IC,
NORMAL);
ExternalArrayType array_type =
ElementsKindToExternalArrayType(receiver->GetElementsKind());
- String* name =
- is_store ? Heap::KeyedStoreExternalArray_symbol()
- : Heap::KeyedLoadExternalArray_symbol();
- // Use the global maps for the particular external array types,
- // rather than the receiver's map, when looking up the cached code,
- // so that we actually canonicalize these stubs.
- Map* map = Heap::MapForExternalArrayType(array_type);
- Object* code = map->FindInCodeCache(name, flags);
+ String* name = ExternalArrayTypeToStubName(array_type, is_store);
+ Object* code = receiver->map()->FindInCodeCache(name, flags);
if (code->IsUndefined()) {
ExternalArrayStubCompiler compiler;
{ MaybeObject* maybe_code =
- is_store ? compiler.CompileKeyedStoreStub(array_type, flags) :
- compiler.CompileKeyedLoadStub(array_type, flags);
+ is_store ?
+ compiler.CompileKeyedStoreStub(receiver, array_type, flags) :
+ compiler.CompileKeyedLoadStub(receiver, array_type, flags);
if (!maybe_code->ToObject(&code)) return maybe_code;
}
if (is_store) {
PROFILE(
- CodeCreateEvent(Logger::KEYED_STORE_IC_TAG, Code::cast(code), 0));
+ CodeCreateEvent(Logger::KEYED_EXTERNAL_ARRAY_STORE_IC_TAG,
+ Code::cast(code), 0));
} else {
PROFILE(
- CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), 0));
+ CodeCreateEvent(Logger::KEYED_EXTERNAL_ARRAY_LOAD_IC_TAG,
+ Code::cast(code), 0));
}
Object* result;
{ MaybeObject* maybe_result =
- map->UpdateCodeCache(name, Code::cast(code));
+ receiver->map()->UpdateCodeCache(name, Code::cast(code));
if (!maybe_result->ToObject(&result)) return maybe_result;
}
}
« src/objects.cc ('K') | « src/stub-cache.h ('k') | src/x64/code-stubs-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698