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

Unified Diff: src/bootstrapper.cc

Issue 1949863002: Fix TypedArray Property optimizations (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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/bootstrapper.cc
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index 13b197d2a8cb5adb85e6c6c766e24c5659e1481a..081f5f4be93b1a7ecea3280349134c129a8994d5 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 = InstallFunction(
+ global, "TypedArray", JS_OBJECT_TYPE, JSObject::kHeaderSize,
adamk 2016/05/04 18:44:36 I don't think you want to install this on the glob
gsathya 2016/05/05 21:16:06 Makes sense. But, I still need to create this JSFu
+ 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>(native_context()->typed_array_prototype());
adamk 2016/05/04 18:44:36 You can use the shorter "isolate()->typed_array_pr
gsathya 2016/05/05 21:16:06 Done.
+ Handle<JSFunction> typed_array_function =
+ Handle<JSFunction>(native_context()->typed_array_function());
adamk 2016/05/04 18:44:36 Same here, isolate()->typed_array_function().
gsathya 2016/05/05 21:16:06 Done.
+
+ 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,19 @@ void Genesis::InstallTypedArray(const char* name, ElementsKind elements_kind,
elements_kind);
JSFunction::SetInitialMap(result, initial_map,
handle(initial_map->prototype(), isolate()));
+
+ if (JSReceiver::SetPrototype(result, typed_array_function, false,
adamk 2016/05/04 18:44:36 I'd use JSObject::SetPrototype() here since you kn
gsathya 2016/05/05 21:16:06 Done.
+ Object::THROW_ON_ERROR)
+ .IsNothing()) {
+ DCHECK(false);
Dan Ehrenberg 2016/05/04 18:11:13 Nit: DCHECK(false) is rather unidiomatic (although
adamk 2016/05/04 18:44:36 I agree with this approach, though a slight modifi
gsathya 2016/05/05 21:16:06 Done.
+ }
+
+ if (JSReceiver::SetPrototype(prototype, typed_array_prototype, false,
adamk 2016/05/04 18:44:36 Same here, JSObject::SetPrototype.
gsathya 2016/05/05 21:16:06 Done.
+ Object::THROW_ON_ERROR)
+ .IsNothing()) {
+ DCHECK(false);
+ }
+
*fun = result;
}

Powered by Google App Engine
This is Rietveld 408576698