Commit 9e07c96f authored by gsathya's avatar gsathya Committed by Commit bot

[typedarrays] Remove duplicate initial map creation

Previously we created a duplicate map because we couldn't set the
correct ElementsKind when we created the function. This patch updates
the ElementsKind field of the existing map directly instead of
creating a new one.

This patch also correctly sets the instance_size when we create the
map the first time.

Review-Url: https://codereview.chromium.org/2486193003
Cr-Commit-Position: refs/heads/master@{#40872}
parent bc37b518
......@@ -2606,16 +2606,10 @@ void Genesis::InstallTypedArray(const char* name, ElementsKind elements_kind,
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,
JSTypedArray::kSizeWithInternalFields,
elements_kind);
JSFunction::SetInitialMap(result, initial_map,
handle(initial_map->prototype(), isolate()));
Handle<JSFunction> result = InstallFunction(
global, name, JS_TYPED_ARRAY_TYPE, JSTypedArray::kSizeWithInternalFields,
prototype, Builtins::kIllegal);
result->initial_map()->set_elements_kind(elements_kind);
CHECK(JSObject::SetPrototype(result, typed_array_function, false,
Object::DONT_THROW)
......
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