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

Unified Diff: src/factory.cc

Issue 631093003: [turbofan] Fix lowering of typed loads/stores. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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/factory.h ('k') | src/handles.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index cc9463f8c3e61e767f3c45daba9f104fa7bdedb3..25d8cd80e50c75f4b2eb3a4d72bf6b831058c575 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -1716,7 +1716,22 @@ Handle<JSDataView> Factory::NewJSDataView() {
}
-static JSFunction* GetTypedArrayFun(ExternalArrayType type, Isolate* isolate) {
+namespace {
+
+ElementsKind GetExternalArrayElementsKind(ExternalArrayType type) {
+ switch (type) {
+#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
+ case kExternal##Type##Array: \
+ return EXTERNAL_##TYPE##_ELEMENTS;
+ TYPED_ARRAYS(TYPED_ARRAY_CASE)
+ }
+ UNREACHABLE();
+ return FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND;
+#undef TYPED_ARRAY_CASE
+}
+
+
+JSFunction* GetTypedArrayFun(ExternalArrayType type, Isolate* isolate) {
Context* native_context = isolate->context()->native_context();
switch (type) {
#define TYPED_ARRAY_FUN(Type, type, TYPE, ctype, size) \
@@ -1732,6 +1747,8 @@ static JSFunction* GetTypedArrayFun(ExternalArrayType type, Isolate* isolate) {
}
}
+} // namespace
+
Handle<JSTypedArray> Factory::NewJSTypedArray(ExternalArrayType type) {
Handle<JSFunction> typed_array_fun_handle(GetTypedArrayFun(type, isolate()));
@@ -1743,6 +1760,28 @@ Handle<JSTypedArray> Factory::NewJSTypedArray(ExternalArrayType type) {
}
+Handle<JSTypedArray> Factory::NewJSTypedArray(ExternalArrayType type,
+ Handle<JSArrayBuffer> buffer,
+ size_t length) {
+ DCHECK(length <= static_cast<size_t>(kMaxInt));
+ Handle<JSTypedArray> array = NewJSTypedArray(type);
+ array->set_buffer(*buffer);
+ array->set_weak_next(buffer->weak_first_view());
+ buffer->set_weak_first_view(*array);
+ array->set_byte_offset(Smi::FromInt(0));
+ array->set_byte_length(buffer->byte_length());
+ Handle<Object> length_handle = NewNumberFromSize(length);
+ array->set_length(*length_handle);
+ Handle<ExternalArray> elements =
+ NewExternalArray(static_cast<int>(length), type, buffer->backing_store());
+ JSObject::SetMapAndElements(array,
+ JSObject::GetElementsTransitionMap(
+ array, GetExternalArrayElementsKind(type)),
+ elements);
+ return array;
+}
+
+
Handle<JSProxy> Factory::NewJSProxy(Handle<Object> handler,
Handle<Object> prototype) {
// Allocate map.
« no previous file with comments | « src/factory.h ('k') | src/handles.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698