cfc6a5c2c6
There is no good reason to have the meat of most objects' initialization
logic in heap.cc, all wrapped by the CALL_HEAP_FUNCTION macro. Instead,
this CL changes the protocol between Heap and Factory to be AllocateRaw,
and all object initialization work after (possibly retried) successful
raw allocation happens in the Factory.
This saves about 20KB of binary size on x64.
Original review: https://chromium-review.googlesource.com/c/v8/v8/+/959533
Originally landed as r52416 / f9a2e24bbc
Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng
Change-Id: Id072cbe6b3ed30afd339c7e502844b99ca12a647
Reviewed-on: https://chromium-review.googlesource.com/1000540
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: Hannes Payer <hpayer@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52492}
41 lines
1.3 KiB
C++
41 lines
1.3 KiB
C++
// Copyright 2014 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "src/heap/factory.h"
|
|
#include "src/objects-inl.h"
|
|
#include "test/cctest/cctest.h"
|
|
|
|
namespace v8 {
|
|
namespace internal {
|
|
|
|
TEST(ArrayList) {
|
|
LocalContext context;
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
HandleScope scope(isolate);
|
|
Handle<ArrayList> array(
|
|
ArrayList::cast(isolate->heap()->empty_fixed_array()));
|
|
CHECK_EQ(0, array->Length());
|
|
array = ArrayList::Add(array, handle(Smi::FromInt(100), isolate));
|
|
CHECK_EQ(1, array->Length());
|
|
CHECK_EQ(100, Smi::ToInt(array->Get(0)));
|
|
array = ArrayList::Add(array, handle(Smi::FromInt(200), isolate),
|
|
handle(Smi::FromInt(300), isolate));
|
|
CHECK_EQ(3, array->Length());
|
|
CHECK_EQ(100, Smi::ToInt(array->Get(0)));
|
|
CHECK_EQ(200, Smi::ToInt(array->Get(1)));
|
|
CHECK_EQ(300, Smi::ToInt(array->Get(2)));
|
|
array->Set(2, Smi::FromInt(400));
|
|
CHECK_EQ(400, Smi::ToInt(array->Get(2)));
|
|
array->Clear(2, isolate->heap()->undefined_value());
|
|
array->SetLength(2);
|
|
CHECK_EQ(2, array->Length());
|
|
CHECK_EQ(100, Smi::ToInt(array->Get(0)));
|
|
CHECK_EQ(200, Smi::ToInt(array->Get(1)));
|
|
}
|
|
|
|
} // namespace internal
|
|
} // namespace v8
|