Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
chakrashim: implement new APIs added in v8
Browse files Browse the repository at this point in the history
Added new v8 APIs to Chakrashim
Context::SetEmbedderData
Context::GetEmbedderData
Isolate::CancelTerminateExecution
Isolate::TerminateExecution
Object::DefineOwnProperty

Updated v8 version

PR-URL: #40
Reviewed-By: Jianchun Xu <Jianchun.Xu@microsoft.com>
Reviewed-By: Kunal Pathak <Kunal.Pathak@microsoft.com>
  • Loading branch information
agarwal-sandeep committed Mar 21, 2016
1 parent 58ff8db commit c6d6e6b
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 10 deletions.
6 changes: 3 additions & 3 deletions deps/chakrashim/include/v8-debug.h
Expand Up @@ -54,9 +54,9 @@ class V8_EXPORT Debug {
static void Dispose();
static void DisableAgent() {}
static bool IsAgentEnabled();
static void ProcessDebugMessages() {}
static Local<Context> GetDebugContext();
static void SetMessageHandler(MessageHandler handler) {}
static void ProcessDebugMessages(Isolate* isolate) {}
static Local<Context> GetDebugContext(Isolate* isolate);
static void SetMessageHandler(Isolate* isolate, MessageHandler handler) {}
static void SendCommand(Isolate* isolate,
const uint16_t* command, int length,
ClientData* client_data = NULL) {
Expand Down
6 changes: 3 additions & 3 deletions deps/chakrashim/include/v8-version.h
Expand Up @@ -32,9 +32,9 @@
// NOTE these macros are used by some of the tool scripts and the build
// system so their names cannot be changed without changing the scripts.
#define V8_MAJOR_VERSION 4
#define V8_MINOR_VERSION 8
#define V8_BUILD_NUMBER 271
#define V8_PATCH_LEVEL 17
#define V8_MINOR_VERSION 9
#define V8_BUILD_NUMBER 385
#define V8_PATCH_LEVEL 27

// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
Expand Down
10 changes: 10 additions & 0 deletions deps/chakrashim/include/v8.h
Expand Up @@ -308,6 +308,7 @@ class Local {
template <class F> friend class MaybeLocal;
template <class F> friend class PersistentBase;
template <class F, class M> friend class Persistent;
template <class F> friend class Local;
friend V8_EXPORT Local<Primitive> Undefined(Isolate* isolate);
friend V8_EXPORT Local<Primitive> Null(Isolate* isolate);
friend V8_EXPORT Local<Boolean> True(Isolate* isolate);
Expand Down Expand Up @@ -1268,6 +1269,10 @@ class V8_EXPORT Object : public Value {
V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context, uint32_t index,
Local<Value> value);

V8_WARN_UNUSED_RESULT Maybe<bool> DefineOwnProperty(
Local<Context> context, Local<Name> key, Local<Value> value,
PropertyAttribute attributes = None);

V8_DEPRECATE_SOON("Use maybe version",
bool ForceSet(Handle<Value> key, Handle<Value> value,
PropertyAttribute attribs = None));
Expand Down Expand Up @@ -2208,6 +2213,9 @@ class V8_EXPORT Isolate {
GCCallback callback, GCType gc_type_filter = kGCTypeAll);
void RemoveGCEpilogueCallback(GCCallback callback);

void CancelTerminateExecution();
void TerminateExecution();

void SetCounterFunction(CounterLookupCallback);
void SetCreateHistogramFunction(CreateHistogramCallback);
void SetAddHistogramSampleFunction(AddHistogramSampleCallback);
Expand Down Expand Up @@ -2371,6 +2379,8 @@ class V8_EXPORT Context {
Isolate* GetIsolate();
void* GetAlignedPointerFromEmbedderData(int index);
void SetAlignedPointerInEmbedderData(int index, void* value);
void SetEmbedderData(int index, Local<Value> value);
Local<Value> GetEmbedderData(int index);
void SetSecurityToken(Handle<Value> token);
Handle<Value> GetSecurityToken();
};
Expand Down
8 changes: 8 additions & 0 deletions deps/chakrashim/src/v8context.cc
Expand Up @@ -98,6 +98,14 @@ void Context::SetAlignedPointerInEmbedderData(int index, void* value) {
return contextShim->SetAlignedPointerInEmbedderData(index, value);
}

void Context::SetEmbedderData(int index, Local<Value> value) {
SetAlignedPointerInEmbedderData(index, *value);
}

Local<Value> Context::GetEmbedderData(int index) {
return Local<Value>(GetAlignedPointerFromEmbedderData(index));
}

void Context::SetSecurityToken(Handle<Value> token) {
// CHAKRA-TODO
}
Expand Down
3 changes: 1 addition & 2 deletions deps/chakrashim/src/v8debug.cc
Expand Up @@ -57,9 +57,8 @@ bool Debug::IsAgentEnabled() {
return g_EnableDebug;
}

Local<Context> Debug::GetDebugContext() {
Local<Context> Debug::GetDebugContext(Isolate* isolate) {
if (g_debugContext == JS_INVALID_REFERENCE) {
Isolate* isolate = Isolate::GetCurrent();
HandleScope scope(isolate);
g_debugContext = *Context::New(isolate);
JsAddRef(g_debugContext, nullptr);
Expand Down
8 changes: 8 additions & 0 deletions deps/chakrashim/src/v8isolate.cc
Expand Up @@ -136,6 +136,14 @@ void Isolate::AddGCEpilogueCallback(
void Isolate::RemoveGCEpilogueCallback(GCCallback callback) {
}

void Isolate::CancelTerminateExecution() {
jsrt::IsolateShim::FromIsolate(this)->EnableExecution();
}

void Isolate::TerminateExecution() {
jsrt::IsolateShim::FromIsolate(this)->DisableExecution();
}

void Isolate::SetCounterFunction(CounterLookupCallback) {
CHAKRA_UNIMPLEMENTED();
}
Expand Down
6 changes: 6 additions & 0 deletions deps/chakrashim/src/v8object.cc
Expand Up @@ -129,6 +129,12 @@ Maybe<bool> Object::Set(Local<Context> context,
return Just(true);
}

Maybe<bool> Object::DefineOwnProperty(
Local<Context> context, Local<Name> key, Local<Value> value,
PropertyAttribute attributes) {
return Set(key, value, attributes, /*force*/true);
}

bool Object::Set(uint32_t index, Handle<Value> value) {
return FromMaybe(Set(Local<Context>(), index, value));
}
Expand Down
4 changes: 2 additions & 2 deletions deps/chakrashim/src/v8v8.cc
Expand Up @@ -157,15 +157,15 @@ bool V8::Dispose() {
}

void V8::TerminateExecution(Isolate* isolate) {
jsrt::IsolateShim::FromIsolate(isolate)->DisableExecution();
isolate->TerminateExecution();
}

bool V8::IsExeuctionDisabled(Isolate* isolate) {
return jsrt::IsolateShim::FromIsolate(isolate)->IsExeuctionDisabled();
}

void V8::CancelTerminateExecution(Isolate* isolate) {
jsrt::IsolateShim::FromIsolate(isolate)->EnableExecution();
isolate->CancelTerminateExecution();
}

void V8::FromJustIsNothing() {
Expand Down

0 comments on commit c6d6e6b

Please sign in to comment.