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

Side by Side Diff: src/bootstrapper.cc

Issue 694533003: Add FLAG_trace_maps (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: updates Created 6 years, 1 month 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/api.cc ('k') | src/factory.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/bootstrapper.h" 5 #include "src/bootstrapper.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 #include "src/extensions/externalize-string-extension.h" 9 #include "src/extensions/externalize-string-extension.h"
10 #include "src/extensions/free-buffer-extension.h" 10 #include "src/extensions/free-buffer-extension.h"
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 if (env.is_null() || !InstallExtensions(env, extensions)) { 354 if (env.is_null() || !InstallExtensions(env, extensions)) {
355 return Handle<Context>(); 355 return Handle<Context>();
356 } 356 }
357 return scope.CloseAndEscape(env); 357 return scope.CloseAndEscape(env);
358 } 358 }
359 359
360 360
361 static void SetObjectPrototype(Handle<JSObject> object, Handle<Object> proto) { 361 static void SetObjectPrototype(Handle<JSObject> object, Handle<Object> proto) {
362 // object.__proto__ = proto; 362 // object.__proto__ = proto;
363 Handle<Map> old_map = Handle<Map>(object->map()); 363 Handle<Map> old_map = Handle<Map>(object->map());
364 Handle<Map> new_map = Map::Copy(old_map); 364 Handle<Map> new_map = Map::Copy(old_map, "SetObjectPrototype");
365 new_map->set_prototype(*proto); 365 new_map->set_prototype(*proto);
366 JSObject::MigrateToMap(object, new_map); 366 JSObject::MigrateToMap(object, new_map);
367 } 367 }
368 368
369 369
370 void Bootstrapper::DetachGlobal(Handle<Context> env) { 370 void Bootstrapper::DetachGlobal(Handle<Context> env) {
371 Factory* factory = env->GetIsolate()->factory(); 371 Factory* factory = env->GetIsolate()->factory();
372 Handle<JSGlobalProxy> global_proxy(JSGlobalProxy::cast(env->global_proxy())); 372 Handle<JSGlobalProxy> global_proxy(JSGlobalProxy::cast(env->global_proxy()));
373 global_proxy->set_native_context(*factory->null_value()); 373 global_proxy->set_native_context(*factory->null_value());
374 SetObjectPrototype(global_proxy, factory->null_value()); 374 SetObjectPrototype(global_proxy, factory->null_value());
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 JSFunction::SetInitialMap(object_fun, object_function_map, 503 JSFunction::SetInitialMap(object_fun, object_function_map,
504 isolate->factory()->null_value()); 504 isolate->factory()->null_value());
505 object_function_map->set_unused_property_fields(unused); 505 object_function_map->set_unused_property_fields(unused);
506 506
507 native_context()->set_object_function(*object_fun); 507 native_context()->set_object_function(*object_fun);
508 508
509 // Allocate a new prototype for the object function. 509 // Allocate a new prototype for the object function.
510 Handle<JSObject> prototype = factory->NewJSObject( 510 Handle<JSObject> prototype = factory->NewJSObject(
511 isolate->object_function(), 511 isolate->object_function(),
512 TENURED); 512 TENURED);
513 Handle<Map> map = Map::Copy(handle(prototype->map())); 513 Handle<Map> map =
514 Map::Copy(handle(prototype->map()), "EmptyObjectPrototype");
514 map->set_is_prototype_map(true); 515 map->set_is_prototype_map(true);
515 prototype->set_map(*map); 516 prototype->set_map(*map);
516 517
517 native_context()->set_initial_object_prototype(*prototype); 518 native_context()->set_initial_object_prototype(*prototype);
518 // For bootstrapping set the array prototype to be the same as the object 519 // For bootstrapping set the array prototype to be the same as the object
519 // prototype, otherwise the missing initial_array_prototype will cause 520 // prototype, otherwise the missing initial_array_prototype will cause
520 // assertions during startup. 521 // assertions during startup.
521 native_context()->set_initial_array_prototype(*prototype); 522 native_context()->set_initial_array_prototype(*prototype);
522 Accessors::FunctionSetPrototype(object_fun, prototype).Assert(); 523 Accessors::FunctionSetPrototype(object_fun, prototype).Assert();
523 } 524 }
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 } 1083 }
1083 1084
1084 initial_map->set_inobject_properties(5); 1085 initial_map->set_inobject_properties(5);
1085 initial_map->set_pre_allocated_property_fields(5); 1086 initial_map->set_pre_allocated_property_fields(5);
1086 initial_map->set_unused_property_fields(0); 1087 initial_map->set_unused_property_fields(0);
1087 initial_map->set_instance_size( 1088 initial_map->set_instance_size(
1088 initial_map->instance_size() + 5 * kPointerSize); 1089 initial_map->instance_size() + 5 * kPointerSize);
1089 initial_map->set_visitor_id(StaticVisitorBase::GetVisitorId(*initial_map)); 1090 initial_map->set_visitor_id(StaticVisitorBase::GetVisitorId(*initial_map));
1090 1091
1091 // RegExp prototype object is itself a RegExp. 1092 // RegExp prototype object is itself a RegExp.
1092 Handle<Map> proto_map = Map::Copy(initial_map); 1093 Handle<Map> proto_map = Map::Copy(initial_map, "RegExpPrototype");
1093 proto_map->set_prototype(native_context()->initial_object_prototype()); 1094 proto_map->set_prototype(native_context()->initial_object_prototype());
1094 Handle<JSObject> proto = factory->NewJSObjectFromMap(proto_map); 1095 Handle<JSObject> proto = factory->NewJSObjectFromMap(proto_map);
1095 proto->InObjectPropertyAtPut(JSRegExp::kSourceFieldIndex, 1096 proto->InObjectPropertyAtPut(JSRegExp::kSourceFieldIndex,
1096 heap->query_colon_string()); 1097 heap->query_colon_string());
1097 proto->InObjectPropertyAtPut(JSRegExp::kGlobalFieldIndex, 1098 proto->InObjectPropertyAtPut(JSRegExp::kGlobalFieldIndex,
1098 heap->false_value()); 1099 heap->false_value());
1099 proto->InObjectPropertyAtPut(JSRegExp::kIgnoreCaseFieldIndex, 1100 proto->InObjectPropertyAtPut(JSRegExp::kIgnoreCaseFieldIndex,
1100 heap->false_value()); 1101 heap->false_value());
1101 proto->InObjectPropertyAtPut(JSRegExp::kMultilineFieldIndex, 1102 proto->InObjectPropertyAtPut(JSRegExp::kMultilineFieldIndex,
1102 heap->false_value()); 1103 heap->false_value());
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 JSFunction::SetInitialMap(function, map, 1238 JSFunction::SetInitialMap(function, map,
1238 isolate->initial_object_prototype()); 1239 isolate->initial_object_prototype());
1239 1240
1240 DCHECK(map->inobject_properties() > Heap::kArgumentsCalleeIndex); 1241 DCHECK(map->inobject_properties() > Heap::kArgumentsCalleeIndex);
1241 DCHECK(map->inobject_properties() > Heap::kArgumentsLengthIndex); 1242 DCHECK(map->inobject_properties() > Heap::kArgumentsLengthIndex);
1242 DCHECK(!map->is_dictionary_map()); 1243 DCHECK(!map->is_dictionary_map());
1243 DCHECK(IsFastObjectElementsKind(map->elements_kind())); 1244 DCHECK(IsFastObjectElementsKind(map->elements_kind()));
1244 } 1245 }
1245 1246
1246 { // --- aliased arguments map 1247 { // --- aliased arguments map
1247 Handle<Map> map = Map::Copy(isolate->sloppy_arguments_map()); 1248 Handle<Map> map =
1249 Map::Copy(isolate->sloppy_arguments_map(), "AliasedArguments");
1248 map->set_elements_kind(SLOPPY_ARGUMENTS_ELEMENTS); 1250 map->set_elements_kind(SLOPPY_ARGUMENTS_ELEMENTS);
1249 DCHECK_EQ(2, map->pre_allocated_property_fields()); 1251 DCHECK_EQ(2, map->pre_allocated_property_fields());
1250 native_context()->set_aliased_arguments_map(*map); 1252 native_context()->set_aliased_arguments_map(*map);
1251 } 1253 }
1252 1254
1253 { // --- strict mode arguments map 1255 { // --- strict mode arguments map
1254 const PropertyAttributes attributes = 1256 const PropertyAttributes attributes =
1255 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); 1257 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
1256 1258
1257 // Create the ThrowTypeError functions. 1259 // Create the ThrowTypeError functions.
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
1650 Handle<JSFunction> array_function = InstallFunction( 1652 Handle<JSFunction> array_function = InstallFunction(
1651 builtins, name, JS_ARRAY_TYPE, JSArray::kSize, 1653 builtins, name, JS_ARRAY_TYPE, JSArray::kSize,
1652 prototype, Builtins::kInternalArrayCode); 1654 prototype, Builtins::kInternalArrayCode);
1653 1655
1654 InternalArrayConstructorStub internal_array_constructor_stub(isolate()); 1656 InternalArrayConstructorStub internal_array_constructor_stub(isolate());
1655 Handle<Code> code = internal_array_constructor_stub.GetCode(); 1657 Handle<Code> code = internal_array_constructor_stub.GetCode();
1656 array_function->shared()->set_construct_stub(*code); 1658 array_function->shared()->set_construct_stub(*code);
1657 array_function->shared()->DontAdaptArguments(); 1659 array_function->shared()->DontAdaptArguments();
1658 1660
1659 Handle<Map> original_map(array_function->initial_map()); 1661 Handle<Map> original_map(array_function->initial_map());
1660 Handle<Map> initial_map = Map::Copy(original_map); 1662 Handle<Map> initial_map = Map::Copy(original_map, "InternalArray");
1661 initial_map->set_elements_kind(elements_kind); 1663 initial_map->set_elements_kind(elements_kind);
1662 JSFunction::SetInitialMap(array_function, initial_map, prototype); 1664 JSFunction::SetInitialMap(array_function, initial_map, prototype);
1663 1665
1664 // Make "length" magic on instances. 1666 // Make "length" magic on instances.
1665 Map::EnsureDescriptorSlack(initial_map, 1); 1667 Map::EnsureDescriptorSlack(initial_map, 1);
1666 1668
1667 PropertyAttributes attribs = static_cast<PropertyAttributes>( 1669 PropertyAttributes attribs = static_cast<PropertyAttributes>(
1668 DONT_ENUM | DONT_DELETE); 1670 DONT_ENUM | DONT_DELETE);
1669 1671
1670 Handle<AccessorInfo> array_length = 1672 Handle<AccessorInfo> array_length =
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
1928 InstallFunction(builtins, "GeneratorFunctionPrototype", 1930 InstallFunction(builtins, "GeneratorFunctionPrototype",
1929 JS_FUNCTION_TYPE, JSFunction::kHeaderSize, 1931 JS_FUNCTION_TYPE, JSFunction::kHeaderSize,
1930 generator_object_prototype, Builtins::kIllegal); 1932 generator_object_prototype, Builtins::kIllegal);
1931 InstallFunction(builtins, "GeneratorFunction", JS_FUNCTION_TYPE, 1933 InstallFunction(builtins, "GeneratorFunction", JS_FUNCTION_TYPE,
1932 JSFunction::kSize, generator_function_prototype, 1934 JSFunction::kSize, generator_function_prototype,
1933 Builtins::kIllegal); 1935 Builtins::kIllegal);
1934 1936
1935 // Create maps for generator functions and their prototypes. Store those 1937 // Create maps for generator functions and their prototypes. Store those
1936 // maps in the native context. 1938 // maps in the native context.
1937 Handle<Map> generator_function_map = 1939 Handle<Map> generator_function_map =
1938 Map::Copy(sloppy_function_map_writable_prototype_); 1940 Map::Copy(sloppy_function_map_writable_prototype_, "GeneratorFunction");
1939 generator_function_map->set_prototype(*generator_function_prototype); 1941 generator_function_map->set_prototype(*generator_function_prototype);
1940 native_context()->set_sloppy_generator_function_map( 1942 native_context()->set_sloppy_generator_function_map(
1941 *generator_function_map); 1943 *generator_function_map);
1942 1944
1943 // The "arguments" and "caller" instance properties aren't specified, so 1945 // The "arguments" and "caller" instance properties aren't specified, so
1944 // technically we could leave them out. They make even less sense for 1946 // technically we could leave them out. They make even less sense for
1945 // generators than for functions. Still, the same argument that it makes 1947 // generators than for functions. Still, the same argument that it makes
1946 // sense to keep them around but poisoned in strict mode applies to 1948 // sense to keep them around but poisoned in strict mode applies to
1947 // generators as well. With poisoned accessors, naive callers can still 1949 // generators as well. With poisoned accessors, naive callers can still
1948 // iterate over the properties without accessing them. 1950 // iterate over the properties without accessing them.
(...skipping 10 matching lines...) Expand all
1959 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); 1961 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE);
1960 Handle<JSFunction> poison_function = GetGeneratorPoisonFunction(); 1962 Handle<JSFunction> poison_function = GetGeneratorPoisonFunction();
1961 poison_pair->set_getter(*poison_function); 1963 poison_pair->set_getter(*poison_function);
1962 poison_pair->set_setter(*poison_function); 1964 poison_pair->set_setter(*poison_function);
1963 ReplaceAccessors(generator_function_map, factory()->arguments_string(), 1965 ReplaceAccessors(generator_function_map, factory()->arguments_string(),
1964 rw_attribs, poison_pair); 1966 rw_attribs, poison_pair);
1965 ReplaceAccessors(generator_function_map, factory()->caller_string(), 1967 ReplaceAccessors(generator_function_map, factory()->caller_string(),
1966 rw_attribs, poison_pair); 1968 rw_attribs, poison_pair);
1967 1969
1968 Handle<Map> strict_function_map(native_context()->strict_function_map()); 1970 Handle<Map> strict_function_map(native_context()->strict_function_map());
1969 Handle<Map> strict_generator_function_map = Map::Copy(strict_function_map); 1971 Handle<Map> strict_generator_function_map =
1972 Map::Copy(strict_function_map, "StrictGeneratorFunction");
1970 // "arguments" and "caller" already poisoned. 1973 // "arguments" and "caller" already poisoned.
1971 strict_generator_function_map->set_prototype(*generator_function_prototype); 1974 strict_generator_function_map->set_prototype(*generator_function_prototype);
1972 native_context()->set_strict_generator_function_map( 1975 native_context()->set_strict_generator_function_map(
1973 *strict_generator_function_map); 1976 *strict_generator_function_map);
1974 1977
1975 Handle<JSFunction> object_function(native_context()->object_function()); 1978 Handle<JSFunction> object_function(native_context()->object_function());
1976 Handle<Map> generator_object_prototype_map = Map::Create(isolate(), 0); 1979 Handle<Map> generator_object_prototype_map = Map::Create(isolate(), 0);
1977 generator_object_prototype_map->set_prototype(*generator_object_prototype); 1980 generator_object_prototype_map->set_prototype(*generator_object_prototype);
1978 native_context()->set_generator_object_prototype_map( 1981 native_context()->set_generator_object_prototype_map(
1979 *generator_object_prototype_map); 1982 *generator_object_prototype_map);
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
2705 if (isolate->initialized_from_snapshot()) { 2708 if (isolate->initialized_from_snapshot()) {
2706 native_context_ = Snapshot::NewContextFromSnapshot(isolate); 2709 native_context_ = Snapshot::NewContextFromSnapshot(isolate);
2707 } else { 2710 } else {
2708 native_context_ = Handle<Context>(); 2711 native_context_ = Handle<Context>();
2709 } 2712 }
2710 2713
2711 if (!native_context().is_null()) { 2714 if (!native_context().is_null()) {
2712 AddToWeakNativeContextList(*native_context()); 2715 AddToWeakNativeContextList(*native_context());
2713 isolate->set_context(*native_context()); 2716 isolate->set_context(*native_context());
2714 isolate->counters()->contexts_created_by_snapshot()->Increment(); 2717 isolate->counters()->contexts_created_by_snapshot()->Increment();
2718 #if TRACE_MAPS
2719 if (FLAG_trace_maps) {
2720 Handle<JSFunction> object_fun = isolate->object_function();
2721 PrintF("[TraceMap: InitialMap map= %p SFI= %d_Object ]\n",
2722 reinterpret_cast<void*>(object_fun->initial_map()),
2723 object_fun->shared()->unique_id());
2724 Map::TraceAllTransitions(object_fun->initial_map());
2725 }
2726 #endif
2715 Handle<GlobalObject> global_object; 2727 Handle<GlobalObject> global_object;
2716 Handle<JSGlobalProxy> global_proxy = CreateNewGlobals( 2728 Handle<JSGlobalProxy> global_proxy = CreateNewGlobals(
2717 global_proxy_template, maybe_global_proxy, &global_object); 2729 global_proxy_template, maybe_global_proxy, &global_object);
2718 2730
2719 HookUpGlobalProxy(global_object, global_proxy); 2731 HookUpGlobalProxy(global_object, global_proxy);
2720 HookUpGlobalObject(global_object); 2732 HookUpGlobalObject(global_object);
2721 native_context()->builtins()->set_global_proxy( 2733 native_context()->builtins()->set_global_proxy(
2722 native_context()->global_proxy()); 2734 native_context()->global_proxy());
2723 2735
2724 if (!ConfigureGlobalObjects(global_proxy_template)) return; 2736 if (!ConfigureGlobalObjects(global_proxy_template)) return;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
2810 return from + sizeof(NestingCounterType); 2822 return from + sizeof(NestingCounterType);
2811 } 2823 }
2812 2824
2813 2825
2814 // Called when the top-level V8 mutex is destroyed. 2826 // Called when the top-level V8 mutex is destroyed.
2815 void Bootstrapper::FreeThreadResources() { 2827 void Bootstrapper::FreeThreadResources() {
2816 DCHECK(!IsActive()); 2828 DCHECK(!IsActive());
2817 } 2829 }
2818 2830
2819 } } // namespace v8::internal 2831 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698