From 939278ac059b44439d41aab12bf552c8ae3c52d0 Mon Sep 17 00:00:00 2001 From: Refael Ackermann Date: Mon, 29 Sep 2014 13:20:04 +0400 Subject: deps: update v8 to 3.28.73 Reviewed-By: Fedor Indutny PR-URL: https://github.com/joyent/node/pull/8476 --- deps/v8/samples/lineprocessor.cc | 80 ++++++---------------------------------- deps/v8/samples/process.cc | 17 ++++++--- deps/v8/samples/samples.gyp | 3 +- deps/v8/samples/shell.cc | 32 +++++++++++++--- 4 files changed, 50 insertions(+), 82 deletions(-) (limited to 'deps/v8/samples') diff --git a/deps/v8/samples/lineprocessor.cc b/deps/v8/samples/lineprocessor.cc index f259ea4e94..9b627f3019 100644 --- a/deps/v8/samples/lineprocessor.cc +++ b/deps/v8/samples/lineprocessor.cc @@ -25,14 +25,15 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include +#include -#include +#include +#include #include -#include #include #include +#include /** * This sample program should demonstrate certain aspects of debugging @@ -69,25 +70,6 @@ while (true) { var res = line + " | " + line; print(res); } - - * - * When run with "-p" argument, the program starts V8 Debugger Agent and - * allows remote debugger to attach and debug JavaScript code. - * - * Interesting aspects: - * 1. Wait for remote debugger to attach - * Normally the program compiles custom script and immediately runs it. - * If programmer needs to debug script from the very beginning, he should - * run this sample program with "--wait-for-connection" command line parameter. - * This way V8 will suspend on the first statement and wait for - * debugger to attach. - * - * 2. Unresponsive V8 - * V8 Debugger Agent holds a connection with remote debugger, but it does - * respond only when V8 is running some script. In particular, when this program - * is waiting for input, all requests from debugger get deferred until V8 - * is called again. See how "--callback" command-line parameter in this sample - * fixes this issue. */ enum MainCycleType { @@ -109,41 +91,16 @@ bool RunCppCycle(v8::Handle script, v8::Persistent debug_message_context; -void DispatchDebugMessages() { - // We are in some random thread. We should already have v8::Locker acquired - // (we requested this when registered this callback). We was called - // because new debug messages arrived; they may have already been processed, - // but we shouldn't worry about this. - // - // All we have to do is to set context and call ProcessDebugMessages. - // - // We should decide which V8 context to use here. This is important for - // "evaluate" command, because it must be executed some context. - // In our sample we have only one context, so there is nothing really to - // think about. - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - v8::HandleScope handle_scope(isolate); - v8::Local context = - v8::Local::New(isolate, debug_message_context); - v8::Context::Scope scope(context); - - v8::Debug::ProcessDebugMessages(); -} - - int RunMain(int argc, char* argv[]) { v8::V8::SetFlagsFromCommandLine(&argc, argv, true); - v8::Isolate* isolate = v8::Isolate::GetCurrent(); + v8::Isolate* isolate = v8::Isolate::New(); + v8::Isolate::Scope isolate_scope(isolate); v8::HandleScope handle_scope(isolate); v8::Handle script_source; v8::Handle script_name; int script_param_counter = 0; - int port_number = -1; - bool wait_for_connection = false; - bool support_callback = false; - MainCycleType cycle_type = CycleInCpp; for (int i = 1; i < argc; i++) { @@ -156,13 +113,6 @@ int RunMain(int argc, char* argv[]) { cycle_type = CycleInCpp; } else if (strcmp(str, "--main-cycle-in-js") == 0) { cycle_type = CycleInJs; - } else if (strcmp(str, "--callback") == 0) { - support_callback = true; - } else if (strcmp(str, "--wait-for-connection") == 0) { - wait_for_connection = true; - } else if (strcmp(str, "-p") == 0 && i + 1 < argc) { - port_number = atoi(argv[i + 1]); // NOLINT - i++; } else if (strncmp(str, "--", 2) == 0) { printf("Warning: unknown flag %s.\nTry --help for options\n", str); } else if (strcmp(str, "-e") == 0 && i + 1 < argc) { @@ -212,16 +162,6 @@ int RunMain(int argc, char* argv[]) { debug_message_context.Reset(isolate, context); - v8::Locker locker(isolate); - - if (support_callback) { - v8::Debug::SetDebugMessageDispatchHandler(DispatchDebugMessages, true); - } - - if (port_number != -1) { - v8::Debug::EnableAgent("lineprocessor", port_number, wait_for_connection); - } - bool report_exceptions = true; v8::Handle script; @@ -265,7 +205,6 @@ bool RunCppCycle(v8::Handle script, v8::Local context, bool report_exceptions) { v8::Isolate* isolate = context->GetIsolate(); - v8::Locker lock(isolate); v8::Handle fun_name = v8::String::NewFromUtf8(isolate, "ProcessLine"); @@ -316,8 +255,12 @@ bool RunCppCycle(v8::Handle script, int main(int argc, char* argv[]) { v8::V8::InitializeICU(); + v8::Platform* platform = v8::platform::CreateDefaultPlatform(); + v8::V8::InitializePlatform(platform); int result = RunMain(argc, argv); v8::V8::Dispose(); + v8::V8::ShutdownPlatform(); + delete platform; return result; } @@ -362,7 +305,7 @@ void ReportException(v8::Isolate* isolate, v8::TryCatch* try_catch) { printf("%s\n", exception_string); } else { // Print (filename):(line number): (message). - v8::String::Utf8Value filename(message->GetScriptResourceName()); + v8::String::Utf8Value filename(message->GetScriptOrigin().ResourceName()); const char* filename_string = ToCString(filename); int linenum = message->GetLineNumber(); printf("%s:%i: %s\n", filename_string, linenum, exception_string); @@ -423,7 +366,6 @@ v8::Handle ReadLine() { char* res; { - v8::Unlocker unlocker(v8::Isolate::GetCurrent()); res = fgets(buffer, kBufferSize, stdin); } v8::Isolate* isolate = v8::Isolate::GetCurrent(); diff --git a/deps/v8/samples/process.cc b/deps/v8/samples/process.cc index 37b4d39208..4db7eeb7b8 100644 --- a/deps/v8/samples/process.cc +++ b/deps/v8/samples/process.cc @@ -25,10 +25,12 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include +#include + +#include -#include #include +#include #ifdef COMPRESS_STARTUP_DATA_BZ2 #error Using compressed startup data is not supported for this sample @@ -574,7 +576,7 @@ StringHttpRequest::StringHttpRequest(const string& path, void ParseOptions(int argc, char* argv[], - map& options, + map* options, string* file) { for (int i = 1; i < argc; i++) { string arg = argv[i]; @@ -584,7 +586,7 @@ void ParseOptions(int argc, } else { string key = arg.substr(0, index); string value = arg.substr(index+1); - options[key] = value; + (*options)[key] = value; } } } @@ -644,14 +646,17 @@ void PrintMap(map* m) { int main(int argc, char* argv[]) { v8::V8::InitializeICU(); + v8::Platform* platform = v8::platform::CreateDefaultPlatform(); + v8::V8::InitializePlatform(platform); map options; string file; - ParseOptions(argc, argv, options, &file); + ParseOptions(argc, argv, &options, &file); if (file.empty()) { fprintf(stderr, "No script was specified.\n"); return 1; } - Isolate* isolate = Isolate::GetCurrent(); + Isolate* isolate = Isolate::New(); + Isolate::Scope isolate_scope(isolate); HandleScope scope(isolate); Handle source = ReadFile(isolate, file); if (source.IsEmpty()) { diff --git a/deps/v8/samples/samples.gyp b/deps/v8/samples/samples.gyp index dfc7410070..0c4c705609 100644 --- a/deps/v8/samples/samples.gyp +++ b/deps/v8/samples/samples.gyp @@ -35,9 +35,10 @@ 'type': 'executable', 'dependencies': [ '../tools/gyp/v8.gyp:v8', + '../tools/gyp/v8.gyp:v8_libplatform', ], 'include_dirs': [ - '../include', + '..', ], 'conditions': [ ['v8_enable_i18n_support==1', { diff --git a/deps/v8/samples/shell.cc b/deps/v8/samples/shell.cc index f8d2c84594..ef61426a0a 100644 --- a/deps/v8/samples/shell.cc +++ b/deps/v8/samples/shell.cc @@ -25,12 +25,15 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include +#include + +#include + #include #include -#include #include #include +#include #ifdef COMPRESS_STARTUP_DATA_BZ2 #error Using compressed startup data is not supported for this sample @@ -65,25 +68,42 @@ void ReportException(v8::Isolate* isolate, v8::TryCatch* handler); static bool run_shell; +class ShellArrayBufferAllocator : public v8::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); } +}; + + int main(int argc, char* argv[]) { v8::V8::InitializeICU(); + v8::Platform* platform = v8::platform::CreateDefaultPlatform(); + v8::V8::InitializePlatform(platform); v8::V8::SetFlagsFromCommandLine(&argc, argv, true); - v8::Isolate* isolate = v8::Isolate::GetCurrent(); + ShellArrayBufferAllocator array_buffer_allocator; + v8::V8::SetArrayBufferAllocator(&array_buffer_allocator); + v8::Isolate* isolate = v8::Isolate::New(); run_shell = (argc == 1); int result; { + v8::Isolate::Scope isolate_scope(isolate); v8::HandleScope handle_scope(isolate); v8::Handle context = CreateShellContext(isolate); if (context.IsEmpty()) { fprintf(stderr, "Error creating context\n"); return 1; } - context->Enter(); + v8::Context::Scope context_scope(context); result = RunMain(isolate, argc, argv); if (run_shell) RunShell(context); - context->Exit(); } v8::V8::Dispose(); + v8::V8::ShutdownPlatform(); + delete platform; return result; } @@ -345,7 +365,7 @@ void ReportException(v8::Isolate* isolate, v8::TryCatch* try_catch) { fprintf(stderr, "%s\n", exception_string); } else { // Print (filename):(line number): (message). - v8::String::Utf8Value filename(message->GetScriptResourceName()); + v8::String::Utf8Value filename(message->GetScriptOrigin().ResourceName()); const char* filename_string = ToCString(filename); int linenum = message->GetLineNumber(); fprintf(stderr, "%s:%i: %s\n", filename_string, linenum, exception_string); -- cgit v1.2.3