Version 3.19.9
Implemented Load IC support for loading properties from primitive values to avoid perpetual soft deopts. (Chromium issue 242512)
Implemented Freeing of PerThreadAssertData when possible to avoid memory leak. (Chromium issue 246567)
Removed V8_USE_OLD_STYLE_PERSISTENT_HANDLE_VISITORS.
Performance and stability improvements on all platforms.
git-svn-id: http://v8.googlecode.com/svn/trunk@14954 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
diff --git a/test/cctest/cctest.status b/test/cctest/cctest.status
index 6297f56..8ce11eb 100644
--- a/test/cctest/cctest.status
+++ b/test/cctest/cctest.status
@@ -73,6 +73,12 @@
test-serialize/DeserializeFromSecondSerialization: SKIP
##############################################################################
+[ $arch == mipsel ]
+
+# BUG(2628): The test sometimes fails on MIPS simulator.
+test-cpu-profiler/SampleWhenFrameIsNotSetup: PASS || FAIL
+
+##############################################################################
[ $arch == android_arm || $arch == android_ia32 ]
# Tests crash as there is no /tmp directory in Android.
diff --git a/test/cctest/test-alloc.cc b/test/cctest/test-alloc.cc
index bc469aa..d316c8e 100644
--- a/test/cctest/test-alloc.cc
+++ b/test/cctest/test-alloc.cc
@@ -117,25 +117,27 @@
TEST(StressJS) {
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope scope(v8::Isolate::GetCurrent());
v8::Handle<v8::Context> env = v8::Context::New(v8::Isolate::GetCurrent());
env->Enter();
Handle<JSFunction> function =
- FACTORY->NewFunction(FACTORY->function_string(), FACTORY->null_value());
+ factory->NewFunction(factory->function_string(), factory->null_value());
// Force the creation of an initial map and set the code to
// something empty.
- FACTORY->NewJSObject(function);
+ factory->NewJSObject(function);
function->ReplaceCode(Isolate::Current()->builtins()->builtin(
Builtins::kEmptyFunction));
// Patch the map to have an accessor for "get".
Handle<Map> map(function->initial_map());
Handle<DescriptorArray> instance_descriptors(map->instance_descriptors());
- Handle<Foreign> foreign = FACTORY->NewForeign(&kDescriptor);
+ Handle<Foreign> foreign = factory->NewForeign(&kDescriptor);
Handle<String> name =
- FACTORY->NewStringFromAscii(Vector<const char>("get", 3));
+ factory->NewStringFromAscii(Vector<const char>("get", 3));
ASSERT(instance_descriptors->IsEmpty());
- Handle<DescriptorArray> new_descriptors = FACTORY->NewDescriptorArray(0, 1);
+ Handle<DescriptorArray> new_descriptors = factory->NewDescriptorArray(0, 1);
v8::internal::DescriptorArray::WhitenessWitness witness(*new_descriptors);
map->set_instance_descriptors(*new_descriptors);
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index 26a9207..cb3a38e 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -596,6 +596,7 @@
THREADED_TEST(UsingExternalString) {
+ i::Factory* factory = i::Isolate::Current()->factory();
{
v8::HandleScope scope(v8::Isolate::GetCurrent());
uint16_t* two_byte_string = AsciiToTwoByteString("test string");
@@ -606,7 +607,7 @@
HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now
HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now
i::Handle<i::String> isymbol =
- FACTORY->InternalizedStringFromString(istring);
+ factory->InternalizedStringFromString(istring);
CHECK(isymbol->IsInternalizedString());
}
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
@@ -615,6 +616,7 @@
THREADED_TEST(UsingExternalAsciiString) {
+ i::Factory* factory = i::Isolate::Current()->factory();
{
v8::HandleScope scope(v8::Isolate::GetCurrent());
const char* one_byte_string = "test string";
@@ -625,7 +627,7 @@
HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now
HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now
i::Handle<i::String> isymbol =
- FACTORY->InternalizedStringFromString(istring);
+ factory->InternalizedStringFromString(istring);
CHECK(isymbol->IsInternalizedString());
}
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
@@ -13509,6 +13511,7 @@
uint16_t* two_byte_string = AsciiToTwoByteString(c_string);
{
LocalContext env;
+ i::Factory* factory = i::Isolate::Current()->factory();
v8::HandleScope scope(env->GetIsolate());
AsciiVectorResource ascii_resource(
i::Vector<const char>(c_string, i::StrLength(c_string)));
@@ -13517,9 +13520,9 @@
i::StrLength(c_string)));
Local<String> lhs(v8::Utils::ToLocal(
- FACTORY->NewExternalStringFromAscii(&ascii_resource)));
+ factory->NewExternalStringFromAscii(&ascii_resource)));
Local<String> rhs(v8::Utils::ToLocal(
- FACTORY->NewExternalStringFromAscii(&ascii_resource)));
+ factory->NewExternalStringFromAscii(&ascii_resource)));
env->Global()->Set(v8_str("lhs"), lhs);
env->Global()->Set(v8_str("rhs"), rhs);
@@ -13606,6 +13609,8 @@
uc16_resource_(i::Vector<const uint16_t>(two_byte_content_, 15)) {}
~RegExpStringModificationTest() { delete block_; }
void RunTest() {
+ i::Factory* factory = i::Isolate::Current()->factory();
+
regexp_success_ = false;
morph_success_ = false;
@@ -13618,11 +13623,11 @@
// Create the input string for the regexp - the one we are going to change
// properties of.
- input_ = FACTORY->NewExternalStringFromAscii(&ascii_resource_);
+ input_ = factory->NewExternalStringFromAscii(&ascii_resource_);
// Inject the input as a global variable.
i::Handle<i::String> input_name =
- FACTORY->NewStringFromAscii(i::Vector<const char>("input", 5));
+ factory->NewStringFromAscii(i::Vector<const char>("input", 5));
i::Isolate::Current()->native_context()->global_object()->SetProperty(
*input_name,
*input_,
@@ -14116,12 +14121,13 @@
THREADED_TEST(PixelArray) {
LocalContext context;
+ i::Factory* factory = i::Isolate::Current()->factory();
v8::HandleScope scope(context->GetIsolate());
const int kElementCount = 260;
uint8_t* pixel_data = reinterpret_cast<uint8_t*>(malloc(kElementCount));
i::Handle<i::ExternalPixelArray> pixels =
i::Handle<i::ExternalPixelArray>::cast(
- FACTORY->NewExternalArray(kElementCount,
+ factory->NewExternalArray(kElementCount,
v8::kExternalPixelArray,
pixel_data));
// Force GC to trigger verification.
@@ -14538,12 +14544,13 @@
THREADED_TEST(PixelArrayWithInterceptor) {
LocalContext context;
+ i::Factory* factory = i::Isolate::Current()->factory();
v8::HandleScope scope(context->GetIsolate());
const int kElementCount = 260;
uint8_t* pixel_data = reinterpret_cast<uint8_t*>(malloc(kElementCount));
i::Handle<i::ExternalPixelArray> pixels =
i::Handle<i::ExternalPixelArray>::cast(
- FACTORY->NewExternalArray(kElementCount,
+ factory->NewExternalArray(kElementCount,
v8::kExternalPixelArray,
pixel_data));
for (int i = 0; i < kElementCount; i++) {
@@ -14905,6 +14912,7 @@
int64_t low,
int64_t high) {
LocalContext context;
+ i::Factory* factory = i::Isolate::Current()->factory();
v8::HandleScope scope(context->GetIsolate());
const int kElementCount = 40;
int element_size = ExternalArrayElementSize(array_type);
@@ -14912,7 +14920,7 @@
static_cast<ElementType*>(malloc(kElementCount * element_size));
i::Handle<ExternalArrayClass> array =
i::Handle<ExternalArrayClass>::cast(
- FACTORY->NewExternalArray(kElementCount, array_type, array_data));
+ factory->NewExternalArray(kElementCount, array_type, array_data));
// Force GC to trigger verification.
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
for (int i = 0; i < kElementCount; i++) {
@@ -15849,10 +15857,11 @@
}
static void CreateGarbageInOldSpace() {
+ i::Factory* factory = i::Isolate::Current()->factory();
v8::HandleScope scope(v8::Isolate::GetCurrent());
i::AlwaysAllocateScope always_allocate;
for (int i = 0; i < 1000; i++) {
- FACTORY->NewFixedArray(1000, i::TENURED);
+ factory->NewFixedArray(1000, i::TENURED);
}
}
@@ -17528,13 +17537,6 @@
explicit Visitor42(v8::Persistent<v8::Object>* object)
: counter_(0), object_(object) { }
-#ifdef V8_USE_OLD_STYLE_PERSISTENT_HANDLE_VISITORS
- virtual void VisitPersistentHandle(Persistent<Value> value,
- uint16_t class_id) {
- VisitPersistentHandle(&value, class_id);
- }
-#endif
-
virtual void VisitPersistentHandle(Persistent<Value>* value,
uint16_t class_id) {
if (class_id != 42) return;
@@ -18547,18 +18549,19 @@
TEST(StaticGetters) {
LocalContext context;
+ i::Factory* factory = i::Isolate::Current()->factory();
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::HandleScope scope(isolate);
- i::Handle<i::Object> undefined_value = FACTORY->undefined_value();
+ i::Handle<i::Object> undefined_value = factory->undefined_value();
CHECK(*v8::Utils::OpenHandle(*v8::Undefined()) == *undefined_value);
CHECK(*v8::Utils::OpenHandle(*v8::Undefined(isolate)) == *undefined_value);
- i::Handle<i::Object> null_value = FACTORY->null_value();
+ i::Handle<i::Object> null_value = factory->null_value();
CHECK(*v8::Utils::OpenHandle(*v8::Null()) == *null_value);
CHECK(*v8::Utils::OpenHandle(*v8::Null(isolate)) == *null_value);
- i::Handle<i::Object> true_value = FACTORY->true_value();
+ i::Handle<i::Object> true_value = factory->true_value();
CHECK(*v8::Utils::OpenHandle(*v8::True()) == *true_value);
CHECK(*v8::Utils::OpenHandle(*v8::True(isolate)) == *true_value);
- i::Handle<i::Object> false_value = FACTORY->false_value();
+ i::Handle<i::Object> false_value = factory->false_value();
CHECK(*v8::Utils::OpenHandle(*v8::False()) == *false_value);
CHECK(*v8::Utils::OpenHandle(*v8::False(isolate)) == *false_value);
@@ -18609,9 +18612,10 @@
TEST(StringEmpty) {
LocalContext context;
+ i::Factory* factory = i::Isolate::Current()->factory();
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::HandleScope scope(isolate);
- i::Handle<i::Object> empty_string = FACTORY->empty_string();
+ i::Handle<i::Object> empty_string = factory->empty_string();
CHECK(*v8::Utils::OpenHandle(*v8::String::Empty()) == *empty_string);
CHECK(*v8::Utils::OpenHandle(*v8::String::Empty(isolate)) == *empty_string);
diff --git a/test/cctest/test-assembler-arm.cc b/test/cctest/test-assembler-arm.cc
index 61eaa98..232f846 100644
--- a/test/cctest/test-assembler-arm.cc
+++ b/test/cctest/test-assembler-arm.cc
@@ -133,7 +133,7 @@
// some relocated stuff here, not executed
__ RecordComment("dead code, just testing relocations");
- __ mov(r0, Operand(FACTORY->true_value()));
+ __ mov(r0, Operand(isolate->factory()->true_value()));
__ RecordComment("dead code, just testing immediate operands");
__ mov(r0, Operand(-1));
__ mov(r0, Operand(0xFF000000));
diff --git a/test/cctest/test-assembler-ia32.cc b/test/cctest/test-assembler-ia32.cc
index 8d39ee7..880370f 100644
--- a/test/cctest/test-assembler-ia32.cc
+++ b/test/cctest/test-assembler-ia32.cc
@@ -137,7 +137,7 @@
__ ret(0);
// some relocated stuff here, not executed
- __ mov(eax, FACTORY->true_value());
+ __ mov(eax, isolate->factory()->true_value());
__ jmp(NULL, RelocInfo::RUNTIME_ENTRY);
CodeDesc desc;
diff --git a/test/cctest/test-compiler.cc b/test/cctest/test-compiler.cc
index f200435..b74ccb2 100644
--- a/test/cctest/test-compiler.cc
+++ b/test/cctest/test-compiler.cc
@@ -80,9 +80,10 @@
static MaybeObject* GetGlobalProperty(const char* name) {
- Handle<String> internalized_name = FACTORY->InternalizeUtf8String(name);
- return Isolate::Current()->context()->global_object()->GetProperty(
- *internalized_name);
+ Isolate* isolate = Isolate::Current();
+ Handle<String> internalized_name =
+ isolate->factory()->InternalizeUtf8String(name);
+ return isolate->context()->global_object()->GetProperty(*internalized_name);
}
@@ -97,19 +98,21 @@
static Handle<JSFunction> Compile(const char* source) {
- Handle<String> source_code(FACTORY->NewStringFromUtf8(CStrVector(source)));
+ Isolate* isolate = Isolate::Current();
+ Handle<String> source_code(
+ isolate->factory()->NewStringFromUtf8(CStrVector(source)));
Handle<SharedFunctionInfo> shared_function =
Compiler::Compile(source_code,
Handle<String>(),
0,
0,
- Handle<Context>(Isolate::Current()->native_context()),
+ Handle<Context>(isolate->native_context()),
NULL,
NULL,
Handle<String>::null(),
NOT_NATIVES_CODE);
- return FACTORY->NewFunctionFromSharedFunctionInfo(shared_function,
- Isolate::Current()->native_context());
+ return isolate->factory()->NewFunctionFromSharedFunctionInfo(
+ shared_function, isolate->native_context());
}
@@ -283,16 +286,15 @@
Execution::Call(fun0, global, 0, NULL, &has_pending_exception);
CHECK(!has_pending_exception);
- Object* foo_string =
- FACTORY->InternalizeOneByteString(STATIC_ASCII_VECTOR("foo"))->
- ToObjectChecked();
+ Object* foo_string = isolate->factory()->InternalizeOneByteString(
+ STATIC_ASCII_VECTOR("foo"))->ToObjectChecked();
MaybeObject* fun1_object = isolate->context()->global_object()->
GetProperty(String::cast(foo_string));
Handle<Object> fun1(fun1_object->ToObjectChecked(), isolate);
CHECK(fun1->IsJSFunction());
- Handle<Object> argv[] =
- { FACTORY->InternalizeOneByteString(STATIC_ASCII_VECTOR("hello")) };
+ Handle<Object> argv[] = { isolate->factory()->InternalizeOneByteString(
+ STATIC_ASCII_VECTOR("hello")) };
Execution::Call(Handle<JSFunction>::cast(fun1),
global,
ARRAY_SIZE(argv),
@@ -306,9 +308,11 @@
// source resulted in crash.
TEST(Regression236) {
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope scope(CcTest::isolate());
- Handle<Script> script = FACTORY->NewScript(FACTORY->empty_string());
+ Handle<Script> script = factory->NewScript(factory->empty_string());
script->set_source(HEAP->undefined_value());
CHECK_EQ(-1, GetScriptLineNumber(script, 0));
CHECK_EQ(-1, GetScriptLineNumber(script, 100));
diff --git a/test/cctest/test-cpu-profiler.cc b/test/cctest/test-cpu-profiler.cc
index 2234e11..901c116 100644
--- a/test/cctest/test-cpu-profiler.cc
+++ b/test/cctest/test-cpu-profiler.cc
@@ -638,3 +638,158 @@
cpu_profiler->DeleteAllCpuProfiles();
}
+
+
+static const char* native_accessor_test_source = "function start(count) {\n"
+" for (var i = 0; i < count; i++) {\n"
+" var o = instance.foo;\n"
+" instance.foo = o + 1;\n"
+" }\n"
+"}\n";
+
+
+class FooAccessorsData {
+ public:
+ explicit FooAccessorsData(int min_duration_ms)
+ : min_duration_ms_(min_duration_ms),
+ getter_duration_(0),
+ setter_duration_(0) {}
+
+ static v8::Handle<v8::Value> Getter(v8::Local<v8::String> name,
+ const v8::AccessorInfo& info) {
+ FooAccessorsData* data = fromInfo(info);
+ data->getter_duration_ = data->Wait();
+ return v8::Int32::New(2013);
+ }
+
+ static void Setter(v8::Local<v8::String> name,
+ v8::Local<v8::Value> value,
+ const v8::AccessorInfo& info) {
+ FooAccessorsData* data = fromInfo(info);
+ data->setter_duration_ = data->Wait();
+ }
+
+ void PrintAccessorTime() {
+ i::OS::Print("getter: %f ms; setter: %f ms\n", getter_duration_,
+ setter_duration_);
+ }
+
+ private:
+ double Wait() {
+ double start = i::OS::TimeCurrentMillis();
+ double duration = 0;
+ while (duration < min_duration_ms_) {
+ duration = i::OS::TimeCurrentMillis() - start;
+ }
+ return duration;
+ }
+
+ static FooAccessorsData* fromInfo(const v8::AccessorInfo& info) {
+ void* data = v8::External::Cast(*info.Data())->Value();
+ return reinterpret_cast<FooAccessorsData*>(data);
+ }
+
+ int min_duration_ms_;
+ double getter_duration_;
+ double setter_duration_;
+};
+
+
+// Test that native accessors are properly reported in the CPU profile.
+// This test checks the case when the long-running accessors are called
+// only once and the optimizer doesn't have chance to change the invocation
+// code.
+TEST(NativeAccessorNameInProfile1) {
+ LocalContext env;
+ v8::HandleScope scope(env->GetIsolate());
+
+
+ v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New();
+ v8::Local<v8::ObjectTemplate> instance_template =
+ func_template->InstanceTemplate();
+
+ FooAccessorsData accessors(100);
+ v8::Local<v8::External> data = v8::External::New(&accessors);
+ instance_template->SetAccessor(
+ v8::String::New("foo"), &FooAccessorsData::Getter,
+ &FooAccessorsData::Setter, data);
+ v8::Local<v8::Function> func = func_template->GetFunction();
+ v8::Local<v8::Object> instance = func->NewInstance();
+ env->Global()->Set(v8::String::New("instance"), instance);
+
+ v8::Script::Compile(v8::String::New(native_accessor_test_source))->Run();
+ v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
+ env->Global()->Get(v8::String::New("start")));
+
+ v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
+ v8::Local<v8::String> profile_name = v8::String::New("my_profile");
+
+ cpu_profiler->StartCpuProfiling(profile_name);
+ int32_t repeat_count = 1;
+ v8::Handle<v8::Value> args[] = { v8::Integer::New(repeat_count) };
+ function->Call(env->Global(), ARRAY_SIZE(args), args);
+ const v8::CpuProfile* profile = cpu_profiler->StopCpuProfiling(profile_name);
+
+ CHECK_NE(NULL, profile);
+ // Dump collected profile to have a better diagnostic in case of failure.
+ reinterpret_cast<i::CpuProfile*>(
+ const_cast<v8::CpuProfile*>(profile))->Print();
+ accessors.PrintAccessorTime();
+
+ const v8::CpuProfileNode* root = profile->GetTopDownRoot();
+ const v8::CpuProfileNode* startNode = GetChild(root, "start");
+ GetChild(startNode, "get foo");
+ GetChild(startNode, "set foo");
+
+ cpu_profiler->DeleteAllCpuProfiles();
+}
+
+
+// Test that native accessors are properly reported in the CPU profile.
+// This test makes sure that the accessors are called enough times to become
+// hot and to trigger optimizations.
+TEST(NativeAccessorNameInProfile2) {
+ LocalContext env;
+ v8::HandleScope scope(env->GetIsolate());
+
+
+ v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New();
+ v8::Local<v8::ObjectTemplate> instance_template =
+ func_template->InstanceTemplate();
+
+ FooAccessorsData accessors(1);
+ v8::Local<v8::External> data = v8::External::New(&accessors);
+ instance_template->SetAccessor(
+ v8::String::New("foo"), &FooAccessorsData::Getter,
+ &FooAccessorsData::Setter, data);
+ v8::Local<v8::Function> func = func_template->GetFunction();
+ v8::Local<v8::Object> instance = func->NewInstance();
+ env->Global()->Set(v8::String::New("instance"), instance);
+
+ v8::Script::Compile(v8::String::New(native_accessor_test_source))->Run();
+ v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
+ env->Global()->Get(v8::String::New("start")));
+
+ v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
+ v8::Local<v8::String> profile_name = v8::String::New("my_profile");
+
+ cpu_profiler->StartCpuProfiling(profile_name);
+ int32_t repeat_count = 100;
+ v8::Handle<v8::Value> args[] = { v8::Integer::New(repeat_count) };
+ function->Call(env->Global(), ARRAY_SIZE(args), args);
+ const v8::CpuProfile* profile = cpu_profiler->StopCpuProfiling(profile_name);
+
+ CHECK_NE(NULL, profile);
+ // Dump collected profile to have a better diagnostic in case of failure.
+ reinterpret_cast<i::CpuProfile*>(
+ const_cast<v8::CpuProfile*>(profile))->Print();
+
+ const v8::CpuProfileNode* root = profile->GetTopDownRoot();
+ const v8::CpuProfileNode* startNode = GetChild(root, "start");
+ // TODO(yurys): in LoadIC should be changed to report external callback
+ // invocation. See r13768 where it was LoadCallbackProperty was removed.
+ // GetChild(startNode, "get foo");
+ GetChild(startNode, "set foo");
+
+ cpu_profiler->DeleteAllCpuProfiles();
+}
diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc
index d802a85..b22092a 100644
--- a/test/cctest/test-debug.cc
+++ b/test/cctest/test-debug.cc
@@ -149,6 +149,7 @@
void ExposeDebug() {
v8::internal::Isolate* isolate =
reinterpret_cast<v8::internal::Isolate*>(context_->GetIsolate());
+ v8::internal::Factory* factory = isolate->factory();
v8::internal::Debug* debug = isolate->debug();
// Expose the debug context global object in the global object for testing.
debug->Load();
@@ -158,7 +159,7 @@
Handle<JSGlobalProxy> global(Handle<JSGlobalProxy>::cast(
v8::Utils::OpenHandle(*context_->Global())));
Handle<v8::internal::String> debug_string =
- FACTORY->InternalizeOneByteString(STATIC_ASCII_VECTOR("debug"));
+ factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("debug"));
SetProperty(isolate, global, debug_string,
Handle<Object>(debug->debug_context()->global_proxy(), isolate),
DONT_ENUM,
@@ -404,7 +405,7 @@
// Allocate array for the debugged functions
Handle<FixedArray> debugged_functions =
- FACTORY->NewFixedArray(count);
+ Isolate::Current()->factory()->NewFixedArray(count);
// Run through the debug info objects and collect all functions.
count = 0;
diff --git a/test/cctest/test-dictionary.cc b/test/cctest/test-dictionary.cc
index 32fff60..27c4fe4 100644
--- a/test/cctest/test-dictionary.cc
+++ b/test/cctest/test-dictionary.cc
@@ -41,10 +41,12 @@
TEST(ObjectHashTable) {
LocalContext context;
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope scope(context->GetIsolate());
- Handle<ObjectHashTable> table = FACTORY->NewObjectHashTable(23);
- Handle<JSObject> a = FACTORY->NewJSArray(7);
- Handle<JSObject> b = FACTORY->NewJSArray(11);
+ Handle<ObjectHashTable> table = factory->NewObjectHashTable(23);
+ Handle<JSObject> a = factory->NewJSArray(7);
+ Handle<JSObject> b = factory->NewJSArray(11);
table = PutIntoObjectHashTable(table, a, b);
CHECK_EQ(table->NumberOfElements(), 1);
CHECK_EQ(table->Lookup(*a), *b);
@@ -57,12 +59,12 @@
CHECK_EQ(table->Lookup(*b), HEAP->the_hole_value());
// Keys that are overwritten should not change number of elements.
- table = PutIntoObjectHashTable(table, a, FACTORY->NewJSArray(13));
+ table = PutIntoObjectHashTable(table, a, factory->NewJSArray(13));
CHECK_EQ(table->NumberOfElements(), 1);
CHECK_NE(table->Lookup(*a), *b);
// Keys mapped to the hole should be removed permanently.
- table = PutIntoObjectHashTable(table, a, FACTORY->the_hole_value());
+ table = PutIntoObjectHashTable(table, a, factory->the_hole_value());
CHECK_EQ(table->NumberOfElements(), 0);
CHECK_EQ(table->NumberOfDeletedElements(), 1);
CHECK_EQ(table->Lookup(*a), HEAP->the_hole_value());
@@ -70,8 +72,8 @@
// Keys should map back to their respective values and also should get
// an identity hash code generated.
for (int i = 0; i < 100; i++) {
- Handle<JSObject> key = FACTORY->NewJSArray(7);
- Handle<JSObject> value = FACTORY->NewJSArray(11);
+ Handle<JSObject> key = factory->NewJSArray(7);
+ Handle<JSObject> value = factory->NewJSArray(11);
table = PutIntoObjectHashTable(table, key, value);
CHECK_EQ(table->NumberOfElements(), i + 1);
CHECK_NE(table->FindEntry(*key), ObjectHashTable::kNotFound);
@@ -82,7 +84,7 @@
// Keys never added to the map which already have an identity hash
// code should not be found.
for (int i = 0; i < 100; i++) {
- Handle<JSObject> key = FACTORY->NewJSArray(7);
+ Handle<JSObject> key = factory->NewJSArray(7);
CHECK(key->GetIdentityHash(ALLOW_CREATION)->ToObjectChecked()->IsSmi());
CHECK_EQ(table->FindEntry(*key), ObjectHashTable::kNotFound);
CHECK_EQ(table->Lookup(*key), HEAP->the_hole_value());
@@ -92,7 +94,7 @@
// Keys that don't have an identity hash should not be found and also
// should not get an identity hash code generated.
for (int i = 0; i < 100; i++) {
- Handle<JSObject> key = FACTORY->NewJSArray(7);
+ Handle<JSObject> key = factory->NewJSArray(7);
CHECK_EQ(table->Lookup(*key), HEAP->the_hole_value());
CHECK_EQ(key->GetIdentityHash(OMIT_CREATION), HEAP->undefined_value());
}
@@ -102,9 +104,11 @@
#ifdef DEBUG
TEST(ObjectHashSetCausesGC) {
LocalContext context;
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope scope(context->GetIsolate());
- Handle<ObjectHashSet> table = FACTORY->NewObjectHashSet(1);
- Handle<JSObject> key = FACTORY->NewJSArray(0);
+ Handle<ObjectHashSet> table = factory->NewObjectHashSet(1);
+ Handle<JSObject> key = factory->NewJSArray(0);
v8::Handle<v8::Object> key_obj = v8::Utils::ToLocal(key);
// Force allocation of hash table backing store for hidden properties.
@@ -132,9 +136,11 @@
#ifdef DEBUG
TEST(ObjectHashTableCausesGC) {
LocalContext context;
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope scope(context->GetIsolate());
- Handle<ObjectHashTable> table = FACTORY->NewObjectHashTable(1);
- Handle<JSObject> key = FACTORY->NewJSArray(0);
+ Handle<ObjectHashTable> table = factory->NewObjectHashTable(1);
+ Handle<JSObject> key = factory->NewJSArray(0);
v8::Handle<v8::Object> key_obj = v8::Utils::ToLocal(key);
// Force allocation of hash table backing store for hidden properties.
diff --git a/test/cctest/test-disasm-ia32.cc b/test/cctest/test-disasm-ia32.cc
index ca81a5a..14447b2 100644
--- a/test/cctest/test-disasm-ia32.cc
+++ b/test/cctest/test-disasm-ia32.cc
@@ -61,7 +61,7 @@
__ sub(eax, Immediate(12345678));
__ xor_(eax, 12345678);
__ and_(eax, 12345678);
- Handle<FixedArray> foo = FACTORY->NewFixedArray(10, TENURED);
+ Handle<FixedArray> foo = isolate->factory()->NewFixedArray(10, TENURED);
__ cmp(eax, foo);
// ---- This one caused crash
@@ -92,7 +92,7 @@
__ cmp(edx, 3);
__ cmp(edx, Operand(esp, 4));
__ cmp(Operand(ebp, ecx, times_4, 0), Immediate(1000));
- Handle<FixedArray> foo2 = FACTORY->NewFixedArray(10, TENURED);
+ Handle<FixedArray> foo2 = isolate->factory()->NewFixedArray(10, TENURED);
__ cmp(ebx, foo2);
__ cmpb(ebx, Operand(ebp, ecx, times_2, 0));
__ cmpb(Operand(ebp, ecx, times_2, 0), ebx);
diff --git a/test/cctest/test-func-name-inference.cc b/test/cctest/test-func-name-inference.cc
index dcc6272..a0c4b1e 100644
--- a/test/cctest/test-func-name-inference.cc
+++ b/test/cctest/test-func-name-inference.cc
@@ -51,6 +51,9 @@
static void CheckFunctionName(v8::Handle<v8::Script> script,
const char* func_pos_src,
const char* ref_inferred_name) {
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
+
// Get script source.
Handle<Object> obj = v8::Utils::OpenHandle(*script);
Handle<SharedFunctionInfo> shared_function;
@@ -67,8 +70,8 @@
// Find the position of a given func source substring in the source.
Handle<String> func_pos_str =
- FACTORY->NewStringFromAscii(CStrVector(func_pos_src));
- int func_pos = Runtime::StringMatch(Isolate::Current(),
+ factory->NewStringFromAscii(CStrVector(func_pos_src));
+ int func_pos = Runtime::StringMatch(isolate,
script_src,
func_pos_str,
0);
@@ -76,10 +79,9 @@
#ifdef ENABLE_DEBUGGER_SUPPORT
// Obtain SharedFunctionInfo for the function.
- Isolate::Current()->debug()->PrepareForBreakPoints();
+ isolate->debug()->PrepareForBreakPoints();
Object* shared_func_info_ptr =
- Isolate::Current()->debug()->FindSharedFunctionInfoInScript(i_script,
- func_pos);
+ isolate->debug()->FindSharedFunctionInfoInScript(i_script, func_pos);
CHECK(shared_func_info_ptr != HEAP->undefined_value());
Handle<SharedFunctionInfo> shared_func_info(
SharedFunctionInfo::cast(shared_func_info_ptr));
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc
index 0c66c8f..68ed83d 100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -146,6 +146,7 @@
TEST(HeapObjects) {
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
Heap* heap = isolate->heap();
HandleScope sc(isolate);
@@ -201,7 +202,7 @@
CHECK(heap->nan_value()->IsNumber());
CHECK(std::isnan(heap->nan_value()->Number()));
- Handle<String> s = FACTORY->NewStringFromAscii(CStrVector("fisk hest "));
+ Handle<String> s = factory->NewStringFromAscii(CStrVector("fisk hest "));
CHECK(s->IsString());
CHECK_EQ(10, s->length());
@@ -339,10 +340,12 @@
TEST(LocalHandles) {
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope scope(CcTest::isolate());
const char* name = "Kasper the spunky";
- Handle<String> string = FACTORY->NewStringFromAscii(CStrVector(name));
+ Handle<String> string = factory->NewStringFromAscii(CStrVector(name));
CHECK_EQ(StrLength(name), string->length());
}
@@ -609,17 +612,19 @@
TEST(FunctionAllocation) {
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope sc(CcTest::isolate());
- Handle<String> name = FACTORY->InternalizeUtf8String("theFunction");
+ Handle<String> name = factory->InternalizeUtf8String("theFunction");
Handle<JSFunction> function =
- FACTORY->NewFunction(name, FACTORY->undefined_value());
+ factory->NewFunction(name, factory->undefined_value());
Handle<Map> initial_map =
- FACTORY->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
+ factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
function->set_initial_map(*initial_map);
- Handle<String> prop_name = FACTORY->InternalizeUtf8String("theSlot");
- Handle<JSObject> obj = FACTORY->NewJSObject(function);
+ Handle<String> prop_name = factory->InternalizeUtf8String("theSlot");
+ Handle<JSObject> obj = factory->NewJSObject(function);
obj->SetProperty(
*prop_name, Smi::FromInt(23), NONE, kNonStrictMode)->ToObjectChecked();
CHECK_EQ(Smi::FromInt(23), obj->GetProperty(*prop_name));
@@ -632,6 +637,8 @@
TEST(ObjectProperties) {
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope sc(CcTest::isolate());
String* object_string = String::cast(HEAP->Object_string());
@@ -639,9 +646,9 @@
GetProperty(object_string)->ToObjectChecked();
JSFunction* object_function = JSFunction::cast(raw_object);
Handle<JSFunction> constructor(object_function);
- Handle<JSObject> obj = FACTORY->NewJSObject(constructor);
- Handle<String> first = FACTORY->InternalizeUtf8String("first");
- Handle<String> second = FACTORY->InternalizeUtf8String("second");
+ Handle<JSObject> obj = factory->NewJSObject(constructor);
+ Handle<String> first = factory->InternalizeUtf8String("first");
+ Handle<String> second = factory->InternalizeUtf8String("second");
// check for empty
CHECK(!obj->HasLocalProperty(*first));
@@ -687,35 +694,37 @@
// check string and internalized string match
const char* string1 = "fisk";
- Handle<String> s1 = FACTORY->NewStringFromAscii(CStrVector(string1));
+ Handle<String> s1 = factory->NewStringFromAscii(CStrVector(string1));
obj->SetProperty(
*s1, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked();
- Handle<String> s1_string = FACTORY->InternalizeUtf8String(string1);
+ Handle<String> s1_string = factory->InternalizeUtf8String(string1);
CHECK(obj->HasLocalProperty(*s1_string));
// check internalized string and string match
const char* string2 = "fugl";
- Handle<String> s2_string = FACTORY->InternalizeUtf8String(string2);
+ Handle<String> s2_string = factory->InternalizeUtf8String(string2);
obj->SetProperty(
*s2_string, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked();
- Handle<String> s2 = FACTORY->NewStringFromAscii(CStrVector(string2));
+ Handle<String> s2 = factory->NewStringFromAscii(CStrVector(string2));
CHECK(obj->HasLocalProperty(*s2));
}
TEST(JSObjectMaps) {
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope sc(CcTest::isolate());
- Handle<String> name = FACTORY->InternalizeUtf8String("theFunction");
+ Handle<String> name = factory->InternalizeUtf8String("theFunction");
Handle<JSFunction> function =
- FACTORY->NewFunction(name, FACTORY->undefined_value());
+ factory->NewFunction(name, factory->undefined_value());
Handle<Map> initial_map =
- FACTORY->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
+ factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
function->set_initial_map(*initial_map);
- Handle<String> prop_name = FACTORY->InternalizeUtf8String("theSlot");
- Handle<JSObject> obj = FACTORY->NewJSObject(function);
+ Handle<String> prop_name = factory->InternalizeUtf8String("theSlot");
+ Handle<JSObject> obj = factory->NewJSObject(function);
// Set a propery
obj->SetProperty(
@@ -729,16 +738,18 @@
TEST(JSArray) {
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope sc(CcTest::isolate());
- Handle<String> name = FACTORY->InternalizeUtf8String("Array");
+ Handle<String> name = factory->InternalizeUtf8String("Array");
Object* raw_object = Isolate::Current()->context()->global_object()->
GetProperty(*name)->ToObjectChecked();
Handle<JSFunction> function = Handle<JSFunction>(
JSFunction::cast(raw_object));
// Allocate the object.
- Handle<JSObject> object = FACTORY->NewJSObject(function);
+ Handle<JSObject> object = factory->NewJSObject(function);
Handle<JSArray> array = Handle<JSArray>::cast(object);
// We just initialized the VM, no heap allocation failure yet.
array->Initialize(0)->ToObjectChecked();
@@ -756,7 +767,7 @@
// Set array length with larger than smi value.
Handle<Object> length =
- FACTORY->NewNumberFromUint(static_cast<uint32_t>(Smi::kMaxValue) + 1);
+ factory->NewNumberFromUint(static_cast<uint32_t>(Smi::kMaxValue) + 1);
array->SetElementsLength(*length)->ToObjectChecked();
uint32_t int_length = 0;
@@ -776,6 +787,8 @@
TEST(JSObjectCopy) {
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope sc(CcTest::isolate());
String* object_string = String::cast(HEAP->Object_string());
@@ -783,9 +796,9 @@
GetProperty(object_string)->ToObjectChecked();
JSFunction* object_function = JSFunction::cast(raw_object);
Handle<JSFunction> constructor(object_function);
- Handle<JSObject> obj = FACTORY->NewJSObject(constructor);
- Handle<String> first = FACTORY->InternalizeUtf8String("first");
- Handle<String> second = FACTORY->InternalizeUtf8String("second");
+ Handle<JSObject> obj = factory->NewJSObject(constructor);
+ Handle<String> first = factory->InternalizeUtf8String("first");
+ Handle<String> second = factory->InternalizeUtf8String("second");
obj->SetProperty(
*first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked();
@@ -824,6 +837,8 @@
TEST(StringAllocation) {
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
const unsigned char chars[] = { 0xe5, 0xa4, 0xa7 };
for (int length = 0; length < 100; length++) {
@@ -839,18 +854,18 @@
non_ascii[3 * i + 2] = chars[2];
}
Handle<String> non_ascii_sym =
- FACTORY->InternalizeUtf8String(
+ factory->InternalizeUtf8String(
Vector<const char>(non_ascii, 3 * length));
CHECK_EQ(length, non_ascii_sym->length());
Handle<String> ascii_sym =
- FACTORY->InternalizeOneByteString(OneByteVector(ascii, length));
+ factory->InternalizeOneByteString(OneByteVector(ascii, length));
CHECK_EQ(length, ascii_sym->length());
Handle<String> non_ascii_str =
- FACTORY->NewStringFromUtf8(Vector<const char>(non_ascii, 3 * length));
+ factory->NewStringFromUtf8(Vector<const char>(non_ascii, 3 * length));
non_ascii_str->Hash();
CHECK_EQ(length, non_ascii_str->length());
Handle<String> ascii_str =
- FACTORY->NewStringFromUtf8(Vector<const char>(ascii, length));
+ factory->NewStringFromUtf8(Vector<const char>(ascii, length));
ascii_str->Hash();
CHECK_EQ(length, ascii_str->length());
DeleteArray(non_ascii);
@@ -876,6 +891,8 @@
TEST(Iteration) {
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope scope(CcTest::isolate());
// Array of objects to scan haep for.
@@ -884,16 +901,16 @@
int next_objs_index = 0;
// Allocate a JS array to OLD_POINTER_SPACE and NEW_SPACE
- objs[next_objs_index++] = FACTORY->NewJSArray(10);
- objs[next_objs_index++] = FACTORY->NewJSArray(10,
+ objs[next_objs_index++] = factory->NewJSArray(10);
+ objs[next_objs_index++] = factory->NewJSArray(10,
FAST_HOLEY_ELEMENTS,
TENURED);
// Allocate a small string to OLD_DATA_SPACE and NEW_SPACE
objs[next_objs_index++] =
- FACTORY->NewStringFromAscii(CStrVector("abcdefghij"));
+ factory->NewStringFromAscii(CStrVector("abcdefghij"));
objs[next_objs_index++] =
- FACTORY->NewStringFromAscii(CStrVector("abcdefghij"), TENURED);
+ factory->NewStringFromAscii(CStrVector("abcdefghij"), TENURED);
// Allocate a large string (for large object space).
int large_size = Page::kMaxNonCodeHeapObjectSize + 1;
@@ -901,7 +918,7 @@
for (int i = 0; i < large_size - 1; ++i) str[i] = 'a';
str[large_size - 1] = '\0';
objs[next_objs_index++] =
- FACTORY->NewStringFromAscii(CStrVector(str), TENURED);
+ factory->NewStringFromAscii(CStrVector(str), TENURED);
delete[] str;
// Add a Map object to look for.
@@ -936,6 +953,8 @@
TEST(Regression39128) {
// Test case for crbug.com/39128.
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
// Increase the chance of 'bump-the-pointer' allocation in old space.
HEAP->CollectAllGarbage(Heap::kNoGCFlags);
@@ -952,7 +971,7 @@
CHECK(object_ctor->has_initial_map());
Handle<Map> object_map(object_ctor->initial_map());
// Create a map with single inobject property.
- Handle<Map> my_map = FACTORY->CopyMap(object_map, 1);
+ Handle<Map> my_map = factory->CopyMap(object_map, 1);
int n_properties = my_map->inobject_properties();
CHECK_GT(n_properties, 0);
@@ -1013,6 +1032,8 @@
if (!FLAG_flush_code) return;
i::FLAG_allow_natives_syntax = true;
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope scope(CcTest::isolate());
const char* source = "function foo() {"
" var x = 42;"
@@ -1020,7 +1041,7 @@
" var z = x + y;"
"};"
"foo()";
- Handle<String> foo_name = FACTORY->InternalizeUtf8String("foo");
+ Handle<String> foo_name = factory->InternalizeUtf8String("foo");
// This compile will add the code to the compilation cache.
{ v8::HandleScope scope(CcTest::isolate());
@@ -1060,6 +1081,8 @@
if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return;
i::FLAG_allow_natives_syntax = true;
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope scope(CcTest::isolate());
const char* source = "function foo() {"
" var x = 42;"
@@ -1067,7 +1090,7 @@
" var z = x + y;"
"};"
"foo()";
- Handle<String> foo_name = FACTORY->InternalizeUtf8String("foo");
+ Handle<String> foo_name = factory->InternalizeUtf8String("foo");
// This compile will add the code to the compilation cache.
{ v8::HandleScope scope(CcTest::isolate());
@@ -1126,6 +1149,8 @@
if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return;
i::FLAG_allow_natives_syntax = true;
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope scope(CcTest::isolate());
const char* source = "var foo = function() {"
" var x = 42;"
@@ -1137,8 +1162,8 @@
" var x = 23;"
"};"
"bar();";
- Handle<String> foo_name = FACTORY->InternalizeUtf8String("foo");
- Handle<String> bar_name = FACTORY->InternalizeUtf8String("bar");
+ Handle<String> foo_name = factory->InternalizeUtf8String("foo");
+ Handle<String> bar_name = factory->InternalizeUtf8String("bar");
// Perfrom one initial GC to enable code flushing.
HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
@@ -1193,6 +1218,7 @@
i::FLAG_allow_natives_syntax = true;
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
Heap* heap = isolate->heap();
v8::HandleScope scope(CcTest::isolate());
const char* source = "function foo() {"
@@ -1201,7 +1227,7 @@
" var z = x + y;"
"};"
"foo()";
- Handle<String> foo_name = FACTORY->InternalizeUtf8String("foo");
+ Handle<String> foo_name = factory->InternalizeUtf8String("foo");
// This compile will add the code to the compilation cache.
{ v8::HandleScope scope(CcTest::isolate());
@@ -1892,6 +1918,8 @@
TEST(PrototypeTransitionClearing) {
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope scope(CcTest::isolate());
CompileRun(
@@ -1931,7 +1959,7 @@
{
AlwaysAllocateScope always_allocate;
SimulateFullSpace(space);
- prototype = FACTORY->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, TENURED);
+ prototype = factory->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, TENURED);
}
// Add a prototype on an evacuation candidate and verify that transition
@@ -2155,6 +2183,30 @@
}
+TEST(OptimizedPretenuringCallNew) {
+ i::FLAG_allow_natives_syntax = true;
+ i::FLAG_pretenuring_call_new = true;
+ CcTest::InitializeVM();
+ if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return;
+ if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
+ v8::HandleScope scope(CcTest::isolate());
+ HEAP->SetNewSpaceHighPromotionModeActive(true);
+
+ AlwaysAllocateScope always_allocate;
+ v8::Local<v8::Value> res = CompileRun(
+ "function g() { this.a = 0; }"
+ "function f() {"
+ " return new g();"
+ "};"
+ "f(); f(); f();"
+ "%OptimizeFunctionOnNextCall(f);"
+ "f();");
+
+ Handle<JSObject> o =
+ v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
+ CHECK(HEAP->InOldPointerSpace(*o));
+}
+
static int CountMapTransitions(Map* map) {
return map->transitions()->number_of_transitions();
}
@@ -2290,6 +2342,8 @@
i::FLAG_crankshaft = false;
i::FLAG_always_opt = false;
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope scope(CcTest::isolate());
static const int number_of_test_pages = 20;
@@ -2299,7 +2353,7 @@
for (int i = 0; i < number_of_test_pages; i++) {
AlwaysAllocateScope always_allocate;
SimulateFullSpace(old_pointer_space);
- FACTORY->NewFixedArray(1, TENURED);
+ factory->NewFixedArray(1, TENURED);
}
CHECK_EQ(number_of_test_pages + 1, old_pointer_space->CountTotalPages());
@@ -2329,6 +2383,8 @@
TEST(Regress2237) {
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope scope(CcTest::isolate());
Handle<String> slice(HEAP->empty_string());
@@ -2336,7 +2392,7 @@
// Generate a parent that lives in new-space.
v8::HandleScope inner_scope(CcTest::isolate());
const char* c = "This text is long enough to trigger sliced strings.";
- Handle<String> s = FACTORY->NewStringFromAscii(CStrVector(c));
+ Handle<String> s = factory->NewStringFromAscii(CStrVector(c));
CHECK(s->IsSeqOneByteString());
CHECK(HEAP->InNewSpace(*s));
@@ -2344,7 +2400,7 @@
// lives in old-space.
SimulateFullSpace(HEAP->new_space());
AlwaysAllocateScope always_allocate;
- Handle<String> t = FACTORY->NewProperSubString(s, 5, 35);
+ Handle<String> t = factory->NewProperSubString(s, 5, 35);
CHECK(t->IsSlicedString());
CHECK(!HEAP->InNewSpace(*t));
*slice.location() = *t.location();
@@ -2900,6 +2956,8 @@
i::FLAG_allow_natives_syntax = true;
i::FLAG_crankshaft = false;
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope scope(CcTest::isolate());
// Some flags turn Scavenge collections into Mark-sweep collections
@@ -2930,7 +2988,7 @@
HEAP->CollectGarbage(NEW_SPACE);
// Allocate the object.
- Handle<FixedArray> array_data = FACTORY->NewFixedArray(2, NOT_TENURED);
+ Handle<FixedArray> array_data = factory->NewFixedArray(2, NOT_TENURED);
array_data->set(0, Smi::FromInt(1));
array_data->set(1, Smi::FromInt(2));
@@ -2938,7 +2996,7 @@
JSArray::kSize + AllocationSiteInfo::kSize +
kPointerSize);
- Handle<JSArray> array = FACTORY->NewJSArrayWithElements(array_data,
+ Handle<JSArray> array = factory->NewJSArrayWithElements(array_data,
FAST_SMI_ELEMENTS,
NOT_TENURED);
diff --git a/test/cctest/test-mark-compact.cc b/test/cctest/test-mark-compact.cc
index c9482d6..45cb39c 100644
--- a/test/cctest/test-mark-compact.cc
+++ b/test/cctest/test-mark-compact.cc
@@ -235,24 +235,26 @@
// TODO(1600): compaction of map space is temporary removed from GC.
#if 0
-static Handle<Map> CreateMap() {
- return FACTORY->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
+static Handle<Map> CreateMap(Isolate* isolate) {
+ return isolate->factory()->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
}
TEST(MapCompact) {
FLAG_max_map_space_pages = 16;
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
{
v8::HandleScope sc;
// keep allocating maps while pointers are still encodable and thus
// mark compact is permitted.
- Handle<JSObject> root = FACTORY->NewJSObjectFromMap(CreateMap());
+ Handle<JSObject> root = factory->NewJSObjectFromMap(CreateMap());
do {
Handle<Map> map = CreateMap();
map->set_prototype(*root);
- root = FACTORY->NewJSObjectFromMap(map);
+ root = factory->NewJSObjectFromMap(map);
} while (HEAP->map_space()->MapPointersEncodable());
}
// Now, as we don't have any handles to just allocated maps, we should
diff --git a/test/cctest/test-object-observe.cc b/test/cctest/test-object-observe.cc
index 9eb6f3c..0dd0265 100644
--- a/test/cctest/test-object-observe.cc
+++ b/test/cctest/test-object-observe.cc
@@ -418,7 +418,8 @@
"Object.observe(obj, function(){});"
"Object.getNotifier(obj);"
"obj = null;");
- i::Handle<i::JSObject> observation_state = FACTORY->observation_state();
+ i::Handle<i::JSObject> observation_state =
+ i::Isolate::Current()->factory()->observation_state();
i::Handle<i::JSWeakMap> observerInfoMap =
i::Handle<i::JSWeakMap>::cast(
i::GetProperty(observation_state, "observerInfoMap"));
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc
index e81bf32..b580f4b 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -336,13 +336,15 @@
TEST(Regress928) {
v8::V8::Initialize();
+ i::Isolate* isolate = i::Isolate::Current();
+ i::Factory* factory = isolate->factory();
// Preparsing didn't consider the catch clause of a try statement
// as with-content, which made it assume that a function inside
// the block could be lazily compiled, and an extra, unexpected,
// entry was added to the data.
int marker;
- i::Isolate::Current()->stack_guard()->SetStackLimit(
+ isolate->stack_guard()->SetStackLimit(
reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
const char* program =
@@ -351,7 +353,7 @@
v8::HandleScope handles(v8::Isolate::GetCurrent());
i::Handle<i::String> source(
- FACTORY->NewStringFromAscii(i::CStrVector(program)));
+ factory->NewStringFromAscii(i::CStrVector(program)));
i::GenericStringUtf16CharacterStream stream(source, 0, source->length());
i::ScriptDataImpl* data = i::PreParserApi::PreParse(&stream);
CHECK(!data->HasError());
@@ -434,17 +436,19 @@
unsigned end = 0) {
if (end == 0) end = length;
unsigned sub_length = end - start;
- i::HandleScope test_scope(i::Isolate::Current());
+ i::Isolate* isolate = i::Isolate::Current();
+ i::Factory* factory = isolate->factory();
+ i::HandleScope test_scope(isolate);
i::SmartArrayPointer<i::uc16> uc16_buffer(new i::uc16[length]);
for (unsigned i = 0; i < length; i++) {
uc16_buffer[i] = static_cast<i::uc16>(ascii_source[i]);
}
i::Vector<const char> ascii_vector(ascii_source, static_cast<int>(length));
i::Handle<i::String> ascii_string(
- FACTORY->NewStringFromAscii(ascii_vector));
+ factory->NewStringFromAscii(ascii_vector));
TestExternalResource resource(*uc16_buffer, length);
i::Handle<i::String> uc16_string(
- FACTORY->NewExternalStringFromTwoByte(&resource));
+ factory->NewExternalStringFromTwoByte(&resource));
i::ExternalTwoByteStringUtf16CharacterStream uc16_stream(
i::Handle<i::ExternalTwoByteString>::cast(uc16_string), start, end);
@@ -984,12 +988,15 @@
{ NULL, NULL, NULL, i::EVAL_SCOPE, i::CLASSIC_MODE }
};
+ i::Isolate* isolate = i::Isolate::Current();
+ i::Factory* factory = isolate->factory();
+
v8::HandleScope handles(v8::Isolate::GetCurrent());
v8::Handle<v8::Context> context = v8::Context::New(v8::Isolate::GetCurrent());
v8::Context::Scope context_scope(context);
int marker;
- i::Isolate::Current()->stack_guard()->SetStackLimit(
+ isolate->stack_guard()->SetStackLimit(
reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
for (int i = 0; source_data[i].outer_prefix; i++) {
@@ -1009,9 +1016,9 @@
// Parse program source.
i::Handle<i::String> source(
- FACTORY->NewStringFromUtf8(i::CStrVector(program.start())));
+ factory->NewStringFromUtf8(i::CStrVector(program.start())));
CHECK_EQ(source->length(), kProgramSize);
- i::Handle<i::Script> script = FACTORY->NewScript(source);
+ i::Handle<i::Script> script = factory->NewScript(source);
i::CompilationInfoWithZone info(script);
i::Parser parser(&info);
parser.set_allow_lazy(true);
@@ -1039,10 +1046,12 @@
i::Handle<i::String> FormatMessage(i::ScriptDataImpl* data) {
+ i::Isolate* isolate = i::Isolate::Current();
+ i::Factory* factory = isolate->factory();
i::Handle<i::String> format = v8::Utils::OpenHandle(
*v8::String::New(data->BuildMessage()));
i::Vector<const char*> args = data->BuildArgs();
- i::Handle<i::JSArray> args_array = FACTORY->NewJSArray(args.length());
+ i::Handle<i::JSArray> args_array = factory->NewJSArray(args.length());
for (int i = 0; i < args.length(); i++) {
i::JSArray::SetElement(args_array,
i,
@@ -1050,7 +1059,7 @@
NONE,
i::kNonStrictMode);
}
- i::Handle<i::JSObject> builtins(i::Isolate::Current()->js_builtins_object());
+ i::Handle<i::JSObject> builtins(isolate->js_builtins_object());
i::Handle<i::Object> format_fun =
i::GetProperty(builtins, "FormatMessage");
i::Handle<i::Object> arg_handles[] = { format, args_array };
@@ -1088,12 +1097,15 @@
parser.set_allow_generators(checkParserFlag(flags, kAllowGenerators));
void TestParserSyncWithFlags(i::Handle<i::String> source, unsigned flags) {
- uintptr_t stack_limit = i::Isolate::Current()->stack_guard()->real_climit();
+ i::Isolate* isolate = i::Isolate::Current();
+ i::Factory* factory = isolate->factory();
+
+ uintptr_t stack_limit = isolate->stack_guard()->real_climit();
// Preparse the data.
i::CompleteParserRecorder log;
{
- i::Scanner scanner(i::Isolate::Current()->unicode_cache());
+ i::Scanner scanner(isolate->unicode_cache());
i::GenericStringUtf16CharacterStream stream(source, 0, source->length());
v8::preparser::PreParser preparser(&scanner, &log, stack_limit);
SET_PARSER_FLAGS(preparser, flags);
@@ -1107,7 +1119,7 @@
// Parse the data
i::FunctionLiteral* function;
{
- i::Handle<i::Script> script = FACTORY->NewScript(source);
+ i::Handle<i::Script> script = factory->NewScript(source);
i::CompilationInfoWithZone info(script);
i::Parser parser(&info);
SET_PARSER_FLAGS(parser, flags);
@@ -1118,8 +1130,8 @@
// Check that preparsing fails iff parsing fails.
if (function == NULL) {
// Extract exception from the parser.
- CHECK(i::Isolate::Current()->has_pending_exception());
- i::MaybeObject* maybe_object = i::Isolate::Current()->pending_exception();
+ CHECK(isolate->has_pending_exception());
+ i::MaybeObject* maybe_object = isolate->pending_exception();
i::JSObject* exception = NULL;
CHECK(maybe_object->To(&exception));
i::Handle<i::JSObject> exception_handle(exception);
@@ -1243,12 +1255,15 @@
// correct timeout for this and re-enable this test again.
if (i::FLAG_stress_compaction) return;
+ i::Isolate* isolate = i::Isolate::Current();
+ i::Factory* factory = isolate->factory();
+
v8::HandleScope handles(v8::Isolate::GetCurrent());
v8::Handle<v8::Context> context = v8::Context::New(v8::Isolate::GetCurrent());
v8::Context::Scope context_scope(context);
int marker;
- i::Isolate::Current()->stack_guard()->SetStackLimit(
+ isolate->stack_guard()->SetStackLimit(
reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
for (int i = 0; context_data[i][0] != NULL; ++i) {
@@ -1271,7 +1286,7 @@
context_data[i][1]);
CHECK(length == kProgramSize);
i::Handle<i::String> source =
- FACTORY->NewStringFromAscii(i::CStrVector(program.start()));
+ factory->NewStringFromAscii(i::CStrVector(program.start()));
TestParserSync(source);
}
}
diff --git a/test/cctest/test-random.cc b/test/cctest/test-random.cc
index 430355c..0a8594c 100644
--- a/test/cctest/test-random.cc
+++ b/test/cctest/test-random.cc
@@ -81,8 +81,8 @@
CompileRun("function f() { return Math.random(); }");
- Object* string = FACTORY->InternalizeOneByteString(STATIC_ASCII_VECTOR("f"))->
- ToObjectChecked();
+ Object* string = Isolate::Current()->factory()->InternalizeOneByteString(
+ STATIC_ASCII_VECTOR("f"))->ToObjectChecked();
MaybeObject* fun_object =
context->global_object()->GetProperty(String::cast(string));
Handle<JSFunction> fun(JSFunction::cast(fun_object->ToObjectChecked()));
diff --git a/test/cctest/test-serialize.cc b/test/cctest/test-serialize.cc
index f87eb96..8973d54 100644
--- a/test/cctest/test-serialize.cc
+++ b/test/cctest/test-serialize.cc
@@ -286,14 +286,15 @@
static void SanityCheck() {
+ Isolate* isolate = Isolate::Current();
v8::HandleScope scope(v8::Isolate::GetCurrent());
#ifdef VERIFY_HEAP
HEAP->Verify();
#endif
- CHECK(Isolate::Current()->global_object()->IsJSObject());
- CHECK(Isolate::Current()->native_context()->IsContext());
+ CHECK(isolate->global_object()->IsJSObject());
+ CHECK(isolate->native_context()->IsContext());
CHECK(HEAP->string_table()->IsStringTable());
- CHECK(!FACTORY->InternalizeOneByteString(
+ CHECK(!isolate->factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("Empty"))->IsFailure());
}
diff --git a/test/cctest/test-strings.cc b/test/cctest/test-strings.cc
index e0ff32f..12d71e9 100644
--- a/test/cctest/test-strings.cc
+++ b/test/cctest/test-strings.cc
@@ -136,7 +136,9 @@
RandomNumberGenerator* rng) {
// A list of pointers that we don't have any interest in cleaning up.
// If they are reachable from a root then leak detection won't complain.
- Zone* zone = Isolate::Current()->runtime_zone();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
+ Zone* zone = isolate->runtime_zone();
for (int i = 0; i < bb_length; i++) {
int len = rng->next(16);
int slice_head_chars = 0;
@@ -168,7 +170,7 @@
buf[j] = rng->next(0x10000);
}
building_blocks[i] =
- FACTORY->NewStringFromTwoByte(Vector<const uc16>(buf, len));
+ factory->NewStringFromTwoByte(Vector<const uc16>(buf, len));
for (int j = 0; j < len; j++) {
CHECK_EQ(buf[j], building_blocks[i]->Get(j));
}
@@ -180,7 +182,7 @@
buf[j] = rng->next(0x80);
}
building_blocks[i] =
- FACTORY->NewStringFromAscii(Vector<const char>(buf, len));
+ factory->NewStringFromAscii(Vector<const char>(buf, len));
for (int j = 0; j < len; j++) {
CHECK_EQ(buf[j], building_blocks[i]->Get(j));
}
@@ -192,7 +194,7 @@
buf[j] = rng->next(0x10000);
}
Resource* resource = new(zone) Resource(Vector<const uc16>(buf, len));
- building_blocks[i] = FACTORY->NewExternalStringFromTwoByte(resource);
+ building_blocks[i] = factory->NewExternalStringFromTwoByte(resource);
for (int j = 0; j < len; j++) {
CHECK_EQ(buf[j], building_blocks[i]->Get(j));
}
@@ -205,7 +207,7 @@
}
AsciiResource* resource =
new(zone) AsciiResource(Vector<const char>(buf, len));
- building_blocks[i] = FACTORY->NewExternalStringFromAscii(resource);
+ building_blocks[i] = factory->NewExternalStringFromAscii(resource);
for (int j = 0; j < len; j++) {
CHECK_EQ(buf[j], building_blocks[i]->Get(j));
}
@@ -213,7 +215,7 @@
}
}
for (int j = slice_depth; j > 0; j--) {
- building_blocks[i] = FACTORY->NewSubString(
+ building_blocks[i] = factory->NewSubString(
building_blocks[i],
slice_head_chars,
building_blocks[i]->length() - slice_tail_chars);
@@ -400,6 +402,7 @@
static Handle<String> ConstructRandomString(ConsStringGenerationData* data,
unsigned max_recursion) {
+ Factory* factory = Isolate::Current()->factory();
// Compute termination characteristics.
bool terminate = false;
bool flat = data->rng_.next(data->empty_leaf_threshold_);
@@ -446,7 +449,7 @@
left = ConstructRandomString(data, max_recursion - 1);
}
// Build the cons string.
- Handle<String> root = FACTORY->NewConsString(left, right);
+ Handle<String> root = factory->NewConsString(left, right);
CHECK(root->IsConsString() && !root->IsFlat());
// Special work needed for flat string.
if (flat) {
@@ -461,11 +464,12 @@
static Handle<String> ConstructLeft(
ConsStringGenerationData* data,
int depth) {
- Handle<String> answer = FACTORY->NewStringFromAscii(CStrVector(""));
+ Factory* factory = Isolate::Current()->factory();
+ Handle<String> answer = factory->NewStringFromAscii(CStrVector(""));
data->stats_.leaves_++;
for (int i = 0; i < depth; i++) {
Handle<String> block = data->block(i);
- Handle<String> next = FACTORY->NewConsString(answer, block);
+ Handle<String> next = factory->NewConsString(answer, block);
if (next->IsConsString()) data->stats_.leaves_++;
data->stats_.chars_ += block->length();
answer = next;
@@ -478,11 +482,12 @@
static Handle<String> ConstructRight(
ConsStringGenerationData* data,
int depth) {
- Handle<String> answer = FACTORY->NewStringFromAscii(CStrVector(""));
+ Factory* factory = Isolate::Current()->factory();
+ Handle<String> answer = factory->NewStringFromAscii(CStrVector(""));
data->stats_.leaves_++;
for (int i = depth - 1; i >= 0; i--) {
Handle<String> block = data->block(i);
- Handle<String> next = FACTORY->NewConsString(block, answer);
+ Handle<String> next = factory->NewConsString(block, answer);
if (next->IsConsString()) data->stats_.leaves_++;
data->stats_.chars_ += block->length();
answer = next;
@@ -496,6 +501,7 @@
ConsStringGenerationData* data,
int from,
int to) {
+ Factory* factory = Isolate::Current()->factory();
CHECK(to > from);
if (to - from == 1) {
data->stats_.chars_ += data->block(from)->length();
@@ -504,7 +510,7 @@
if (to - from == 2) {
data->stats_.chars_ += data->block(from)->length();
data->stats_.chars_ += data->block(from+1)->length();
- return FACTORY->NewConsString(data->block(from), data->block(from+1));
+ return factory->NewConsString(data->block(from), data->block(from+1));
}
Handle<String> part1 =
ConstructBalancedHelper(data, from, from + ((to - from) / 2));
@@ -512,7 +518,7 @@
ConstructBalancedHelper(data, from + ((to - from) / 2), to);
if (part1->IsConsString()) data->stats_.left_traversals_++;
if (part2->IsConsString()) data->stats_.right_traversals_++;
- return FACTORY->NewConsString(part1, part2);
+ return factory->NewConsString(part1, part2);
}
@@ -690,6 +696,7 @@
static Handle<String> BuildEdgeCaseConsString(
int test_case, ConsStringGenerationData* data) {
+ Factory* factory = Isolate::Current()->factory();
data->Reset();
switch (test_case) {
case 0:
@@ -707,7 +714,7 @@
data->stats_.chars_ += data->block(0)->length();
data->stats_.chars_ += data->block(1)->length();
data->stats_.leaves_ += 2;
- return FACTORY->NewConsString(data->block(0), data->block(1));
+ return factory->NewConsString(data->block(0), data->block(1));
case 6:
// Simple flattened tree.
data->stats_.chars_ += data->block(0)->length();
@@ -716,7 +723,7 @@
data->stats_.empty_leaves_ += 1;
{
Handle<String> string =
- FACTORY->NewConsString(data->block(0), data->block(1));
+ factory->NewConsString(data->block(0), data->block(1));
FlattenString(string);
return string;
}
@@ -730,9 +737,9 @@
data->stats_.left_traversals_ += 1;
{
Handle<String> left =
- FACTORY->NewConsString(data->block(0), data->block(1));
+ factory->NewConsString(data->block(0), data->block(1));
FlattenString(left);
- return FACTORY->NewConsString(left, data->block(2));
+ return factory->NewConsString(left, data->block(2));
}
case 8:
// Left node and right node flattened.
@@ -746,12 +753,12 @@
data->stats_.right_traversals_ += 1;
{
Handle<String> left =
- FACTORY->NewConsString(data->block(0), data->block(1));
+ factory->NewConsString(data->block(0), data->block(1));
FlattenString(left);
Handle<String> right =
- FACTORY->NewConsString(data->block(2), data->block(2));
+ factory->NewConsString(data->block(2), data->block(2));
FlattenString(right);
- return FACTORY->NewConsString(left, right);
+ return factory->NewConsString(left, right);
}
}
UNREACHABLE();
@@ -852,6 +859,7 @@
TEST(DeepAscii) {
printf("TestDeepAscii\n");
CcTest::InitializeVM();
+ Factory* factory = Isolate::Current()->factory();
v8::HandleScope scope(CcTest::isolate());
char* foo = NewArray<char>(DEEP_ASCII_DEPTH);
@@ -859,12 +867,12 @@
foo[i] = "foo "[i % 4];
}
Handle<String> string =
- FACTORY->NewStringFromAscii(Vector<const char>(foo, DEEP_ASCII_DEPTH));
- Handle<String> foo_string = FACTORY->NewStringFromAscii(CStrVector("foo"));
+ factory->NewStringFromAscii(Vector<const char>(foo, DEEP_ASCII_DEPTH));
+ Handle<String> foo_string = factory->NewStringFromAscii(CStrVector("foo"));
for (int i = 0; i < DEEP_ASCII_DEPTH; i += 10) {
- string = FACTORY->NewConsString(string, foo_string);
+ string = factory->NewConsString(string, foo_string);
}
- Handle<String> flat_string = FACTORY->NewConsString(string, foo_string);
+ Handle<String> flat_string = factory->NewConsString(string, foo_string);
FlattenString(flat_string);
for (int i = 0; i < 500; i++) {
@@ -1059,13 +1067,14 @@
TEST(SliceFromCons) {
FLAG_string_slices = true;
CcTest::InitializeVM();
+ Factory* factory = Isolate::Current()->factory();
v8::HandleScope scope(CcTest::isolate());
Handle<String> string =
- FACTORY->NewStringFromAscii(CStrVector("parentparentparent"));
- Handle<String> parent = FACTORY->NewConsString(string, string);
+ factory->NewStringFromAscii(CStrVector("parentparentparent"));
+ Handle<String> parent = factory->NewConsString(string, string);
CHECK(parent->IsConsString());
CHECK(!parent->IsFlat());
- Handle<String> slice = FACTORY->NewSubString(parent, 1, 25);
+ Handle<String> slice = factory->NewSubString(parent, 1, 25);
// After slicing, the original string becomes a flat cons.
CHECK(parent->IsFlat());
CHECK(slice->IsSlicedString());
@@ -1093,12 +1102,13 @@
TEST(SliceFromExternal) {
FLAG_string_slices = true;
CcTest::InitializeVM();
+ Factory* factory = Isolate::Current()->factory();
v8::HandleScope scope(CcTest::isolate());
AsciiVectorResource resource(
i::Vector<const char>("abcdefghijklmnopqrstuvwxyz", 26));
- Handle<String> string = FACTORY->NewExternalStringFromAscii(&resource);
+ Handle<String> string = factory->NewExternalStringFromAscii(&resource);
CHECK(string->IsExternalString());
- Handle<String> slice = FACTORY->NewSubString(string, 1, 25);
+ Handle<String> slice = factory->NewSubString(string, 1, 25);
CHECK(slice->IsSlicedString());
CHECK(string->IsExternalString());
CHECK_EQ(SlicedString::cast(*slice)->parent(), *string);
@@ -1112,6 +1122,7 @@
// actually creates a new string (it should not).
FLAG_string_slices = true;
CcTest::InitializeVM();
+ Factory* factory = Isolate::Current()->factory();
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Value> result;
Handle<String> string;
@@ -1126,7 +1137,7 @@
string = v8::Utils::OpenHandle(v8::String::Cast(*result));
CHECK(!string->IsSlicedString());
- string = FACTORY->NewSubString(string, 0, 26);
+ string = factory->NewSubString(string, 0, 26);
CHECK(!string->IsSlicedString());
result = CompileRun(crosscheck);
CHECK(result->IsString());
diff --git a/test/mjsunit/bugs/bug-618.js b/test/mjsunit/bugs/bug-618.js
deleted file mode 100644
index 0513f87..0000000
--- a/test/mjsunit/bugs/bug-618.js
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2010 the V8 project authors. All rights reserved.
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following
-// disclaimer in the documentation and/or other materials provided
-// with the distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived
-// from this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// When this bug is corrected move to object-define-property and add
-// additional tests for configurable in the same manner as existing tests
-// there.
-
-function C() {
- this.x = 23;
-}
-
-// If a setter is added to the prototype chain of a simple constructor setting
-// one of the properties assigned in the constructor then this setter is
-// ignored when constructing new objects from the constructor.
-
-// This only happens if the setter is added _after_ an instance has been
-// created.
-
-assertEquals(23, new C().x);
-C.prototype.__defineSetter__('x', function(value) { this.y = 23; });
-assertEquals(void 0, new C().x);
diff --git a/test/mjsunit/debug-evaluate-locals-optimized-double.js b/test/mjsunit/debug-evaluate-locals-optimized-double.js
index 8d91b97..6696ec5 100644
--- a/test/mjsunit/debug-evaluate-locals-optimized-double.js
+++ b/test/mjsunit/debug-evaluate-locals-optimized-double.js
@@ -185,6 +185,7 @@
a0 = a0 + a0 / 100;
b0 = b0 + b0 / 100;
debugger; // Breakpoint.
+ return a0 + b0;
};
function g3(i, x1, y1) {
@@ -193,7 +194,7 @@
a1 = a1 + a1 / 100;
b1 = b1 + b1 / 100;
h(i - 1, a1, b1);
- return a1+b1;
+ return a1 + b1;
};
function g2(i) {
@@ -202,6 +203,7 @@
a2 = a2 + a2 / 100;
b2 = b2 + b2 / 100;
g3(i - 1, a2, b2);
+ return a2 + b2;
};
function g1(i, x3, y3, z3) {
@@ -210,6 +212,7 @@
a3 = a3 + a3 / 100;
b3 = b3 + b3 / 100;
new g2(i - 1, a3, b3);
+ return a3 + b3;
};
function f(i, x4, y4) {
@@ -218,6 +221,7 @@
a4 = a4 + a4 / 100;
b4 = b4 + b4 / 100;
g1(i - 1, a4, b4);
+ return a4 + b4;
};
// Test calling f normally and as a constructor.
diff --git a/test/mjsunit/debug-evaluate-locals-optimized.js b/test/mjsunit/debug-evaluate-locals-optimized.js
index f662912..d424001 100644
--- a/test/mjsunit/debug-evaluate-locals-optimized.js
+++ b/test/mjsunit/debug-evaluate-locals-optimized.js
@@ -174,30 +174,35 @@
var a0 = expected[i].locals.a0;
var b0 = expected[i].locals.b0;
debugger; // Breakpoint.
+ return a0 + b0;
}
function g3(i, x1, y1) {
var a1 = expected[i].locals.a1;
var b1 = expected[i].locals.b1;
h(i - 1, a1, b1);
+ return a1 + b1;
}
function g2(i) {
var a2 = expected[i].locals.a2;
var b2 = expected[i].locals.b2;
g3(i - 1, a2, b2);
+ return a2 + b2;
}
function g1(i, x3, y3, z3) {
var a3 = expected[i].locals.a3;
var b3 = expected[i].locals.b3;
new g2(i - 1, a3, b3);
+ return a3 + b3;
}
function f(i, x4, y4) {
var a4 = expected[i].locals.a4;
var b4 = expected[i].locals.b4;
g1(i - 1, a4, b4);
+ return a4 + b4;
}
// Test calling f normally and as a constructor.
diff --git a/test/mjsunit/harmony/object-observe.js b/test/mjsunit/harmony/object-observe.js
index 4c75e63..0434ccd 100644
--- a/test/mjsunit/harmony/object-observe.js
+++ b/test/mjsunit/harmony/object-observe.js
@@ -957,15 +957,15 @@
var arr3 = ['hello'];
arr3[2] = 'goodbye';
arr3.length = 6;
-var slow_arr = new Array(1000000000);
-slow_arr[500000000] = 'hello';
Object.defineProperty(arr, '0', {configurable: false});
Object.defineProperty(arr, '2', {get: function(){}});
Object.defineProperty(arr2, '0', {get: function(){}, configurable: false});
Object.observe(arr, observer.callback);
+Array.observe(arr, observer2.callback);
Object.observe(arr2, observer.callback);
+Array.observe(arr2, observer2.callback);
Object.observe(arr3, observer.callback);
-Object.observe(slow_arr, observer.callback);
+Array.observe(arr3, observer2.callback);
arr.length = 2;
arr.length = 0;
arr.length = 10;
@@ -978,8 +978,8 @@
arr3.length++;
arr3.length /= 2;
Object.defineProperty(arr3, 'length', {value: 5});
-Object.defineProperty(arr3, 'length', {value: 10, writable: false});
-slow_arr.length = 100;
+arr3[4] = 5;
+Object.defineProperty(arr3, 'length', {value: 1, writable: false});
Object.deliverChangeRecords(observer.callback);
observer.assertCallbackRecords([
{ object: arr, name: '3', type: 'deleted', oldValue: 'd' },
@@ -991,7 +991,7 @@
{ object: arr, name: 'length', type: 'reconfigured' },
{ object: arr2, name: '1', type: 'deleted', oldValue: 'beta' },
{ object: arr2, name: 'length', type: 'updated', oldValue: 2 },
- { object: arr2, name: 'length', type: 'reconfigured', oldValue: 1 },
+ { object: arr2, name: 'length', type: 'reconfigured' },
{ object: arr3, name: '2', type: 'deleted', oldValue: 'goodbye' },
{ object: arr3, name: '0', type: 'deleted', oldValue: 'hello' },
{ object: arr3, name: 'length', type: 'updated', oldValue: 6 },
@@ -999,10 +999,60 @@
{ object: arr3, name: 'length', type: 'updated', oldValue: 1 },
{ object: arr3, name: 'length', type: 'updated', oldValue: 2 },
{ object: arr3, name: 'length', type: 'updated', oldValue: 1 },
- { object: arr3, name: 'length', type: 'reconfigured', oldValue: 5 },
+ { object: arr3, name: '4', type: 'new' },
+ { object: arr3, name: '4', type: 'deleted', oldValue: 5 },
+ // TODO(rafaelw): It breaks spec compliance to get two records here.
+ // When the TODO in v8natives.js::DefineArrayProperty is addressed
+ // which prevents DefineProperty from over-writing the magic length
+ // property, these will collapse into a single record.
+ { object: arr3, name: 'length', type: 'updated', oldValue: 5 },
+ { object: arr3, name: 'length', type: 'reconfigured' }
+]);
+Object.deliverChangeRecords(observer2.callback);
+observer2.assertCallbackRecords([
+ { object: arr, type: 'splice', index: 2, removed: [, 'd'], addedCount: 0 },
+ { object: arr, type: 'splice', index: 1, removed: ['b'], addedCount: 0 },
+ { object: arr, type: 'splice', index: 1, removed: [], addedCount: 9 },
+ { object: arr2, type: 'splice', index: 1, removed: ['beta'], addedCount: 0 },
+ { object: arr3, type: 'splice', index: 0, removed: ['hello',, 'goodbye',,,,], addedCount: 0 },
+ { object: arr3, type: 'splice', index: 0, removed: [], addedCount: 1 },
+ { object: arr3, type: 'splice', index: 1, removed: [], addedCount: 1 },
+ { object: arr3, type: 'splice', index: 1, removed: [,], addedCount: 0 },
+ { object: arr3, type: 'splice', index: 1, removed: [], addedCount: 4 },
+ { object: arr3, name: '4', type: 'new' },
+ { object: arr3, type: 'splice', index: 1, removed: [,,,5], addedCount: 0 }
+]);
+
+
+// Updating length on large (slow) array
+reset();
+var slow_arr = new Array(1000000000);
+slow_arr[500000000] = 'hello';
+Object.observe(slow_arr, observer.callback);
+var spliceRecords;
+function slowSpliceCallback(records) {
+ spliceRecords = records;
+}
+Array.observe(slow_arr, slowSpliceCallback);
+slow_arr.length = 100;
+Object.deliverChangeRecords(observer.callback);
+observer.assertCallbackRecords([
{ object: slow_arr, name: '500000000', type: 'deleted', oldValue: 'hello' },
{ object: slow_arr, name: 'length', type: 'updated', oldValue: 1000000000 },
]);
+Object.deliverChangeRecords(slowSpliceCallback);
+assertEquals(spliceRecords.length, 1);
+// Have to custom assert this splice record because the removed array is huge.
+var splice = spliceRecords[0];
+assertSame(splice.object, slow_arr);
+assertEquals(splice.type, 'splice');
+assertEquals(splice.index, 100);
+assertEquals(splice.addedCount, 0);
+var array_keys = %GetArrayKeys(splice.removed, splice.removed.length);
+assertEquals(array_keys.length, 1);
+assertEquals(array_keys[0], 499999900);
+assertEquals(splice.removed[499999900], 'hello');
+assertEquals(splice.removed.length, 999999900);
// Assignments in loops (checking different IC states).
@@ -1037,10 +1087,12 @@
]);
-// Adding elements past the end of an array should notify on length
+// Adding elements past the end of an array should notify on length for
+// Object.observe and emit "splices" for Array.observe.
reset();
var arr = [1, 2, 3];
Object.observe(arr, observer.callback);
+Array.observe(arr, observer2.callback);
arr[3] = 10;
arr[100] = 20;
Object.defineProperty(arr, '200', {value: 7});
@@ -1058,6 +1110,14 @@
{ object: arr, name: 'length', type: 'updated', oldValue: 201 },
{ object: arr, name: '50', type: 'new' },
]);
+Object.deliverChangeRecords(observer2.callback);
+observer2.assertCallbackRecords([
+ { object: arr, type: 'splice', index: 3, removed: [], addedCount: 1 },
+ { object: arr, type: 'splice', index: 4, removed: [], addedCount: 97 },
+ { object: arr, type: 'splice', index: 101, removed: [], addedCount: 100 },
+ { object: arr, type: 'splice', index: 201, removed: [], addedCount: 200 },
+ { object: arr, type: 'new', name: '50' },
+]);
// Tests for array methods, first on arrays and then on plain objects
diff --git a/test/mjsunit/object-define-property.js b/test/mjsunit/object-define-property.js
index 835d0e0..cbb2d21 100644
--- a/test/mjsunit/object-define-property.js
+++ b/test/mjsunit/object-define-property.js
@@ -1195,3 +1195,12 @@
%OptimizeFunctionOnNextCall(Assign);
Object.defineProperty(C.prototype, "blubb", {get: function() { return -42; }});
Assign(new C);
+
+// Test that changes to the prototype of a simple constructor are not ignored,
+// even after creating initial instances.
+function C() {
+ this.x = 23;
+}
+assertEquals(23, new C().x);
+C.prototype.__defineSetter__('x', function(value) { this.y = 23; });
+assertEquals(void 0, new C().x);
diff --git a/test/mjsunit/bugs/618.js b/test/mjsunit/regress/regress-618.js
similarity index 100%
rename from test/mjsunit/bugs/618.js
rename to test/mjsunit/regress/regress-618.js