Skip to content

Commit

Permalink
Update v8 to 7.4.288.25
Browse files Browse the repository at this point in the history
  • Loading branch information
darind committed Apr 30, 2019
1 parent 7c2ae2e commit 3c1a20f
Show file tree
Hide file tree
Showing 362 changed files with 104,015 additions and 110,109 deletions.
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=10
- NDK_VERSION=r19b
- NDK_VERSION=r19c
- 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,4 +1,4 @@
{
"v8Version": "7.3.492.25",
"v8Version": "7.4.288.25",
"mksnapshotParams": "--profile_deserialization --turbo_instruction_scheduling"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
"version": "4.10.2",
"android": "3.3.2"
},
"android_ndk_version": "19b"
"android_ndk_version": "19c"
}
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.
3 changes: 2 additions & 1 deletion test-app/runtime/src/main/cpp/ArgConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ using namespace tns;

void ArgConverter::Init(Isolate* isolate) {
auto cache = GetTypeLongCache(isolate);
auto context = isolate->GetCurrentContext();

auto ft = FunctionTemplate::New(isolate, ArgConverter::NativeScriptLongFunctionCallback);
ft->SetClassName(V8StringConstants::GetLongNumber(isolate));
ft->InstanceTemplate()->Set(V8StringConstants::GetValueOf(isolate), FunctionTemplate::New(isolate, ArgConverter::NativeScriptLongValueOfFunctionCallback));
ft->InstanceTemplate()->Set(V8StringConstants::GetToString(isolate), FunctionTemplate::New(isolate, ArgConverter::NativeScriptLongToStringFunctionCallback));
cache->LongNumberCtorFunc = new Persistent<Function>(isolate, ft->GetFunction());
cache->LongNumberCtorFunc = new Persistent<Function>(isolate, ft->GetFunction(context).ToLocalChecked());

auto nanObject = Number::New(isolate, numeric_limits<double>::quiet_NaN()).As<NumberObject>();
cache->NanNumberObject = new Persistent<NumberObject>(isolate, nanObject);
Expand Down
3 changes: 2 additions & 1 deletion test-app/runtime/src/main/cpp/ArrayBufferHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ ArrayBufferHelper::ArrayBufferHelper()
void ArrayBufferHelper::CreateConvertFunctions(Isolate* isolate, const Local<Object>& global, ObjectManager* objectManager) {
m_objectManager = objectManager;
auto extData = External::New(isolate, this);
auto fromFunc = FunctionTemplate::New(isolate, CreateFromCallbackStatic, extData)->GetFunction();
auto context = isolate->GetCurrentContext();
auto fromFunc = FunctionTemplate::New(isolate, CreateFromCallbackStatic, extData)->GetFunction(context).ToLocalChecked();
auto ctx = isolate->GetCurrentContext();
auto arrBufferCtorFunc = global->Get(ArgConverter::ConvertToV8String(isolate, "ArrayBuffer")).As<Function>();
arrBufferCtorFunc->Set(ctx, ArgConverter::ConvertToV8String(isolate, "from"), fromFunc);
Expand Down
2 changes: 1 addition & 1 deletion test-app/runtime/src/main/cpp/ArrayHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void ArrayHelper::Init(const Local<Context>& context) {
auto success = arr.ToLocal(&arrVal);
if (success) {
auto arrayObj = arrVal.As<Object>();
arrayObj->Set(context, ArgConverter::ConvertToV8String(isolate, "create"), FunctionTemplate::New(isolate, CreateJavaArrayCallback)->GetFunction());
arrayObj->Set(context, ArgConverter::ConvertToV8String(isolate, "create"), FunctionTemplate::New(isolate, CreateJavaArrayCallback)->GetFunction(context).ToLocalChecked());
}
}
}
Expand Down
25 changes: 16 additions & 9 deletions test-app/runtime/src/main/cpp/CallbackHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,9 @@ CallbackHandlers::GetImplementedInterfaces(JEnv& env, const Local<Object>& imple
}

vector<jstring> interfacesToImplement;
auto propNames = implementationObject->GetOwnPropertyNames();
auto isolate = implementationObject->GetIsolate();
auto context = isolate->GetCurrentContext();
auto propNames = implementationObject->GetOwnPropertyNames(context).ToLocalChecked();
for (int i = 0; i < propNames->Length(); i++) {
auto name = propNames->Get(i).As<String>();
auto prop = implementationObject->Get(name);
Expand Down Expand Up @@ -616,8 +617,9 @@ CallbackHandlers::GetMethodOverrides(JEnv& env, const Local<Object>& implementat
}

vector<jstring> methodNames;
auto propNames = implementationObject->GetOwnPropertyNames();
auto isolate = implementationObject->GetIsolate();
auto context = isolate->GetCurrentContext();
auto propNames = implementationObject->GetOwnPropertyNames(context).ToLocalChecked();
for (int i = 0; i < propNames->Length(); i++) {
auto name = propNames->Get(i).As<String>();
auto method = implementationObject->Get(name);
Expand Down Expand Up @@ -842,11 +844,13 @@ Local<Value> CallbackHandlers::CallJSMethod(Isolate* isolate, JNIEnv* _env,
arguments[i] = jsArgs->Get(i);
}

auto context = isolate->GetCurrentContext();

TryCatch tc(isolate);
Local<Value> jsResult;
{
SET_PROFILER_FRAME();
jsResult = jsMethod->Call(jsObject, argc, argc == 0 ? nullptr : arguments.data());
jsMethod->Call(context, jsObject, argc, argc == 0 ? nullptr : arguments.data()).ToLocal(&jsResult);
}

//TODO: if javaResult is a pure js object create a java object that represents this object in java land
Expand Down Expand Up @@ -1043,7 +1047,7 @@ void CallbackHandlers::WorkerGlobalOnMessageCallback(Isolate* isolate, jstring m

auto func = callback.As<Function>();

func->Call(Undefined(isolate), 1, args1);
func->Call(context, Undefined(isolate), 1, args1);
} else {
DEBUG_WRITE(
"WORKER: WorkerGlobalOnMessageCallback couldn't fire a worker's `onmessage` callback because it isn't implemented!");
Expand Down Expand Up @@ -1154,7 +1158,7 @@ CallbackHandlers::WorkerObjectOnMessageCallback(Isolate* isolate, jint workerId,

auto func = callback.As<Function>();

func->Call(Undefined(isolate), 1, args1);
func->Call(context, Undefined(isolate), 1, args1);
} else {
DEBUG_WRITE(
"MAIN: WorkerObjectOnMessageCallback couldn't fire a worker(id=%d) object's `onmessage` callback because it isn't implemented.",
Expand Down Expand Up @@ -1264,7 +1268,7 @@ void CallbackHandlers::WorkerGlobalCloseCallback(const v8::FunctionCallbackInfo<
auto func = callback.As<Function>();

DEBUG_WRITE("WORKER: WorketThreadCloseCallback onclose handle is being called.");
func->Call(Undefined(isolate), 0, args1);
func->Call(context, Undefined(isolate), 0, args1);
DEBUG_WRITE("WORKER: WorketThreadCloseCallback onclose handle was called.");
}

Expand Down Expand Up @@ -1309,7 +1313,8 @@ void CallbackHandlers::CallWorkerScopeOnErrorHandle(Isolate* isolate, TryCatch&

auto func = callback.As<Function>();

auto result = func->Call(Undefined(isolate), 1, args1);
Local<Value> result;
func->Call(context, Undefined(isolate), 1, args1).ToLocal(&result);

// return 'true'-like value, don't bubble up to main Worker.onerror
if (!result.IsEmpty() && result->BooleanValue(context).ToChecked()) {
Expand Down Expand Up @@ -1404,9 +1409,11 @@ CallbackHandlers::CallWorkerObjectOnErrorHandle(Isolate* isolate, jint workerId,

auto func = callback.As<Function>();

// Handle exceptions thrown in onmessage with the worker.onerror handler, if present
auto result = func->Call(Undefined(isolate), 1, args1);
auto context = isolate->GetCurrentContext();

// Handle exceptions thrown in onmessage with the worker.onerror handler, if present
Local<Value> result;
func->Call(context, Undefined(isolate), 1, args1).ToLocal(&result);
if (!result.IsEmpty() && result->BooleanValue(context).ToChecked()) {
// Do nothing, exception is handled and does not need to be raised to application level
return;
Expand Down
2 changes: 1 addition & 1 deletion test-app/runtime/src/main/cpp/JsArgConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ bool JsArgConverter::ConvertJavaScriptBoolean(const Local<Value>& jsValue, int i
auto boolObj = Local<BooleanObject>::Cast(jsValue);
auto val = boolObj->Get(V8StringConstants::GetValueOf(m_isolate));
if (!val.IsEmpty() && val->IsFunction()) {
argValue = val.As<Function>()->Call(boolObj, 0, nullptr)->BooleanValue(context).ToChecked();
argValue = val.As<Function>()->Call(context, boolObj, 0, nullptr).ToLocalChecked()->BooleanValue(context).ToChecked();
} else {
argValue = false;
}
Expand Down
24 changes: 14 additions & 10 deletions test-app/runtime/src/main/cpp/MetadataNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ Local<Object> MetadataNode::CreateArrayWrapper(Isolate* isolate) {
arrayObjectTemplate->SetInternalFieldCount(static_cast<int>(ObjectManager::MetadataNodeKeys::END));
arrayObjectTemplate->SetIndexedPropertyHandler(ArrayIndexedPropertyGetterCallback, ArrayIndexedPropertySetterCallback);

auto arr = arrayObjectTemplate->NewInstance();
auto context = isolate->GetCurrentContext();
auto arr = arrayObjectTemplate->NewInstance(context).ToLocalChecked();
arr->SetPrototype(context, ctorFunc->Get(V8StringConstants::GetPrototype(isolate)));
arr->SetAccessor(context, ArgConverter::ConvertToV8String(isolate, "length"), ArrayLengthGetterCallack, nullptr, Local<Value>(), AccessControl::ALL_CAN_READ, PropertyAttribute::DontDelete);

Expand Down Expand Up @@ -269,7 +269,7 @@ void MetadataNode::NullObjectAccessorGetterCallback(Local<Name> property,const P
auto funcTemplate = FunctionTemplate::New(isolate, MetadataNode::NullValueOfCallback);
auto context = isolate->GetCurrentContext();
thiz->Delete(context, V8StringConstants::GetValueOf(isolate));
thiz->Set(V8StringConstants::GetValueOf(isolate), funcTemplate->GetFunction());
thiz->Set(V8StringConstants::GetValueOf(isolate), funcTemplate->GetFunction(context).ToLocalChecked());
}

info.GetReturnValue().Set(thiz);
Expand Down Expand Up @@ -441,6 +441,8 @@ vector<MetadataNode::MethodCallbackData*> MetadataNode::SetInstanceMethodsFromSt
string lastMethodName;
MethodCallbackData* callbackData = nullptr;

auto context = isolate->GetCurrentContext();

auto origin = Constants::APP_ROOT_FOLDER_PATH + GetOrCreateInternal(treeNode)->m_name;
for (auto i = 0; i < instanceMethodCount; i++) {
auto entry = s_metadataReader.ReadInstanceMethodEntry(&curPtr);
Expand All @@ -466,9 +468,9 @@ vector<MetadataNode::MethodCallbackData*> MetadataNode::SetInstanceMethodsFromSt
auto funcName = ArgConverter::ConvertToV8String(isolate, entry.name);

if (s_profilerEnabled) {
auto func = funcTemplate->GetFunction();
auto func = funcTemplate->GetFunction(context).ToLocalChecked();
Local<Function> wrapperFunc = Wrap(isolate, func, entry.name, origin, false /* isCtorFunc */);
Local<Function> ctorFunc = ctorFuncTemplate->GetFunction();
Local<Function> ctorFunc = ctorFuncTemplate->GetFunction(context).ToLocalChecked();
Local<Object> protoObject = ctorFunc->Get(ArgConverter::ConvertToV8String(isolate, "prototype")).As<Object>();
if (!protoObject.IsEmpty() && !protoObject->IsUndefined() && !protoObject->IsNull()) {
protoObject->Set(funcName, wrapperFunc);
Expand Down Expand Up @@ -632,7 +634,7 @@ void MetadataNode::SetStaticMembers(Isolate* isolate, Local<Function>& ctorFunct
callbackData = new MethodCallbackData(this);
auto funcData = External::New(isolate, callbackData);
auto funcTemplate = FunctionTemplate::New(isolate, MethodCallback, funcData);
auto func = funcTemplate->GetFunction();
auto func = funcTemplate->GetFunction(context).ToLocalChecked();
auto funcName = ArgConverter::ConvertToV8String(isolate, entry.name);
ctorFunction->Set(funcName, Wrap(isolate, func, entry.name, origin, false /* isCtorFunc */));
lastMethodName = entry.name;
Expand All @@ -643,7 +645,7 @@ void MetadataNode::SetStaticMembers(Isolate* isolate, Local<Function>& ctorFunct
//attach .extend function
auto extendFuncName = V8StringConstants::GetExtend(isolate);
auto extendFuncTemplate = FunctionTemplate::New(isolate, ExtendMethodCallback, External::New(isolate, this));
ctorFunction->Set(extendFuncName, extendFuncTemplate->GetFunction());
ctorFunction->Set(extendFuncName, extendFuncTemplate->GetFunction(context).ToLocalChecked());

//get candidates from static fields metadata
auto staticFieldCout = *reinterpret_cast<uint16_t*>(curPtr);
Expand Down Expand Up @@ -742,7 +744,8 @@ Local<FunctionTemplate> MetadataNode::GetConstructorFunctionTemplate(Isolate* is
node->SetMissingBaseMethods(isolate, skippedBaseTypes, instanceMethodData, prototypeTemplate);
}

auto ctorFunc = ctorFuncTemplate->GetFunction();
auto context = isolate->GetCurrentContext();
auto ctorFunc = ctorFuncTemplate->GetFunction(context).ToLocalChecked();

auto origin = Constants::APP_ROOT_FOLDER_PATH + node->m_name;

Expand Down Expand Up @@ -1403,9 +1406,9 @@ void MetadataNode::ExtendMethodCallback(const v8::FunctionCallbackInfo<v8::Value
auto extendFuncTemplate = FunctionTemplate::New(isolate, ExtendedClassConstructorCallback, extendData);
extendFuncTemplate->InstanceTemplate()->SetInternalFieldCount(static_cast<int>(ObjectManager::MetadataNodeKeys::END));

auto extendFunc = extendFuncTemplate->GetFunction();
auto prototypeName = V8StringConstants::GetPrototype(isolate);
auto context = isolate->GetCurrentContext();
auto extendFunc = extendFuncTemplate->GetFunction(context).ToLocalChecked();
auto prototypeName = V8StringConstants::GetPrototype(isolate);
implementationObject->SetPrototype(context, baseClassCtorFunc->Get(prototypeName));
implementationObject->SetAccessor(context, V8StringConstants::GetSuper(isolate), SuperAccessorGetterCallback, nullptr, implementationObject);

Expand Down Expand Up @@ -1841,7 +1844,8 @@ void MetadataNode::RegisterSymbolHasInstanceCallback(Isolate* isolate, MetadataE

auto extData = External::New(isolate, clazz);
auto hasInstanceTemplate = FunctionTemplate::New(isolate, MetadataNode::SymbolHasInstanceCallback, extData);
auto hasInstanceFunc = hasInstanceTemplate->GetFunction();
auto context = isolate->GetCurrentContext();
auto hasInstanceFunc = hasInstanceTemplate->GetFunction(context).ToLocalChecked();
PropertyDescriptor descriptor(hasInstanceFunc, false);
auto hasInstanceSymbol = Symbol::GetHasInstance(isolate);
interface->ToObject(isolate)->DefineProperty(isolate->GetCurrentContext(), hasInstanceSymbol, descriptor);
Expand Down
5 changes: 3 additions & 2 deletions test-app/runtime/src/main/cpp/ModuleInternal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void ModuleInternal::Init(Isolate* isolate, const string& baseDir) {
m_requireFactoryFunction = new Persistent<Function>(isolate, requireFactoryFunction);

auto requireFuncTemplate = FunctionTemplate::New(isolate, RequireCallback, External::New(isolate, this));
auto requireFunc = requireFuncTemplate->GetFunction();
auto requireFunc = requireFuncTemplate->GetFunction(context).ToLocalChecked();
global->Set(ArgConverter::ConvertToV8String(isolate, "__nativeRequire"), requireFunc);
m_requireFunction = new Persistent<Function>(isolate, requireFunc);

Expand Down Expand Up @@ -339,7 +339,8 @@ Local<Object> ModuleInternal::LoadModule(Isolate* isolate, const string& moduleP
auto thiz = Object::New(isolate);
auto extendsName = ArgConverter::ConvertToV8String(isolate, "__extends");
thiz->Set(extendsName, isolate->GetCurrentContext()->Global()->Get(extendsName));
moduleFunc->Call(thiz, sizeof(requireArgs) / sizeof(Local<Value> ), requireArgs);
auto context = isolate->GetCurrentContext();
moduleFunc->Call(context, thiz, sizeof(requireArgs) / sizeof(Local<Value> ), requireArgs);

if (tc.HasCaught()) {
throw NativeScriptException(tc, "Error calling module function ");
Expand Down
2 changes: 1 addition & 1 deletion test-app/runtime/src/main/cpp/NativeScriptException.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ void NativeScriptException::CallJsFuncWithErr(Local<Value> errObj, jboolean isDi
auto thiz = Object::New(isolate);
auto func = handler.As<Function>();

func->Call(thiz, 1, &errObj);
func->Call(context, thiz, 1, &errObj);
}
}

Expand Down
5 changes: 3 additions & 2 deletions test-app/runtime/src/main/cpp/ObjectManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ void ObjectManager::Init(Isolate *isolate) {
auto jsWrapperFuncTemplate = FunctionTemplate::New(isolate, JSWrapperConstructorCallback);
jsWrapperFuncTemplate->InstanceTemplate()->SetInternalFieldCount(
static_cast<int>(MetadataNodeKeys::END));
auto jsWrapperFunc = jsWrapperFuncTemplate->GetFunction();
auto context = isolate->GetCurrentContext();
auto jsWrapperFunc = jsWrapperFuncTemplate->GetFunction(context).ToLocalChecked();
m_poJsWrapperFunc = new Persistent<Function>(isolate, jsWrapperFunc);

if (m_markingMode != JavaScriptMarkingMode::None) {
Expand Down Expand Up @@ -569,7 +570,7 @@ void ObjectManager::MarkReachableObjects(Isolate *isolate, const Local<Object> &
if (propName->IsString()) {
auto name = propName.As<String>();

bool isPropDescriptor = o->HasRealNamedCallbackProperty(name);
bool isPropDescriptor = o->HasRealNamedCallbackProperty(context, name).ToChecked();
if (isPropDescriptor) {
Local<Value> getter;
Local<Value> setter;
Expand Down
11 changes: 6 additions & 5 deletions test-app/runtime/src/main/cpp/Profiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ void Profiler::Init(Isolate* isolate, const Local<Object>& globalObj, const stri
m_appName = appName;
m_outputDir = outputDir;
auto extData = External::New(isolate, this);
globalObj->Set(ArgConverter::ConvertToV8String(isolate, "__startCPUProfiler"), FunctionTemplate::New(isolate, Profiler::StartCPUProfilerCallback, extData)->GetFunction());
globalObj->Set(ArgConverter::ConvertToV8String(isolate, "__stopCPUProfiler"), FunctionTemplate::New(isolate, Profiler::StopCPUProfilerCallback, extData)->GetFunction());
globalObj->Set(ArgConverter::ConvertToV8String(isolate, "__heapSnapshot"), FunctionTemplate::New(isolate, Profiler::HeapSnapshotMethodCallback, extData)->GetFunction());
globalObj->Set(ArgConverter::ConvertToV8String(isolate, "__startNDKProfiler"), FunctionTemplate::New(isolate, Profiler::StartNDKProfilerCallback, extData)->GetFunction());
globalObj->Set(ArgConverter::ConvertToV8String(isolate, "__stopNDKProfiler"), FunctionTemplate::New(isolate, Profiler::StopNDKProfilerCallback, extData)->GetFunction());
Local<Context> context = isolate->GetCurrentContext();
globalObj->Set(ArgConverter::ConvertToV8String(isolate, "__startCPUProfiler"), FunctionTemplate::New(isolate, Profiler::StartCPUProfilerCallback, extData)->GetFunction(context).ToLocalChecked());
globalObj->Set(ArgConverter::ConvertToV8String(isolate, "__stopCPUProfiler"), FunctionTemplate::New(isolate, Profiler::StopCPUProfilerCallback, extData)->GetFunction(context).ToLocalChecked());
globalObj->Set(ArgConverter::ConvertToV8String(isolate, "__heapSnapshot"), FunctionTemplate::New(isolate, Profiler::HeapSnapshotMethodCallback, extData)->GetFunction(context).ToLocalChecked());
globalObj->Set(ArgConverter::ConvertToV8String(isolate, "__startNDKProfiler"), FunctionTemplate::New(isolate, Profiler::StartNDKProfilerCallback, extData)->GetFunction(context).ToLocalChecked());
globalObj->Set(ArgConverter::ConvertToV8String(isolate, "__stopNDKProfiler"), FunctionTemplate::New(isolate, Profiler::StopNDKProfilerCallback, extData)->GetFunction(context).ToLocalChecked());
}

void Profiler::StartCPUProfilerCallback(const v8::FunctionCallbackInfo<v8::Value>& args) {
Expand Down
2 changes: 1 addition & 1 deletion test-app/runtime/src/main/cpp/Runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ static void InitializeV8() {
// timeout=0 flag.
V8InspectorPlatform::CreateDefaultPlatform();
#else
v8::platform::CreateDefaultPlatform();
v8::platform::NewDefaultPlatform().release();
#endif

V8::InitializePlatform(Runtime::platform);
Expand Down
Loading

0 comments on commit 3c1a20f

Please sign in to comment.