Improved performance of garbage collection by moving the function that updates pointers during compacting collection into the updating visitor. This gives the compiler a better chance to inline and avoid a function call per (potential) pointer.

Extended the shell sample with a --runtime-flags option.

Added Visual Studio project files for the shell.cc and process.cc samples.



git-svn-id: http://v8.googlecode.com/svn/trunk@14 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
mads.s.ager 2008-08-14 13:41:48 +00:00
parent 31e7138e1a
commit cbaa060d28
18 changed files with 641 additions and 108 deletions

View File

@ -1,4 +1,18 @@
2008-08-13: Version 0.2.2 (130807)
2008-08-14: Version 0.2.3
Improved performance of garbage collection by moving the
function that updates pointers during compacting collection
into the updating visitor. This gives the compiler a better
chance to inline and avoid a function call per (potential)
pointer.
Extended the shell sample with a --runtime-flags option.
Added Visual Studio project files for the shell.cc and
process.cc samples.
2008-08-13: Version 0.2.2
Improved performance of garbage collection by changing the way
we use the marking stack in the event of stack overflow during
@ -16,7 +30,7 @@
Added first version of Visual Studio project files.
2008-08-06: Version 0.2.1 (130029)
2008-08-06: Version 0.2.1
Improved performance of unary addition by avoiding runtime calls.
@ -38,7 +52,7 @@
implementations.
2008-07-30: Version 0.2.0 (129146)
2008-07-30: Version 0.2.0
Changed all text files to have native svn:eol-style.
@ -75,7 +89,7 @@
Merged disassembler-{arch} files.
2008-07-28: Version 0.1.4 (128918)
2008-07-28: Version 0.1.4
Added support for storing JavaScript stack traces in a stack
allocated buffer to make it visible in shallow core dumps.
@ -83,7 +97,7 @@
disabled by default.
2008-07-25: Version 0.1.3 (128832)
2008-07-25: Version 0.1.3
Fixed bug in JSObject::GetPropertyAttributePostInterceptor where
map transitions would count as properties.
@ -103,7 +117,7 @@
across multiple users of V8 when linked as a shared library.
2008-07-16: Version 0.1.2 (127441)
2008-07-16: Version 0.1.2
Fixed building on Mac OS X by recognizing i386 and friends as
IA-32 platforms.
@ -119,7 +133,7 @@
SetInternalFieldCount from FunctionTemplate to ObjectTemplate.
2008-07-09: Version 0.1.1 (126448)
2008-07-09: Version 0.1.1
Fixed bug in stack overflow check code for IA-32 targets where a
non-tagged value in register eax was pushed to the stack.
@ -135,7 +149,7 @@
setting break points in them.
2008-07-03: Version 0.1.0 (125876)
2008-07-03: Version 0.1.0
Initial export.

View File

