Permalink
Browse files

Update for latest stable version of V8 (4.8)

Closes #32
  • Loading branch information...
1 parent 8e09d7e commit 0e863927116c1aaf4e9d302484ba7e95914d973a @kib357 kib357 committed with Feb 10, 2016
Showing with 29 additions and 19 deletions.
  1. +1 −1 Makefile
  2. +18 −17 binding.cc
  3. +1 −1 build.sh
  4. +9 −0 worker_test.go
View
@@ -1,4 +1,4 @@
-version?=4.3.59
+version?=4.8-lkgr
target?=native # available: x64.debug, ia32.debug, ia32.release, x64.release
test: v8worker.test
View
@@ -9,12 +9,23 @@
using namespace v8;
+class ArrayBufferAllocator : public ArrayBuffer::Allocator {
+ public:
+ virtual void* Allocate(size_t length) {
+ void* data = AllocateUninitialized(length);
+ return data == NULL ? data : memset(data, 0, length);
+ }
+ virtual void* AllocateUninitialized(size_t length) { return malloc(length); }
+ virtual void Free(void* data, size_t) { free(data); }
+};
+
struct worker_s {
int x;
int table_index;
worker_recv_cb cb;
worker_recv_sync_cb sync_cb;
Isolate* isolate;
+ ArrayBufferAllocator allocator;
std::string last_exception;
Persistent<Function> recv;
Persistent<Context> context;
@@ -26,17 +37,6 @@ const char* ToCString(const String::Utf8Value& value) {
return *value ? *value : "<string conversion failed>";
}
-class ArrayBufferAllocator : public ArrayBuffer::Allocator {
- public:
- virtual void* Allocate(size_t length) {
- void* data = AllocateUninitialized(length);
- return data == NULL ? data : memset(data, 0, length);
- }
- virtual void* AllocateUninitialized(size_t length) { return malloc(length); }
- virtual void Free(void* data, size_t) { free(data); }
-};
-
-
// Exception details will be appended to the first argument.
std::string ExceptionString(Isolate* isolate, TryCatch* try_catch) {
std::string out;
@@ -321,21 +321,22 @@ const char* worker_send_sync(worker* w, const char* msg) {
static ArrayBufferAllocator array_buffer_allocator;
void v8_init() {
- V8::Initialize();
-
+ V8::InitializeICU();
Platform* platform = platform::CreateDefaultPlatform();
V8::InitializePlatform(platform);
-
- V8::SetArrayBufferAllocator(&array_buffer_allocator);
+ V8::Initialize();
}
worker* worker_new(worker_recv_cb cb, worker_recv_sync_cb sync_cb, int table_index) {
- Isolate* isolate = Isolate::New();
+ worker* w = new(worker);
+
+ Isolate::CreateParams create_params;
+ create_params.array_buffer_allocator = &w->allocator;
+ Isolate* isolate = Isolate::New(create_params);
Locker locker(isolate);
Isolate::Scope isolate_scope(isolate);
HandleScope handle_scope(isolate);
- worker* w = new(worker);
w->isolate = isolate;
w->isolate->SetCaptureStackTraceForUncaughtExceptions(true);
w->isolate->SetData(0, w);
View
@@ -12,7 +12,7 @@ set -e -x
cd `dirname "${BASH_SOURCE[0]}"`
# build v8
-make -C v8/ i18nsupport=off $target
+GYPFLAGS="-Dv8_use_external_startup_data=0" make -C v8/ i18nsupport=off $target
outdir="`pwd`/v8/out/$target"
View
@@ -61,6 +61,15 @@ func TestBasic(t *testing.T) {
}
}
+func TestUnit8Array(t *testing.T) {
+ worker := New(func(msg string) {}, DiscardSendSync)
+ codeWithArrayBufferAllocator := ` var _utf8len = new Uint8Array(256); $print(_utf8len); `
+ err := worker.Load("buffer.js", codeWithArrayBufferAllocator)
+ if err != nil {
+ t.Fatal(err)
+ }
+}
+
func TestMultipleWorkers(t *testing.T) {
recvCount := 0
worker1 := New(func(msg string) {

0 comments on commit 0e86392

Please sign in to comment.