diff options
Diffstat (limited to 'deps/v8/test/cctest/test-code-stub-assembler.cc')
-rw-r--r-- | deps/v8/test/cctest/test-code-stub-assembler.cc | 156 |
1 files changed, 81 insertions, 75 deletions
diff --git a/deps/v8/test/cctest/test-code-stub-assembler.cc b/deps/v8/test/cctest/test-code-stub-assembler.cc index 4289efa1d0..0c22f4503b 100644 --- a/deps/v8/test/cctest/test-code-stub-assembler.cc +++ b/deps/v8/test/cctest/test-code-stub-assembler.cc @@ -7,6 +7,7 @@ #include "src/api-inl.h" #include "src/base/utils/random-number-generator.h" #include "src/builtins/builtins-promise-gen.h" +#include "src/builtins/builtins-promise.h" #include "src/builtins/builtins-string-gen.h" #include "src/char-predicates.h" #include "src/code-factory.h" @@ -17,9 +18,12 @@ #include "src/isolate.h" #include "src/objects-inl.h" #include "src/objects/hash-table-inl.h" +#include "src/objects/heap-number-inl.h" #include "src/objects/js-array-buffer-inl.h" #include "src/objects/js-array-inl.h" #include "src/objects/promise-inl.h" +#include "src/objects/smi.h" +#include "src/objects/struct-inl.h" #include "test/cctest/compiler/code-assembler-tester.h" #include "test/cctest/compiler/function-tester.h" @@ -345,7 +349,7 @@ TEST(ComputeIntegerHash) { Handle<Object> result = ft.Call(key).ToHandleChecked(); uint32_t hash = ComputeSeededHash(k, isolate->heap()->HashSeed()); - Smi* expected = Smi::FromInt(hash); + Smi expected = Smi::FromInt(hash); CHECK_EQ(expected, Smi::cast(*result)); } } @@ -1541,7 +1545,7 @@ TEST(TryLookupElement) { CHECK_ABSENT(object, 42); v8::ArrayBuffer::Contents contents = buffer->Externalize(); - buffer->Neuter(); + buffer->Detach(); isolate->array_buffer_allocator()->Free(contents.Data(), contents.ByteLength()); @@ -1710,7 +1714,8 @@ TEST(AllocateNameDictionary) { // Both dictionaries should be memory equal. int size = FixedArrayBase::kHeaderSize + (dict->length() - 1) * kPointerSize; - CHECK_EQ(0, memcmp(*dict, *result, size)); + CHECK_EQ(0, memcmp(reinterpret_cast<void*>(dict->ptr()), + reinterpret_cast<void*>(result->ptr()), size)); } } } @@ -1786,16 +1791,17 @@ TEST(OneToTwoByteStringCopy) { isolate->factory()->NewStringFromTwoByte(str).ToHandleChecked(); FunctionTester ft(asm_tester.GenerateCode(), kNumParams); ft.Call(string1, string2); - CHECK_EQ(Handle<SeqOneByteString>::cast(string1)->GetChars()[0], - Handle<SeqTwoByteString>::cast(string2)->GetChars()[0]); - CHECK_EQ(Handle<SeqOneByteString>::cast(string1)->GetChars()[1], - Handle<SeqTwoByteString>::cast(string2)->GetChars()[1]); - CHECK_EQ(Handle<SeqOneByteString>::cast(string1)->GetChars()[2], - Handle<SeqTwoByteString>::cast(string2)->GetChars()[2]); - CHECK_EQ(Handle<SeqOneByteString>::cast(string1)->GetChars()[3], - Handle<SeqTwoByteString>::cast(string2)->GetChars()[3]); - CHECK_EQ(Handle<SeqOneByteString>::cast(string1)->GetChars()[4], - Handle<SeqTwoByteString>::cast(string2)->GetChars()[4]); + DisallowHeapAllocation no_gc; + CHECK_EQ(Handle<SeqOneByteString>::cast(string1)->GetChars(no_gc)[0], + Handle<SeqTwoByteString>::cast(string2)->GetChars(no_gc)[0]); + CHECK_EQ(Handle<SeqOneByteString>::cast(string1)->GetChars(no_gc)[1], + Handle<SeqTwoByteString>::cast(string2)->GetChars(no_gc)[1]); + CHECK_EQ(Handle<SeqOneByteString>::cast(string1)->GetChars(no_gc)[2], + Handle<SeqTwoByteString>::cast(string2)->GetChars(no_gc)[2]); + CHECK_EQ(Handle<SeqOneByteString>::cast(string1)->GetChars(no_gc)[3], + Handle<SeqTwoByteString>::cast(string2)->GetChars(no_gc)[3]); + CHECK_EQ(Handle<SeqOneByteString>::cast(string1)->GetChars(no_gc)[4], + Handle<SeqTwoByteString>::cast(string2)->GetChars(no_gc)[4]); } TEST(OneToOneByteStringCopy) { @@ -1817,16 +1823,17 @@ TEST(OneToOneByteStringCopy) { isolate->factory()->NewStringFromOneByte(str).ToHandleChecked(); FunctionTester ft(asm_tester.GenerateCode(), kNumParams); ft.Call(string1, string2); - CHECK_EQ(Handle<SeqOneByteString>::cast(string1)->GetChars()[0], - Handle<SeqOneByteString>::cast(string2)->GetChars()[0]); - CHECK_EQ(Handle<SeqOneByteString>::cast(string1)->GetChars()[1], - Handle<SeqOneByteString>::cast(string2)->GetChars()[1]); - CHECK_EQ(Handle<SeqOneByteString>::cast(string1)->GetChars()[2], - Handle<SeqOneByteString>::cast(string2)->GetChars()[2]); - CHECK_EQ(Handle<SeqOneByteString>::cast(string1)->GetChars()[3], - Handle<SeqOneByteString>::cast(string2)->GetChars()[3]); - CHECK_EQ(Handle<SeqOneByteString>::cast(string1)->GetChars()[4], - Handle<SeqOneByteString>::cast(string2)->GetChars()[4]); + DisallowHeapAllocation no_gc; + CHECK_EQ(Handle<SeqOneByteString>::cast(string1)->GetChars(no_gc)[0], + Handle<SeqOneByteString>::cast(string2)->GetChars(no_gc)[0]); + CHECK_EQ(Handle<SeqOneByteString>::cast(string1)->GetChars(no_gc)[1], + Handle<SeqOneByteString>::cast(string2)->GetChars(no_gc)[1]); + CHECK_EQ(Handle<SeqOneByteString>::cast(string1)->GetChars(no_gc)[2], + Handle<SeqOneByteString>::cast(string2)->GetChars(no_gc)[2]); + CHECK_EQ(Handle<SeqOneByteString>::cast(string1)->GetChars(no_gc)[3], + Handle<SeqOneByteString>::cast(string2)->GetChars(no_gc)[3]); + CHECK_EQ(Handle<SeqOneByteString>::cast(string1)->GetChars(no_gc)[4], + Handle<SeqOneByteString>::cast(string2)->GetChars(no_gc)[4]); } TEST(OneToOneByteStringCopyNonZeroStart) { @@ -1848,13 +1855,14 @@ TEST(OneToOneByteStringCopyNonZeroStart) { isolate->factory()->NewStringFromOneByte(str).ToHandleChecked(); FunctionTester ft(asm_tester.GenerateCode(), kNumParams); ft.Call(string1, string2); - CHECK_EQ(Handle<SeqOneByteString>::cast(string1)->GetChars()[0], - Handle<SeqOneByteString>::cast(string2)->GetChars()[3]); - CHECK_EQ(Handle<SeqOneByteString>::cast(string1)->GetChars()[1], - Handle<SeqOneByteString>::cast(string2)->GetChars()[4]); - CHECK_EQ(100, Handle<SeqOneByteString>::cast(string2)->GetChars()[0]); - CHECK_EQ(101, Handle<SeqOneByteString>::cast(string2)->GetChars()[1]); - CHECK_EQ(102, Handle<SeqOneByteString>::cast(string2)->GetChars()[2]); + DisallowHeapAllocation no_gc; + CHECK_EQ(Handle<SeqOneByteString>::cast(string1)->GetChars(no_gc)[0], + Handle<SeqOneByteString>::cast(string2)->GetChars(no_gc)[3]); + CHECK_EQ(Handle<SeqOneByteString>::cast(string1)->GetChars(no_gc)[1], + Handle<SeqOneByteString>::cast(string2)->GetChars(no_gc)[4]); + CHECK_EQ(100, Handle<SeqOneByteString>::cast(string2)->GetChars(no_gc)[0]); + CHECK_EQ(101, Handle<SeqOneByteString>::cast(string2)->GetChars(no_gc)[1]); + CHECK_EQ(102, Handle<SeqOneByteString>::cast(string2)->GetChars(no_gc)[2]); } TEST(TwoToTwoByteStringCopy) { @@ -1879,16 +1887,17 @@ TEST(TwoToTwoByteStringCopy) { isolate->factory()->NewStringFromTwoByte(str2).ToHandleChecked(); FunctionTester ft(asm_tester.GenerateCode(), kNumParams); ft.Call(string1, string2); - CHECK_EQ(Handle<SeqTwoByteString>::cast(string1)->GetChars()[0], - Handle<SeqTwoByteString>::cast(string2)->GetChars()[0]); - CHECK_EQ(Handle<SeqTwoByteString>::cast(string1)->GetChars()[1], - Handle<SeqTwoByteString>::cast(string2)->GetChars()[1]); - CHECK_EQ(Handle<SeqTwoByteString>::cast(string1)->GetChars()[2], - Handle<SeqTwoByteString>::cast(string2)->GetChars()[2]); - CHECK_EQ(Handle<SeqTwoByteString>::cast(string1)->GetChars()[3], - Handle<SeqTwoByteString>::cast(string2)->GetChars()[3]); - CHECK_EQ(Handle<SeqTwoByteString>::cast(string1)->GetChars()[4], - Handle<SeqTwoByteString>::cast(string2)->GetChars()[4]); + DisallowHeapAllocation no_gc; + CHECK_EQ(Handle<SeqTwoByteString>::cast(string1)->GetChars(no_gc)[0], + Handle<SeqTwoByteString>::cast(string2)->GetChars(no_gc)[0]); + CHECK_EQ(Handle<SeqTwoByteString>::cast(string1)->GetChars(no_gc)[1], + Handle<SeqTwoByteString>::cast(string2)->GetChars(no_gc)[1]); + CHECK_EQ(Handle<SeqTwoByteString>::cast(string1)->GetChars(no_gc)[2], + Handle<SeqTwoByteString>::cast(string2)->GetChars(no_gc)[2]); + CHECK_EQ(Handle<SeqTwoByteString>::cast(string1)->GetChars(no_gc)[3], + Handle<SeqTwoByteString>::cast(string2)->GetChars(no_gc)[3]); + CHECK_EQ(Handle<SeqTwoByteString>::cast(string1)->GetChars(no_gc)[4], + Handle<SeqTwoByteString>::cast(string2)->GetChars(no_gc)[4]); } TEST(Arguments) { @@ -1965,8 +1974,8 @@ TNode<Smi> NonConstantSmi(CodeStubAssembler* m, int value) { m->BIND(&dummy_done); // Ensure that the above hackery actually created a non-constant SMI. - Smi* smi_constant; - CHECK(!m->ToSmiConstant(var.value(), smi_constant)); + Smi smi_constant; + CHECK(!m->ToSmiConstant(var.value(), &smi_constant)); return m->UncheckedCast<Smi>(var.value()); } @@ -2075,17 +2084,15 @@ class AppendJSArrayCodeStubAssembler : public CodeStubAssembler { : CodeStubAssembler(state), kind_(kind) {} void TestAppendJSArrayImpl(Isolate* isolate, CodeAssemblerTester* csa_tester, - Object* o1, Object* o2, Object* o3, Object* o4, + Object o1, Object o2, Object o3, Object o4, int initial_size, int result_size) { Handle<JSArray> array = isolate->factory()->NewJSArray( kind_, 2, initial_size, INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE); - JSObject::SetElement(isolate, array, 0, - Handle<Smi>(Smi::FromInt(1), isolate), - LanguageMode::kSloppy) + Object::SetElement(isolate, array, 0, Handle<Smi>(Smi::FromInt(1), isolate), + LanguageMode::kSloppy) .Check(); - JSObject::SetElement(isolate, array, 1, - Handle<Smi>(Smi::FromInt(2), isolate), - LanguageMode::kSloppy) + Object::SetElement(isolate, array, 1, Handle<Smi>(Smi::FromInt(2), isolate), + LanguageMode::kSloppy) .Check(); CodeStubArguments args(this, IntPtrConstant(kNumParams)); TVariable<IntPtrT> arg_index(this); @@ -2108,8 +2115,8 @@ class AppendJSArrayCodeStubAssembler : public CodeStubAssembler { CHECK_EQ(kind_, array->GetElementsKind()); CHECK_EQ(result_size, Handle<Smi>::cast(result)->value()); CHECK_EQ(result_size, Smi::ToInt(array->length())); - Object* obj = *JSObject::GetElement(isolate, array, 2).ToHandleChecked(); - HeapObject* undefined_value = ReadOnlyRoots(isolate).undefined_value(); + Object obj = *JSObject::GetElement(isolate, array, 2).ToHandleChecked(); + HeapObject undefined_value = ReadOnlyRoots(isolate).undefined_value(); CHECK_EQ(result_size < 3 ? undefined_value : o1, obj); obj = *JSObject::GetElement(isolate, array, 3).ToHandleChecked(); CHECK_EQ(result_size < 4 ? undefined_value : o2, obj); @@ -2119,8 +2126,8 @@ class AppendJSArrayCodeStubAssembler : public CodeStubAssembler { CHECK_EQ(result_size < 6 ? undefined_value : o4, obj); } - static void TestAppendJSArray(Isolate* isolate, ElementsKind kind, Object* o1, - Object* o2, Object* o3, Object* o4, + static void TestAppendJSArray(Isolate* isolate, ElementsKind kind, Object o1, + Object o2, Object o3, Object o4, int initial_size, int result_size) { CodeAssemblerTester asm_tester(isolate, kNumParams); AppendJSArrayCodeStubAssembler m(asm_tester.state(), kind); @@ -2355,9 +2362,9 @@ TEST(CreatePromiseResolvingFunctionsContext) { CHECK_EQ(isolate->native_context()->scope_info(), context_js->scope_info()); CHECK_EQ(ReadOnlyRoots(isolate).the_hole_value(), context_js->extension()); CHECK_EQ(*isolate->native_context(), context_js->native_context()); - CHECK(context_js->get(PromiseBuiltinsAssembler::kPromiseSlot)->IsJSPromise()); + CHECK(context_js->get(PromiseBuiltins::kPromiseSlot)->IsJSPromise()); CHECK_EQ(ReadOnlyRoots(isolate).false_value(), - context_js->get(PromiseBuiltinsAssembler::kDebugEventSlot)); + context_js->get(PromiseBuiltins::kDebugEventSlot)); } TEST(CreatePromiseResolvingFunctions) { @@ -2480,7 +2487,7 @@ TEST(AllocateFunctionWithMapAndContext) { CHECK_EQ(ReadOnlyRoots(isolate).empty_property_array(), fun->property_array()); CHECK_EQ(ReadOnlyRoots(isolate).empty_fixed_array(), fun->elements()); - CHECK_EQ(isolate->heap()->many_closures_cell(), fun->feedback_cell()); + CHECK_EQ(isolate->heap()->many_closures_cell(), fun->raw_feedback_cell()); CHECK(!fun->has_prototype_slot()); CHECK_EQ(*isolate->promise_capability_default_resolve_shared_fun(), fun->shared()); @@ -2515,13 +2522,12 @@ TEST(CreatePromiseGetCapabilitiesExecutorContext) { ft.Call(isolate->factory()->undefined_value()).ToHandleChecked(); CHECK(result_obj->IsContext()); Handle<Context> context_js = Handle<Context>::cast(result_obj); - CHECK_EQ(PromiseBuiltinsAssembler::kCapabilitiesContextLength, - context_js->length()); + CHECK_EQ(PromiseBuiltins::kCapabilitiesContextLength, context_js->length()); CHECK_EQ(isolate->native_context()->scope_info(), context_js->scope_info()); CHECK_EQ(ReadOnlyRoots(isolate).the_hole_value(), context_js->extension()); CHECK_EQ(*isolate->native_context(), context_js->native_context()); - CHECK(context_js->get(PromiseBuiltinsAssembler::kCapabilitySlot) - ->IsPromiseCapability()); + CHECK( + context_js->get(PromiseBuiltins::kCapabilitySlot)->IsPromiseCapability()); } TEST(NewPromiseCapability) { @@ -2568,10 +2574,8 @@ TEST(NewPromiseCapability) { CHECK_EQ(isolate->native_context()->scope_info(), context->scope_info()); CHECK_EQ(ReadOnlyRoots(isolate).the_hole_value(), context->extension()); CHECK_EQ(*isolate->native_context(), context->native_context()); - CHECK_EQ(PromiseBuiltinsAssembler::kPromiseContextLength, - context->length()); - CHECK_EQ(context->get(PromiseBuiltinsAssembler::kPromiseSlot), - result->promise()); + CHECK_EQ(PromiseBuiltins::kPromiseContextLength, context->length()); + CHECK_EQ(context->get(PromiseBuiltins::kPromiseSlot), result->promise()); } } @@ -2891,7 +2895,7 @@ TEST(GotoIfNotWhiteSpaceOrLineTerminator) { for (uc16 c = 0; c < 0xFFFF; c++) { Handle<Object> expected_value = - WhiteSpaceOrLineTerminator::Is(c) ? true_value : false_value; + IsWhiteSpaceOrLineTerminator(c) ? true_value : false_value; ft.CheckCall(expected_value, handle(Smi::FromInt(c), isolate)); } } @@ -3087,7 +3091,7 @@ TEST(CloneEmptyFixedArray) { Handle<FixedArray> source(isolate->factory()->empty_fixed_array()); Handle<Object> result_raw = ft.Call(source).ToHandleChecked(); - FixedArray* result(FixedArray::cast(*result_raw)); + FixedArray result(FixedArray::cast(*result_raw)); CHECK_EQ(0, result->length()); CHECK_EQ(*(isolate->factory()->empty_fixed_array()), result); } @@ -3105,7 +3109,7 @@ TEST(CloneFixedArray) { Handle<FixedArray> source(isolate->factory()->NewFixedArrayWithHoles(5)); source->set(1, Smi::FromInt(1234)); Handle<Object> result_raw = ft.Call(source).ToHandleChecked(); - FixedArray* result(FixedArray::cast(*result_raw)); + FixedArray result(FixedArray::cast(*result_raw)); CHECK_EQ(5, result->length()); CHECK(result->get(0)->IsTheHole(isolate)); CHECK_EQ(Smi::cast(result->get(1))->value(), 1234); @@ -3128,7 +3132,7 @@ TEST(CloneFixedArrayCOW) { source->set(1, Smi::FromInt(1234)); source->set_map(ReadOnlyRoots(isolate).fixed_cow_array_map()); Handle<Object> result_raw = ft.Call(source).ToHandleChecked(); - FixedArray* result(FixedArray::cast(*result_raw)); + FixedArray result(FixedArray::cast(*result_raw)); CHECK_EQ(*source, result); } @@ -3150,7 +3154,7 @@ TEST(ExtractFixedArrayCOWForceCopy) { source->set(1, Smi::FromInt(1234)); source->set_map(ReadOnlyRoots(isolate).fixed_cow_array_map()); Handle<Object> result_raw = ft.Call(source).ToHandleChecked(); - FixedArray* result(FixedArray::cast(*result_raw)); + FixedArray result(FixedArray::cast(*result_raw)); CHECK_NE(*source, result); CHECK_EQ(5, result->length()); CHECK(result->get(0)->IsTheHole(isolate)); @@ -3181,7 +3185,7 @@ TEST(ExtractFixedArraySimple) { ft.Call(source, Handle<Smi>(Smi::FromInt(1), isolate), Handle<Smi>(Smi::FromInt(2), isolate)) .ToHandleChecked(); - FixedArray* result(FixedArray::cast(*result_raw)); + FixedArray result(FixedArray::cast(*result_raw)); CHECK_EQ(2, result->length()); CHECK_EQ(Smi::cast(result->get(0))->value(), 1234); CHECK(result->get(1)->IsTheHole(isolate)); @@ -3205,7 +3209,7 @@ TEST(ExtractFixedArraySimpleSmiConstant) { Handle<FixedArray> source(isolate->factory()->NewFixedArrayWithHoles(5)); source->set(1, Smi::FromInt(1234)); Handle<Object> result_raw = ft.Call(source).ToHandleChecked(); - FixedArray* result(FixedArray::cast(*result_raw)); + FixedArray result(FixedArray::cast(*result_raw)); CHECK_EQ(2, result->length()); CHECK_EQ(Smi::cast(result->get(0))->value(), 1234); CHECK(result->get(1)->IsTheHole(isolate)); @@ -3229,7 +3233,7 @@ TEST(ExtractFixedArraySimpleIntPtrConstant) { Handle<FixedArray> source(isolate->factory()->NewFixedArrayWithHoles(5)); source->set(1, Smi::FromInt(1234)); Handle<Object> result_raw = ft.Call(source).ToHandleChecked(); - FixedArray* result(FixedArray::cast(*result_raw)); + FixedArray result(FixedArray::cast(*result_raw)); CHECK_EQ(2, result->length()); CHECK_EQ(Smi::cast(result->get(0))->value(), 1234); CHECK(result->get(1)->IsTheHole(isolate)); @@ -3251,7 +3255,7 @@ TEST(ExtractFixedArraySimpleIntPtrConstantNoDoubles) { Handle<FixedArray> source(isolate->factory()->NewFixedArrayWithHoles(5)); source->set(1, Smi::FromInt(1234)); Handle<Object> result_raw = ft.Call(source).ToHandleChecked(); - FixedArray* result(FixedArray::cast(*result_raw)); + FixedArray result(FixedArray::cast(*result_raw)); CHECK_EQ(2, result->length()); CHECK_EQ(Smi::cast(result->get(0))->value(), 1234); CHECK(result->get(1)->IsTheHole(isolate)); @@ -3275,7 +3279,7 @@ TEST(ExtractFixedArraySimpleIntPtrParameters) { ft.Call(source, Handle<Smi>(Smi::FromInt(1), isolate), Handle<Smi>(Smi::FromInt(2), isolate)) .ToHandleChecked(); - FixedArray* result(FixedArray::cast(*result_raw)); + FixedArray result(FixedArray::cast(*result_raw)); CHECK_EQ(2, result->length()); CHECK_EQ(Smi::cast(result->get(0))->value(), 1234); CHECK(result->get(1)->IsTheHole(isolate)); @@ -3291,7 +3295,7 @@ TEST(ExtractFixedArraySimpleIntPtrParameters) { ft.Call(source_double, Handle<Smi>(Smi::FromInt(1), isolate), Handle<Smi>(Smi::FromInt(2), isolate)) .ToHandleChecked(); - FixedDoubleArray* double_result(FixedDoubleArray::cast(*double_result_raw)); + FixedDoubleArray double_result = FixedDoubleArray::cast(*double_result_raw); CHECK_EQ(2, double_result->length()); CHECK_EQ(double_result->get_scalar(0), 11); CHECK_EQ(double_result->get_scalar(1), 12); @@ -3451,6 +3455,7 @@ TEST(IsDoubleElementsKind) { } TEST(TestCallBuiltinInlineTrampoline) { + if (!i::FLAG_embedded_builtins) return; Isolate* isolate(CcTest::InitIsolateOnce()); const int kNumParams = 1; CodeAssemblerTester asm_tester(isolate, kNumParams); @@ -3475,6 +3480,7 @@ TEST(TestCallBuiltinInlineTrampoline) { } TEST(TestCallBuiltinIndirectLoad) { + if (!i::FLAG_embedded_builtins) return; Isolate* isolate(CcTest::InitIsolateOnce()); const int kNumParams = 1; CodeAssemblerTester asm_tester(isolate, kNumParams); |