OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1314 | 1314 |
1315 if (FLAG_harmony_typed_arrays) { | 1315 if (FLAG_harmony_typed_arrays) { |
1316 { // -- A r r a y B u f f e r | 1316 { // -- A r r a y B u f f e r |
1317 Handle<JSObject> prototype = | 1317 Handle<JSObject> prototype = |
1318 factory()->NewJSObject(isolate()->object_function(), TENURED); | 1318 factory()->NewJSObject(isolate()->object_function(), TENURED); |
1319 InstallFunction(global, "__ArrayBuffer", JS_ARRAY_BUFFER_TYPE, | 1319 InstallFunction(global, "__ArrayBuffer", JS_ARRAY_BUFFER_TYPE, |
1320 JSArrayBuffer::kSize, prototype, | 1320 JSArrayBuffer::kSize, prototype, |
1321 Builtins::kIllegal, true); | 1321 Builtins::kIllegal, true); |
1322 } | 1322 } |
1323 } | 1323 } |
| 1324 |
| 1325 if (FLAG_harmony_generators) { |
| 1326 // Fetch Function, Function.prototype, Object.prototype, and some maps from |
| 1327 // the environment. |
| 1328 Handle<String> function_string = factory()->function_class_string(); |
| 1329 Handle<JSFunction> function = Handle<JSFunction>::cast( |
| 1330 GetProperty(isolate(), isolate()->global_object(), function_string)); |
| 1331 Handle<JSObject> function_prototype(JSObject::cast( |
| 1332 function->instance_prototype())); |
| 1333 Handle<JSObject> object_prototype(isolate()->initial_object_prototype()); |
| 1334 Handle<Map> function_map(native_context()->function_map()); |
| 1335 Handle<Map> strict_mode_function_map( |
| 1336 native_context()->strict_mode_function_map()); |
| 1337 Handle<Map> object_map(native_context()->object_function()->initial_map()); |
| 1338 |
| 1339 // Create generator meta-objects and install them on the builtins object. |
| 1340 Handle<JSObject> builtins(native_context()->builtins()); |
| 1341 Handle<JSObject> generator_object_prototype = |
| 1342 factory()->NewJSObject(isolate()->object_function(), TENURED); |
| 1343 Handle<JSFunction> generator_function_prototype = |
| 1344 InstallFunction(builtins, "GeneratorFunctionPrototype", |
| 1345 JS_FUNCTION_TYPE, JSFunction::kHeaderSize, |
| 1346 generator_object_prototype, Builtins::kIllegal, |
| 1347 false); |
| 1348 SetPrototype(Handle<JSObject>::cast(generator_function_prototype), |
| 1349 function_prototype); |
| 1350 Handle<JSFunction> generator_function = |
| 1351 InstallFunction(builtins, "GeneratorFunction", JS_FUNCTION_TYPE, |
| 1352 JSFunction::kSize, generator_function_prototype, |
| 1353 Builtins::kIllegal, false); |
| 1354 SetPrototype(Handle<JSObject>::cast(generator_function), |
| 1355 function); |
| 1356 |
| 1357 // Create maps for generator functions and their prototypes. Store those |
| 1358 // maps in the native context. |
| 1359 Handle<Map> generator_function_map = factory()->CopyMap(function_map); |
| 1360 generator_function_map->set_prototype(*generator_function_prototype); |
| 1361 native_context()->set_generator_function_map(*generator_function_map); |
| 1362 |
| 1363 Handle<Map> strict_mode_generator_function_map = factory()->CopyMap( |
| 1364 strict_mode_function_map); |
| 1365 strict_mode_generator_function_map->set_prototype( |
| 1366 *generator_function_prototype); |
| 1367 native_context()->set_strict_mode_generator_function_map( |
| 1368 *strict_mode_generator_function_map); |
| 1369 |
| 1370 Handle<Map> generator_object_prototype_map = factory()->CopyMap( |
| 1371 object_map, 0); |
| 1372 generator_object_prototype_map->set_prototype( |
| 1373 *generator_object_prototype); |
| 1374 native_context()->set_generator_object_prototype_map( |
| 1375 *generator_object_prototype_map); |
| 1376 } |
1324 } | 1377 } |
1325 | 1378 |
1326 | 1379 |
1327 bool Genesis::CompileBuiltin(Isolate* isolate, int index) { | 1380 bool Genesis::CompileBuiltin(Isolate* isolate, int index) { |
1328 Vector<const char> name = Natives::GetScriptName(index); | 1381 Vector<const char> name = Natives::GetScriptName(index); |
1329 Handle<String> source_code = | 1382 Handle<String> source_code = |
1330 isolate->bootstrapper()->NativesSourceLookup(index); | 1383 isolate->bootstrapper()->NativesSourceLookup(index); |
1331 return CompileNative(isolate, name, source_code); | 1384 return CompileNative(isolate, name, source_code); |
1332 } | 1385 } |
1333 | 1386 |
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1926 if (FLAG_harmony_observation && | 1979 if (FLAG_harmony_observation && |
1927 strcmp(ExperimentalNatives::GetScriptName(i).start(), | 1980 strcmp(ExperimentalNatives::GetScriptName(i).start(), |
1928 "native object-observe.js") == 0) { | 1981 "native object-observe.js") == 0) { |
1929 if (!CompileExperimentalBuiltin(isolate(), i)) return false; | 1982 if (!CompileExperimentalBuiltin(isolate(), i)) return false; |
1930 } | 1983 } |
1931 if (FLAG_harmony_typed_arrays && | 1984 if (FLAG_harmony_typed_arrays && |
1932 strcmp(ExperimentalNatives::GetScriptName(i).start(), | 1985 strcmp(ExperimentalNatives::GetScriptName(i).start(), |
1933 "native typedarray.js") == 0) { | 1986 "native typedarray.js") == 0) { |
1934 if (!CompileExperimentalBuiltin(isolate(), i)) return false; | 1987 if (!CompileExperimentalBuiltin(isolate(), i)) return false; |
1935 } | 1988 } |
| 1989 if (FLAG_harmony_generators && |
| 1990 strcmp(ExperimentalNatives::GetScriptName(i).start(), |
| 1991 "native generator.js") == 0) { |
| 1992 if (!CompileExperimentalBuiltin(isolate(), i)) return false; |
| 1993 } |
1936 } | 1994 } |
1937 | 1995 |
1938 InstallExperimentalNativeFunctions(); | 1996 InstallExperimentalNativeFunctions(); |
1939 | 1997 |
1940 return true; | 1998 return true; |
1941 } | 1999 } |
1942 | 2000 |
1943 | 2001 |
1944 static Handle<JSObject> ResolveBuiltinIdHolder( | 2002 static Handle<JSObject> ResolveBuiltinIdHolder( |
1945 Handle<Context> native_context, | 2003 Handle<Context> native_context, |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2510 return from + sizeof(NestingCounterType); | 2568 return from + sizeof(NestingCounterType); |
2511 } | 2569 } |
2512 | 2570 |
2513 | 2571 |
2514 // Called when the top-level V8 mutex is destroyed. | 2572 // Called when the top-level V8 mutex is destroyed. |
2515 void Bootstrapper::FreeThreadResources() { | 2573 void Bootstrapper::FreeThreadResources() { |
2516 ASSERT(!IsActive()); | 2574 ASSERT(!IsActive()); |
2517 } | 2575 } |
2518 | 2576 |
2519 } } // namespace v8::internal | 2577 } } // namespace v8::internal |
OLD | NEW |