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

Unified Diff: src/bootstrapper.cc

Issue 1949863002: Fix TypedArray Property optimizations (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Use CreateFunction Created 4 years, 7 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/accessors.cc ('k') | src/contexts.h » ('j') | src/js/array-iterator.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/bootstrapper.cc
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index 9af851f710d25c5476ab924bbbe8850adb9986cb..e718249d192595107cc238ad33f80034cadfd600 100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -1605,6 +1605,17 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
}
{ // -- T y p e d A r r a y s
+ // Create the %TypedArrayPrototype%
+ Handle<JSObject> typed_array_prototype =
+ factory->NewJSObject(isolate->object_function(), TENURED);
+ native_context()->set_typed_array_prototype(*typed_array_prototype);
+
+ Handle<JSFunction> typed_array_fun = CreateFunction(
+ isolate, factory->InternalizeUtf8String("TypedArray"), JS_OBJECT_TYPE,
+ JSObject::kHeaderSize, typed_array_prototype, Builtins::kIllegal);
+ InstallWithIntrinsicDefaultProto(isolate, typed_array_fun,
+ Context::TYPED_ARRAY_FUN_INDEX);
+
#define INSTALL_TYPED_ARRAY(Type, type, TYPE, ctype, size) \
{ \
Handle<JSFunction> fun; \
@@ -1927,9 +1938,17 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
void Genesis::InstallTypedArray(const char* name, ElementsKind elements_kind,
Handle<JSFunction>* fun) {
Handle<JSObject> global = Handle<JSObject>(native_context()->global_object());
- Handle<JSFunction> result = InstallFunction(
- global, name, JS_TYPED_ARRAY_TYPE, JSTypedArray::kSize,
- isolate()->initial_object_prototype(), Builtins::kIllegal);
+
+ Handle<JSObject> typed_array_prototype =
+ Handle<JSObject>(isolate()->typed_array_prototype());
+ Handle<JSFunction> typed_array_function =
+ Handle<JSFunction>(isolate()->typed_array_function());
+
+ Handle<JSObject> prototype =
+ factory()->NewJSObject(isolate()->object_function(), TENURED);
+ Handle<JSFunction> result =
+ InstallFunction(global, name, JS_TYPED_ARRAY_TYPE, JSTypedArray::kSize,
+ prototype, Builtins::kIllegal);
Handle<Map> initial_map = isolate()->factory()->NewMap(
JS_TYPED_ARRAY_TYPE,
@@ -1937,6 +1956,15 @@ void Genesis::InstallTypedArray(const char* name, ElementsKind elements_kind,
elements_kind);
JSFunction::SetInitialMap(result, initial_map,
handle(initial_map->prototype(), isolate()));
+
+ CHECK(JSObject::SetPrototype(result, typed_array_function, false,
+ Object::DONT_THROW)
+ .FromJust());
+
+ CHECK(JSObject::SetPrototype(prototype, typed_array_prototype, false,
+ Object::DONT_THROW)
+ .FromJust());
+
*fun = result;
}
« no previous file with comments | « src/accessors.cc ('k') | src/contexts.h » ('j') | src/js/array-iterator.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698