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

Side by Side Diff: src/bootstrapper.cc

Issue 8139027: Version 3.6.5 (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: '' Created 9 years, 2 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/ast.cc ('k') | src/builtins.cc » ('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 16 matching lines...) Expand all
27 27
28 #include "v8.h" 28 #include "v8.h"
29 29
30 #include "accessors.h" 30 #include "accessors.h"
31 #include "api.h" 31 #include "api.h"
32 #include "bootstrapper.h" 32 #include "bootstrapper.h"
33 #include "compiler.h" 33 #include "compiler.h"
34 #include "debug.h" 34 #include "debug.h"
35 #include "execution.h" 35 #include "execution.h"
36 #include "global-handles.h" 36 #include "global-handles.h"
37 #include "isolate-inl.h"
37 #include "macro-assembler.h" 38 #include "macro-assembler.h"
38 #include "natives.h" 39 #include "natives.h"
39 #include "objects-visiting.h" 40 #include "objects-visiting.h"
40 #include "snapshot.h" 41 #include "snapshot.h"
41 #include "extensions/externalize-string-extension.h" 42 #include "extensions/externalize-string-extension.h"
42 #include "extensions/gc-extension.h" 43 #include "extensions/gc-extension.h"
43 44
44 namespace v8 { 45 namespace v8 {
45 namespace internal { 46 namespace internal {
46 47
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 descriptors->SetNextEnumerationIndex(enum_index); 989 descriptors->SetNextEnumerationIndex(enum_index);
989 descriptors->Sort(); 990 descriptors->Sort();
990 991
991 initial_map->set_inobject_properties(5); 992 initial_map->set_inobject_properties(5);
992 initial_map->set_pre_allocated_property_fields(5); 993 initial_map->set_pre_allocated_property_fields(5);
993 initial_map->set_unused_property_fields(0); 994 initial_map->set_unused_property_fields(0);
994 initial_map->set_instance_size( 995 initial_map->set_instance_size(
995 initial_map->instance_size() + 5 * kPointerSize); 996 initial_map->instance_size() + 5 * kPointerSize);
996 initial_map->set_instance_descriptors(*descriptors); 997 initial_map->set_instance_descriptors(*descriptors);
997 initial_map->set_visitor_id(StaticVisitorBase::GetVisitorId(*initial_map)); 998 initial_map->set_visitor_id(StaticVisitorBase::GetVisitorId(*initial_map));
999
1000 // RegExp prototype object is itself a RegExp.
1001 Handle<Map> proto_map = factory->CopyMapDropTransitions(initial_map);
1002 proto_map->set_prototype(global_context()->initial_object_prototype());
1003 Handle<JSObject> proto = factory->NewJSObjectFromMap(proto_map);
1004 proto->InObjectPropertyAtPut(JSRegExp::kSourceFieldIndex,
1005 heap->empty_string());
1006 proto->InObjectPropertyAtPut(JSRegExp::kGlobalFieldIndex,
1007 heap->false_value());
1008 proto->InObjectPropertyAtPut(JSRegExp::kIgnoreCaseFieldIndex,
1009 heap->false_value());
1010 proto->InObjectPropertyAtPut(JSRegExp::kMultilineFieldIndex,
1011 heap->false_value());
1012 proto->InObjectPropertyAtPut(JSRegExp::kLastIndexFieldIndex,
1013 Smi::FromInt(0),
1014 SKIP_WRITE_BARRIER); // It's a Smi.
1015 initial_map->set_prototype(*proto);
1016 factory->SetRegExpIrregexpData(Handle<JSRegExp>::cast(proto),
1017 JSRegExp::IRREGEXP, factory->empty_string(),
1018 JSRegExp::Flags(0), 0);
998 } 1019 }
999 1020
1000 { // -- J S O N 1021 { // -- J S O N
1001 Handle<String> name = factory->NewStringFromAscii(CStrVector("JSON")); 1022 Handle<String> name = factory->NewStringFromAscii(CStrVector("JSON"));
1002 Handle<JSFunction> cons = factory->NewFunction( 1023 Handle<JSFunction> cons = factory->NewFunction(
1003 name, 1024 name,
1004 factory->the_hole_value()); 1025 factory->the_hole_value());
1005 cons->SetInstancePrototype(global_context()->initial_object_prototype()); 1026 cons->SetInstancePrototype(global_context()->initial_object_prototype());
1006 cons->SetInstanceClassName(*name); 1027 cons->SetInstanceClassName(*name);
1007 Handle<JSObject> json_object = factory->NewJSObject(cons, TENURED); 1028 Handle<JSObject> json_object = factory->NewJSObject(cons, TENURED);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1069 Handle<JSObject> result = factory->NewJSObjectFromMap(new_map); 1090 Handle<JSObject> result = factory->NewJSObjectFromMap(new_map);
1070 new_map->set_elements_kind(NON_STRICT_ARGUMENTS_ELEMENTS); 1091 new_map->set_elements_kind(NON_STRICT_ARGUMENTS_ELEMENTS);
1071 // Set up a well-formed parameter map to make assertions happy. 1092 // Set up a well-formed parameter map to make assertions happy.
1072 Handle<FixedArray> elements = factory->NewFixedArray(2); 1093 Handle<FixedArray> elements = factory->NewFixedArray(2);
1073 elements->set_map(heap->non_strict_arguments_elements_map()); 1094 elements->set_map(heap->non_strict_arguments_elements_map());
1074 Handle<FixedArray> array; 1095 Handle<FixedArray> array;
1075 array = factory->NewFixedArray(0); 1096 array = factory->NewFixedArray(0);
1076 elements->set(0, *array); 1097 elements->set(0, *array);
1077 array = factory->NewFixedArray(0); 1098 array = factory->NewFixedArray(0);
1078 elements->set(1, *array); 1099 elements->set(1, *array);
1100 Handle<Map> non_strict_arguments_elements_map =
1101 factory->GetElementsTransitionMap(result,
1102 NON_STRICT_ARGUMENTS_ELEMENTS);
1103 result->set_map(*non_strict_arguments_elements_map);
1104 ASSERT(result->HasNonStrictArgumentsElements());
1079 result->set_elements(*elements); 1105 result->set_elements(*elements);
1080 global_context()->set_aliased_arguments_boilerplate(*result); 1106 global_context()->set_aliased_arguments_boilerplate(*result);
1081 } 1107 }
1082 1108
1083 { // --- strict mode arguments boilerplate 1109 { // --- strict mode arguments boilerplate
1084 const PropertyAttributes attributes = 1110 const PropertyAttributes attributes =
1085 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); 1111 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
1086 1112
1087 // Create the ThrowTypeError functions. 1113 // Create the ThrowTypeError functions.
1088 Handle<FixedArray> callee = factory->NewFixedArray(2, TENURED); 1114 Handle<FixedArray> callee = factory->NewFixedArray(2, TENURED);
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1320 INSTALL_NATIVE(JSFunction, "ToObject", to_object_fun); 1346 INSTALL_NATIVE(JSFunction, "ToObject", to_object_fun);
1321 INSTALL_NATIVE(JSFunction, "ToInteger", to_integer_fun); 1347 INSTALL_NATIVE(JSFunction, "ToInteger", to_integer_fun);
1322 INSTALL_NATIVE(JSFunction, "ToUint32", to_uint32_fun); 1348 INSTALL_NATIVE(JSFunction, "ToUint32", to_uint32_fun);
1323 INSTALL_NATIVE(JSFunction, "ToInt32", to_int32_fun); 1349 INSTALL_NATIVE(JSFunction, "ToInt32", to_int32_fun);
1324 INSTALL_NATIVE(JSFunction, "GlobalEval", global_eval_fun); 1350 INSTALL_NATIVE(JSFunction, "GlobalEval", global_eval_fun);
1325 INSTALL_NATIVE(JSFunction, "Instantiate", instantiate_fun); 1351 INSTALL_NATIVE(JSFunction, "Instantiate", instantiate_fun);
1326 INSTALL_NATIVE(JSFunction, "ConfigureTemplateInstance", 1352 INSTALL_NATIVE(JSFunction, "ConfigureTemplateInstance",
1327 configure_instance_fun); 1353 configure_instance_fun);
1328 INSTALL_NATIVE(JSFunction, "GetStackTraceLine", get_stack_trace_line_fun); 1354 INSTALL_NATIVE(JSFunction, "GetStackTraceLine", get_stack_trace_line_fun);
1329 INSTALL_NATIVE(JSObject, "functionCache", function_cache); 1355 INSTALL_NATIVE(JSObject, "functionCache", function_cache);
1356 INSTALL_NATIVE(JSFunction, "ToCompletePropertyDescriptor",
1357 to_complete_property_descriptor);
1330 } 1358 }
1331 1359
1332 void Genesis::InstallExperimentalNativeFunctions() { 1360 void Genesis::InstallExperimentalNativeFunctions() {
1333 if (FLAG_harmony_proxies) { 1361 if (FLAG_harmony_proxies) {
1334 INSTALL_NATIVE(JSFunction, "DerivedHasTrap", derived_has_trap); 1362 INSTALL_NATIVE(JSFunction, "DerivedHasTrap", derived_has_trap);
1335 INSTALL_NATIVE(JSFunction, "DerivedGetTrap", derived_get_trap); 1363 INSTALL_NATIVE(JSFunction, "DerivedGetTrap", derived_get_trap);
1336 INSTALL_NATIVE(JSFunction, "DerivedSetTrap", derived_set_trap); 1364 INSTALL_NATIVE(JSFunction, "DerivedSetTrap", derived_set_trap);
1337 } 1365 }
1338 } 1366 }
1339 1367
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1548 Builtins::kArrayCode, 1576 Builtins::kArrayCode,
1549 true); 1577 true);
1550 Handle<JSObject> prototype = 1578 Handle<JSObject> prototype =
1551 factory()->NewJSObject(isolate()->object_function(), TENURED); 1579 factory()->NewJSObject(isolate()->object_function(), TENURED);
1552 SetPrototype(array_function, prototype); 1580 SetPrototype(array_function, prototype);
1553 1581
1554 array_function->shared()->set_construct_stub( 1582 array_function->shared()->set_construct_stub(
1555 isolate()->builtins()->builtin(Builtins::kArrayConstructCode)); 1583 isolate()->builtins()->builtin(Builtins::kArrayConstructCode));
1556 array_function->shared()->DontAdaptArguments(); 1584 array_function->shared()->DontAdaptArguments();
1557 1585
1586 // InternalArrays should not use Smi-Only array optimizations. There are too
1587 // many places in the C++ runtime code (e.g. RegEx) that assume that
1588 // elements in InternalArrays can be set to non-Smi values without going
1589 // through a common bottleneck that would make the SMI_ONLY -> FAST_ELEMENT
1590 // transition easy to trap. Moreover, they rarely are smi-only.
1591 MaybeObject* maybe_map =
1592 array_function->initial_map()->CopyDropTransitions();
1593 Map* new_map;
1594 if (!maybe_map->To<Map>(&new_map)) return maybe_map;
1595 new_map->set_elements_kind(FAST_ELEMENTS);
1596 array_function->set_initial_map(new_map);
1597
1558 // Make "length" magic on instances. 1598 // Make "length" magic on instances.
1559 Handle<DescriptorArray> array_descriptors = 1599 Handle<DescriptorArray> array_descriptors =
1560 factory()->CopyAppendForeignDescriptor( 1600 factory()->CopyAppendForeignDescriptor(
1561 factory()->empty_descriptor_array(), 1601 factory()->empty_descriptor_array(),
1562 factory()->length_symbol(), 1602 factory()->length_symbol(),
1563 factory()->NewForeign(&Accessors::ArrayLength), 1603 factory()->NewForeign(&Accessors::ArrayLength),
1564 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE)); 1604 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE));
1565 1605
1566 array_function->initial_map()->set_instance_descriptors( 1606 array_function->initial_map()->set_instance_descriptors(
1567 *array_descriptors); 1607 *array_descriptors);
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
1931 return false; 1971 return false;
1932 } 1972 }
1933 ASSERT(current->state() == v8::UNVISITED); 1973 ASSERT(current->state() == v8::UNVISITED);
1934 current->set_state(v8::VISITED); 1974 current->set_state(v8::VISITED);
1935 v8::Extension* extension = current->extension(); 1975 v8::Extension* extension = current->extension();
1936 // Install the extension's dependencies 1976 // Install the extension's dependencies
1937 for (int i = 0; i < extension->dependency_count(); i++) { 1977 for (int i = 0; i < extension->dependency_count(); i++) {
1938 if (!InstallExtension(extension->dependencies()[i])) return false; 1978 if (!InstallExtension(extension->dependencies()[i])) return false;
1939 } 1979 }
1940 Isolate* isolate = Isolate::Current(); 1980 Isolate* isolate = Isolate::Current();
1941 Vector<const char> source = CStrVector(extension->source()); 1981 Handle<String> source_code =
1942 Handle<String> source_code = isolate->factory()->NewStringFromAscii(source); 1982 isolate->factory()->NewExternalStringFromAscii(extension->source());
1943 bool result = CompileScriptCached(CStrVector(extension->name()), 1983 bool result = CompileScriptCached(
1944 source_code, 1984 CStrVector(extension->name()),
1945 isolate->bootstrapper()->extensions_cache(), 1985 source_code,
1946 extension, 1986 isolate->bootstrapper()->extensions_cache(),
1947 Handle<Context>(isolate->context()), 1987 extension,
1948 false); 1988 Handle<Context>(isolate->context()),
1989 false);
1949 ASSERT(isolate->has_pending_exception() != result); 1990 ASSERT(isolate->has_pending_exception() != result);
1950 if (!result) { 1991 if (!result) {
1951 isolate->clear_pending_exception(); 1992 isolate->clear_pending_exception();
1952 } 1993 }
1953 current->set_state(v8::INSTALLED); 1994 current->set_state(v8::INSTALLED);
1954 return result; 1995 return result;
1955 } 1996 }
1956 1997
1957 1998
1958 bool Genesis::InstallJSBuiltins(Handle<JSBuiltinsObject> builtins) { 1999 bool Genesis::InstallJSBuiltins(Handle<JSBuiltinsObject> builtins) {
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
2225 return from + sizeof(NestingCounterType); 2266 return from + sizeof(NestingCounterType);
2226 } 2267 }
2227 2268
2228 2269
2229 // Called when the top-level V8 mutex is destroyed. 2270 // Called when the top-level V8 mutex is destroyed.
2230 void Bootstrapper::FreeThreadResources() { 2271 void Bootstrapper::FreeThreadResources() {
2231 ASSERT(!IsActive()); 2272 ASSERT(!IsActive());
2232 } 2273 }
2233 2274
2234 } } // namespace v8::internal 2275 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast.cc ('k') | src/builtins.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698