cached_data_buf.ToLocalChecked()

This commit is contained in:
Igor Klopov 2016-09-18 12:25:05 +03:00
parent 31edd0abe4
commit d08b6a78fb
4 changed files with 23 additions and 14 deletions

View File

@ -40,10 +40,18 @@ index 7b6ffc8..5c99f80 100644
V(readable_string, "readable") \
V(received_shutdown_string, "receivedShutdown") \
diff --git a/src/node_contextify.cc b/src/node_contextify.cc
index 7404bbb..8cd1293 100644
index 7404bbb..ecf9444 100644
--- a/src/node_contextify.cc
+++ b/src/node_contextify.cc
@@ -11,10 +11,11 @@
@@ -1,6 +1,7 @@
#include "node.h"
+#include "node_buffer.h"
#include "node_internals.h"
#include "node_watchdog.h"
#include "base-object.h"
#include "base-object-inl.h"
#include "env.h"
@@ -11,10 +12,11 @@
namespace node {
@ -55,7 +63,7 @@ index 7404bbb..8cd1293 100644
using v8::Debug;
using v8::EscapableHandleScope;
using v8::External;
@@ -474,28 +475,60 @@ class ContextifyScript : public BaseObject {
@@ -474,28 +476,61 @@ class ContextifyScript : public BaseObject {
Local<String> code = args[0]->ToString(env->isolate());
Local<String> filename = GetFilenameArg(args, 1);
Local<Integer> lineOffset = GetLineOffsetArg(args, 1);
@ -70,9 +78,10 @@ index 7404bbb..8cd1293 100644
+ ScriptCompiler::CachedData* cached_data = nullptr;
+ if (!cached_data_buf.IsEmpty()) {
+ auto cached_data_local = cached_data_buf.ToLocalChecked();
+ cached_data = new ScriptCompiler::CachedData(
+ reinterpret_cast<uint8_t*>(Buffer::Data(cached_data_buf)),
+ Buffer::Length(cached_data_buf));
+ reinterpret_cast<uint8_t*>(Buffer::Data(cached_data_local)),
+ Buffer::Length(cached_data_local));
+ }
+
ScriptOrigin origin(filename, lineOffset, columnOffset);
@ -119,7 +128,7 @@ index 7404bbb..8cd1293 100644
static bool InstanceOf(Environment* env, const Local<Value>& value) {
return !value.IsEmpty() &&
@@ -644,10 +677,47 @@ class ContextifyScript : public BaseObject {
@@ -644,10 +679,47 @@ class ContextifyScript : public BaseObject {
return defaultFilename;
return value->ToString(args.GetIsolate());
}

View File

@ -7,10 +7,10 @@ PR-URL: https://github.com/nodejs/node/pull/5159
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
diff --git a/src/node_contextify.cc b/src/node_contextify.cc
index 8cd1293..23b938a 100644
index ecf9444..8769b53 100644
--- a/src/node_contextify.cc
+++ b/src/node_contextify.cc
@@ -499,11 +499,11 @@ class ContextifyScript : public BaseObject {
@@ -501,11 +501,11 @@ class ContextifyScript : public BaseObject {
if (source.GetCachedData() != nullptr)
compile_options = ScriptCompiler::kConsumeCodeCache;
else if (produce_cached_data)
@ -23,7 +23,7 @@ index 8cd1293..23b938a 100644
compile_options);
if (v8_script.IsEmpty()) {
@@ -511,11 +511,12 @@ class ContextifyScript : public BaseObject {
@@ -513,11 +513,12 @@ class ContextifyScript : public BaseObject {
AppendExceptionLine(env, try_catch.Exception(), try_catch.Message());
}
try_catch.ReThrow();

View File

@ -29,10 +29,10 @@ index 5c99f80..c0b6dcd 100644
V(oncertcb_string, "oncertcb") \
V(onclose_string, "_onclose") \
diff --git a/src/node_contextify.cc b/src/node_contextify.cc
index 23b938a..5d312b7 100644
index 8769b53..4f63c20 100644
--- a/src/node_contextify.cc
+++ b/src/node_contextify.cc
@@ -520,15 +520,21 @@ class ContextifyScript : public BaseObject {
@@ -522,15 +522,21 @@ class ContextifyScript : public BaseObject {
args.This()->Set(
env->cached_data_rejected_string(),
Boolean::New(env->isolate(), source.GetCachedData()->rejected));

View File

@ -259,7 +259,7 @@
process.nextTick(function() {
--- node/src/node_contextify.cc
+++ node/src/node_contextify.cc
@@ -477,10 +477,11 @@
@@ -478,10 +478,11 @@
Local<Integer> lineOffset = GetLineOffsetArg(args, 1);
Local<Integer> columnOffset = GetColumnOffsetArg(args, 1);
bool display_errors = GetDisplayErrorsArg(args, 1);
@ -271,7 +271,7 @@
return;
}
@@ -499,22 +500,37 @@
@@ -501,22 +502,37 @@
if (source.GetCachedData() != nullptr)
compile_options = ScriptCompiler::kConsumeCodeCache;
else if (produce_cached_data)
@ -309,7 +309,7 @@
if (compile_options == ScriptCompiler::kConsumeCodeCache) {
args.This()->Set(
@@ -721,10 +737,24 @@
@@ -723,10 +739,24 @@
return value->IsTrue();
}