Skip to content

Commit cb6a4b2

Browse files
authored
Merge pull request #1233 from NativeScript/darind/v8-7.1.302.31
Upgrade V8 to 7.1.302.31
2 parents 9621bce + 43ed041 commit cb6a4b2

File tree

144 files changed

+4180
-3361
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+4180
-3361
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
env:
22
global:
33
- NODE_VERSION=6.11.1
4-
- NDK_VERSION=r17b
4+
- NDK_VERSION=r18b
55
- DATE=$(date +%Y-%m-%d)
66
- PACKAGE_VERSION=next-$DATE-$TRAVIS_BUILD_NUMBER
77
- EMULATOR_API_LEVEL=21
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"v8Version": "6.9.427.23"
2+
"v8Version": "7.1.302.31"
33
}

package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"**/*"
1111
],
1212
"gradle": {
13-
"version": "4.10.2",
14-
"android": "3.2.1"
15-
}
13+
"version": "4.10.2",
14+
"android": "3.2.1"
15+
},
16+
"android_ndk_version": "18b"
1617
}
Binary file not shown.
Binary file not shown.
Binary file not shown.

test-app/app/src/main/assets/app/tests/exceptionHandlingTests.js

+21-40
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,10 @@ describe("Tests exception handling ", function () {
3131

3232
var eh = new EH();
3333

34-
try
35-
{
34+
try {
3635
eh.triggerEvent1("test", 5);
3736
}
38-
catch (e)
39-
{
37+
catch (e) {
4038
exceptionCaught = true;
4139
sameExObject = e === ex;
4240
__log("e=" + e);
@@ -71,16 +69,13 @@ describe("Tests exception handling ", function () {
7169

7270
var eh = new EH();
7371

74-
try
75-
{
72+
try {
7673
eh.triggerEvent1("test", 5);
7774
}
78-
catch (e)
79-
{
75+
catch (e) {
8076
exceptionCaught = true;
8177
nativeExceptionFound = e.nativeException !== undefined;
82-
if (nativeExceptionFound)
83-
{
78+
if (nativeExceptionFound) {
8479
exMsg = e.nativeException.getMessage();
8580
}
8681
}
@@ -111,13 +106,11 @@ describe("Tests exception handling ", function () {
111106

112107
var eh = new EH();
113108

114-
try
115-
{
109+
try {
116110
eh.triggerEvent1WithCatchClause("test", 5);
117111
exceptionCaught = false;
118112
}
119-
catch (e)
120-
{
113+
catch (e) {
121114
exceptionCaught = true;
122115
}
123116

@@ -147,13 +140,11 @@ describe("Tests exception handling ", function () {
147140

148141
var eh = new EH();
149142

150-
try
151-
{
143+
try {
152144
eh.triggerEvent1WithCatchClause("test", 5);
153145
exceptionCaught = false;
154146
}
155-
catch (e)
156-
{
147+
catch (e) {
157148
exceptionCaught = true;
158149
}
159150

@@ -169,12 +160,10 @@ describe("Tests exception handling ", function () {
169160

170161
var dummy = new com.tns.tests.DummyClass();
171162

172-
try
173-
{
163+
try {
174164
dummy.methodThatThrowsException();
175165
}
176-
catch (e)
177-
{
166+
catch (e) {
178167
exceptionCaught = true;
179168
}
180169

@@ -190,12 +179,10 @@ describe("Tests exception handling ", function () {
190179

191180
var dummy = new com.tns.tests.DummyClass();
192181

193-
try
194-
{
182+
try {
195183
dummy.methodThatThrowsException();
196184
}
197-
catch (e)
198-
{
185+
catch (e) {
199186
var nativeException = e.nativeException;
200187
}
201188

@@ -214,12 +201,10 @@ describe("Tests exception handling ", function () {
214201

215202
var exceptionCaught = false;
216203

217-
try
218-
{
204+
try {
219205
var dummy = new com.tns.tests.DummyClass(true /* throwsException */);
220206
}
221-
catch (e)
222-
{
207+
catch (e) {
223208
exceptionCaught = true;
224209
}
225210

@@ -240,14 +225,12 @@ describe("Tests exception handling ", function () {
240225

241226
expect(arrLength).toEqual(1);
242227

243-
try
244-
{
228+
try {
245229
var dummy = arr[arrLength];
246230

247231
var name = dummy.getName();
248232
}
249-
catch (e)
250-
{
233+
catch (e) {
251234
exceptionCaught = true;
252235
}
253236

@@ -270,12 +253,10 @@ describe("Tests exception handling ", function () {
270253

271254
var last = arr[arrLength - 1];
272255

273-
try
274-
{
256+
try {
275257
arr[arrLength] = last;
276258
}
277-
catch (e)
278-
{
259+
catch (e) {
279260
exceptionCaught = true;
280261
}
281262

@@ -335,8 +316,8 @@ describe("Tests exception handling ", function () {
335316
}
336317
expect(exceptionCaught).toBe(true);
337318
expect(errMsg).toContain("Cannot compile /data/data/com.tns.testapplication/files/app/tests/syntaxErrors.js");
338-
expect(errMsg).toContain("SyntaxError: Unexpected token =");
339-
expect(errMsg).toContain("File: \"file:///data/data/com.tns.testapplication/files/app/tests/syntaxErrors.js, line: 3, column: 10");
319+
expect(errMsg).toContain("SyntaxError: Unexpected token class");
320+
expect(errMsg).toContain("File: \"file:///data/data/com.tns.testapplication/files/app/tests/syntaxErrors.js, line: 3, column: 4");
340321
});
341322

342323
// run this test only for API level bigger than 25 as we have handling there

test-app/runtime/src/main/cpp/ArgConverter.cpp

+5-13
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ int64_t ArgConverter::ConvertToJavaLong(Isolate* isolate, const Local<Value>& va
216216

217217
assert(!valueProp.IsEmpty());
218218

219-
string num = ConvertToString(valueProp->ToString());
219+
string num = ConvertToString(valueProp->ToString(isolate));
220220

221221
int64_t longValue = atoll(num.c_str());
222222

@@ -241,7 +241,8 @@ string ArgConverter::ConvertToString(const v8::Local<String>& s) {
241241
if (s.IsEmpty()) {
242242
return string();
243243
} else {
244-
String::Utf8Value str(s);
244+
auto isolate = v8::Isolate::GetCurrent();
245+
String::Utf8Value str(isolate, s);
245246
return string(*str);
246247
}
247248
}
@@ -259,7 +260,8 @@ u16string ArgConverter::ConvertToUtf16String(const v8::Local<String>& s) {
259260

260261
jstring ArgConverter::ConvertToJavaString(const Local<Value>& value) {
261262
JEnv env;
262-
String::Value stringValue(value);
263+
auto isolate = v8::Isolate::GetCurrent();
264+
String::Value stringValue(isolate, value);
263265
return env.NewString((const jchar*) *stringValue, stringValue.length());
264266
}
265267

@@ -276,18 +278,8 @@ Local<String> ArgConverter::ConvertToV8String(Isolate* isolate, const char* data
276278
return String::NewFromUtf8(isolate, (const char*) data, String::kNormalString, length);
277279
}
278280

279-
Local<String> ArgConverter::ConvertToV8UTF16String(Isolate* isolate, const string& string) {
280-
auto utf16str = Util::ConvertFromUtf8ToUtf16(string);
281-
282-
return ConvertToV8UTF16String(isolate, utf16str);
283-
}
284-
285281
Local<String> ArgConverter::ConvertToV8UTF16String(Isolate* isolate, const u16string& utf16string) {
286282
return String::NewFromTwoByte(isolate, ((const uint16_t*) utf16string.data()));
287283
}
288284

289-
Local<String> ArgConverter::ConvertToV8UTF16String(v8::Isolate* isolate, const uint16_t* utf16string, int size) {
290-
return String::NewFromTwoByte(isolate, utf16string, NewStringType::kNormal, size).ToLocalChecked();
291-
}
292-
293285
std::map<Isolate*, ArgConverter::TypeLongOperationsCache*> ArgConverter::s_type_long_operations_cache;

test-app/runtime/src/main/cpp/ArgConverter.h

-4
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ class ArgConverter {
4040

4141
static v8::Local<v8::String> ConvertToV8String(v8::Isolate* isolate, const char* data, int length);
4242

43-
static v8::Local<v8::String> ConvertToV8UTF16String(v8::Isolate* isolate, const std::string& string);
44-
45-
static v8::Local<v8::String> ConvertToV8UTF16String(v8::Isolate* isolate, const uint16_t* utf16string, int size);
46-
4743
static v8::Local<v8::String> ConvertToV8UTF16String(v8::Isolate* isolate, const std::u16string& utf16string);
4844

4945
private:

test-app/runtime/src/main/cpp/ArrayElementAccessor.cpp

+9-8
Original file line numberDiff line numberDiff line change
@@ -83,51 +83,52 @@ void ArrayElementAccessor::SetArrayElement(Isolate* isolate, const Local<Object>
8383
HandleScope handleScope(isolate);
8484
auto runtime = Runtime::GetRuntime(isolate);
8585
auto objectManager = runtime->GetObjectManager();
86+
auto context = isolate->GetCurrentContext();
8687

8788
auto arr = objectManager->GetJavaObjectByJsObject(array);
8889

8990
const string elementSignature = arraySignature.substr(1);
9091
jboolean isCopy = false;
9192

9293
if (elementSignature == "Z") { //bool
93-
jboolean boolElementValue = (jboolean) value->BooleanValue();
94+
jboolean boolElementValue = (jboolean) value->BooleanValue(context).ToChecked();
9495
jbooleanArray boolArr = static_cast<jbooleanArray>(arr);
9596
env.SetBooleanArrayRegion(boolArr, index, 1, &boolElementValue);
9697
} else if (elementSignature == "B") { //byte
97-
jbyte byteElementValue = (jbyte) value->Int32Value();
98+
jbyte byteElementValue = (jbyte) value->Int32Value(context).ToChecked();
9899
jbyteArray byteArr = static_cast<jbyteArray>(arr);
99100
env.SetByteArrayRegion(byteArr, index, 1, &byteElementValue);
100101
} else if (elementSignature == "C") { //char
101-
String::Utf8Value utf8(value->ToString());
102+
String::Utf8Value utf8(isolate, value->ToString(isolate));
102103
JniLocalRef s(env.NewString((jchar*) *utf8, 1));
103104
const char* singleChar = env.GetStringUTFChars(s, &isCopy);
104105
jchar charElementValue = *singleChar;
105106
env.ReleaseStringUTFChars(s, singleChar);
106107
jcharArray charArr = static_cast<jcharArray>(arr);
107108
env.SetCharArrayRegion(charArr, index, 1, &charElementValue);
108109
} else if (elementSignature == "S") { //short
109-
jshort shortElementValue = (jshort) value->Int32Value();
110+
jshort shortElementValue = (jshort) value->Int32Value(context).ToChecked();
110111
jshortArray shortArr = static_cast<jshortArray>(arr);
111112
env.SetShortArrayRegion(shortArr, index, 1, &shortElementValue);
112113
} else if (elementSignature == "I") { //int
113-
jint intElementValue = value->Int32Value();
114+
jint intElementValue = value->Int32Value(context).ToChecked();
114115
jintArray intArr = static_cast<jintArray>(arr);
115116
env.SetIntArrayRegion(intArr, index, 1, &intElementValue);
116117
} else if (elementSignature == "J") { //long
117118
jlong longElementValue;
118119
if (value->IsObject()) {
119120
longElementValue = (jlong) ArgConverter::ConvertToJavaLong(isolate, value);
120121
} else {
121-
longElementValue = (jlong) value->IntegerValue();
122+
longElementValue = (jlong) value->IntegerValue(context).ToChecked();
122123
}
123124
jlongArray longArr = static_cast<jlongArray>(arr);
124125
env.SetLongArrayRegion(longArr, index, 1, &longElementValue);
125126
} else if (elementSignature == "F") { //float
126-
jfloat floatElementValue = (jfloat) value->NumberValue();
127+
jfloat floatElementValue = (jfloat) value->NumberValue(context).ToChecked();
127128
jfloatArray floatArr = static_cast<jfloatArray>(arr);
128129
env.SetFloatArrayRegion(floatArr, index, 1, &floatElementValue);
129130
} else if (elementSignature == "D") { //double
130-
jdouble doubleElementValue = (jdouble) value->NumberValue();
131+
jdouble doubleElementValue = (jdouble) value->NumberValue(context).ToChecked();
131132
jdoubleArray doubleArr = static_cast<jdoubleArray>(arr);
132133
env.SetDoubleArrayRegion(doubleArr, index, 1, &doubleElementValue);
133134
} else { //string or object

0 commit comments

Comments
 (0)