Revision: 7630
Author: [email protected]
Date: Fri Apr 15 05:31:03 2011
Log: Introduce experimental natives that are enabled by a runtime flag.
Clean up the use of js2c. We generated two identical files.
[email protected],[email protected]
BUG=
TEST=
Review URL: http://codereview.chromium.org/6865013
http://code.google.com/p/v8/source/detail?r=7630
Added:
/branches/bleeding_edge/src/proxy.js
Modified:
/branches/bleeding_edge/src/SConscript
/branches/bleeding_edge/src/bootstrapper.cc
/branches/bleeding_edge/src/d8.gyp
/branches/bleeding_edge/src/extensions/experimental/experimental.gyp
/branches/bleeding_edge/src/flag-definitions.h
/branches/bleeding_edge/src/natives.h
/branches/bleeding_edge/tools/gyp/v8.gyp
/branches/bleeding_edge/tools/js2c.py
=======================================
--- /dev/null
+++ /branches/bleeding_edge/src/proxy.js Fri Apr 15 05:31:03 2011
@@ -0,0 +1,28 @@
+// Copyright 2011 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.
+
+global.Proxy = new $Object();
=======================================
--- /branches/bleeding_edge/src/SConscript Thu Apr 7 07:42:37 2011
+++ /branches/bleeding_edge/src/SConscript Fri Apr 15 05:31:03 2011
@@ -297,6 +297,11 @@
'''.split()
+EXPERIMENTAL_LIBRARY_FILES = '''
+proxy.js
+'''.split()
+
+
def Abort(message):
print message
sys.exit(1)
@@ -321,9 +326,16 @@
# compile it.
library_files = [s for s in LIBRARY_FILES]
library_files.append('macros.py')
- libraries_src, libraries_empty_src =
env.JS2C(['libraries.cc', 'libraries-empty.cc'], library_files, TYPE='CORE')
+ libraries_src = env.JS2C(['libraries.cc'], library_files, TYPE='CORE')
libraries_obj = context.ConfigureObject(env, libraries_src,
CPPPATH=['.'])
+ # Combine the experimental JavaScript library files into a C++ file
+ # and compile it.
+ experimental_library_files = [ s for s in EXPERIMENTAL_LIBRARY_FILES ]
+ experimental_library_files.append('macros.py')
+ experimental_libraries_src = env.JS2C(['experimental-libraries.cc'],
experimental_library_files, TYPE='EXPERIMENTAL')
+ experimental_libraries_obj = context.ConfigureObject(env,
experimental_libraries_src, CPPPATH=['.'])
+
source_objs = context.ConfigureObject(env, source_files)
non_snapshot_files = [source_objs]
@@ -340,7 +352,7 @@
mksnapshot_env = env.Copy()
mksnapshot_env.Replace(**context.flags['mksnapshot'])
mksnapshot_src = 'mksnapshot.cc'
- mksnapshot = mksnapshot_env.Program('mksnapshot', [mksnapshot_src,
libraries_obj, non_snapshot_files, empty_snapshot_obj],
PDB='mksnapshot.exe.pdb')
+ mksnapshot = mksnapshot_env.Program('mksnapshot', [mksnapshot_src,
libraries_obj, experimental_libraries_obj, non_snapshot_files,
empty_snapshot_obj], PDB='mksnapshot.exe.pdb')
if context.use_snapshot:
if context.build_snapshot:
snapshot_cc = env.Snapshot('snapshot.cc', mksnapshot,
LOGFILE=File('snapshot.log').abspath)
@@ -349,7 +361,7 @@
snapshot_obj = context.ConfigureObject(env, snapshot_cc, CPPPATH=['.'])
else:
snapshot_obj = empty_snapshot_obj
- library_objs = [non_snapshot_files, libraries_obj, snapshot_obj]
+ library_objs = [non_snapshot_files, libraries_obj,
experimental_libraries_obj, snapshot_obj]
return (library_objs, d8_objs, [mksnapshot], preparser_objs)
=======================================
--- /branches/bleeding_edge/src/bootstrapper.cc Thu Apr 14 05:05:03 2011
+++ /branches/bleeding_edge/src/bootstrapper.cc Fri Apr 15 05:31:03 2011
@@ -200,6 +200,7 @@
// Used for creating a context from scratch.
void InstallNativeFunctions();
bool InstallNatives();
+ bool InstallExperimentalNatives();
void InstallBuiltinFunctionIds();
void InstallJSFunctionResultCaches();
void InitializeNormalizedMapCaches();
@@ -246,6 +247,7 @@
Handle<FixedArray> caller);
static bool CompileBuiltin(Isolate* isolate, int index);
+ static bool CompileExperimentalBuiltin(Isolate* isolate, int index);
static bool CompileNative(Vector<const char> name, Handle<String>
source);
static bool CompileScriptCached(Vector<const char> name,
Handle<String> source,
@@ -1173,6 +1175,15 @@
isolate->bootstrapper()->NativesSourceLookup(index);
return CompileNative(name, source_code);
}
+
+
+bool Genesis::CompileExperimentalBuiltin(Isolate* isolate, int index) {
+ Vector<const char> name = ExperimentalNatives::GetScriptName(index);
+ Factory* factory = isolate->factory();
+ Handle<String> source_code =
+
factory->NewStringFromAscii(ExperimentalNatives::GetScriptSource(index));
+ return CompileNative(name, source_code);
+}
bool Genesis::CompileNative(Vector<const char> name, Handle<String>
source) {
@@ -1510,7 +1521,6 @@
for (int i = Natives::GetDebuggerCount();
i < Natives::GetBuiltinsCount();
i++) {
- Vector<const char> name = Natives::GetScriptName(i);
if (!CompileBuiltin(isolate(), i)) return false;
// TODO(ager): We really only need to install the JS builtin
// functions on the builtins object after compiling and running
@@ -1626,6 +1636,18 @@
return true;
}
+
+
+bool Genesis::InstallExperimentalNatives() {
+ if (FLAG_harmony_proxies) {
+ for (int i = ExperimentalNatives::GetDebuggerCount();
+ i < ExperimentalNatives::GetBuiltinsCount();
+ i++) {
+ if (!CompileExperimentalBuiltin(isolate(), i)) return false;
+ }
+ }
+ return true;
+}
static Handle<JSObject> ResolveBuiltinIdHolder(
@@ -2107,6 +2129,9 @@
if (!ConfigureGlobalObjects(global_template)) return;
isolate->counters()->contexts_created_from_scratch()->Increment();
}
+
+ // Install experimental natives.
+ if (!InstallExperimentalNatives()) return;
result_ = global_context_;
}
=======================================
--- /branches/bleeding_edge/src/d8.gyp Tue Mar 29 10:54:44 2011
+++ /branches/bleeding_edge/src/d8.gyp Fri Apr 15 05:31:03 2011
@@ -61,6 +61,7 @@
'variables': {
'js_files': [
'd8.js',
+ 'macros.py',
],
},
'actions': [
@@ -72,7 +73,6 @@
],
'outputs': [
'<(SHARED_INTERMEDIATE_DIR)/d8-js.cc',
- '<(SHARED_INTERMEDIATE_DIR)/d8-js-empty.cc',
],
'action': [
'python',
=======================================
--- /branches/bleeding_edge/src/extensions/experimental/experimental.gyp
Thu Apr 14 12:10:51 2011
+++ /branches/bleeding_edge/src/extensions/experimental/experimental.gyp
Fri Apr 15 05:31:03 2011
@@ -75,7 +75,6 @@
],
'outputs': [
'<(SHARED_INTERMEDIATE_DIR)/i18n-js.cc',
- '<(SHARED_INTERMEDIATE_DIR)/i18n-js-empty.cc'
],
'action': [
'python',
=======================================
--- /branches/bleeding_edge/src/flag-definitions.h Mon Apr 11 23:12:45 2011
+++ /branches/bleeding_edge/src/flag-definitions.h Fri Apr 15 05:31:03 2011
@@ -96,6 +96,9 @@
//
#define FLAG FLAG_FULL
+// Flags for experimental language features.
+DEFINE_bool(harmony_proxies, false, "enable harmony proxies")
+
// Flags for Crankshaft.
#ifdef V8_TARGET_ARCH_MIPS
DEFINE_bool(crankshaft, false, "use crankshaft")
=======================================
--- /branches/bleeding_edge/src/natives.h Tue Apr 12 11:19:40 2011
+++ /branches/bleeding_edge/src/natives.h Fri Apr 15 05:31:03 2011
@@ -1,4 +1,4 @@
-// Copyright 2006-2008 the V8 project authors. All rights reserved.
+// Copyright 2011 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:
@@ -36,7 +36,7 @@
int index);
enum NativeType {
- CORE, D8, I18N
+ CORE, EXPERIMENTAL, D8, I18N
};
template <NativeType type>
@@ -57,6 +57,7 @@
};
typedef NativesCollection<CORE> Natives;
+typedef NativesCollection<EXPERIMENTAL> ExperimentalNatives;
} } // namespace v8::internal
=======================================
--- /branches/bleeding_edge/tools/gyp/v8.gyp Thu Apr 7 08:02:38 2011
+++ /branches/bleeding_edge/tools/gyp/v8.gyp Fri Apr 15 05:31:03 2011
@@ -230,7 +230,8 @@
'../../src',
],
'sources': [
- '<(SHARED_INTERMEDIATE_DIR)/libraries-empty.cc',
+ '<(SHARED_INTERMEDIATE_DIR)/libraries.cc',
+ '<(SHARED_INTERMEDIATE_DIR)/experimental-libraries.cc',
'<(INTERMEDIATE_DIR)/snapshot.cc',
],
'actions': [
@@ -259,6 +260,7 @@
],
'sources': [
'<(SHARED_INTERMEDIATE_DIR)/libraries.cc',
+ '<(SHARED_INTERMEDIATE_DIR)/experimental-libraries.cc',
'../../src/snapshot-empty.cc',
],
'conditions': [
@@ -722,6 +724,10 @@
'../../src/regexp.js',
'../../src/macros.py',
],
+ 'experimental_library_files': [
+ '../../src/proxy.js',
+ '../../src/macros.py',
+ ],
},
'actions': [
{
@@ -732,7 +738,6 @@
],
'outputs': [
'<(SHARED_INTERMEDIATE_DIR)/libraries.cc',
- '<(SHARED_INTERMEDIATE_DIR)/libraries-empty.cc',
],
'action': [
'python',
@@ -742,6 +747,23 @@
'<@(library_files)'
],
},
+ {
+ 'action_name': 'js2c_experimental',
+ 'inputs': [
+ '../../tools/js2c.py',
+ '<@(experimental_library_files)',
+ ],
+ 'outputs': [
+ '<(SHARED_INTERMEDIATE_DIR)/experimental-libraries.cc',
+ ],
+ 'action': [
+ 'python',
+ '../../tools/js2c.py',
+ '<@(_outputs)',
+ 'EXPERIMENTAL',
+ '<@(experimental_library_files)'
+ ],
+ },
],
},
{
=======================================
--- /branches/bleeding_edge/tools/js2c.py Tue Dec 7 03:01:02 2010
+++ /branches/bleeding_edge/tools/js2c.py Fri Apr 15 05:31:03 2011
@@ -204,7 +204,7 @@
HEADER_TEMPLATE = """\
-// Copyright 2008 Google Inc. All Rights Reserved.
+// Copyright 2011 Google Inc. All Rights Reserved.
// This file was generated from .js source files by SCons. If you
// want to make changes to this file you should either change the
@@ -288,7 +288,6 @@
minifier = jsmin.JavaScriptMinifier()
- source_lines_empty = []
for module in modules:
filename = str(module)
debugger = filename.endswith('-debugger.js')
@@ -305,7 +304,6 @@
else:
ids.append((id, len(lines)))
source_lines.append(SOURCE_DECLARATION % { 'id': id, 'data': data })
- source_lines_empty.append(SOURCE_DECLARATION % { 'id': id, 'data':
data })
# Build debugger support functions
get_index_cases = [ ]
@@ -356,25 +354,11 @@
})
output.close()
- if len(target) > 1:
- output = open(str(target[1]), "w")
- output.write(HEADER_TEMPLATE % {
- 'builtin_count': len(ids) + len(debugger_ids),
- 'debugger_count': len(debugger_ids),
- 'source_lines': "\n".join(source_lines_empty),
- 'get_index_cases': "".join(get_index_cases),
- 'get_script_source_cases': "".join(get_script_source_cases),
- 'get_script_name_cases': "".join(get_script_name_cases),
- 'type': env['TYPE']
- })
- output.close()
-
def main():
natives = sys.argv[1]
- natives_empty = sys.argv[2]
- type = sys.argv[3]
- source_files = sys.argv[4:]
- JS2C(source_files, [natives, natives_empty], { 'TYPE': type })
+ type = sys.argv[2]
+ source_files = sys.argv[3:]
+ JS2C(source_files, [natives], { 'TYPE': type })
if __name__ == "__main__":
main()
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev