Skip to content

Upgrade V8 to 7.1.302.31 #1233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
env:
global:
- NODE_VERSION=6.11.1
- NDK_VERSION=r17b
- NDK_VERSION=r18b
- DATE=$(date +%Y-%m-%d)
- PACKAGE_VERSION=next-$DATE-$TRAVIS_BUILD_NUMBER
- EMULATOR_API_LEVEL=21
Expand Down
2 changes: 1 addition & 1 deletion build-artifacts/project-template-gradle/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"v8Version": "6.9.427.23"
"v8Version": "7.1.302.31"
}
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"**/*"
],
"gradle": {
"version": "4.10.2",
"android": "3.2.1"
}
"version": "4.10.2",
"android": "3.2.1"
},
"android_ndk_version": "18b"
}
Binary file modified test-app/app/src/main/assets/app/modules/libCalc-arm.so
Binary file not shown.
Binary file modified test-app/app/src/main/assets/app/modules/libCalc-arm64.so
Binary file not shown.
Binary file modified test-app/app/src/main/assets/app/modules/libCalc-x86.so
Binary file not shown.
61 changes: 21 additions & 40 deletions test-app/app/src/main/assets/app/tests/exceptionHandlingTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ describe("Tests exception handling ", function () {

var eh = new EH();

try
{
try {
eh.triggerEvent1("test", 5);
}
catch (e)
{
catch (e) {
exceptionCaught = true;
sameExObject = e === ex;
__log("e=" + e);
Expand Down Expand Up @@ -71,16 +69,13 @@ describe("Tests exception handling ", function () {

var eh = new EH();

try
{
try {
eh.triggerEvent1("test", 5);
}
catch (e)
{
catch (e) {
exceptionCaught = true;
nativeExceptionFound = e.nativeException !== undefined;
if (nativeExceptionFound)
{
if (nativeExceptionFound) {
exMsg = e.nativeException.getMessage();
}
}
Expand Down Expand Up @@ -111,13 +106,11 @@ describe("Tests exception handling ", function () {

var eh = new EH();

try
{
try {
eh.triggerEvent1WithCatchClause("test", 5);
exceptionCaught = false;
}
catch (e)
{
catch (e) {
exceptionCaught = true;
}

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

var eh = new EH();

try
{
try {
eh.triggerEvent1WithCatchClause("test", 5);
exceptionCaught = false;
}
catch (e)
{
catch (e) {
exceptionCaught = true;
}

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

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

try
{
try {
dummy.methodThatThrowsException();
}
catch (e)
{
catch (e) {
exceptionCaught = true;
}

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

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

try
{
try {
dummy.methodThatThrowsException();
}
catch (e)
{
catch (e) {
var nativeException = e.nativeException;
}

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

var exceptionCaught = false;

try
{
try {
var dummy = new com.tns.tests.DummyClass(true /* throwsException */);
}
catch (e)
{
catch (e) {
exceptionCaught = true;
}

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

expect(arrLength).toEqual(1);

try
{
try {
var dummy = arr[arrLength];

var name = dummy.getName();
}
catch (e)
{
catch (e) {
exceptionCaught = true;
}

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

var last = arr[arrLength - 1];

try
{
try {
arr[arrLength] = last;
}
catch (e)
{
catch (e) {
exceptionCaught = true;
}

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

// run this test only for API level bigger than 25 as we have handling there
Expand Down
18 changes: 5 additions & 13 deletions test-app/runtime/src/main/cpp/ArgConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ int64_t ArgConverter::ConvertToJavaLong(Isolate* isolate, const Local<Value>& va

assert(!valueProp.IsEmpty());

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

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

Expand All @@ -241,7 +241,8 @@ string ArgConverter::ConvertToString(const v8::Local<String>& s) {
if (s.IsEmpty()) {
return string();
} else {
String::Utf8Value str(s);
auto isolate = v8::Isolate::GetCurrent();
String::Utf8Value str(isolate, s);
return string(*str);
}
}
Expand All @@ -259,7 +260,8 @@ u16string ArgConverter::ConvertToUtf16String(const v8::Local<String>& s) {

jstring ArgConverter::ConvertToJavaString(const Local<Value>& value) {
JEnv env;
String::Value stringValue(value);
auto isolate = v8::Isolate::GetCurrent();
String::Value stringValue(isolate, value);
return env.NewString((const jchar*) *stringValue, stringValue.length());
}

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

Local<String> ArgConverter::ConvertToV8UTF16String(Isolate* isolate, const string& string) {
auto utf16str = Util::ConvertFromUtf8ToUtf16(string);

return ConvertToV8UTF16String(isolate, utf16str);
}

Local<String> ArgConverter::ConvertToV8UTF16String(Isolate* isolate, const u16string& utf16string) {
return String::NewFromTwoByte(isolate, ((const uint16_t*) utf16string.data()));
}

Local<String> ArgConverter::ConvertToV8UTF16String(v8::Isolate* isolate, const uint16_t* utf16string, int size) {
return String::NewFromTwoByte(isolate, utf16string, NewStringType::kNormal, size).ToLocalChecked();
}

std::map<Isolate*, ArgConverter::TypeLongOperationsCache*> ArgConverter::s_type_long_operations_cache;
4 changes: 0 additions & 4 deletions test-app/runtime/src/main/cpp/ArgConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ class ArgConverter {

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

static v8::Local<v8::String> ConvertToV8UTF16String(v8::Isolate* isolate, const std::string& string);

static v8::Local<v8::String> ConvertToV8UTF16String(v8::Isolate* isolate, const uint16_t* utf16string, int size);

static v8::Local<v8::String> ConvertToV8UTF16String(v8::Isolate* isolate, const std::u16string& utf16string);

private:
Expand Down
17 changes: 9 additions & 8 deletions test-app/runtime/src/main/cpp/ArrayElementAccessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,51 +83,52 @@ void ArrayElementAccessor::SetArrayElement(Isolate* isolate, const Local<Object>
HandleScope handleScope(isolate);
auto runtime = Runtime::GetRuntime(isolate);
auto objectManager = runtime->GetObjectManager();
auto context = isolate->GetCurrentContext();

auto arr = objectManager->GetJavaObjectByJsObject(array);

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

if (elementSignature == "Z") { //bool
jboolean boolElementValue = (jboolean) value->BooleanValue();
jboolean boolElementValue = (jboolean) value->BooleanValue(context).ToChecked();
jbooleanArray boolArr = static_cast<jbooleanArray>(arr);
env.SetBooleanArrayRegion(boolArr, index, 1, &boolElementValue);
} else if (elementSignature == "B") { //byte
jbyte byteElementValue = (jbyte) value->Int32Value();
jbyte byteElementValue = (jbyte) value->Int32Value(context).ToChecked();
jbyteArray byteArr = static_cast<jbyteArray>(arr);
env.SetByteArrayRegion(byteArr, index, 1, &byteElementValue);
} else if (elementSignature == "C") { //char
String::Utf8Value utf8(value->ToString());
String::Utf8Value utf8(isolate, value->ToString(isolate));
JniLocalRef s(env.NewString((jchar*) *utf8, 1));
const char* singleChar = env.GetStringUTFChars(s, &isCopy);
jchar charElementValue = *singleChar;
env.ReleaseStringUTFChars(s, singleChar);
jcharArray charArr = static_cast<jcharArray>(arr);
env.SetCharArrayRegion(charArr, index, 1, &charElementValue);
} else if (elementSignature == "S") { //short
jshort shortElementValue = (jshort) value->Int32Value();
jshort shortElementValue = (jshort) value->Int32Value(context).ToChecked();
jshortArray shortArr = static_cast<jshortArray>(arr);
env.SetShortArrayRegion(shortArr, index, 1, &shortElementValue);
} else if (elementSignature == "I") { //int
jint intElementValue = value->Int32Value();
jint intElementValue = value->Int32Value(context).ToChecked();
jintArray intArr = static_cast<jintArray>(arr);
env.SetIntArrayRegion(intArr, index, 1, &intElementValue);
} else if (elementSignature == "J") { //long
jlong longElementValue;
if (value->IsObject()) {
longElementValue = (jlong) ArgConverter::ConvertToJavaLong(isolate, value);
} else {
longElementValue = (jlong) value->IntegerValue();
longElementValue = (jlong) value->IntegerValue(context).ToChecked();
}
jlongArray longArr = static_cast<jlongArray>(arr);
env.SetLongArrayRegion(longArr, index, 1, &longElementValue);
} else if (elementSignature == "F") { //float
jfloat floatElementValue = (jfloat) value->NumberValue();
jfloat floatElementValue = (jfloat) value->NumberValue(context).ToChecked();
jfloatArray floatArr = static_cast<jfloatArray>(arr);
env.SetFloatArrayRegion(floatArr, index, 1, &floatElementValue);
} else if (elementSignature == "D") { //double
jdouble doubleElementValue = (jdouble) value->NumberValue();
jdouble doubleElementValue = (jdouble) value->NumberValue(context).ToChecked();
jdoubleArray doubleArr = static_cast<jdoubleArray>(arr);
env.SetDoubleArrayRegion(doubleArr, index, 1, &doubleElementValue);
} else { //string or object
Expand Down
Loading