diff options
author | Ben Murdoch <benm@google.com> | 2011-05-05 13:52:32 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-05-10 15:41:47 +0100 |
commit | b0fe1620dcb4135ac3ab2d66ff93072373911299 (patch) | |
tree | 3487cdc7e01ec56a6f84ea20f4bae596a0b73986 /samples | |
parent | df5bff59602802b769e994b0dc1d8869a27fa40c (diff) | |
download | android_external_v8-b0fe1620dcb4135ac3ab2d66ff93072373911299.tar.gz android_external_v8-b0fe1620dcb4135ac3ab2d66ff93072373911299.tar.bz2 android_external_v8-b0fe1620dcb4135ac3ab2d66ff93072373911299.zip |
Update V8 to r6101 as required by WebKit r74534
Change-Id: I7f84af8dd732f11898fd644b2c2b1538914cb78d
Diffstat (limited to 'samples')
-rw-r--r-- | samples/samples.gyp | 51 | ||||
-rw-r--r-- | samples/shell.cc | 48 |
2 files changed, 94 insertions, 5 deletions
diff --git a/samples/samples.gyp b/samples/samples.gyp new file mode 100644 index 00000000..f383ee20 --- /dev/null +++ b/samples/samples.gyp @@ -0,0 +1,51 @@ +# Copyright 2010 the V8 project authors. All rights reserved. +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +{ + 'targets': [ + { + 'target_name': 'shell', + 'type': 'executable', + 'dependencies': [ + '../tools/gyp/v8.gyp:v8', + ], + 'sources': [ + 'shell.cc', + ], + }, + { + 'target_name': 'process', + 'type': 'executable', + 'dependencies': [ + '../tools/gyp/v8.gyp:v8', + ], + 'sources': [ + 'process.cc', + ], + } + ], +} diff --git a/samples/shell.cc b/samples/shell.cc index 1a13f5f8..6b67df6c 100644 --- a/samples/shell.cc +++ b/samples/shell.cc @@ -26,6 +26,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <v8.h> +#include <v8-testing.h> #include <fcntl.h> #include <string.h> #include <stdio.h> @@ -47,7 +48,6 @@ void ReportException(v8::TryCatch* handler); int RunMain(int argc, char* argv[]) { - v8::V8::SetFlagsFromCommandLine(&argc, argv, true); v8::HandleScope handle_scope; // Create a template for the global object. v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(); @@ -63,11 +63,11 @@ int RunMain(int argc, char* argv[]) { global->Set(v8::String::New("version"), v8::FunctionTemplate::New(Version)); // Create a new execution environment containing the built-in // functions - v8::Handle<v8::Context> context = v8::Context::New(NULL, global); - // Enter the newly created execution environment. - v8::Context::Scope context_scope(context); + v8::Persistent<v8::Context> context = v8::Context::New(NULL, global); bool run_shell = (argc == 1); for (int i = 1; i < argc; i++) { + // Enter the execution environment before evaluating any code. + v8::Context::Scope context_scope(context); const char* str = argv[i]; if (strcmp(str, "--shell") == 0) { run_shell = true; @@ -99,12 +99,48 @@ int RunMain(int argc, char* argv[]) { } } if (run_shell) RunShell(context); + context.Dispose(); return 0; } int main(int argc, char* argv[]) { - int result = RunMain(argc, argv); + // Figure out if we're requested to stress the optimization + // infrastructure by running tests multiple times and forcing + // optimization in the last run. + bool FLAG_stress_opt = false; + bool FLAG_stress_deopt = false; + for (int i = 0; i < argc; i++) { + if (strcmp(argv[i], "--stress-opt") == 0) { + FLAG_stress_opt = true; + argv[i] = NULL; + } else if (strcmp(argv[i], "--stress-deopt") == 0) { + FLAG_stress_deopt = true; + argv[i] = NULL; + } else if (strcmp(argv[i], "--noalways-opt") == 0) { + // No support for stressing if we can't use --always-opt. + FLAG_stress_opt = false; + FLAG_stress_deopt = false; + break; + } + } + + v8::V8::SetFlagsFromCommandLine(&argc, argv, true); + int result = 0; + if (FLAG_stress_opt || FLAG_stress_deopt) { + v8::Testing::SetStressRunType(FLAG_stress_opt + ? v8::Testing::kStressTypeOpt + : v8::Testing::kStressTypeDeopt); + int stress_runs = v8::Testing::GetStressRuns(); + for (int i = 0; i < stress_runs && result == 0; i++) { + printf("============ Stress %d/%d ============\n", + i + 1, stress_runs); + v8::Testing::PrepareStressRun(i); + result = RunMain(argc, argv); + } + } else { + result = RunMain(argc, argv); + } v8::V8::Dispose(); return result; } @@ -221,6 +257,8 @@ v8::Handle<v8::String> ReadFile(const char* name) { void RunShell(v8::Handle<v8::Context> context) { printf("V8 version %s\n", v8::V8::GetVersion()); static const int kBufferSize = 256; + // Enter the execution environment before evaluating any code. + v8::Context::Scope context_scope(context); while (true) { char buffer[kBufferSize]; printf("> "); |