Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(498)

Side by Side Diff: src/bootstrapper.cc

Issue 6865013: Introduce experimental natives that are enabled by a runtime flag. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address comments Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/SConscript ('k') | src/d8.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 // templates passed through the API. The inner global from the snapshot is 193 // templates passed through the API. The inner global from the snapshot is
194 // detached from the other objects in the snapshot. 194 // detached from the other objects in the snapshot.
195 void HookUpInnerGlobal(Handle<GlobalObject> inner_global); 195 void HookUpInnerGlobal(Handle<GlobalObject> inner_global);
196 // New context initialization. Used for creating a context from scratch. 196 // New context initialization. Used for creating a context from scratch.
197 void InitializeGlobal(Handle<GlobalObject> inner_global, 197 void InitializeGlobal(Handle<GlobalObject> inner_global,
198 Handle<JSFunction> empty_function); 198 Handle<JSFunction> empty_function);
199 // Installs the contents of the native .js files on the global objects. 199 // Installs the contents of the native .js files on the global objects.
200 // Used for creating a context from scratch. 200 // Used for creating a context from scratch.
201 void InstallNativeFunctions(); 201 void InstallNativeFunctions();
202 bool InstallNatives(); 202 bool InstallNatives();
203 bool InstallExperimentalNatives();
203 void InstallBuiltinFunctionIds(); 204 void InstallBuiltinFunctionIds();
204 void InstallJSFunctionResultCaches(); 205 void InstallJSFunctionResultCaches();
205 void InitializeNormalizedMapCaches(); 206 void InitializeNormalizedMapCaches();
206 // Used both for deserialized and from-scratch contexts to add the extensions 207 // Used both for deserialized and from-scratch contexts to add the extensions
207 // provided. 208 // provided.
208 static bool InstallExtensions(Handle<Context> global_context, 209 static bool InstallExtensions(Handle<Context> global_context,
209 v8::ExtensionConfiguration* extensions); 210 v8::ExtensionConfiguration* extensions);
210 static bool InstallExtension(const char* name); 211 static bool InstallExtension(const char* name);
211 static bool InstallExtension(v8::RegisteredExtension* current); 212 static bool InstallExtension(v8::RegisteredExtension* current);
212 static void InstallSpecialObjects(Handle<Context> global_context); 213 static void InstallSpecialObjects(Handle<Context> global_context);
(...skipping 26 matching lines...) Expand all
239 Handle<JSFunction> empty_function, 240 Handle<JSFunction> empty_function,
240 Handle<FixedArray> arguments_callbacks, 241 Handle<FixedArray> arguments_callbacks,
241 Handle<FixedArray> caller_callbacks); 242 Handle<FixedArray> caller_callbacks);
242 243
243 Handle<DescriptorArray> ComputeStrictFunctionInstanceDescriptor( 244 Handle<DescriptorArray> ComputeStrictFunctionInstanceDescriptor(
244 PrototypePropertyMode propertyMode, 245 PrototypePropertyMode propertyMode,
245 Handle<FixedArray> arguments, 246 Handle<FixedArray> arguments,
246 Handle<FixedArray> caller); 247 Handle<FixedArray> caller);
247 248
248 static bool CompileBuiltin(Isolate* isolate, int index); 249 static bool CompileBuiltin(Isolate* isolate, int index);
250 static bool CompileExperimentalBuiltin(Isolate* isolate, int index);
249 static bool CompileNative(Vector<const char> name, Handle<String> source); 251 static bool CompileNative(Vector<const char> name, Handle<String> source);
250 static bool CompileScriptCached(Vector<const char> name, 252 static bool CompileScriptCached(Vector<const char> name,
251 Handle<String> source, 253 Handle<String> source,
252 SourceCodeCache* cache, 254 SourceCodeCache* cache,
253 v8::Extension* extension, 255 v8::Extension* extension,
254 Handle<Context> top_context, 256 Handle<Context> top_context,
255 bool use_runtime_context); 257 bool use_runtime_context);
256 258
257 Handle<Context> result_; 259 Handle<Context> result_;
258 260
(...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 1170
1169 1171
1170 bool Genesis::CompileBuiltin(Isolate* isolate, int index) { 1172 bool Genesis::CompileBuiltin(Isolate* isolate, int index) {
1171 Vector<const char> name = Natives::GetScriptName(index); 1173 Vector<const char> name = Natives::GetScriptName(index);
1172 Handle<String> source_code = 1174 Handle<String> source_code =
1173 isolate->bootstrapper()->NativesSourceLookup(index); 1175 isolate->bootstrapper()->NativesSourceLookup(index);
1174 return CompileNative(name, source_code); 1176 return CompileNative(name, source_code);
1175 } 1177 }
1176 1178
1177 1179
1180 bool Genesis::CompileExperimentalBuiltin(Isolate* isolate, int index) {
1181 Vector<const char> name = ExperimentalNatives::GetScriptName(index);
1182 Factory* factory = isolate->factory();
1183 Handle<String> source_code =
1184 factory->NewStringFromAscii(ExperimentalNatives::GetScriptSource(index));
1185 return CompileNative(name, source_code);
1186 }
1187
1188
1178 bool Genesis::CompileNative(Vector<const char> name, Handle<String> source) { 1189 bool Genesis::CompileNative(Vector<const char> name, Handle<String> source) {
1179 HandleScope scope; 1190 HandleScope scope;
1180 Isolate* isolate = source->GetIsolate(); 1191 Isolate* isolate = source->GetIsolate();
1181 #ifdef ENABLE_DEBUGGER_SUPPORT 1192 #ifdef ENABLE_DEBUGGER_SUPPORT
1182 isolate->debugger()->set_compiling_natives(true); 1193 isolate->debugger()->set_compiling_natives(true);
1183 #endif 1194 #endif
1184 bool result = CompileScriptCached(name, 1195 bool result = CompileScriptCached(name,
1185 source, 1196 source,
1186 NULL, 1197 NULL,
1187 NULL, 1198 NULL,
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
1503 1514
1504 if (FLAG_disable_native_files) { 1515 if (FLAG_disable_native_files) {
1505 PrintF("Warning: Running without installed natives!\n"); 1516 PrintF("Warning: Running without installed natives!\n");
1506 return true; 1517 return true;
1507 } 1518 }
1508 1519
1509 // Install natives. 1520 // Install natives.
1510 for (int i = Natives::GetDebuggerCount(); 1521 for (int i = Natives::GetDebuggerCount();
1511 i < Natives::GetBuiltinsCount(); 1522 i < Natives::GetBuiltinsCount();
1512 i++) { 1523 i++) {
1513 Vector<const char> name = Natives::GetScriptName(i);
1514 if (!CompileBuiltin(isolate(), i)) return false; 1524 if (!CompileBuiltin(isolate(), i)) return false;
1515 // TODO(ager): We really only need to install the JS builtin 1525 // TODO(ager): We really only need to install the JS builtin
1516 // functions on the builtins object after compiling and running 1526 // functions on the builtins object after compiling and running
1517 // runtime.js. 1527 // runtime.js.
1518 if (!InstallJSBuiltins(builtins)) return false; 1528 if (!InstallJSBuiltins(builtins)) return false;
1519 } 1529 }
1520 1530
1521 InstallNativeFunctions(); 1531 InstallNativeFunctions();
1522 1532
1523 // Store the map for the string prototype after the natives has been compiled 1533 // Store the map for the string prototype after the natives has been compiled
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1621 1631
1622 1632
1623 #ifdef DEBUG 1633 #ifdef DEBUG
1624 builtins->Verify(); 1634 builtins->Verify();
1625 #endif 1635 #endif
1626 1636
1627 return true; 1637 return true;
1628 } 1638 }
1629 1639
1630 1640
1641 bool Genesis::InstallExperimentalNatives() {
1642 if (FLAG_harmony_proxies) {
1643 for (int i = ExperimentalNatives::GetDebuggerCount();
1644 i < ExperimentalNatives::GetBuiltinsCount();
1645 i++) {
1646 if (!CompileExperimentalBuiltin(isolate(), i)) return false;
1647 }
1648 }
1649 return true;
1650 }
1651
1652
1631 static Handle<JSObject> ResolveBuiltinIdHolder( 1653 static Handle<JSObject> ResolveBuiltinIdHolder(
1632 Handle<Context> global_context, 1654 Handle<Context> global_context,
1633 const char* holder_expr) { 1655 const char* holder_expr) {
1634 Factory* factory = global_context->GetIsolate()->factory(); 1656 Factory* factory = global_context->GetIsolate()->factory();
1635 Handle<GlobalObject> global(global_context->global()); 1657 Handle<GlobalObject> global(global_context->global());
1636 const char* period_pos = strchr(holder_expr, '.'); 1658 const char* period_pos = strchr(holder_expr, '.');
1637 if (period_pos == NULL) { 1659 if (period_pos == NULL) {
1638 return Handle<JSObject>::cast( 1660 return Handle<JSObject>::cast(
1639 GetProperty(global, factory->LookupAsciiSymbol(holder_expr))); 1661 GetProperty(global, factory->LookupAsciiSymbol(holder_expr)));
1640 } 1662 }
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
2101 InstallJSFunctionResultCaches(); 2123 InstallJSFunctionResultCaches();
2102 InitializeNormalizedMapCaches(); 2124 InitializeNormalizedMapCaches();
2103 if (!InstallNatives()) return; 2125 if (!InstallNatives()) return;
2104 2126
2105 MakeFunctionInstancePrototypeWritable(); 2127 MakeFunctionInstancePrototypeWritable();
2106 2128
2107 if (!ConfigureGlobalObjects(global_template)) return; 2129 if (!ConfigureGlobalObjects(global_template)) return;
2108 isolate->counters()->contexts_created_from_scratch()->Increment(); 2130 isolate->counters()->contexts_created_from_scratch()->Increment();
2109 } 2131 }
2110 2132
2133 // Install experimental natives.
2134 if (!InstallExperimentalNatives()) return;
2135
2111 result_ = global_context_; 2136 result_ = global_context_;
2112 } 2137 }
2113 2138
2114 2139
2115 // Support for thread preemption. 2140 // Support for thread preemption.
2116 2141
2117 // Reserve space for statics needing saving and restoring. 2142 // Reserve space for statics needing saving and restoring.
2118 int Bootstrapper::ArchiveSpacePerThread() { 2143 int Bootstrapper::ArchiveSpacePerThread() {
2119 return sizeof(NestingCounterType); 2144 return sizeof(NestingCounterType);
2120 } 2145 }
(...skipping 13 matching lines...) Expand all
2134 return from + sizeof(NestingCounterType); 2159 return from + sizeof(NestingCounterType);
2135 } 2160 }
2136 2161
2137 2162
2138 // Called when the top-level V8 mutex is destroyed. 2163 // Called when the top-level V8 mutex is destroyed.
2139 void Bootstrapper::FreeThreadResources() { 2164 void Bootstrapper::FreeThreadResources() {
2140 ASSERT(!IsActive()); 2165 ASSERT(!IsActive());
2141 } 2166 }
2142 2167
2143 } } // namespace v8::internal 2168 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/SConscript ('k') | src/d8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698