@ -462,17 +462,17 @@ class ScriptData {
*/
class ScriptOrigin {
public:
ScriptOrigin(Handle<String> resource_name,
ScriptOrigin(Handle<Value> resource_name,
Handle<Integer> resource_line_offset = Handle<Integer>(),
Handle<Integer> resource_column_offset = Handle<Integer>())
: resource_name_(resource_name),
resource_line_offset_(resource_line_offset),
resource_column_offset_(resource_column_offset) { }
inline Handle<String> ResourceName();
inline Handle<Value> ResourceName();
inline Handle<Integer> ResourceLineOffset();
inline Handle<Integer> ResourceColumnOffset();
private:
Handle<String> resource_name_;
Handle<Value> resource_name_;
Handle<Integer> resource_line_offset_;
Handle<Integer> resource_column_offset_;
};
@ -493,6 +493,13 @@ class Script {
ScriptOrigin* origin = NULL,
ScriptData* pre_data = NULL);
/**
* Compiles the specified script using the specified file name
* object (typically a string) as the script's origin.
*/
static Local<Script> Compile(Handle<String> source,
Handle<Value> file_name);
Local<Value> Run();
};
@ -2052,7 +2059,7 @@ Local<T> HandleScope::Close(Handle<T> value) {
return Local<T>(reinterpret_cast<T*>(after));
}
Handle<String> ScriptOrigin::ResourceName() {
Handle<Value> ScriptOrigin::ResourceName() {
return resource_name_;
}

View File

@ -31,12 +31,16 @@
void RunShell(v8::Handle<v8::Context> context);
bool ExecuteString(v8::Handle<v8::String> source);
bool ExecuteString(v8::Handle<v8::String> source,
v8::Handle<v8::Value> name,
bool print_result);
v8::Handle<v8::Value> Print(const v8::Arguments& args);
v8::Handle<v8::String> ReadFile(const char* name);
void ProcessRuntimeFlags(int argc, char* argv[]);
int main(int argc, char* argv[]) {
ProcessRuntimeFlags(argc, argv);
v8::HandleScope handle_scope;
// Create a template for the global object.
v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New();
@ -51,14 +55,19 @@ int main(int argc, char* argv[]) {
const char* str = argv[i];
if (strcmp(str, "--shell") == 0) {
run_shell = true;
} else if (strcmp(str, "--runtime-flags") == 0) {
// Skip the --runtime-flags flag since it was processed earlier.
i++;
} else {
// Use all other arguments as names of files to load and run.
v8::HandleScope handle_scope;
v8::Handle<v8::String> file_name = v8::String::New(str);
v8::Handle<v8::String> source = ReadFile(str);
if (source.IsEmpty()) {
printf("Error reading '%s'\n", str);
return 1;
}
if (!ExecuteString(source))
if (!ExecuteString(source, file_name, false))
return 1;
}
}
@ -116,17 +125,19 @@ void RunShell(v8::Handle<v8::Context> context) {
char* str = fgets(buffer, kBufferSize, stdin);
if (str == NULL) break;
v8::HandleScope handle_scope;
ExecuteString(v8::String::New(str));
ExecuteString(v8::String::New(str), v8::Undefined(), true);
}
printf("\n");
}
// Executes a string within the current v8 context.
bool ExecuteString(v8::Handle<v8::String> source) {
bool ExecuteString(v8::Handle<v8::String> source,
v8::Handle<v8::Value> name,
bool print_result) {
v8::HandleScope handle_scope;
v8::TryCatch try_catch;
v8::Handle<v8::Script> script = v8::Script::Compile(source);
v8::Handle<v8::Script> script = v8::Script::Compile(source, name);
if (script.IsEmpty()) {
// Print errors that happened during compilation.
v8::String::AsciiValue error(try_catch.Exception());
@ -140,7 +151,7 @@ bool ExecuteString(v8::Handle<v8::String> source) {
printf("%s\n", *error);
return false;
} else {
if (!result->IsUndefined()) {
if (print_result && !result->IsUndefined()) {
// If all went well and the result wasn't undefined then print
// the returned value.
v8::String::AsciiValue str(result);
@ -150,3 +161,14 @@ bool ExecuteString(v8::Handle<v8::String> source) {
}
}
}
// Set the vm flags before using the vm.
void ProcessRuntimeFlags(int argc, char* argv[]) {
for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "--runtime-flags") == 0 && i + 1 < argc) {
i++;
v8::V8::SetFlagsFromString(argv[i], strlen(argv[i]));
}
}
}

View File

@ -1010,7 +1010,7 @@ Local<Script> Script::Compile(v8::Handle<String> source,
ON_BAILOUT("v8::Script::Compile()", return Local<Script>());
LOG_API("Script::Compile");
i::Handle<i::String> str = Utils::OpenHandle(*source);
i::Handle<i::String> name_obj;
i::Handle<i::Object> name_obj;
int line_offset = 0;
int column_offset = 0;
if (origin != NULL) {
@ -1047,6 +1047,13 @@ Local<Script> Script::Compile(v8::Handle<String> source,
}
Local<Script> Script::Compile(v8::Handle<String> source,
v8::Handle<Value> file_name) {
ScriptOrigin origin(file_name);
return Compile(source, &origin);
}
Local<Value> Script::Run() {
ON_BAILOUT("v8::Script::Run()", return Local<Value>());
LOG_API("Script::Run");
@ -2091,7 +2098,7 @@ bool v8::V8::Initialize() {
const char* v8::V8::GetVersion() {
return "0.2.2 (130807)";
return "0.2.3";
}

View File

@ -39,6 +39,8 @@
namespace v8 { namespace internal {
DEFINE_string(expose_natives_as, NULL, "expose natives in global object");
DEFINE_string(expose_debug_as, NULL, "expose debug in global object");
DEFINE_string(natives_file, NULL, "alternative natives file"); // for debugging
DEFINE_bool(expose_gc, false, "expose gc extension"); // for debugging
@ -277,6 +279,7 @@ class Genesis BASE_EMBEDDED {
bool InstallExtensions(v8::ExtensionConfiguration* extensions);
bool InstallExtension(const char* name);
bool InstallExtension(v8::RegisteredExtension* current);
bool InstallSpecialObjects();
bool ConfigureGlobalObject(v8::Handle<v8::ObjectTemplate> global_template);
// Migrates all properties from the 'from' object to the 'to'
@ -997,6 +1000,42 @@ bool Genesis::InstallNatives() {
}
bool Genesis::InstallSpecialObjects() {
HandleScope scope;
Handle<JSGlobalObject> global(
JSGlobalObject::cast(global_context()->global()));
// Expose the natives in global if a name for it is specified.
if (FLAG_expose_natives_as != NULL && strlen(FLAG_expose_natives_as) != 0) {
Handle<String> natives_string =
Factory::LookupAsciiSymbol(FLAG_expose_natives_as);
SetProperty(global, natives_string,
Handle<JSObject>(global->builtins()), DONT_ENUM);
}
// Expose the debug global object in global if a name for it is specified.
if (FLAG_expose_debug_as != NULL && strlen(FLAG_expose_debug_as) != 0) {
// If loading fails we just bail out without installing the
// debugger but without tanking the whole context.
if (!Debug::Load())
return true;
Handle<JSGlobalObject> debug_global =
Handle<JSGlobalObject>(
JSGlobalObject::cast(Debug::debug_context()->global()));
Handle<String> debug_string =
Factory::LookupAsciiSymbol(FLAG_expose_debug_as);
SetProperty(global, debug_string,
Handle<JSObject>(debug_global), DONT_ENUM);
// Set the security token for the debugger global object to the same as
// the shell global object to allow calling between these (otherwise
// exposing debug global object dosen't make much sense).
debug_global->set_security_token(global->security_token());
}
return true;
}
bool Genesis::InstallExtensions(v8::ExtensionConfiguration* extensions) {
// Clear coloring of extension list
v8::RegisteredExtension* current = v8::RegisteredExtension::first_extension();
@ -1296,6 +1335,8 @@ Genesis::Genesis(Handle<Object> global_object,
if (!InstallExtensions(extensions)) return;
if (!InstallSpecialObjects()) return;
result_ = global_context_;
}

View File

@ -181,7 +181,7 @@ static StaticResource<SafeStringInputBuffer> safe_string_input_buffer;
Handle<JSFunction> Compiler::Compile(Handle<String> source,
Handle<String> script_name,
Handle<Object> script_name,
int line_offset, int column_offset,
v8::Extension* extension,
ScriptDataImpl* input_pre_data) {

View File

@ -51,7 +51,7 @@ class Compiler : public AllStatic {
// Compile a String source within a context.
static Handle<JSFunction> Compile(Handle<String> source,
Handle<String> script_name,
Handle<Object> script_name,
int line_offset, int column_offset,
v8::Extension* extension,
ScriptDataImpl* script_Data);

View File

@ -406,10 +406,32 @@ Debug.breakLocations = function(f) {
// Returns a Script object. If the parameter is a function the return value
// is the script in which the function is defined. If the parameter is a string
// the return value is the script for which the script name has that string
// value.
// value. If it is a regexp and there is a unique script whose name matches
// we return that, otherwise undefined.
Debug.findScript = function(func_or_script_name) {
if (IS_FUNCTION(func_or_script_name)) {
return %FunctionGetScript(func_or_script_name);
} else if (IS_REGEXP(func_or_script_name)) {
var scripts = Debug.scripts();
var last_result = null;
var result_count = 0;
for (var i in scripts) {
var script = scripts[i];
if (func_or_script_name.test(script.name)) {
last_result = script;
result_count++;
}
}
// Return the unique script matching the regexp. If there are more
// than one we don't return a value since there is no good way to
// decide which one to return. Returning a "random" one, say the
// first, would introduce nondeterminism (or something close to it)
// because the order is the heap iteration order.
if (result_count == 1) {
return last_result;
} else {
return undefined;
}
} else {
return %GetScript(func_or_script_name);
}

View File

@ -42,7 +42,6 @@
namespace v8 { namespace internal {
DEFINE_bool(remote_debugging, false, "enable remote debugging");
DEFINE_int(debug_port, 5858, "port for remote debugging");
DEFINE_bool(trace_debug_json, false, "trace debugging JSON request/response");
DECLARE_bool(allow_natives_syntax);
DECLARE_bool(log_debugger);
@ -556,7 +555,9 @@ bool Debug::Load() {
// Bail out if we're already in the process of compiling the native
// JavaScript source code for the debugger.
if (Debugger::compiling_natives()) return false;
if (Debugger::compiling_natives() || Debugger::is_loading_debugger())
return false;
Debugger::set_loading_debugger(true);
// Disable breakpoints and interrupts while compiling and running the
// debugger scripts including the context creation code.
@ -587,6 +588,10 @@ bool Debug::Load() {
!CompileDebuggerScript(Natives::GetIndex("debug"));
Debugger::set_compiling_natives(false);
// Make sure we mark the debugger as not loading before we might
// return.
Debugger::set_loading_debugger(false);
// Check for caught exceptions.
if (caught_exception) return false;
@ -1295,6 +1300,7 @@ bool Debug::IsDebugGlobal(GlobalObject* global) {
bool Debugger::debugger_active_ = false;
bool Debugger::compiling_natives_ = false;
bool Debugger::is_loading_debugger_ = false;
DebugMessageThread* Debugger::message_thread_ = NULL;
v8::DebugMessageHandler Debugger::debug_message_handler_ = NULL;
void* Debugger::debug_message_handler_data_ = NULL;

View File

@ -373,10 +373,13 @@ class Debugger {
Debugger::compiling_natives_ = compiling_natives;
}
static bool compiling_natives() { return Debugger::compiling_natives_; }
static void set_loading_debugger(bool v) { is_loading_debugger_ = v; }
static bool is_loading_debugger() { return Debugger::is_loading_debugger_; }
private:
static bool debugger_active_; // Are there any active debugger?
static bool compiling_natives_; // Are we compiling natives?
static bool is_loading_debugger_; // Are we loading the debugger?
static DebugMessageThread* message_thread_;
static v8::DebugMessageHandler debug_message_handler_;
static void* debug_message_handler_data_;

View File

@ -1240,19 +1240,80 @@ void MarkCompactCollector::VerifyPageHeaders(PagedSpace* space) {
// Helper class for updating pointers in HeapObjects.
class UpdatingVisitor: public ObjectVisitor {
public:
void VisitPointer(Object** p) {
MarkCompactCollector::UpdatePointer(p);
UpdatePointer(p);
}
void VisitPointers(Object** start, Object** end) {
// Mark all HeapObject pointers in [start, end)
for (Object** p = start; p < end; p++) {
MarkCompactCollector::UpdatePointer(p);
for (Object** p = start; p < end; p++) UpdatePointer(p);
}
private:
void UpdatePointer(Object** p) {
if (!(*p)->IsHeapObject()) return;
HeapObject* obj = HeapObject::cast(*p);
Address old_addr = obj->address();
Address new_addr;
ASSERT(!Heap::InFromSpace(obj));
if (Heap::new_space()->Contains(obj)) {
Address f_addr = Heap::new_space()->FromSpaceLow() +
Heap::new_space()->ToSpaceOffsetForAddress(old_addr);
new_addr = Memory::Address_at(f_addr);
#ifdef DEBUG
ASSERT(Heap::old_space()->Contains(new_addr) ||
Heap::code_space()->Contains(new_addr) ||
Heap::new_space()->FromSpaceContains(new_addr));
if (Heap::new_space()->FromSpaceContains(new_addr)) {
ASSERT(Heap::new_space()->FromSpaceOffsetForAddress(new_addr) <=
Heap::new_space()->ToSpaceOffsetForAddress(old_addr));
}
#endif
} else if (Heap::lo_space()->Contains(obj)) {
// Don't move objects in the large object space.
return;
} else {
ASSERT(Heap::old_space()->Contains(obj) ||
Heap::code_space()->Contains(obj) ||
Heap::map_space()->Contains(obj));
new_addr = MarkCompactCollector::GetForwardingAddressInOldSpace(obj);
ASSERT(Heap::old_space()->Contains(new_addr) ||
Heap::code_space()->Contains(new_addr) ||
Heap::map_space()->Contains(new_addr));
#ifdef DEBUG
if (Heap::old_space()->Contains(obj)) {
ASSERT(Heap::old_space()->MCSpaceOffsetForAddress(new_addr) <=
Heap::old_space()->MCSpaceOffsetForAddress(old_addr));
} else if (Heap::code_space()->Contains(obj)) {
ASSERT(Heap::code_space()->MCSpaceOffsetForAddress(new_addr) <=
Heap::code_space()->MCSpaceOffsetForAddress(old_addr));
} else {
ASSERT(Heap::map_space()->MCSpaceOffsetForAddress(new_addr) <=
Heap::map_space()->MCSpaceOffsetForAddress(old_addr));
}
#endif
}
*p = HeapObject::FromAddress(new_addr);
#ifdef DEBUG
if (FLAG_gc_verbose) {
PrintF("update %p : %p -> %p\n",
reinterpret_cast<Address>(p), old_addr, new_addr);
}
#endif
}
};
void MarkCompactCollector::UpdatePointers() {
#ifdef DEBUG
ASSERT(state_ == ENCODE_FORWARDING_ADDRESSES);
@ -1391,70 +1452,6 @@ Address MarkCompactCollector::GetForwardingAddressInOldSpace(HeapObject* obj) {
return next_page->OffsetToAddress(offset);
}
void MarkCompactCollector::UpdatePointer(Object** p) {
// We need to check if p is in to_space.
if (!(*p)->IsHeapObject()) return;
HeapObject* obj = HeapObject::cast(*p);
Address old_addr = obj->address();
Address new_addr;
ASSERT(!Heap::InFromSpace(obj));
if (Heap::new_space()->Contains(obj)) {
Address f_addr = Heap::new_space()->FromSpaceLow() +
Heap::new_space()->ToSpaceOffsetForAddress(old_addr);
new_addr = Memory::Address_at(f_addr);
#ifdef DEBUG
ASSERT(Heap::old_space()->Contains(new_addr) ||
Heap::code_space()->Contains(new_addr) ||
Heap::new_space()->FromSpaceContains(new_addr));
if (Heap::new_space()->FromSpaceContains(new_addr)) {
ASSERT(Heap::new_space()->FromSpaceOffsetForAddress(new_addr) <=
Heap::new_space()->ToSpaceOffsetForAddress(old_addr));
}
#endif
} else if (Heap::lo_space()->Contains(obj)) {
// Don't move objects in the large object space.
new_addr = obj->address();
} else {
ASSERT(Heap::old_space()->Contains(obj) ||
Heap::code_space()->Contains(obj) ||
Heap::map_space()->Contains(obj));
new_addr = GetForwardingAddressInOldSpace(obj);
ASSERT(Heap::old_space()->Contains(new_addr) ||
Heap::code_space()->Contains(new_addr) ||
Heap::map_space()->Contains(new_addr));
#ifdef DEBUG
if (Heap::old_space()->Contains(obj)) {
ASSERT(Heap::old_space()->MCSpaceOffsetForAddress(new_addr) <=
Heap::old_space()->MCSpaceOffsetForAddress(old_addr));
} else if (Heap::code_space()->Contains(obj)) {
ASSERT(Heap::code_space()->MCSpaceOffsetForAddress(new_addr) <=
Heap::code_space()->MCSpaceOffsetForAddress(old_addr));
} else {
ASSERT(Heap::map_space()->MCSpaceOffsetForAddress(new_addr) <=
Heap::map_space()->MCSpaceOffsetForAddress(old_addr));
}
#endif
}
*p = HeapObject::FromAddress(new_addr);
#ifdef DEBUG
if (FLAG_gc_verbose) {
PrintF("update %p : %p -> %p\n",
reinterpret_cast<Address>(p), old_addr, new_addr);
}
#endif
}
#ifdef DEBUG
void MarkCompactCollector::VerifyHeapAfterUpdatingPointers() {

View File

@ -272,9 +272,6 @@ class MarkCompactCollector : public AllStatic {
// Returns the heap size of the object.
static int UpdatePointersInOldObject(HeapObject* obj);
// Updates the pointer in a slot.
static void UpdatePointer(Object** p);
// Calculates the forwarding address of an object in an old space.
static Address GetForwardingAddressInOldSpace(HeapObject* obj);

View File

@ -94,12 +94,10 @@ static Object* IllegalOperation() {
static Object* Runtime_CloneObjectLiteralBoilerplate(Arguments args) {
CONVERT_CHECKED(JSObject, boilerplate, args[0]);
#ifdef DEBUG
// Verify the constructor of the boilerplate is equal to the
// object function in the CURRENT global_context.
CHECK(boilerplate->map()->constructor()
== Top::context()->global_context()->object_function());
#endif
// Verify that the constructor of the boilerplate is equal to the
// object function in the current global context.
ASSERT(boilerplate->map()->constructor() ==
Top::context()->global_context()->object_function());
return boilerplate->Copy();
}

119
test/mjsunit/mjsunit.js Normal file
View File

@ -0,0 +1,119 @@
// Copyright 2006-2008 Google Inc. 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.
/*
* This file is included in all mini jsunit test cases. The test
* framework expects lines that signal failed tests to start with
* the f-word and ignore all other lines.
*/
// Avoid writing the f-word, since some tests output parts of this code.
var the_f_word = "Fai" + "lure";
function fail(expected, found, name_opt) {
var start;
if (name_opt) {
start = the_f_word + " (" + name_opt + "): ";
} else {
start = the_f_word + ":";
}
print(start + " expected <" + expected + "> found <" + found + ">");
}
function assertEquals(expected, found, name_opt) {
if (expected != found) {
fail(expected, found, name_opt);
}
}
function assertArrayEquals(expected, found, name_opt) {
var start = "";
if (name_opt) {
start = name_opt + " - ";
}
assertEquals(expected.length, found.length, start + "array length");
if (expected.length == found.length) {
for (var i = 0; i < expected.length; ++i) {
assertEquals(expected[i], found[i], start + "array element at index " + i);
}
}
}
function assertTrue(value, name_opt) {
assertEquals(true, value, name_opt);
}
function assertFalse(value, name_opt) {
assertEquals(false, value, name_opt);
}
function assertNaN(value, name_opt) {
if (!isNaN(value)) {
fail("NaN", value, name_opt);
}
}
function assertThrows(code) {
try {
eval(code);
assertTrue(false, "did not throw exception");
} catch (e) {
// Do nothing.
}
}
function assertInstanceof(obj, type) {
if (!(obj instanceof type)) {
assertTrue(false, "Object <" + obj + "> is not an instance of <" + type + ">");
}
}
function assertDoesNotThrow(code) {
try {
eval(code);
} catch (e) {
assertTrue(false, "threw an exception");
}
}
function assertUnreachable(name_opt) {
var message = the_f_word + ": unreachable"
if (name_opt) {
message += " - " + name_opt;
}
print(message);
}

View File

@ -43,6 +43,12 @@ A project which uses V8 should then depend on v8_snapshot.vcproj.
If V8 without snapshot if preferred only v8_base.vcproj and v8.vcproj are
required and a project which uses V8 should depend on v8.vcproj.
Two sample project files are available as well. These are v8_shell_sample.vcproj
for building the sample in samples\shell.cc and v8_process_sample.vcproj for
building the sample in samples\process.cc. Add either of these (or both) to a
solution with v8_base, v8, v8_mksnapshot and v8_snapshot set up as described
above and have them depend on v8_snapshot.
Python requirements
-------------------
When using the Microsoft Visual Studio project files Python version 2.4 or later

View File

@ -183,7 +183,7 @@
<Tool
Name="VCCustomBuildTool"
Description="Processing js files..."
CommandLine=".\js2c.cmd ..\..\src $(IntDir)\DerivedSources"
CommandLine=".\js2c.cmd ..\..\src $(IntDir)\DerivedSources&#x0D;&#x0A;"
AdditionalDependencies="..\..\src\macros.py;..\..\src\runtime.js;..\..\src\v8natives.js;..\..\src\array.js;..\..\src\string.js;..\..\src\uri.js;..\..\src\math.js;..\..\src\messages.js;..\..\src\apinatives.js;..\..\src\debug-delay.js;..\..\src\mirror-delay.js;..\..\src\date-delay.js;..\..\src\regexp-delay.js"
Outputs="$(IntDir)\DerivedSources\natives.cc;$(IntDir)\DerivedSources\natives-empty.cc"
/>
@ -194,7 +194,7 @@
<Tool
Name="VCCustomBuildTool"
Description="Processing js files..."
CommandLine=".\js2c.cmd ..\..\src $(IntDir)\DerivedSources"
CommandLine=".\js2c.cmd ..\..\src $(IntDir)\DerivedSources&#x0D;&#x0A;"
AdditionalDependencies="..\..\src\macros.py;..\..\src\runtime.js;..\..\src\v8natives.js;..\..\src\array.js;..\..\src\string.js;..\..\src\uri.js;..\..\src\math.js;..\..\src\messages.js;..\..\src\apinatives.js;..\..\src\debug-delay.js;..\..\src\mirror-delay.js;..\..\src\date-delay.js;..\..\src\regexp-delay.js"
Outputs="$(IntDir)\DerivedSources\natives.cc;$(IntDir)\DerivedSources\natives-empty.cc"
/>
@ -208,10 +208,6 @@
RelativePath="$(IntDir)\DerivedSources\natives.cc"
>
</File>
<File
RelativePath=".\prebuild.py"
>
</File>
</Filter>
<File
RelativePath="..\..\src\snapshot-empty.cc"

View File

@ -0,0 +1,149 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Name="v8_process_sample"
ProjectGUID="{EF019874-D38A-40E3-B17C-DB5923F0A79C}"
RootNamespace="v8_process_sample"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
ConfigurationType="1"
InheritedPropertySheets=".\common.vsprops;.\debug.vsprops"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
ConfigurationType="1"
InheritedPropertySheets=".\common.vsprops;.\release.vsprops"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath="..\..\samples\process.cc"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,149 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Name="v8_shell_sample"
ProjectGUID="{2DE20FFA-6F5E-48D9-84D8-09B044A5B119}"
RootNamespace="v8_shell_sample"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
ConfigurationType="1"
InheritedPropertySheets=".\common.vsprops;.\debug.vsprops"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
ConfigurationType="1"
InheritedPropertySheets=".\common.vsprops;.\release.vsprops"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath="..\..\samples\shell.cc"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>