Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/test/cctest/test-api.cc')
-rw-r--r--deps/v8/test/cctest/test-api.cc658
1 files changed, 437 insertions, 221 deletions
diff --git a/deps/v8/test/cctest/test-api.cc b/deps/v8/test/cctest/test-api.cc
index a018e128531..bf5aba2df66 100644
--- a/deps/v8/test/cctest/test-api.cc
+++ b/deps/v8/test/cctest/test-api.cc
@@ -38,7 +38,7 @@
#endif
#include "include/v8-util.h"
-#include "src/api.h"
+#include "src/api-inl.h"
#include "src/arguments.h"
#include "src/base/platform/platform.h"
#include "src/code-stubs.h"
@@ -52,12 +52,14 @@
#include "src/lookup.h"
#include "src/objects-inl.h"
#include "src/objects/hash-table-inl.h"
+#include "src/objects/js-array-buffer-inl.h"
+#include "src/objects/js-array-inl.h"
#include "src/objects/js-promise-inl.h"
-#include "src/parsing/preparse-data.h"
#include "src/profiler/cpu-profiler.h"
#include "src/unicode-inl.h"
#include "src/utils.h"
#include "src/vm-state.h"
+#include "src/wasm/wasm-js.h"
#include "test/cctest/heap/heap-tester.h"
#include "test/cctest/heap/heap-utils.h"
@@ -374,7 +376,7 @@ THREADED_TEST(HulIgennem) {
v8::Local<v8::Primitive> undef = v8::Undefined(isolate);
Local<String> undef_str = undef->ToString(env.local()).ToLocalChecked();
char* value = i::NewArray<char>(undef_str->Utf8Length(isolate) + 1);
- undef_str->WriteUtf8(value);
+ undef_str->WriteUtf8(isolate, value);
CHECK_EQ(0, strcmp(value, "undefined"));
i::DeleteArray(value);
}
@@ -911,7 +913,8 @@ TEST(ExternalStringWithDisposeHandling) {
THREADED_TEST(StringConcat) {
{
LocalContext env;
- v8::HandleScope scope(env->GetIsolate());
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
const char* one_byte_string_1 = "function a_times_t";
const char* two_byte_string_1 = "wo_plus_b(a, b) {return ";
const char* one_byte_extern_1 = "a * 2 + b;} a_times_two_plus_b(4, 8) + ";
@@ -928,19 +931,19 @@ THREADED_TEST(StringConcat) {
.ToLocalChecked();
i::DeleteArray(two_byte_source);
- Local<String> source = String::Concat(left, right);
+ Local<String> source = String::Concat(isolate, left, right);
right = String::NewExternalOneByte(
env->GetIsolate(),
new TestOneByteResource(i::StrDup(one_byte_extern_1)))
.ToLocalChecked();
- source = String::Concat(source, right);
+ source = String::Concat(isolate, source, right);
right = String::NewExternalTwoByte(
env->GetIsolate(),
new TestResource(AsciiToTwoByteString(two_byte_extern_1)))
.ToLocalChecked();
- source = String::Concat(source, right);
+ source = String::Concat(isolate, source, right);
right = v8_str(one_byte_string_2);
- source = String::Concat(source, right);
+ source = String::Concat(isolate, source, right);
two_byte_source = AsciiToTwoByteString(two_byte_string_2);
right = String::NewFromTwoByte(env->GetIsolate(), two_byte_source,
@@ -948,12 +951,12 @@ THREADED_TEST(StringConcat) {
.ToLocalChecked();
i::DeleteArray(two_byte_source);
- source = String::Concat(source, right);
+ source = String::Concat(isolate, source, right);
right = String::NewExternalTwoByte(
env->GetIsolate(),
new TestResource(AsciiToTwoByteString(two_byte_extern_2)))
.ToLocalChecked();
- source = String::Concat(source, right);
+ source = String::Concat(isolate, source, right);
Local<Script> script = v8_compile(source);
Local<Value> value = script->Run(env.local()).ToLocalChecked();
CHECK(value->IsNumber());
@@ -1736,7 +1739,8 @@ THREADED_TEST(StringObject) {
Local<v8::String> the_string = as_boxed->ValueOf();
CHECK(!the_string.IsEmpty());
ExpectObject("\"test\"", the_string);
- v8::Local<v8::Value> new_boxed_string = v8::StringObject::New(the_string);
+ v8::Local<v8::Value> new_boxed_string =
+ v8::StringObject::New(CcTest::isolate(), the_string);
CHECK(new_boxed_string->IsStringObject());
as_boxed = new_boxed_string.As<v8::StringObject>();
the_string = as_boxed->ValueOf();
@@ -2469,7 +2473,7 @@ THREADED_TEST(DescriptorInheritance2) {
for (int i = 0; i < kDataPropertiesNumber; i++) {
v8::Local<v8::Value> val = v8_num(i);
v8::Local<v8::String> val_str = val->ToString(env.local()).ToLocalChecked();
- v8::Local<v8::String> name = String::Concat(v8_str("p"), val_str);
+ v8::Local<v8::String> name = String::Concat(isolate, v8_str("p"), val_str);
templ->Set(name, val);
templ->Set(val_str, val);
@@ -2506,7 +2510,7 @@ THREADED_TEST(DescriptorInheritance2) {
for (int i = 0; i < kDataPropertiesNumber; i++) {
v8::Local<v8::Value> val = v8_num(i);
v8::Local<v8::String> val_str = val->ToString(env.local()).ToLocalChecked();
- v8::Local<v8::String> name = String::Concat(v8_str("p"), val_str);
+ v8::Local<v8::String> name = String::Concat(isolate, v8_str("p"), val_str);
CHECK_EQ(i, object->Get(env.local(), name)
.ToLocalChecked()
@@ -2525,16 +2529,18 @@ THREADED_TEST(DescriptorInheritance2) {
void SimpleAccessorGetter(Local<String> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
Local<Object> self = Local<Object>::Cast(info.This());
- info.GetReturnValue().Set(self->Get(info.GetIsolate()->GetCurrentContext(),
- String::Concat(v8_str("accessor_"), name))
- .ToLocalChecked());
+ info.GetReturnValue().Set(
+ self->Get(info.GetIsolate()->GetCurrentContext(),
+ String::Concat(info.GetIsolate(), v8_str("accessor_"), name))
+ .ToLocalChecked());
}
void SimpleAccessorSetter(Local<String> name, Local<Value> value,
const v8::PropertyCallbackInfo<void>& info) {
Local<Object> self = Local<Object>::Cast(info.This());
CHECK(self->Set(info.GetIsolate()->GetCurrentContext(),
- String::Concat(v8_str("accessor_"), name), value)
+ String::Concat(info.GetIsolate(), v8_str("accessor_"), name),
+ value)
.FromJust());
}
@@ -7841,10 +7847,18 @@ static void IndependentWeakHandle(bool global_gc, bool interlinked) {
v8::WeakCallbackType::kParameter);
object_b.handle.SetWeak(&object_b, &SetFlag,
v8::WeakCallbackType::kParameter);
+#if __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated"
+#endif
+ // MarkIndependent is marked deprecated but we still rely on it temporarily.
CHECK(!object_b.handle.IsIndependent());
object_a.handle.MarkIndependent();
object_b.handle.MarkIndependent();
CHECK(object_b.handle.IsIndependent());
+#if __clang__
+#pragma clang diagnostic pop
+#endif
if (global_gc) {
CcTest::CollectAllGarbage();
} else {
@@ -7996,9 +8010,17 @@ void v8::internal::heap::HeapTester::ResetWeakHandle(bool global_gc) {
object_b.handle.SetWeak(&object_b, &ResetUseValueAndSetFlag,
v8::WeakCallbackType::kParameter);
if (!global_gc) {
+#if __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated"
+#endif
+ // MarkIndependent is marked deprecated but we still rely on it temporarily.
object_a.handle.MarkIndependent();
object_b.handle.MarkIndependent();
CHECK(object_b.handle.IsIndependent());
+#if __clang__
+#pragma clang diagnostic pop
+#endif
}
if (global_gc) {
CcTest::CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
@@ -8067,7 +8089,16 @@ THREADED_TEST(GCFromWeakCallbacks) {
object.flag = false;
object.handle.SetWeak(&object, gc_forcing_callback[inner_gc],
v8::WeakCallbackType::kParameter);
+#if __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated"
+#endif
+ // MarkIndependent is marked deprecated but we still rely on it
+ // temporarily.
object.handle.MarkIndependent();
+#if __clang__
+#pragma clang diagnostic pop
+#endif
invoke_gc[outer_gc]();
EmptyMessageQueues(isolate);
CHECK(object.flag);
@@ -8285,7 +8316,8 @@ int GetUtf8Length(v8::Isolate* isolate, Local<String> str) {
THREADED_TEST(StringWrite) {
LocalContext context;
- v8::HandleScope scope(context->GetIsolate());
+ v8::Isolate* isolate = context->GetIsolate();
+ v8::HandleScope scope(isolate);
v8::Local<String> str = v8_str("abcde");
// abc<Icelandic eth><Unicode snowman>.
v8::Local<String> str2 = v8_str("abc\xC3\xB0\xE2\x98\x83");
@@ -8347,65 +8379,63 @@ THREADED_TEST(StringWrite) {
int charlen;
memset(utf8buf, 0x1, 1000);
- len = str2->WriteUtf8(utf8buf, sizeof(utf8buf), &charlen);
+ len = str2->WriteUtf8(isolate, utf8buf, sizeof(utf8buf), &charlen);
CHECK_EQ(9, len);
CHECK_EQ(5, charlen);
CHECK_EQ(0, strcmp(utf8buf, "abc\xC3\xB0\xE2\x98\x83"));
memset(utf8buf, 0x1, 1000);
- len = str2->WriteUtf8(utf8buf, 8, &charlen);
+ len = str2->WriteUtf8(isolate, utf8buf, 8, &charlen);
CHECK_EQ(8, len);
CHECK_EQ(5, charlen);
CHECK_EQ(0, strncmp(utf8buf, "abc\xC3\xB0\xE2\x98\x83\x01", 9));
memset(utf8buf, 0x1, 1000);
- len = str2->WriteUtf8(utf8buf, 7, &charlen);
+ len = str2->WriteUtf8(isolate, utf8buf, 7, &charlen);
CHECK_EQ(5, len);
CHECK_EQ(4, charlen);
CHECK_EQ(0, strncmp(utf8buf, "abc\xC3\xB0\x01", 5));
memset(utf8buf, 0x1, 1000);
- len = str2->WriteUtf8(utf8buf, 6, &charlen);
+ len = str2->WriteUtf8(isolate, utf8buf, 6, &charlen);
CHECK_EQ(5, len);
CHECK_EQ(4, charlen);
CHECK_EQ(0, strncmp(utf8buf, "abc\xC3\xB0\x01", 5));
memset(utf8buf, 0x1, 1000);
- len = str2->WriteUtf8(utf8buf, 5, &charlen);
+ len = str2->WriteUtf8(isolate, utf8buf, 5, &charlen);
CHECK_EQ(5, len);
CHECK_EQ(4, charlen);
CHECK_EQ(0, strncmp(utf8buf, "abc\xC3\xB0\x01", 5));
memset(utf8buf, 0x1, 1000);
- len = str2->WriteUtf8(utf8buf, 4, &charlen);
+ len = str2->WriteUtf8(isolate, utf8buf, 4, &charlen);
CHECK_EQ(3, len);
CHECK_EQ(3, charlen);
CHECK_EQ(0, strncmp(utf8buf, "abc\x01", 4));
memset(utf8buf, 0x1, 1000);
- len = str2->WriteUtf8(utf8buf, 3, &charlen);
+ len = str2->WriteUtf8(isolate, utf8buf, 3, &charlen);
CHECK_EQ(3, len);
CHECK_EQ(3, charlen);
CHECK_EQ(0, strncmp(utf8buf, "abc\x01", 4));
memset(utf8buf, 0x1, 1000);
- len = str2->WriteUtf8(utf8buf, 2, &charlen);
+ len = str2->WriteUtf8(isolate, utf8buf, 2, &charlen);
CHECK_EQ(2, len);
CHECK_EQ(2, charlen);
CHECK_EQ(0, strncmp(utf8buf, "ab\x01", 3));
// allow orphan surrogates by default
memset(utf8buf, 0x1, 1000);
- len = orphans_str->WriteUtf8(utf8buf, sizeof(utf8buf), &charlen);
+ len = orphans_str->WriteUtf8(isolate, utf8buf, sizeof(utf8buf), &charlen);
CHECK_EQ(13, len);
CHECK_EQ(8, charlen);
CHECK_EQ(0, strcmp(utf8buf, "ab\xED\xA0\x80wx\xED\xB0\x80yz"));
// replace orphan surrogates with Unicode replacement character
memset(utf8buf, 0x1, 1000);
- len = orphans_str->WriteUtf8(utf8buf,
- sizeof(utf8buf),
- &charlen,
+ len = orphans_str->WriteUtf8(isolate, utf8buf, sizeof(utf8buf), &charlen,
String::REPLACE_INVALID_UTF8);
CHECK_EQ(13, len);
CHECK_EQ(8, charlen);
@@ -8413,9 +8443,7 @@ THREADED_TEST(StringWrite) {
// replace single lead surrogate with Unicode replacement character
memset(utf8buf, 0x1, 1000);
- len = lead_str->WriteUtf8(utf8buf,
- sizeof(utf8buf),
- &charlen,
+ len = lead_str->WriteUtf8(isolate, utf8buf, sizeof(utf8buf), &charlen,
String::REPLACE_INVALID_UTF8);
CHECK_EQ(4, len);
CHECK_EQ(1, charlen);
@@ -8423,9 +8451,7 @@ THREADED_TEST(StringWrite) {
// replace single trail surrogate with Unicode replacement character
memset(utf8buf, 0x1, 1000);
- len = trail_str->WriteUtf8(utf8buf,
- sizeof(utf8buf),
- &charlen,
+ len = trail_str->WriteUtf8(isolate, utf8buf, sizeof(utf8buf), &charlen,
String::REPLACE_INVALID_UTF8);
CHECK_EQ(4, len);
CHECK_EQ(1, charlen);
@@ -8434,19 +8460,17 @@ THREADED_TEST(StringWrite) {
// do not replace / write anything if surrogate pair does not fit the buffer
// space
memset(utf8buf, 0x1, 1000);
- len = pair_str->WriteUtf8(utf8buf,
- 3,
- &charlen,
- String::REPLACE_INVALID_UTF8);
+ len = pair_str->WriteUtf8(isolate, utf8buf, 3, &charlen,
+ String::REPLACE_INVALID_UTF8);
CHECK_EQ(0, len);
CHECK_EQ(0, charlen);
memset(utf8buf, 0x1, sizeof(utf8buf));
- len = GetUtf8Length(context->GetIsolate(), left_tree);
+ len = GetUtf8Length(isolate, left_tree);
int utf8_expected =
(0x80 + (0x800 - 0x80) * 2 + (0xD800 - 0x800) * 3) / kStride;
CHECK_EQ(utf8_expected, len);
- len = left_tree->WriteUtf8(utf8buf, utf8_expected, &charlen);
+ len = left_tree->WriteUtf8(isolate, utf8buf, utf8_expected, &charlen);
CHECK_EQ(utf8_expected, len);
CHECK_EQ(0xD800 / kStride, charlen);
CHECK_EQ(0xED, static_cast<unsigned char>(utf8buf[utf8_expected - 3]));
@@ -8456,9 +8480,9 @@ THREADED_TEST(StringWrite) {
CHECK_EQ(1, utf8buf[utf8_expected]);
memset(utf8buf, 0x1, sizeof(utf8buf));
- len = GetUtf8Length(context->GetIsolate(), right_tree);
+ len = GetUtf8Length(isolate, right_tree);
CHECK_EQ(utf8_expected, len);
- len = right_tree->WriteUtf8(utf8buf, utf8_expected, &charlen);
+ len = right_tree->WriteUtf8(isolate, utf8buf, utf8_expected, &charlen);
CHECK_EQ(utf8_expected, len);
CHECK_EQ(0xD800 / kStride, charlen);
CHECK_EQ(0xED, static_cast<unsigned char>(utf8buf[0]));
@@ -8468,9 +8492,9 @@ THREADED_TEST(StringWrite) {
memset(buf, 0x1, sizeof(buf));
memset(wbuf, 0x1, sizeof(wbuf));
- len = str->WriteOneByte(reinterpret_cast<uint8_t*>(buf));
+ len = str->WriteOneByte(isolate, reinterpret_cast<uint8_t*>(buf));
CHECK_EQ(5, len);
- len = str->Write(wbuf);
+ len = str->Write(isolate, wbuf);
CHECK_EQ(5, len);
CHECK_EQ(0, strcmp("abcde", buf));
uint16_t answer1[] = {'a', 'b', 'c', 'd', 'e', '\0'};
@@ -8478,9 +8502,9 @@ THREADED_TEST(StringWrite) {
memset(buf, 0x1, sizeof(buf));
memset(wbuf, 0x1, sizeof(wbuf));
- len = str->WriteOneByte(reinterpret_cast<uint8_t*>(buf), 0, 4);
+ len = str->WriteOneByte(isolate, reinterpret_cast<uint8_t*>(buf), 0, 4);
CHECK_EQ(4, len);
- len = str->Write(wbuf, 0, 4);
+ len = str->Write(isolate, wbuf, 0, 4);
CHECK_EQ(4, len);
CHECK_EQ(0, strncmp("abcd\x01", buf, 5));
uint16_t answer2[] = {'a', 'b', 'c', 'd', 0x101};
@@ -8488,9 +8512,9 @@ THREADED_TEST(StringWrite) {
memset(buf, 0x1, sizeof(buf));
memset(wbuf, 0x1, sizeof(wbuf));
- len = str->WriteOneByte(reinterpret_cast<uint8_t*>(buf), 0, 5);
+ len = str->WriteOneByte(isolate, reinterpret_cast<uint8_t*>(buf), 0, 5);
CHECK_EQ(5, len);
- len = str->Write(wbuf, 0, 5);
+ len = str->Write(isolate, wbuf, 0, 5);
CHECK_EQ(5, len);
CHECK_EQ(0, strncmp("abcde\x01", buf, 6));
uint16_t answer3[] = {'a', 'b', 'c', 'd', 'e', 0x101};
@@ -8498,9 +8522,9 @@ THREADED_TEST(StringWrite) {
memset(buf, 0x1, sizeof(buf));
memset(wbuf, 0x1, sizeof(wbuf));
- len = str->WriteOneByte(reinterpret_cast<uint8_t*>(buf), 0, 6);
+ len = str->WriteOneByte(isolate, reinterpret_cast<uint8_t*>(buf), 0, 6);
CHECK_EQ(5, len);
- len = str->Write(wbuf, 0, 6);
+ len = str->Write(isolate, wbuf, 0, 6);
CHECK_EQ(5, len);
CHECK_EQ(0, strcmp("abcde", buf));
uint16_t answer4[] = {'a', 'b', 'c', 'd', 'e', '\0'};
@@ -8508,9 +8532,9 @@ THREADED_TEST(StringWrite) {
memset(buf, 0x1, sizeof(buf));
memset(wbuf, 0x1, sizeof(wbuf));
- len = str->WriteOneByte(reinterpret_cast<uint8_t*>(buf), 4, -1);
+ len = str->WriteOneByte(isolate, reinterpret_cast<uint8_t*>(buf), 4, -1);
CHECK_EQ(1, len);
- len = str->Write(wbuf, 4, -1);
+ len = str->Write(isolate, wbuf, 4, -1);
CHECK_EQ(1, len);
CHECK_EQ(0, strcmp("e", buf));
uint16_t answer5[] = {'e', '\0'};
@@ -8518,18 +8542,18 @@ THREADED_TEST(StringWrite) {
memset(buf, 0x1, sizeof(buf));
memset(wbuf, 0x1, sizeof(wbuf));
- len = str->WriteOneByte(reinterpret_cast<uint8_t*>(buf), 4, 6);
+ len = str->WriteOneByte(isolate, reinterpret_cast<uint8_t*>(buf), 4, 6);
CHECK_EQ(1, len);
- len = str->Write(wbuf, 4, 6);
+ len = str->Write(isolate, wbuf, 4, 6);
CHECK_EQ(1, len);
CHECK_EQ(0, strcmp("e", buf));
CHECK_EQ(0, StrCmp16(answer5, wbuf));
memset(buf, 0x1, sizeof(buf));
memset(wbuf, 0x1, sizeof(wbuf));
- len = str->WriteOneByte(reinterpret_cast<uint8_t*>(buf), 4, 1);
+ len = str->WriteOneByte(isolate, reinterpret_cast<uint8_t*>(buf), 4, 1);
CHECK_EQ(1, len);
- len = str->Write(wbuf, 4, 1);
+ len = str->Write(isolate, wbuf, 4, 1);
CHECK_EQ(1, len);
CHECK_EQ(0, strncmp("e\x01", buf, 2));
uint16_t answer6[] = {'e', 0x101};
@@ -8537,9 +8561,9 @@ THREADED_TEST(StringWrite) {
memset(buf, 0x1, sizeof(buf));
memset(wbuf, 0x1, sizeof(wbuf));
- len = str->WriteOneByte(reinterpret_cast<uint8_t*>(buf), 3, 1);
+ len = str->WriteOneByte(isolate, reinterpret_cast<uint8_t*>(buf), 3, 1);
CHECK_EQ(1, len);
- len = str->Write(wbuf, 3, 1);
+ len = str->Write(isolate, wbuf, 3, 1);
CHECK_EQ(1, len);
CHECK_EQ(0, strncmp("d\x01", buf, 2));
uint16_t answer7[] = {'d', 0x101};
@@ -8547,7 +8571,7 @@ THREADED_TEST(StringWrite) {
memset(wbuf, 0x1, sizeof(wbuf));
wbuf[5] = 'X';
- len = str->Write(wbuf, 0, 6, String::NO_NULL_TERMINATION);
+ len = str->Write(isolate, wbuf, 0, 6, String::NO_NULL_TERMINATION);
CHECK_EQ(5, len);
CHECK_EQ('X', wbuf[5]);
uint16_t answer8a[] = {'a', 'b', 'c', 'd', 'e'};
@@ -8559,9 +8583,7 @@ THREADED_TEST(StringWrite) {
memset(buf, 0x1, sizeof(buf));
buf[5] = 'X';
- len = str->WriteOneByte(reinterpret_cast<uint8_t*>(buf),
- 0,
- 6,
+ len = str->WriteOneByte(isolate, reinterpret_cast<uint8_t*>(buf), 0, 6,
String::NO_NULL_TERMINATION);
CHECK_EQ(5, len);
CHECK_EQ('X', buf[5]);
@@ -8572,7 +8594,7 @@ THREADED_TEST(StringWrite) {
memset(utf8buf, 0x1, sizeof(utf8buf));
utf8buf[8] = 'X';
- len = str2->WriteUtf8(utf8buf, sizeof(utf8buf), &charlen,
+ len = str2->WriteUtf8(isolate, utf8buf, sizeof(utf8buf), &charlen,
String::NO_NULL_TERMINATION);
CHECK_EQ(8, len);
CHECK_EQ('X', utf8buf[8]);
@@ -8584,8 +8606,8 @@ THREADED_TEST(StringWrite) {
memset(utf8buf, 0x1, sizeof(utf8buf));
utf8buf[5] = 'X';
- len = str->WriteUtf8(utf8buf, sizeof(utf8buf), &charlen,
- String::NO_NULL_TERMINATION);
+ len = str->WriteUtf8(isolate, utf8buf, sizeof(utf8buf), &charlen,
+ String::NO_NULL_TERMINATION);
CHECK_EQ(5, len);
CHECK_EQ('X', utf8buf[5]); // Test that the sixth character is untouched.
CHECK_EQ(5, charlen);
@@ -8593,15 +8615,17 @@ THREADED_TEST(StringWrite) {
CHECK_EQ(0, strcmp(utf8buf, "abcde"));
memset(buf, 0x1, sizeof(buf));
- len = str3->WriteOneByte(reinterpret_cast<uint8_t*>(buf));
+ len = str3->WriteOneByte(isolate, reinterpret_cast<uint8_t*>(buf));
CHECK_EQ(7, len);
CHECK_EQ(0, strcmp("abc", buf));
CHECK_EQ(0, buf[3]);
CHECK_EQ(0, strcmp("def", buf + 4));
- CHECK_EQ(0, str->WriteOneByte(nullptr, 0, 0, String::NO_NULL_TERMINATION));
- CHECK_EQ(0, str->WriteUtf8(nullptr, 0, 0, String::NO_NULL_TERMINATION));
- CHECK_EQ(0, str->Write(nullptr, 0, 0, String::NO_NULL_TERMINATION));
+ CHECK_EQ(0, str->WriteOneByte(isolate, nullptr, 0, 0,
+ String::NO_NULL_TERMINATION));
+ CHECK_EQ(0,
+ str->WriteUtf8(isolate, nullptr, 0, 0, String::NO_NULL_TERMINATION));
+ CHECK_EQ(0, str->Write(isolate, nullptr, 0, 0, String::NO_NULL_TERMINATION));
}
@@ -8627,14 +8651,14 @@ static void Utf16Helper(
}
void TestUtf8DecodingAgainstReference(
- const char* cases[],
+ v8::Isolate* isolate, const char* cases[],
const std::vector<std::vector<uint16_t>>& unicode_expected) {
for (size_t test_ix = 0; test_ix < unicode_expected.size(); ++test_ix) {
v8::Local<String> str = v8_str(cases[test_ix]);
CHECK_EQ(unicode_expected[test_ix].size(), str->Length());
std::unique_ptr<uint16_t[]> buffer(new uint16_t[str->Length()]);
- str->Write(buffer.get(), 0, -1, String::NO_NULL_TERMINATION);
+ str->Write(isolate, buffer.get(), 0, -1, String::NO_NULL_TERMINATION);
for (size_t i = 0; i < unicode_expected[test_ix].size(); ++i) {
CHECK_EQ(unicode_expected[test_ix][i], buffer[i]);
@@ -8684,7 +8708,8 @@ THREADED_TEST(OverlongSequencesAndSurrogates) {
{0x58, 0xFFFD, 0xFFFD, 0xFFFD, 0x59},
};
CHECK_EQ(unicode_expected.size(), arraysize(cases));
- TestUtf8DecodingAgainstReference(cases, unicode_expected);
+ TestUtf8DecodingAgainstReference(context->GetIsolate(), cases,
+ unicode_expected);
}
THREADED_TEST(Utf16) {
@@ -10592,7 +10617,7 @@ THREADED_TEST(GlobalObjectInstanceProperties) {
v8::FunctionTemplate::New(isolate,
InstanceFunctionCallback));
- // The script to check how Crankshaft compiles missing global function
+ // The script to check how TurboFan compiles missing global function
// invocations. function g is not defined and should throw on call.
const char* script =
"function wrapper(call) {"
@@ -10639,8 +10664,8 @@ THREADED_TEST(ObjectGetOwnPropertyNames) {
v8::Isolate* isolate = context->GetIsolate();
v8::HandleScope handle_scope(isolate);
- v8::Local<v8::Object> value =
- v8::Local<v8::Object>::Cast(v8::StringObject::New(v8_str("test")));
+ v8::Local<v8::Object> value = v8::Local<v8::Object>::Cast(
+ v8::StringObject::New(CcTest::isolate(), v8_str("test")));
v8::Local<v8::Array> properties;
CHECK(value
@@ -15366,6 +15391,9 @@ THREADED_TEST(GetPropertyNames) {
v8::HandleScope scope(isolate);
v8::Local<v8::Value> result = CompileRun(
"var result = {0: 0, 1: 1, a: 2, b: 3};"
+ "result[2**32] = '4294967296';"
+ "result[2**32-1] = '4294967295';"
+ "result[2**32-2] = '4294967294';"
"result[Symbol('symbol')] = true;"
"result.__proto__ = {__proto__:null, 2: 4, 3: 5, c: 6, d: 7};"
"result;");
@@ -15376,8 +15404,10 @@ THREADED_TEST(GetPropertyNames) {
v8::Local<v8::Array> properties =
object->GetPropertyNames(context.local()).ToLocalChecked();
- const char* expected_properties1[] = {"0", "1", "a", "b", "2", "3", "c", "d"};
- CheckStringArray(isolate, properties, 8, expected_properties1);
+ const char* expected_properties1[] = {"0", "1", "4294967294", "a",
+ "b", "4294967296", "4294967295", "2",
+ "3", "c", "d"};
+ CheckStringArray(isolate, properties, 11, expected_properties1);
properties =
object
@@ -15385,7 +15415,7 @@ THREADED_TEST(GetPropertyNames) {
v8::KeyCollectionMode::kIncludePrototypes,
default_filter, v8::IndexFilter::kIncludeIndices)
.ToLocalChecked();
- CheckStringArray(isolate, properties, 8, expected_properties1);
+ CheckStringArray(isolate, properties, 11, expected_properties1);
properties = object
->GetPropertyNames(context.local(),
@@ -15393,10 +15423,11 @@ THREADED_TEST(GetPropertyNames) {
include_symbols_filter,
v8::IndexFilter::kIncludeIndices)
.ToLocalChecked();
- const char* expected_properties1_1[] = {"0", "1", "a", "b", nullptr,
- "2", "3", "c", "d"};
- CheckStringArray(isolate, properties, 9, expected_properties1_1);
- CheckIsSymbolAt(isolate, properties, 4, "symbol");
+ const char* expected_properties1_1[] = {
+ "0", "1", "4294967294", "a", "b", "4294967296",
+ "4294967295", nullptr, "2", "3", "c", "d"};
+ CheckStringArray(isolate, properties, 12, expected_properties1_1);
+ CheckIsSymbolAt(isolate, properties, 7, "symbol");
properties =
object
@@ -15404,8 +15435,9 @@ THREADED_TEST(GetPropertyNames) {
v8::KeyCollectionMode::kIncludePrototypes,
default_filter, v8::IndexFilter::kSkipIndices)
.ToLocalChecked();
- const char* expected_properties2[] = {"a", "b", "c", "d"};
- CheckStringArray(isolate, properties, 4, expected_properties2);
+ const char* expected_properties2[] = {"a", "b", "4294967296",
+ "4294967295", "c", "d"};
+ CheckStringArray(isolate, properties, 6, expected_properties2);
properties = object
->GetPropertyNames(context.local(),
@@ -15413,43 +15445,48 @@ THREADED_TEST(GetPropertyNames) {
include_symbols_filter,
v8::IndexFilter::kSkipIndices)
.ToLocalChecked();
- const char* expected_properties2_1[] = {"a", "b", nullptr, "c", "d"};
- CheckStringArray(isolate, properties, 5, expected_properties2_1);
- CheckIsSymbolAt(isolate, properties, 2, "symbol");
+ const char* expected_properties2_1[] = {
+ "a", "b", "4294967296", "4294967295", nullptr, "c", "d"};
+ CheckStringArray(isolate, properties, 7, expected_properties2_1);
+ CheckIsSymbolAt(isolate, properties, 4, "symbol");
properties =
object
->GetPropertyNames(context.local(), v8::KeyCollectionMode::kOwnOnly,
default_filter, v8::IndexFilter::kIncludeIndices)
.ToLocalChecked();
- const char* expected_properties3[] = {"0", "1", "a", "b"};
- CheckStringArray(isolate, properties, 4, expected_properties3);
+ const char* expected_properties3[] = {
+ "0", "1", "4294967294", "a", "b", "4294967296", "4294967295",
+ };
+ CheckStringArray(isolate, properties, 7, expected_properties3);
properties = object
->GetPropertyNames(
context.local(), v8::KeyCollectionMode::kOwnOnly,
include_symbols_filter, v8::IndexFilter::kIncludeIndices)
.ToLocalChecked();
- const char* expected_properties3_1[] = {"0", "1", "a", "b", nullptr};
- CheckStringArray(isolate, properties, 5, expected_properties3_1);
- CheckIsSymbolAt(isolate, properties, 4, "symbol");
+ const char* expected_properties3_1[] = {
+ "0", "1", "4294967294", "a", "b", "4294967296", "4294967295", nullptr};
+ CheckStringArray(isolate, properties, 8, expected_properties3_1);
+ CheckIsSymbolAt(isolate, properties, 7, "symbol");
properties =
object
->GetPropertyNames(context.local(), v8::KeyCollectionMode::kOwnOnly,
default_filter, v8::IndexFilter::kSkipIndices)
.ToLocalChecked();
- const char* expected_properties4[] = {"a", "b"};
- CheckStringArray(isolate, properties, 2, expected_properties4);
+ const char* expected_properties4[] = {"a", "b", "4294967296", "4294967295"};
+ CheckStringArray(isolate, properties, 4, expected_properties4);
properties = object
->GetPropertyNames(
context.local(), v8::KeyCollectionMode::kOwnOnly,
include_symbols_filter, v8::IndexFilter::kSkipIndices)
.ToLocalChecked();
- const char* expected_properties4_1[] = {"a", "b", nullptr};
- CheckStringArray(isolate, properties, 3, expected_properties4_1);
- CheckIsSymbolAt(isolate, properties, 2, "symbol");
+ const char* expected_properties4_1[] = {"a", "b", "4294967296", "4294967295",
+ nullptr};
+ CheckStringArray(isolate, properties, 5, expected_properties4_1);
+ CheckIsSymbolAt(isolate, properties, 4, "symbol");
}
THREADED_TEST(ProxyGetPropertyNames) {
@@ -15458,6 +15495,9 @@ THREADED_TEST(ProxyGetPropertyNames) {
v8::HandleScope scope(isolate);
v8::Local<v8::Value> result = CompileRun(
"var target = {0: 0, 1: 1, a: 2, b: 3};"
+ "target[2**32] = '4294967296';"
+ "target[2**32-1] = '4294967295';"
+ "target[2**32-2] = '4294967294';"
"target[Symbol('symbol')] = true;"
"target.__proto__ = {__proto__:null, 2: 4, 3: 5, c: 6, d: 7};"
"var result = new Proxy(target, {});"
@@ -15469,8 +15509,10 @@ THREADED_TEST(ProxyGetPropertyNames) {
v8::Local<v8::Array> properties =
object->GetPropertyNames(context.local()).ToLocalChecked();
- const char* expected_properties1[] = {"0", "1", "a", "b", "2", "3", "c", "d"};
- CheckStringArray(isolate, properties, 8, expected_properties1);
+ const char* expected_properties1[] = {"0", "1", "4294967294", "a",
+ "b", "4294967296", "4294967295", "2",
+ "3", "c", "d"};
+ CheckStringArray(isolate, properties, 11, expected_properties1);
properties =
object
@@ -15478,7 +15520,7 @@ THREADED_TEST(ProxyGetPropertyNames) {
v8::KeyCollectionMode::kIncludePrototypes,
default_filter, v8::IndexFilter::kIncludeIndices)
.ToLocalChecked();
- CheckStringArray(isolate, properties, 8, expected_properties1);
+ CheckStringArray(isolate, properties, 11, expected_properties1);
properties = object
->GetPropertyNames(context.local(),
@@ -15486,10 +15528,11 @@ THREADED_TEST(ProxyGetPropertyNames) {
include_symbols_filter,
v8::IndexFilter::kIncludeIndices)
.ToLocalChecked();
- const char* expected_properties1_1[] = {"0", "1", "a", "b", nullptr,
- "2", "3", "c", "d"};
- CheckStringArray(isolate, properties, 9, expected_properties1_1);
- CheckIsSymbolAt(isolate, properties, 4, "symbol");
+ const char* expected_properties1_1[] = {
+ "0", "1", "4294967294", "a", "b", "4294967296",
+ "4294967295", nullptr, "2", "3", "c", "d"};
+ CheckStringArray(isolate, properties, 12, expected_properties1_1);
+ CheckIsSymbolAt(isolate, properties, 7, "symbol");
properties =
object
@@ -15497,8 +15540,9 @@ THREADED_TEST(ProxyGetPropertyNames) {
v8::KeyCollectionMode::kIncludePrototypes,
default_filter, v8::IndexFilter::kSkipIndices)
.ToLocalChecked();
- const char* expected_properties2[] = {"a", "b", "c", "d"};
- CheckStringArray(isolate, properties, 4, expected_properties2);
+ const char* expected_properties2[] = {"a", "b", "4294967296",
+ "4294967295", "c", "d"};
+ CheckStringArray(isolate, properties, 6, expected_properties2);
properties = object
->GetPropertyNames(context.local(),
@@ -15506,43 +15550,47 @@ THREADED_TEST(ProxyGetPropertyNames) {
include_symbols_filter,
v8::IndexFilter::kSkipIndices)
.ToLocalChecked();
- const char* expected_properties2_1[] = {"a", "b", nullptr, "c", "d"};
- CheckStringArray(isolate, properties, 5, expected_properties2_1);
- CheckIsSymbolAt(isolate, properties, 2, "symbol");
+ const char* expected_properties2_1[] = {
+ "a", "b", "4294967296", "4294967295", nullptr, "c", "d"};
+ CheckStringArray(isolate, properties, 7, expected_properties2_1);
+ CheckIsSymbolAt(isolate, properties, 4, "symbol");
properties =
object
->GetPropertyNames(context.local(), v8::KeyCollectionMode::kOwnOnly,
default_filter, v8::IndexFilter::kIncludeIndices)
.ToLocalChecked();
- const char* expected_properties3[] = {"0", "1", "a", "b"};
- CheckStringArray(isolate, properties, 4, expected_properties3);
+ const char* expected_properties3[] = {"0", "1", "4294967294", "a",
+ "b", "4294967296", "4294967295"};
+ CheckStringArray(isolate, properties, 7, expected_properties3);
properties = object
->GetPropertyNames(
context.local(), v8::KeyCollectionMode::kOwnOnly,
include_symbols_filter, v8::IndexFilter::kIncludeIndices)
.ToLocalChecked();
- const char* expected_properties3_1[] = {"0", "1", "a", "b", nullptr};
- CheckStringArray(isolate, properties, 5, expected_properties3_1);
- CheckIsSymbolAt(isolate, properties, 4, "symbol");
+ const char* expected_properties3_1[] = {
+ "0", "1", "4294967294", "a", "b", "4294967296", "4294967295", nullptr};
+ CheckStringArray(isolate, properties, 8, expected_properties3_1);
+ CheckIsSymbolAt(isolate, properties, 7, "symbol");
properties =
object
->GetPropertyNames(context.local(), v8::KeyCollectionMode::kOwnOnly,
default_filter, v8::IndexFilter::kSkipIndices)
.ToLocalChecked();
- const char* expected_properties4[] = {"a", "b"};
- CheckStringArray(isolate, properties, 2, expected_properties4);
+ const char* expected_properties4[] = {"a", "b", "4294967296", "4294967295"};
+ CheckStringArray(isolate, properties, 4, expected_properties4);
properties = object
->GetPropertyNames(
context.local(), v8::KeyCollectionMode::kOwnOnly,
include_symbols_filter, v8::IndexFilter::kSkipIndices)
.ToLocalChecked();
- const char* expected_properties4_1[] = {"a", "b", nullptr};
- CheckStringArray(isolate, properties, 3, expected_properties4_1);
- CheckIsSymbolAt(isolate, properties, 2, "symbol");
+ const char* expected_properties4_1[] = {"a", "b", "4294967296", "4294967295",
+ nullptr};
+ CheckStringArray(isolate, properties, 5, expected_properties4_1);
+ CheckIsSymbolAt(isolate, properties, 4, "symbol");
}
THREADED_TEST(AccessChecksReenabledCorrectly) {
@@ -15739,6 +15787,7 @@ class UC16VectorResource : public v8::String::ExternalStringResource {
static void MorphAString(i::String* string,
OneByteVectorResource* one_byte_resource,
UC16VectorResource* uc16_resource) {
+ i::Isolate* isolate = CcTest::i_isolate();
CHECK(i::StringShape(string).IsExternal());
i::ReadOnlyRoots roots(CcTest::heap());
if (string->IsOneByteRepresentation()) {
@@ -15748,14 +15797,16 @@ static void MorphAString(i::String* string,
string->set_map(roots.external_string_map());
i::ExternalTwoByteString* morphed =
i::ExternalTwoByteString::cast(string);
- morphed->set_resource(uc16_resource);
+ CcTest::heap()->UpdateExternalString(morphed, string->length(), 0);
+ morphed->SetResource(isolate, uc16_resource);
} else {
// Check old map is not internalized or long.
CHECK(string->map() == roots.external_string_map());
// Morph external string to be one-byte string.
string->set_map(roots.external_one_byte_string_map());
i::ExternalOneByteString* morphed = i::ExternalOneByteString::cast(string);
- morphed->set_resource(one_byte_resource);
+ CcTest::heap()->UpdateExternalString(morphed, string->length(), 0);
+ morphed->SetResource(isolate, one_byte_resource);
}
}
@@ -15771,6 +15822,7 @@ THREADED_TEST(MorphCompositeStringTest) {
LocalContext env;
i::Factory* factory = CcTest::i_isolate()->factory();
v8::Isolate* isolate = env->GetIsolate();
+ i::Isolate* i_isolate = CcTest::i_isolate();
v8::HandleScope scope(isolate);
OneByteVectorResource one_byte_resource(
i::Vector<const char>(c_string, i::StrLength(c_string)));
@@ -15805,7 +15857,7 @@ THREADED_TEST(MorphCompositeStringTest) {
v8_compile("cons")->Run(env.local()).ToLocalChecked().As<String>();
CHECK_EQ(128, cons->Utf8Length(isolate));
int nchars = -1;
- CHECK_EQ(129, cons->WriteUtf8(utf_buffer, -1, &nchars));
+ CHECK_EQ(129, cons->WriteUtf8(isolate, utf_buffer, -1, &nchars));
CHECK_EQ(128, nchars);
CHECK_EQ(0, strcmp(
utf_buffer,
@@ -15844,13 +15896,13 @@ THREADED_TEST(MorphCompositeStringTest) {
// This avoids the GC from trying to free a stack allocated resource.
if (ilhs->IsExternalOneByteString())
- i::ExternalOneByteString::cast(ilhs)->set_resource(nullptr);
+ i::ExternalOneByteString::cast(ilhs)->SetResource(i_isolate, nullptr);
else
- i::ExternalTwoByteString::cast(ilhs)->set_resource(nullptr);
+ i::ExternalTwoByteString::cast(ilhs)->SetResource(i_isolate, nullptr);
if (irhs->IsExternalOneByteString())
- i::ExternalOneByteString::cast(irhs)->set_resource(nullptr);
+ i::ExternalOneByteString::cast(irhs)->SetResource(i_isolate, nullptr);
else
- i::ExternalTwoByteString::cast(irhs)->set_resource(nullptr);
+ i::ExternalTwoByteString::cast(irhs)->SetResource(i_isolate, nullptr);
}
i::DeleteArray(two_byte_string);
}
@@ -17342,60 +17394,67 @@ void AnalyzeStackInNativeCode(const v8::FunctionCallbackInfo<v8::Value>& args) {
CHECK_EQ(args.Length(), 1);
v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext();
+ v8::Isolate* isolate = args.GetIsolate();
int testGroup = args[0]->Int32Value(context).FromJust();
if (testGroup == kOverviewTest) {
v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
args.GetIsolate(), 10, v8::StackTrace::kOverview);
CHECK_EQ(4, stackTrace->GetFrameCount());
checkStackFrame(origin, "bar", 2, 10, false, false,
- stackTrace->GetFrame(0));
- checkStackFrame(origin, "foo", 6, 3, false, true, stackTrace->GetFrame(1));
+ stackTrace->GetFrame(args.GetIsolate(), 0));
+ checkStackFrame(origin, "foo", 6, 3, false, true,
+ stackTrace->GetFrame(isolate, 1));
// This is the source string inside the eval which has the call to foo.
- checkStackFrame(nullptr, "", 1, 1, true, false, stackTrace->GetFrame(2));
+ checkStackFrame(nullptr, "", 1, 1, true, false,
+ stackTrace->GetFrame(isolate, 2));
// The last frame is an anonymous function which has the initial eval call.
- checkStackFrame(origin, "", 8, 7, false, false, stackTrace->GetFrame(3));
+ checkStackFrame(origin, "", 8, 7, false, false,
+ stackTrace->GetFrame(isolate, 3));
} else if (testGroup == kDetailedTest) {
v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
args.GetIsolate(), 10, v8::StackTrace::kDetailed);
CHECK_EQ(4, stackTrace->GetFrameCount());
checkStackFrame(origin, "bat", 4, 22, false, false,
- stackTrace->GetFrame(0));
+ stackTrace->GetFrame(isolate, 0));
checkStackFrame(origin, "baz", 8, 3, false, true,
- stackTrace->GetFrame(1));
+ stackTrace->GetFrame(isolate, 1));
bool is_eval = true;
// This is the source string inside the eval which has the call to baz.
- checkStackFrame(nullptr, "", 1, 1, is_eval, false, stackTrace->GetFrame(2));
+ checkStackFrame(nullptr, "", 1, 1, is_eval, false,
+ stackTrace->GetFrame(isolate, 2));
// The last frame is an anonymous function which has the initial eval call.
- checkStackFrame(origin, "", 10, 1, false, false, stackTrace->GetFrame(3));
+ checkStackFrame(origin, "", 10, 1, false, false,
+ stackTrace->GetFrame(isolate, 3));
} else if (testGroup == kFunctionName) {
v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
args.GetIsolate(), 5, v8::StackTrace::kOverview);
CHECK_EQ(3, stackTrace->GetFrameCount());
checkStackFrame(nullptr, "function.name", 3, 1, true, false,
- stackTrace->GetFrame(0));
+ stackTrace->GetFrame(isolate, 0));
} else if (testGroup == kDisplayName) {
v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
args.GetIsolate(), 5, v8::StackTrace::kOverview);
CHECK_EQ(3, stackTrace->GetFrameCount());
checkStackFrame(nullptr, "function.displayName", 3, 1, true, false,
- stackTrace->GetFrame(0));
+ stackTrace->GetFrame(isolate, 0));
} else if (testGroup == kFunctionNameAndDisplayName) {
v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
args.GetIsolate(), 5, v8::StackTrace::kOverview);
CHECK_EQ(3, stackTrace->GetFrameCount());
checkStackFrame(nullptr, "function.displayName", 3, 1, true, false,
- stackTrace->GetFrame(0));
+ stackTrace->GetFrame(isolate, 0));
} else if (testGroup == kDisplayNameIsNotString) {
v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
args.GetIsolate(), 5, v8::StackTrace::kOverview);
CHECK_EQ(3, stackTrace->GetFrameCount());
checkStackFrame(nullptr, "function.name", 3, 1, true, false,
- stackTrace->GetFrame(0));
+ stackTrace->GetFrame(isolate, 0));
} else if (testGroup == kFunctionNameIsNotString) {
v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
args.GetIsolate(), 5, v8::StackTrace::kOverview);
CHECK_EQ(3, stackTrace->GetFrameCount());
- checkStackFrame(nullptr, "", 3, 1, true, false, stackTrace->GetFrame(0));
+ checkStackFrame(nullptr, "", 3, 1, true, false,
+ stackTrace->GetFrame(isolate, 0));
}
}
@@ -17498,9 +17557,9 @@ static void StackTraceForUncaughtExceptionListener(
v8::Local<v8::StackTrace> stack_trace = message->GetStackTrace();
CHECK_EQ(2, stack_trace->GetFrameCount());
checkStackFrame("origin", "foo", 2, 3, false, false,
- stack_trace->GetFrame(0));
+ stack_trace->GetFrame(message->GetIsolate(), 0));
checkStackFrame("origin", "bar", 5, 3, false, false,
- stack_trace->GetFrame(1));
+ stack_trace->GetFrame(message->GetIsolate(), 1));
}
@@ -17629,16 +17688,18 @@ TEST(ErrorLevelWarning) {
static void StackTraceFunctionNameListener(v8::Local<v8::Message> message,
v8::Local<Value>) {
v8::Local<v8::StackTrace> stack_trace = message->GetStackTrace();
+ v8::Isolate* isolate = message->GetIsolate();
CHECK_EQ(5, stack_trace->GetFrameCount());
checkStackFrame("origin", "foo:0", 4, 7, false, false,
- stack_trace->GetFrame(0));
+ stack_trace->GetFrame(isolate, 0));
checkStackFrame("origin", "foo:1", 5, 27, false, false,
- stack_trace->GetFrame(1));
+ stack_trace->GetFrame(isolate, 1));
checkStackFrame("origin", "foo", 5, 27, false, false,
- stack_trace->GetFrame(2));
+ stack_trace->GetFrame(isolate, 2));
checkStackFrame("origin", "foo", 5, 27, false, false,
- stack_trace->GetFrame(3));
- checkStackFrame("origin", "", 1, 14, false, false, stack_trace->GetFrame(4));
+ stack_trace->GetFrame(isolate, 3));
+ checkStackFrame("origin", "", 1, 14, false, false,
+ stack_trace->GetFrame(isolate, 4));
}
@@ -17684,7 +17745,8 @@ static void RethrowStackTraceHandler(v8::Local<v8::Message> message,
CHECK_EQ(3, frame_count);
int line_number[] = {1, 2, 5};
for (int i = 0; i < frame_count; i++) {
- CHECK_EQ(line_number[i], stack_trace->GetFrame(i)->GetLineNumber());
+ CHECK_EQ(line_number[i],
+ stack_trace->GetFrame(message->GetIsolate(), i)->GetLineNumber());
}
}
@@ -17728,7 +17790,8 @@ static void RethrowPrimitiveStackTraceHandler(v8::Local<v8::Message> message,
CHECK_EQ(2, frame_count);
int line_number[] = {3, 7};
for (int i = 0; i < frame_count; i++) {
- CHECK_EQ(line_number[i], stack_trace->GetFrame(i)->GetLineNumber());
+ CHECK_EQ(line_number[i],
+ stack_trace->GetFrame(message->GetIsolate(), i)->GetLineNumber());
}
}
@@ -17763,7 +17826,7 @@ static void RethrowExistingStackTraceHandler(v8::Local<v8::Message> message,
v8::Local<v8::StackTrace> stack_trace = message->GetStackTrace();
CHECK(!stack_trace.IsEmpty());
CHECK_EQ(1, stack_trace->GetFrameCount());
- CHECK_EQ(1, stack_trace->GetFrame(0)->GetLineNumber());
+ CHECK_EQ(1, stack_trace->GetFrame(message->GetIsolate(), 0)->GetLineNumber());
}
@@ -17790,7 +17853,7 @@ static void RethrowBogusErrorStackTraceHandler(v8::Local<v8::Message> message,
v8::Local<v8::StackTrace> stack_trace = message->GetStackTrace();
CHECK(!stack_trace.IsEmpty());
CHECK_EQ(1, stack_trace->GetFrameCount());
- CHECK_EQ(2, stack_trace->GetFrame(0)->GetLineNumber());
+ CHECK_EQ(2, stack_trace->GetFrame(message->GetIsolate(), 0)->GetLineNumber());
}
@@ -17845,13 +17908,14 @@ void PromiseRejectCallback(v8::PromiseRejectMessage reject_message) {
if (!stack_trace.IsEmpty()) {
promise_reject_frame_count = stack_trace->GetFrameCount();
if (promise_reject_frame_count > 0) {
- CHECK(stack_trace->GetFrame(0)
+ CHECK(stack_trace->GetFrame(CcTest::isolate(), 0)
->GetScriptName()
->Equals(context, v8_str("pro"))
.FromJust());
promise_reject_line_number =
- stack_trace->GetFrame(0)->GetLineNumber();
- promise_reject_column_number = stack_trace->GetFrame(0)->GetColumn();
+ stack_trace->GetFrame(CcTest::isolate(), 0)->GetLineNumber();
+ promise_reject_column_number =
+ stack_trace->GetFrame(CcTest::isolate(), 0)->GetColumn();
} else {
promise_reject_line_number = -1;
promise_reject_column_number = -1;
@@ -18309,7 +18373,7 @@ void AnalyzeStackOfEvalWithSourceURL(
v8::Local<v8::String> url = v8_str("eval_url");
for (int i = 0; i < 3; i++) {
v8::Local<v8::String> name =
- stackTrace->GetFrame(i)->GetScriptNameOrSourceURL();
+ stackTrace->GetFrame(args.GetIsolate(), i)->GetScriptNameOrSourceURL();
CHECK(!name.IsEmpty());
CHECK(url->Equals(args.GetIsolate()->GetCurrentContext(), name).FromJust());
}
@@ -18355,7 +18419,8 @@ void AnalyzeScriptIdInStack(
args.GetIsolate(), 10, v8::StackTrace::kScriptId);
CHECK_EQ(2, stackTrace->GetFrameCount());
for (int i = 0; i < 2; i++) {
- scriptIdInStack[i] = stackTrace->GetFrame(i)->GetScriptId();
+ scriptIdInStack[i] =
+ stackTrace->GetFrame(args.GetIsolate(), i)->GetScriptId();
}
}
@@ -18391,7 +18456,7 @@ void AnalyzeStackOfInlineScriptWithSourceURL(
v8::Local<v8::String> url = v8_str("source_url");
for (int i = 0; i < 3; i++) {
v8::Local<v8::String> name =
- stackTrace->GetFrame(i)->GetScriptNameOrSourceURL();
+ stackTrace->GetFrame(args.GetIsolate(), i)->GetScriptNameOrSourceURL();
CHECK(!name.IsEmpty());
CHECK(url->Equals(args.GetIsolate()->GetCurrentContext(), name).FromJust());
}
@@ -18806,7 +18871,7 @@ void AnalyzeStackOfDynamicScriptWithSourceURL(
v8::Local<v8::String> url = v8_str("source_url");
for (int i = 0; i < 3; i++) {
v8::Local<v8::String> name =
- stackTrace->GetFrame(i)->GetScriptNameOrSourceURL();
+ stackTrace->GetFrame(args.GetIsolate(), i)->GetScriptNameOrSourceURL();
CHECK(!name.IsEmpty());
CHECK(url->Equals(args.GetIsolate()->GetCurrentContext(), name).FromJust());
}
@@ -19072,7 +19137,8 @@ TEST(GetHeapSpaceStatistics) {
// Force allocation in LO_SPACE so that every space has non-zero size.
v8::internal::Isolate* i_isolate =
reinterpret_cast<v8::internal::Isolate*>(isolate);
- (void)i_isolate->factory()->TryNewFixedArray(512 * 1024);
+ auto unused = i_isolate->factory()->TryNewFixedArray(512 * 1024);
+ USE(unused);
isolate->GetHeapStatistics(&heap_statistics);
@@ -19620,7 +19686,7 @@ THREADED_TEST(ScriptOrigin) {
v8::HandleScope scope(isolate);
Local<v8::PrimitiveArray> array(v8::PrimitiveArray::New(isolate, 1));
Local<v8::Symbol> symbol(v8::Symbol::New(isolate));
- array->Set(0, symbol);
+ array->Set(isolate, 0, symbol);
v8::ScriptOrigin origin = v8::ScriptOrigin(
v8_str("test"), v8::Integer::New(env->GetIsolate(), 1),
@@ -19648,7 +19714,7 @@ THREADED_TEST(ScriptOrigin) {
CHECK(script_origin_f.Options().IsSharedCrossOrigin());
CHECK(script_origin_f.Options().IsOpaque());
printf("is name = %d\n", script_origin_f.SourceMapUrl()->IsUndefined());
- CHECK(script_origin_f.HostDefinedOptions()->Get(0)->IsSymbol());
+ CHECK(script_origin_f.HostDefinedOptions()->Get(isolate, 0)->IsSymbol());
CHECK_EQ(0, strcmp("http://sourceMapUrl",
*v8::String::Utf8Value(env->GetIsolate(),
@@ -19666,7 +19732,7 @@ THREADED_TEST(ScriptOrigin) {
CHECK_EQ(0, strcmp("http://sourceMapUrl",
*v8::String::Utf8Value(env->GetIsolate(),
script_origin_g.SourceMapUrl())));
- CHECK(script_origin_g.HostDefinedOptions()->Get(0)->IsSymbol());
+ CHECK(script_origin_g.HostDefinedOptions()->Get(isolate, 0)->IsSymbol());
}
@@ -20470,7 +20536,8 @@ THREADED_TEST(TwoByteStringInOneByteCons) {
CHECK_EQ(static_cast<int32_t>('e'),
reresult->Int32Value(context.local()).FromJust());
// This avoids the GC from trying to free stack allocated resources.
- i::Handle<i::ExternalTwoByteString>::cast(flat_string)->set_resource(nullptr);
+ i::Handle<i::ExternalTwoByteString>::cast(flat_string)
+ ->SetResource(i_isolate, nullptr);
}
@@ -20506,11 +20573,11 @@ TEST(ContainsOnlyOneByte) {
Local<String> left = base;
Local<String> right = base;
for (int i = 0; i < 1000; i++) {
- left = String::Concat(base, left);
- right = String::Concat(right, base);
+ left = String::Concat(isolate, base, left);
+ right = String::Concat(isolate, right, base);
}
- Local<String> balanced = String::Concat(left, base);
- balanced = String::Concat(balanced, right);
+ Local<String> balanced = String::Concat(isolate, left, base);
+ balanced = String::Concat(isolate, balanced, right);
Local<String> cons_strings[] = {left, balanced, right};
Local<String> two_byte =
String::NewExternalTwoByte(
@@ -20522,9 +20589,9 @@ TEST(ContainsOnlyOneByte) {
string = cons_strings[i];
CHECK(string->IsOneByte() && string->ContainsOnlyOneByte());
// Test left and right concatentation.
- string = String::Concat(two_byte, cons_strings[i]);
+ string = String::Concat(isolate, two_byte, cons_strings[i]);
CHECK(!string->IsOneByte() && string->ContainsOnlyOneByte());
- string = String::Concat(cons_strings[i], two_byte);
+ string = String::Concat(isolate, cons_strings[i], two_byte);
CHECK(!string->IsOneByte() && string->ContainsOnlyOneByte());
}
// Set bits in different positions
@@ -21921,12 +21988,11 @@ THREADED_TEST(ReadOnlyIndexedProperties) {
static int CountLiveMapsInMapCache(i::Context* context) {
- i::FixedArray* map_cache = i::FixedArray::cast(context->map_cache());
+ i::WeakFixedArray* map_cache = i::WeakFixedArray::cast(context->map_cache());
int length = map_cache->length();
int count = 0;
for (int i = 0; i < length; i++) {
- i::Object* value = map_cache->get(i);
- if (value->IsWeakCell() && !i::WeakCell::cast(value)->cleared()) count++;
+ if (map_cache->Get(i)->IsWeakHeapObject()) count++;
}
return count;
}
@@ -22752,7 +22818,7 @@ void Recompile(Args... args) {
stub.GetCode();
}
-void RecompileICStubs(i::Isolate* isolate) {
+void RecompileICStubs() {
// BUG(5784): We had a list of IC stubs here to recompile. These are now
// builtins and we can't compile them again (easily). Bug 5784 tracks
// our progress in finding another way to do this.
@@ -22805,7 +22871,6 @@ void TestStubCache(bool primary) {
create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
create_params.counter_lookup_callback = LookupCounter;
v8::Isolate* isolate = v8::Isolate::New(create_params);
- i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
{
v8::Isolate::Scope isolate_scope(isolate);
@@ -22814,7 +22879,7 @@ void TestStubCache(bool primary) {
// Enforce recompilation of IC stubs that access megamorphic stub cache
// to respect enabled native code counters and stub cache test flags.
- RecompileICStubs(i_isolate);
+ RecompileICStubs();
int initial_probes = probes_counter;
int initial_misses = misses_counter;
@@ -23745,7 +23810,6 @@ TEST(AccessCheckInIC) {
create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
create_params.counter_lookup_callback = LookupCounter;
v8::Isolate* isolate = v8::Isolate::New(create_params);
- i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
{
v8::Isolate::Scope isolate_scope(isolate);
@@ -23754,7 +23818,7 @@ TEST(AccessCheckInIC) {
// Enforce recompilation of IC stubs that access megamorphic stub cache
// to respect enabled native code counters and stub cache test flags.
- RecompileICStubs(i_isolate);
+ RecompileICStubs();
// Create an ObjectTemplate for global objects and install access
// check callbacks that will block access.
@@ -25010,8 +25074,12 @@ TEST(ResolvedPromiseReFulfill) {
LocalContext context;
v8::Isolate* isolate = context->GetIsolate();
v8::HandleScope scope(isolate);
- v8::Local<v8::String> value1 = v8::String::NewFromUtf8(isolate, "foo");
- v8::Local<v8::String> value2 = v8::String::NewFromUtf8(isolate, "bar");
+ v8::Local<v8::String> value1 =
+ v8::String::NewFromUtf8(isolate, "foo", v8::NewStringType::kNormal)
+ .ToLocalChecked();
+ v8::Local<v8::String> value2 =
+ v8::String::NewFromUtf8(isolate, "bar", v8::NewStringType::kNormal)
+ .ToLocalChecked();
v8::Local<v8::Promise::Resolver> resolver =
v8::Promise::Resolver::New(context.local()).ToLocalChecked();
@@ -25037,8 +25105,12 @@ TEST(RejectedPromiseReFulfill) {
LocalContext context;
v8::Isolate* isolate = context->GetIsolate();
v8::HandleScope scope(isolate);
- v8::Local<v8::String> value1 = v8::String::NewFromUtf8(isolate, "foo");
- v8::Local<v8::String> value2 = v8::String::NewFromUtf8(isolate, "bar");
+ v8::Local<v8::String> value1 =
+ v8::String::NewFromUtf8(isolate, "foo", v8::NewStringType::kNormal)
+ .ToLocalChecked();
+ v8::Local<v8::String> value2 =
+ v8::String::NewFromUtf8(isolate, "bar", v8::NewStringType::kNormal)
+ .ToLocalChecked();
v8::Local<v8::Promise::Resolver> resolver =
v8::Promise::Resolver::New(context.local()).ToLocalChecked();
@@ -26325,14 +26397,16 @@ TEST(InvalidCodeCacheData) {
TEST(StringConcatOverflow) {
v8::V8::Initialize();
- v8::HandleScope scope(CcTest::isolate());
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
RandomLengthOneByteResource* r =
new RandomLengthOneByteResource(i::String::kMaxLength);
v8::Local<v8::String> str =
- v8::String::NewExternalOneByte(CcTest::isolate(), r).ToLocalChecked();
+ v8::String::NewExternalOneByte(isolate, r).ToLocalChecked();
CHECK(!str.IsEmpty());
- v8::TryCatch try_catch(CcTest::isolate());
- v8::Local<v8::String> result = v8::String::Concat(str, str);
+ v8::TryCatch try_catch(isolate);
+ v8::Local<v8::String> result = v8::String::Concat(isolate, str, str);
+ v8::String::Concat(CcTest::isolate(), str, str);
CHECK(result.IsEmpty());
CHECK(!try_catch.HasCaught());
}
@@ -26350,7 +26424,7 @@ TEST(TurboAsmDisablesNeuter) {
" function load() { return MEM32[0] | 0; }"
" return { load: load };"
"}"
- "var buffer = new ArrayBuffer(1024);"
+ "var buffer = new ArrayBuffer(4096);"
"var module = Module(this, {}, buffer);"
"%OptimizeFunctionOnNextCall(module.load);"
"module.load();"
@@ -26366,7 +26440,7 @@ TEST(TurboAsmDisablesNeuter) {
" function store() { MEM32[0] = 0; }"
" return { store: store };"
"}"
- "var buffer = new ArrayBuffer(1024);"
+ "var buffer = new ArrayBuffer(4096);"
"var module = Module(this, {}, buffer);"
"%OptimizeFunctionOnNextCall(module.store);"
"module.store();"
@@ -27981,7 +28055,9 @@ v8::MaybeLocal<v8::Promise> HostImportModuleDynamicallyCallbackResolve(
String::Utf8Value referrer_utf8(
context->GetIsolate(), Local<String>::Cast(referrer->GetResourceName()));
CHECK_EQ(0, strcmp("www.google.com", *referrer_utf8));
- CHECK(referrer->GetHostDefinedOptions()->Get(0)->IsSymbol());
+ CHECK(referrer->GetHostDefinedOptions()
+ ->Get(context->GetIsolate(), 0)
+ ->IsSymbol());
CHECK(!specifier.IsEmpty());
String::Utf8Value specifier_utf8(context->GetIsolate(), specifier);
@@ -28151,41 +28227,41 @@ TEST(PrimitiveArray) {
CHECK_EQ(length, array->Length());
for (int i = 0; i < length; i++) {
- Local<v8::Primitive> item = array->Get(i);
+ Local<v8::Primitive> item = array->Get(isolate, i);
CHECK(item->IsUndefined());
}
Local<v8::Symbol> symbol(v8::Symbol::New(isolate));
- array->Set(0, symbol);
- CHECK(array->Get(0)->IsSymbol());
+ array->Set(isolate, 0, symbol);
+ CHECK(array->Get(isolate, 0)->IsSymbol());
Local<v8::String> string =
v8::String::NewFromUtf8(isolate, "test", v8::NewStringType::kInternalized)
.ToLocalChecked();
- array->Set(1, string);
- CHECK(array->Get(0)->IsSymbol());
- CHECK(array->Get(1)->IsString());
+ array->Set(isolate, 1, string);
+ CHECK(array->Get(isolate, 0)->IsSymbol());
+ CHECK(array->Get(isolate, 1)->IsString());
Local<v8::Number> num = v8::Number::New(env->GetIsolate(), 3.1415926);
- array->Set(2, num);
- CHECK(array->Get(0)->IsSymbol());
- CHECK(array->Get(1)->IsString());
- CHECK(array->Get(2)->IsNumber());
+ array->Set(isolate, 2, num);
+ CHECK(array->Get(isolate, 0)->IsSymbol());
+ CHECK(array->Get(isolate, 1)->IsString());
+ CHECK(array->Get(isolate, 2)->IsNumber());
v8::Local<v8::Boolean> f = v8::False(isolate);
- array->Set(3, f);
- CHECK(array->Get(0)->IsSymbol());
- CHECK(array->Get(1)->IsString());
- CHECK(array->Get(2)->IsNumber());
- CHECK(array->Get(3)->IsBoolean());
+ array->Set(isolate, 3, f);
+ CHECK(array->Get(isolate, 0)->IsSymbol());
+ CHECK(array->Get(isolate, 1)->IsString());
+ CHECK(array->Get(isolate, 2)->IsNumber());
+ CHECK(array->Get(isolate, 3)->IsBoolean());
v8::Local<v8::Primitive> n = v8::Null(isolate);
- array->Set(4, n);
- CHECK(array->Get(0)->IsSymbol());
- CHECK(array->Get(1)->IsString());
- CHECK(array->Get(2)->IsNumber());
- CHECK(array->Get(3)->IsBoolean());
- CHECK(array->Get(4)->IsNull());
+ array->Set(isolate, 4, n);
+ CHECK(array->Get(isolate, 0)->IsSymbol());
+ CHECK(array->Get(isolate, 1)->IsString());
+ CHECK(array->Get(isolate, 2)->IsNumber());
+ CHECK(array->Get(isolate, 3)->IsBoolean());
+ CHECK(array->Get(isolate, 4)->IsNull());
}
TEST(PersistentValueMap) {
@@ -28204,22 +28280,123 @@ TEST(PersistentValueMap) {
map.Set("key", value);
}
-TEST(WasmStreamingAbort) {
- LocalContext env;
- v8::Isolate* isolate = env->GetIsolate();
- v8::HandleScope scope(isolate);
- v8::WasmModuleObjectBuilderStreaming streaming(isolate);
- streaming.Abort(v8::Object::New(isolate));
- CHECK_EQ(streaming.GetPromise()->State(), v8::Promise::kRejected);
+namespace {
+
+bool wasm_streaming_callback_got_called = false;
+bool wasm_streaming_data_got_collected = false;
+
+void WasmStreamingTestFinalizer(const v8::WeakCallbackInfo<void>& data) {
+ CHECK(!wasm_streaming_data_got_collected);
+ wasm_streaming_data_got_collected = true;
+ i::JSObject** p = reinterpret_cast<i::JSObject**>(data.GetParameter());
+ i::GlobalHandles::Destroy(reinterpret_cast<i::Object**>(p));
+}
+
+void WasmStreamingCallbackTestCallbackIsCalled(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ CHECK(!wasm_streaming_callback_got_called);
+ wasm_streaming_callback_got_called = true;
+
+ i::Handle<i::Object> global_handle =
+ reinterpret_cast<i::Isolate*>(args.GetIsolate())
+ ->global_handles()
+ ->Create(*v8::Utils::OpenHandle(*args.Data()));
+ i::GlobalHandles::MakeWeak(global_handle.location(), global_handle.location(),
+ WasmStreamingTestFinalizer,
+ v8::WeakCallbackType::kParameter);
+}
+
+void WasmStreamingCallbackTestOnBytesReceived(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ std::shared_ptr<v8::WasmStreaming> streaming =
+ v8::WasmStreaming::Unpack(args.GetIsolate(), args.Data());
+
+ // The first bytes of the WebAssembly magic word.
+ const uint8_t bytes[]{0x00, 0x61, 0x73};
+ streaming->OnBytesReceived(bytes, arraysize(bytes));
+}
+
+void WasmStreamingCallbackTestFinishWithSuccess(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ std::shared_ptr<v8::WasmStreaming> streaming =
+ v8::WasmStreaming::Unpack(args.GetIsolate(), args.Data());
+ // The bytes of a minimal WebAssembly module.
+ const uint8_t bytes[]{0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00};
+ streaming->OnBytesReceived(bytes, arraysize(bytes));
+ streaming->Finish();
+}
+
+void WasmStreamingCallbackTestFinishWithFailure(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ std::shared_ptr<v8::WasmStreaming> streaming =
+ v8::WasmStreaming::Unpack(args.GetIsolate(), args.Data());
+ streaming->Finish();
+}
+
+void WasmStreamingCallbackTestAbortWithReject(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ std::shared_ptr<v8::WasmStreaming> streaming =
+ v8::WasmStreaming::Unpack(args.GetIsolate(), args.Data());
+ streaming->Abort(v8::Object::New(args.GetIsolate()));
+}
+
+void WasmStreamingCallbackTestAbortNoReject(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ std::shared_ptr<v8::WasmStreaming> streaming =
+ v8::WasmStreaming::Unpack(args.GetIsolate(), args.Data());
+ streaming->Abort({});
}
-TEST(WasmStreamingAbortNoReject) {
+void TestWasmStreaming(v8::WasmStreamingCallback callback,
+ v8::Promise::PromiseState expected_state) {
+ CcTest::isolate()->SetWasmStreamingCallback(callback);
LocalContext env;
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
- v8::WasmModuleObjectBuilderStreaming streaming(isolate);
- streaming.Abort({});
- CHECK_EQ(streaming.GetPromise()->State(), v8::Promise::kPending);
+
+ // Call {WebAssembly.compileStreaming} with {null} as parameter. The parameter
+ // is only really processed by the embedder, so for this test the value is
+ // irrelevant.
+ v8::Local<v8::Promise> promise = v8::Local<v8::Promise>::Cast(
+ CompileRun("WebAssembly.compileStreaming(null)"));
+
+ EmptyMessageQueues(isolate);
+ CHECK_EQ(expected_state, promise->State());
+}
+
+} // namespace
+
+TEST(WasmStreamingCallback) {
+ TestWasmStreaming(WasmStreamingCallbackTestCallbackIsCalled,
+ v8::Promise::kPending);
+ CHECK(wasm_streaming_callback_got_called);
+ CcTest::CollectAllAvailableGarbage();
+ CHECK(wasm_streaming_data_got_collected);
+}
+
+TEST(WasmStreamingOnBytesReceived) {
+ TestWasmStreaming(WasmStreamingCallbackTestOnBytesReceived,
+ v8::Promise::kPending);
+}
+
+TEST(WasmStreamingFinishWithSuccess) {
+ TestWasmStreaming(WasmStreamingCallbackTestFinishWithSuccess,
+ v8::Promise::kFulfilled);
+}
+
+TEST(WasmStreamingFinishWithFailure) {
+ TestWasmStreaming(WasmStreamingCallbackTestFinishWithFailure,
+ v8::Promise::kRejected);
+}
+
+TEST(WasmStreamingAbortWithReject) {
+ TestWasmStreaming(WasmStreamingCallbackTestAbortWithReject,
+ v8::Promise::kRejected);
+}
+
+TEST(WasmStreamingAbortWithoutReject) {
+ TestWasmStreaming(WasmStreamingCallbackTestAbortNoReject,
+ v8::Promise::kPending);
}
enum class AtomicsWaitCallbackAction {
@@ -28545,3 +28722,42 @@ TEST(BigIntAPI) {
CHECK_EQ(word_count, 2);
}
}
+
+namespace {
+
+bool wasm_threads_enabled_value = false;
+
+bool MockWasmThreadsEnabledCallback(Local<Context>) {
+ return wasm_threads_enabled_value;
+}
+
+} // namespace
+
+TEST(TestSetWasmThreadsEnabledCallback) {
+ LocalContext env;
+ v8::Isolate* isolate = env->GetIsolate();
+ i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
+ v8::HandleScope scope(isolate);
+ v8::Local<Context> context = Context::New(CcTest::isolate());
+ i::Handle<i::Context> i_context = v8::Utils::OpenHandle(*context);
+
+ // {Isolate::AreWasmThreadsEnabled} calls the callback set by the embedder if
+ // such a callback exists. Otherwise it returns
+ // {FLAG_experimental_wasm_threads}. First we test that the flag is returned
+ // correctly if no callback is set. Then we test that the flag is ignored if
+ // the callback is set.
+
+ i::FLAG_experimental_wasm_threads = false;
+ CHECK(!i_isolate->AreWasmThreadsEnabled(i_context));
+
+ i::FLAG_experimental_wasm_threads = true;
+ CHECK(i_isolate->AreWasmThreadsEnabled(i_context));
+
+ isolate->SetWasmThreadsEnabledCallback(MockWasmThreadsEnabledCallback);
+ wasm_threads_enabled_value = false;
+ CHECK(!i_isolate->AreWasmThreadsEnabled(i_context));
+
+ wasm_threads_enabled_value = true;
+ i::FLAG_experimental_wasm_threads = false;
+ CHECK(i_isolate->AreWasmThreadsEnabled(i_context));
+}