54 : data_(source), length_(length) {
55 if (bootstrapper->delete_these_non_arrays_on_tear_down_ ==
NULL) {
56 bootstrapper->delete_these_non_arrays_on_tear_down_ =
new List<char*>(2);
60 bootstrapper->delete_these_non_arrays_on_tear_down_->
61 Add(reinterpret_cast<char*>(
this));
65 Bootstrapper::Bootstrapper()
67 extensions_cache_(
Script::TYPE_EXTENSION),
68 delete_these_non_arrays_on_tear_down_(
NULL),
69 delete_these_arrays_on_tear_down_(
NULL) {
75 Isolate* isolate = Isolate::Current();
78 if (heap->natives_source_cache()->get(index)->IsUndefined()) {
87 heap->natives_source_cache()->set(index, *source_code);
89 Handle<Object> cached_source(heap->natives_source_cache()->get(index));
95 extensions_cache_.Initialize(create_heap_objects);
102 char* memory =
new char[bytes];
103 if (memory !=
NULL) {
104 if (delete_these_arrays_on_tear_down_ ==
NULL) {
105 delete_these_arrays_on_tear_down_ =
new List<char*>(2);
107 delete_these_arrays_on_tear_down_->
Add(memory);
114 if (delete_these_non_arrays_on_tear_down_ !=
NULL) {
115 int len = delete_these_non_arrays_on_tear_down_->length();
117 for (
int i = 0; i < len; i++) {
118 delete delete_these_non_arrays_on_tear_down_->
at(i);
119 delete_these_non_arrays_on_tear_down_->
at(i) =
NULL;
121 delete delete_these_non_arrays_on_tear_down_;
122 delete_these_non_arrays_on_tear_down_ =
NULL;
125 if (delete_these_arrays_on_tear_down_ !=
NULL) {
126 int len = delete_these_arrays_on_tear_down_->length();
128 for (
int i = 0; i < len; i++) {
129 delete[] delete_these_arrays_on_tear_down_->
at(i);
130 delete_these_arrays_on_tear_down_->
at(i) =
NULL;
132 delete delete_these_arrays_on_tear_down_;
133 delete_these_arrays_on_tear_down_ =
NULL;
136 extensions_cache_.Initialize(
false);
201 void InitializeExperimentalGlobal();
204 void InstallNativeFunctions();
205 void InstallExperimentalNativeFunctions();
206 bool InstallNatives();
207 bool InstallExperimentalNatives();
208 void InstallBuiltinFunctionIds();
209 void InstallJSFunctionResultCaches();
210 void InitializeNormalizedMapCaches();
212 enum ExtensionTraversalState {
213 UNVISITED, VISITED, INSTALLED
216 class ExtensionStates {
219 ExtensionTraversalState get_state(RegisteredExtension* extension);
220 void set_state(RegisteredExtension* extension,
221 ExtensionTraversalState state);
229 static bool InstallExtensions(Handle<Context> global_context,
231 static bool InstallExtension(
const char*
name,
232 ExtensionStates* extension_states);
234 ExtensionStates* extension_states);
235 static void InstallSpecialObjects(Handle<Context> global_context);
236 bool InstallJSBuiltins(Handle<JSBuiltinsObject> builtins);
237 bool ConfigureApiObject(Handle<JSObject>
object,
238 Handle<ObjectTemplateInfo> object_template);
244 void TransferObject(Handle<JSObject> from, Handle<JSObject> to);
245 void TransferNamedProperties(Handle<JSObject> from, Handle<JSObject> to);
246 void TransferIndexedProperties(Handle<JSObject> from, Handle<JSObject> to);
248 enum PrototypePropertyMode {
250 ADD_READONLY_PROTOTYPE,
251 ADD_WRITEABLE_PROTOTYPE
254 Handle<Map> CreateFunctionMap(PrototypePropertyMode prototype_mode);
256 Handle<DescriptorArray> ComputeFunctionInstanceDescriptor(
257 PrototypePropertyMode prototypeMode);
258 void MakeFunctionInstancePrototypeWritable();
260 Handle<Map> CreateStrictModeFunctionMap(
261 PrototypePropertyMode prototype_mode,
262 Handle<JSFunction> empty_function);
264 Handle<DescriptorArray> ComputeStrictFunctionInstanceDescriptor(
265 PrototypePropertyMode propertyMode);
267 static bool CompileBuiltin(Isolate* isolate,
int index);
268 static bool CompileExperimentalBuiltin(Isolate* isolate,
int index);
269 static bool CompileNative(Vector<const char>
name, Handle<String> source);
270 static bool CompileScriptCached(Vector<const char>
name,
271 Handle<String> source,
272 SourceCodeCache* cache,
274 Handle<Context> top_context,
275 bool use_runtime_context);
277 Handle<Context> result_;
283 Handle<Map> function_instance_map_writable_prototype_;
284 Handle<Map> strict_mode_function_instance_map_writable_prototype_;
285 Handle<JSFunction> throw_type_error_function;
287 BootstrapperActive active_;
293 extensions_cache_.Iterate(v);
294 v->Synchronize(VisitorSynchronization::kExtensions);
305 Genesis genesis(isolate, global_object, global_template, extensions);
306 env = genesis.result();
307 if (!env.is_null()) {
318 Factory* factory =
object->GetIsolate()->factory();
321 new_to_map->set_prototype(*proto);
322 object->set_map(*new_to_map);
327 Factory* factory = env->GetIsolate()->factory();
330 factory->null_value());
331 env->set_global_proxy(env->global());
332 env->global()->set_global_receiver(env->global());
338 ASSERT(global_object->IsJSGlobalProxy());
340 env->global()->set_global_receiver(*global);
341 env->set_global_proxy(*global);
343 global->set_context(*env);
353 bool is_ecma_native) {
354 Isolate* isolate = target->GetIsolate();
367 if (target->IsJSBuiltinsObject()) {
375 target, symbol,
function, attributes));
376 if (is_ecma_native) {
377 function->shared()->set_instance_class_name(*symbol);
379 function->shared()->set_native(
true);
384 Handle<DescriptorArray> Genesis::ComputeFunctionInstanceDescriptor(
385 PrototypePropertyMode prototypeMode) {
386 int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5;
387 Handle<DescriptorArray> descriptors(factory()->NewDescriptorArray(size));
391 DescriptorArray::WhitenessWitness witness(*descriptors);
394 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionLength));
395 CallbacksDescriptor d(*factory()->length_symbol(), *f, attribs);
396 descriptors->Set(0, &d, witness);
399 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionName));
400 CallbacksDescriptor d(*factory()->name_symbol(), *f, attribs);
401 descriptors->Set(1, &d, witness);
404 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionArguments));
405 CallbacksDescriptor d(*factory()->arguments_symbol(), *f, attribs);
406 descriptors->Set(2, &d, witness);
409 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionCaller));
410 CallbacksDescriptor d(*factory()->caller_symbol(), *f, attribs);
411 descriptors->Set(3, &d, witness);
413 if (prototypeMode != DONT_ADD_PROTOTYPE) {
415 if (prototypeMode == ADD_WRITEABLE_PROTOTYPE) {
418 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionPrototype));
419 CallbacksDescriptor d(*factory()->prototype_symbol(), *f, attribs);
420 descriptors->Set(4, &d, witness);
422 descriptors->Sort(witness);
427 Handle<Map> Genesis::CreateFunctionMap(PrototypePropertyMode prototype_mode) {
429 Handle<DescriptorArray> descriptors =
430 ComputeFunctionInstanceDescriptor(prototype_mode);
431 map->set_instance_descriptors(*descriptors);
432 map->set_function_with_prototype(prototype_mode != DONT_ADD_PROTOTYPE);
437 Handle<JSFunction> Genesis::CreateEmptyFunction(Isolate* isolate) {
443 Handle<Map> function_instance_map =
444 CreateFunctionMap(ADD_WRITEABLE_PROTOTYPE);
445 global_context()->set_function_instance_map(*function_instance_map);
449 Handle<Map> function_without_prototype_map =
450 CreateFunctionMap(DONT_ADD_PROTOTYPE);
451 global_context()->set_function_without_prototype_map(
452 *function_without_prototype_map);
457 Handle<Map> function_map = CreateFunctionMap(ADD_READONLY_PROTOTYPE);
458 global_context()->set_function_map(*function_map);
462 function_instance_map_writable_prototype_ =
463 CreateFunctionMap(ADD_WRITEABLE_PROTOTYPE);
465 Factory* factory = isolate->factory();
466 Heap* heap = isolate->heap();
468 Handle<String> object_name = Handle<String>(heap->Object_symbol());
471 Handle<JSFunction> object_fun =
472 factory->NewFunction(object_name, factory->null_value());
473 Handle<Map> object_function_map =
475 object_fun->set_initial_map(*object_function_map);
476 object_function_map->set_constructor(*object_fun);
478 global_context()->set_object_function(*object_fun);
481 Handle<JSObject> prototype = factory->NewJSObject(
482 isolate->object_function(),
485 global_context()->set_initial_object_prototype(*prototype);
487 object_function_map->set_instance_descriptors(
488 heap->empty_descriptor_array());
493 Handle<String> symbol = factory->LookupAsciiSymbol(
"Empty");
494 Handle<JSFunction> empty_function =
495 factory->NewFunctionWithoutPrototype(symbol,
CLASSIC_MODE);
499 Handle<Code>(isolate->builtins()->builtin(
500 Builtins::kEmptyFunction));
501 empty_function->set_code(*code);
502 empty_function->shared()->set_code(*code);
503 Handle<String> source = factory->NewStringFromAscii(
CStrVector(
"() {}"));
504 Handle<Script> script = factory->NewScript(source);
506 empty_function->shared()->set_script(*script);
507 empty_function->shared()->set_start_position(0);
508 empty_function->shared()->set_end_position(source->length());
509 empty_function->shared()->DontAdaptArguments();
512 global_context()->function_map()->set_prototype(*empty_function);
513 global_context()->function_instance_map()->set_prototype(*empty_function);
514 global_context()->function_without_prototype_map()->
515 set_prototype(*empty_function);
516 function_instance_map_writable_prototype_->set_prototype(*empty_function);
519 Handle<Map> empty_function_map = CreateFunctionMap(DONT_ADD_PROTOTYPE);
520 empty_function_map->set_prototype(
521 global_context()->object_function()->prototype());
522 empty_function->set_map(*empty_function_map);
523 return empty_function;
527 Handle<DescriptorArray> Genesis::ComputeStrictFunctionInstanceDescriptor(
528 PrototypePropertyMode prototypeMode) {
529 int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5;
530 Handle<DescriptorArray> descriptors(factory()->NewDescriptorArray(size));
534 DescriptorArray::WhitenessWitness witness(*descriptors);
537 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionLength));
538 CallbacksDescriptor d(*factory()->length_symbol(), *f, attribs);
539 descriptors->Set(0, &d, witness);
542 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionName));
543 CallbacksDescriptor d(*factory()->name_symbol(), *f, attribs);
544 descriptors->Set(1, &d, witness);
547 Handle<AccessorPair> arguments(factory()->NewAccessorPair());
548 CallbacksDescriptor d(*factory()->arguments_symbol(), *arguments, attribs);
549 descriptors->Set(2, &d, witness);
552 Handle<AccessorPair> caller(factory()->NewAccessorPair());
553 CallbacksDescriptor d(*factory()->caller_symbol(), *caller, attribs);
554 descriptors->Set(3, &d, witness);
557 if (prototypeMode != DONT_ADD_PROTOTYPE) {
559 if (prototypeMode != ADD_WRITEABLE_PROTOTYPE) {
562 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionPrototype));
563 CallbacksDescriptor d(*factory()->prototype_symbol(), *f, attribs);
564 descriptors->Set(4, &d, witness);
567 descriptors->Sort(witness);
573 Handle<JSFunction> Genesis::GetThrowTypeErrorFunction() {
574 if (throw_type_error_function.is_null()) {
575 Handle<String> name = factory()->LookupAsciiSymbol(
"ThrowTypeError");
576 throw_type_error_function =
577 factory()->NewFunctionWithoutPrototype(name,
CLASSIC_MODE);
578 Handle<Code> code(isolate()->builtins()->builtin(
579 Builtins::kStrictModePoisonPill));
580 throw_type_error_function->set_map(
581 global_context()->function_map());
582 throw_type_error_function->set_code(*code);
583 throw_type_error_function->shared()->set_code(*code);
584 throw_type_error_function->shared()->DontAdaptArguments();
588 return throw_type_error_function;
592 Handle<Map> Genesis::CreateStrictModeFunctionMap(
593 PrototypePropertyMode prototype_mode,
594 Handle<JSFunction> empty_function) {
596 Handle<DescriptorArray> descriptors =
597 ComputeStrictFunctionInstanceDescriptor(prototype_mode);
598 map->set_instance_descriptors(*descriptors);
599 map->set_function_with_prototype(prototype_mode != DONT_ADD_PROTOTYPE);
600 map->set_prototype(*empty_function);
605 void Genesis::CreateStrictModeFunctionMaps(Handle<JSFunction> empty) {
607 Handle<Map> strict_mode_function_instance_map =
608 CreateStrictModeFunctionMap(ADD_WRITEABLE_PROTOTYPE, empty);
609 global_context()->set_strict_mode_function_instance_map(
610 *strict_mode_function_instance_map);
613 Handle<Map> strict_mode_function_without_prototype_map =
614 CreateStrictModeFunctionMap(DONT_ADD_PROTOTYPE, empty);
615 global_context()->set_strict_mode_function_without_prototype_map(
616 *strict_mode_function_without_prototype_map);
621 Handle<Map> strict_mode_function_map =
622 CreateStrictModeFunctionMap(ADD_READONLY_PROTOTYPE, empty);
623 global_context()->set_strict_mode_function_map(
624 *strict_mode_function_map);
628 strict_mode_function_instance_map_writable_prototype_ =
629 CreateStrictModeFunctionMap(ADD_WRITEABLE_PROTOTYPE, empty);
632 PoisonArgumentsAndCaller(strict_mode_function_instance_map);
633 PoisonArgumentsAndCaller(strict_mode_function_without_prototype_map);
634 PoisonArgumentsAndCaller(strict_mode_function_map);
635 PoisonArgumentsAndCaller(
636 strict_mode_function_instance_map_writable_prototype_);
640 static void SetAccessors(Handle<Map> map,
642 Handle<JSFunction> func) {
643 DescriptorArray* descs = map->instance_descriptors();
644 int number = descs->Search(*name);
646 accessors->set_getter(*func);
647 accessors->set_setter(*func);
651 void Genesis::PoisonArgumentsAndCaller(Handle<Map> map) {
652 SetAccessors(map, factory()->arguments_symbol(), GetThrowTypeErrorFunction());
653 SetAccessors(map, factory()->caller_symbol(), GetThrowTypeErrorFunction());
657 static void AddToWeakGlobalContextList(Context* context) {
658 ASSERT(context->IsGlobalContext());
659 Heap* heap = context->GetIsolate()->heap();
664 for (
Object* current = heap->global_contexts_list();
665 !current->IsUndefined();
667 ASSERT(current != context);
672 heap->set_global_contexts_list(context);
676 void Genesis::CreateRoots() {
682 *factory()->NewGlobalContext()));
683 AddToWeakGlobalContextList(*global_context_);
684 isolate()->set_context(*global_context());
689 global_context()->set_message_listeners(*listeners.
value());
694 Handle<JSGlobalProxy> Genesis::CreateNewGlobals(
696 Handle<Object> global_object,
697 Handle<GlobalObject>* inner_global_out) {
711 Handle<JSFunction> js_global_function;
712 Handle<ObjectTemplateInfo> js_global_template;
713 if (!global_template.
IsEmpty()) {
715 Handle<ObjectTemplateInfo> data =
717 Handle<FunctionTemplateInfo> global_constructor =
718 Handle<FunctionTemplateInfo>(
720 Handle<Object> proto_template(global_constructor->prototype_template());
721 if (!proto_template->IsUndefined()) {
727 if (js_global_template.is_null()) {
728 Handle<String> name = Handle<String>(heap()->empty_symbol());
729 Handle<Code> code = Handle<Code>(isolate()->builtins()->builtin(
730 Builtins::kIllegal));
736 Handle<JSObject> prototype =
741 prototype, factory()->constructor_symbol(),
742 isolate()->object_function(),
NONE));
744 Handle<FunctionTemplateInfo> js_global_constructor(
747 factory()->CreateApiFunction(js_global_constructor,
748 factory()->InnerGlobalObject);
751 js_global_function->initial_map()->set_is_hidden_prototype();
752 Handle<GlobalObject> inner_global =
753 factory()->NewGlobalObject(js_global_function);
754 if (inner_global_out !=
NULL) {
755 *inner_global_out = inner_global;
759 Handle<JSFunction> global_proxy_function;
760 if (global_template.
IsEmpty()) {
761 Handle<String> name = Handle<String>(heap()->empty_symbol());
762 Handle<Code> code = Handle<Code>(isolate()->builtins()->builtin(
763 Builtins::kIllegal));
764 global_proxy_function =
768 Handle<ObjectTemplateInfo> data =
770 Handle<FunctionTemplateInfo> global_constructor(
772 global_proxy_function =
773 factory()->CreateApiFunction(global_constructor,
774 factory()->OuterGlobalObject);
777 Handle<String> global_name = factory()->LookupAsciiSymbol(
"global");
778 global_proxy_function->shared()->set_instance_class_name(*global_name);
779 global_proxy_function->initial_map()->set_is_access_check_needed(
true);
784 if (global_object.location() !=
NULL) {
785 ASSERT(global_object->IsJSGlobalProxy());
787 global_proxy_function,
788 Handle<JSGlobalProxy>::cast(global_object));
791 factory()->NewJSObject(global_proxy_function,
TENURED));
796 void Genesis::HookUpGlobalProxy(Handle<GlobalObject> inner_global,
797 Handle<JSGlobalProxy> global_proxy) {
799 inner_global->set_global_context(*global_context());
800 inner_global->set_global_receiver(*global_proxy);
801 global_proxy->set_context(*global_context());
802 global_context()->set_global_proxy(*global_proxy);
806 void Genesis::HookUpInnerGlobal(Handle<GlobalObject> inner_global) {
807 Handle<GlobalObject> inner_global_from_snapshot(
809 Handle<JSBuiltinsObject> builtins_global(global_context_->builtins());
810 global_context_->set_extension(*inner_global);
811 global_context_->set_global(*inner_global);
812 global_context_->set_security_token(*inner_global);
816 factory()->LookupAsciiSymbol(
"global"),
821 TransferNamedProperties(inner_global_from_snapshot, inner_global);
822 TransferIndexedProperties(inner_global_from_snapshot, inner_global);
828 bool Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
829 Handle<JSFunction> empty_function) {
832 global_context()->set_closure(*empty_function);
833 global_context()->set_previous(
NULL);
835 global_context()->set_extension(*inner_global);
836 global_context()->set_global(*inner_global);
841 global_context()->set_security_token(*inner_global);
843 Isolate* isolate = inner_global->GetIsolate();
844 Factory* factory = isolate->factory();
845 Heap* heap = isolate->heap();
847 Handle<String> object_name = Handle<String>(heap->Object_symbol());
850 inner_global, object_name,
853 Handle<JSObject> global = Handle<JSObject>(global_context()->global());
857 empty_function, Builtins::kIllegal,
true);
860 Handle<JSFunction> array_function =
862 isolate->initial_object_prototype(),
863 Builtins::kArrayCode,
true);
864 array_function->shared()->set_construct_stub(
865 isolate->builtins()->builtin(Builtins::kArrayConstructCode));
866 array_function->shared()->DontAdaptArguments();
870 array_function->shared()->set_length(1);
871 Handle<DescriptorArray> array_descriptors =
872 factory->CopyAppendForeignDescriptor(
873 factory->empty_descriptor_array(),
874 factory->length_symbol(),
875 factory->NewForeign(&Accessors::ArrayLength),
882 global_context()->set_array_function(*array_function);
883 array_function->initial_map()->set_instance_descriptors(*array_descriptors);
887 Handle<JSFunction> number_fun =
889 isolate->initial_object_prototype(),
890 Builtins::kIllegal,
true);
891 global_context()->set_number_function(*number_fun);
895 Handle<JSFunction> boolean_fun =
897 isolate->initial_object_prototype(),
898 Builtins::kIllegal,
true);
899 global_context()->set_boolean_function(*boolean_fun);
903 Handle<JSFunction> string_fun =
905 isolate->initial_object_prototype(),
906 Builtins::kIllegal,
true);
907 string_fun->shared()->set_construct_stub(
908 isolate->builtins()->builtin(Builtins::kStringConstructCode));
909 global_context()->set_string_function(*string_fun);
911 Handle<DescriptorArray> string_descriptors =
912 factory->CopyAppendForeignDescriptor(
913 factory->empty_descriptor_array(),
914 factory->length_symbol(),
915 factory->NewForeign(&Accessors::StringLength),
920 Handle<Map> string_map =
921 Handle<Map>(global_context()->string_function()->initial_map());
922 string_map->set_instance_descriptors(*string_descriptors);
927 Handle<JSFunction> date_fun =
929 isolate->initial_object_prototype(),
930 Builtins::kIllegal,
true);
932 global_context()->set_date_function(*date_fun);
938 Handle<JSFunction> regexp_fun =
940 isolate->initial_object_prototype(),
941 Builtins::kIllegal,
true);
942 global_context()->set_regexp_function(*regexp_fun);
944 ASSERT(regexp_fun->has_initial_map());
945 Handle<Map> initial_map(regexp_fun->initial_map());
947 ASSERT_EQ(0, initial_map->inobject_properties());
949 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(5);
950 DescriptorArray::WhitenessWitness witness(*descriptors);
956 FieldDescriptor field(heap->source_symbol(),
960 descriptors->Set(0, &field, witness);
964 FieldDescriptor field(heap->global_symbol(),
968 descriptors->Set(1, &field, witness);
972 FieldDescriptor field(heap->ignore_case_symbol(),
976 descriptors->Set(2, &field, witness);
980 FieldDescriptor field(heap->multiline_symbol(),
984 descriptors->Set(3, &field, witness);
990 FieldDescriptor field(heap->last_index_symbol(),
994 descriptors->Set(4, &field, witness);
996 descriptors->SetNextEnumerationIndex(enum_index);
997 descriptors->Sort(witness);
999 initial_map->set_inobject_properties(5);
1000 initial_map->set_pre_allocated_property_fields(5);
1001 initial_map->set_unused_property_fields(0);
1002 initial_map->set_instance_size(
1004 initial_map->set_instance_descriptors(*descriptors);
1008 Handle<Map> proto_map = factory->CopyMapDropTransitions(initial_map);
1009 proto_map->set_prototype(global_context()->initial_object_prototype());
1010 Handle<JSObject> proto = factory->NewJSObjectFromMap(proto_map);
1012 heap->query_colon_symbol());
1014 heap->false_value());
1016 heap->false_value());
1018 heap->false_value());
1022 initial_map->set_prototype(*proto);
1023 factory->SetRegExpIrregexpData(Handle<JSRegExp>::cast(proto),
1025 JSRegExp::Flags(0), 0);
1029 Handle<String> name = factory->NewStringFromAscii(
CStrVector(
"JSON"));
1030 Handle<JSFunction> cons = factory->NewFunction(name,
1031 factory->the_hole_value());
1032 { MaybeObject* result = cons->SetInstancePrototype(
1033 global_context()->initial_object_prototype());
1034 if (result->IsFailure())
return false;
1036 cons->SetInstanceClassName(*name);
1037 Handle<JSObject> json_object = factory->NewJSObject(cons,
TENURED);
1038 ASSERT(json_object->IsJSObject());
1042 global_context()->set_json_object(*json_object);
1049 Handle<String> symbol = factory->LookupAsciiSymbol(
"Arguments");
1050 Handle<Code> code = Handle<Code>(
1051 isolate->builtins()->builtin(Builtins::kIllegal));
1052 Handle<JSObject> prototype =
1054 JSObject::cast(global_context()->object_function()->prototype()));
1056 Handle<JSFunction>
function =
1057 factory->NewFunctionWithPrototype(symbol,
1063 ASSERT(!function->has_initial_map());
1064 function->shared()->set_instance_class_name(*symbol);
1065 function->shared()->set_expected_nof_properties(2);
1066 Handle<JSObject> result = factory->NewJSObject(
function);
1068 global_context()->set_arguments_boilerplate(*result);
1073 result, factory->length_symbol(),
1074 factory->undefined_value(),
DONT_ENUM));
1077 result, factory->callee_symbol(),
1078 factory->undefined_value(),
DONT_ENUM));
1081 LookupResult lookup(isolate);
1082 result->LocalLookup(heap->callee_symbol(), &lookup);
1083 ASSERT(lookup.IsFound() && (lookup.type() ==
FIELD));
1086 result->LocalLookup(heap->length_symbol(), &lookup);
1087 ASSERT(lookup.IsFound() && (lookup.type() ==
FIELD));
1094 ASSERT(result->HasFastProperties());
1095 ASSERT(result->HasFastObjectElements());
1101 Handle<FixedArray> elements = factory->NewFixedArray(2);
1102 elements->set_map(heap->non_strict_arguments_elements_map());
1103 Handle<FixedArray> array;
1104 array = factory->NewFixedArray(0);
1105 elements->set(0, *array);
1106 array = factory->NewFixedArray(0);
1107 elements->set(1, *array);
1109 Handle<Map> old_map(global_context()->arguments_boilerplate()->map());
1110 Handle<Map> new_map = factory->CopyMapDropTransitions(old_map);
1111 new_map->set_pre_allocated_property_fields(2);
1112 Handle<JSObject> result = factory->NewJSObjectFromMap(new_map);
1116 result->set_elements(*elements);
1117 ASSERT(result->HasNonStrictArgumentsElements());
1118 global_context()->set_aliased_arguments_boilerplate(*result);
1126 Handle<AccessorPair> callee = factory->NewAccessorPair();
1127 Handle<AccessorPair> caller = factory->NewAccessorPair();
1129 Handle<JSFunction> throw_function =
1130 GetThrowTypeErrorFunction();
1133 callee->set_getter(*throw_function);
1134 callee->set_setter(*throw_function);
1135 caller->set_getter(*throw_function);
1136 caller->set_setter(*throw_function);
1139 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(3);
1140 DescriptorArray::WhitenessWitness witness(*descriptors);
1142 FieldDescriptor d(*factory->length_symbol(), 0,
DONT_ENUM);
1143 descriptors->Set(0, &d, witness);
1146 CallbacksDescriptor d(*factory->callee_symbol(), *callee, attributes);
1147 descriptors->Set(1, &d, witness);
1150 CallbacksDescriptor d(*factory->caller_symbol(), *caller, attributes);
1151 descriptors->Set(2, &d, witness);
1153 descriptors->Sort(witness);
1158 map->set_instance_descriptors(*descriptors);
1159 map->set_function_with_prototype(
true);
1160 map->set_prototype(global_context()->object_function()->prototype());
1161 map->set_pre_allocated_property_fields(1);
1162 map->set_inobject_properties(1);
1165 map->set_constructor(
1166 global_context()->arguments_boilerplate()->map()->constructor());
1169 Handle<JSObject> result = factory->NewJSObjectFromMap(map);
1170 global_context()->set_strict_mode_arguments_boilerplate(*result);
1175 result, factory->length_symbol(),
1176 factory->undefined_value(),
DONT_ENUM));
1179 LookupResult lookup(isolate);
1180 result->LocalLookup(heap->length_symbol(), &lookup);
1181 ASSERT(lookup.IsFound() && (lookup.type() ==
FIELD));
1187 ASSERT(result->HasFastProperties());
1188 ASSERT(result->HasFastObjectElements());
1194 Handle<Code> code = Handle<Code>(
1195 isolate->builtins()->builtin(Builtins::kIllegal));
1196 Handle<JSFunction> context_extension_fun =
1197 factory->NewFunction(factory->empty_symbol(),
1203 Handle<String> name = factory->LookupAsciiSymbol(
"context_extension");
1204 context_extension_fun->shared()->set_instance_class_name(*name);
1205 global_context()->set_context_extension_function(*context_extension_fun);
1212 Handle<Code>(isolate->builtins()->builtin(
1213 Builtins::kHandleApiCallAsFunction));
1214 Handle<JSFunction> delegate =
1217 global_context()->set_call_as_function_delegate(*delegate);
1218 delegate->shared()->DontAdaptArguments();
1224 Handle<Code>(isolate->builtins()->builtin(
1225 Builtins::kHandleApiCallAsConstructor));
1226 Handle<JSFunction> delegate =
1229 global_context()->set_call_as_constructor_delegate(*delegate);
1230 delegate->shared()->DontAdaptArguments();
1234 global_context()->set_out_of_memory(heap->false_value());
1237 global_context()->set_data(heap->undefined_value());
1241 Handle<ByteArray> zeroed_byte_array(
1243 global_context()->set_random_seed(*zeroed_byte_array);
1250 void Genesis::InitializeExperimentalGlobal() {
1251 Handle<JSObject> global = Handle<JSObject>(global_context()->global());
1255 if (FLAG_harmony_collections) {
1257 Handle<JSObject> prototype =
1258 factory()->NewJSObject(isolate()->object_function(),
TENURED);
1260 prototype, Builtins::kIllegal,
true);
1263 Handle<JSObject> prototype =
1264 factory()->NewJSObject(isolate()->object_function(),
TENURED);
1266 prototype, Builtins::kIllegal,
true);
1269 Handle<JSObject> prototype =
1270 factory()->NewJSObject(isolate()->object_function(),
TENURED);
1272 prototype, Builtins::kIllegal,
true);
1278 bool Genesis::CompileBuiltin(Isolate* isolate,
int index) {
1280 Handle<String> source_code =
1281 isolate->bootstrapper()->NativesSourceLookup(index);
1282 return CompileNative(name, source_code);
1286 bool Genesis::CompileExperimentalBuiltin(Isolate* isolate,
int index) {
1288 Factory* factory = isolate->factory();
1289 Handle<String> source_code =
1290 factory->NewStringFromAscii(
1292 return CompileNative(name, source_code);
1296 bool Genesis::CompileNative(Vector<const char> name, Handle<String> source) {
1298 Isolate* isolate = source->GetIsolate();
1299 #ifdef ENABLE_DEBUGGER_SUPPORT
1300 isolate->debugger()->set_compiling_natives(
true);
1305 StackLimitCheck
check(Isolate::Current());
1306 if (
check.HasOverflowed())
return false;
1308 bool result = CompileScriptCached(name,
1312 Handle<Context>(isolate->context()),
1314 ASSERT(isolate->has_pending_exception() != result);
1315 if (!result) isolate->clear_pending_exception();
1316 #ifdef ENABLE_DEBUGGER_SUPPORT
1317 isolate->debugger()->set_compiling_natives(
false);
1323 bool Genesis::CompileScriptCached(Vector<const char> name,
1324 Handle<String> source,
1325 SourceCodeCache* cache,
1327 Handle<Context> top_context,
1328 bool use_runtime_context) {
1329 Factory* factory = source->GetIsolate()->factory();
1331 Handle<SharedFunctionInfo> function_info;
1335 if (cache ==
NULL || !cache->Lookup(name, &function_info)) {
1336 ASSERT(source->IsAsciiRepresentation());
1337 Handle<String> script_name = factory->NewStringFromUtf8(name);
1347 if (function_info.is_null())
return false;
1348 if (cache !=
NULL) cache->Add(name, function_info);
1354 ASSERT(top_context->IsGlobalContext());
1355 Handle<Context> context =
1356 Handle<Context>(use_runtime_context
1357 ? Handle<Context>(top_context->runtime_context())
1359 Handle<JSFunction> fun =
1360 factory->NewFunctionFromSharedFunctionInfo(function_info, context);
1364 Handle<Object> receiver =
1365 Handle<Object>(use_runtime_context
1366 ? top_context->builtins()
1367 : top_context->global());
1368 bool has_pending_exception;
1370 if (has_pending_exception)
return false;
1375 #define INSTALL_NATIVE(Type, name, var) \
1376 Handle<String> var##_name = factory()->LookupAsciiSymbol(name); \
1377 Object* var##_native = \
1378 global_context()->builtins()->GetPropertyNoExceptionThrown( \
1380 global_context()->set_##var(Type::cast(var##_native));
1383 void Genesis::InstallNativeFunctions() {
1388 INSTALL_NATIVE(JSFunction,
"ToDetailString", to_detail_string_fun);
1396 configure_instance_fun);
1397 INSTALL_NATIVE(JSFunction,
"GetStackTraceLine", get_stack_trace_line_fun);
1400 to_complete_property_descriptor);
1403 void Genesis::InstallExperimentalNativeFunctions() {
1404 if (FLAG_harmony_proxies) {
1412 #undef INSTALL_NATIVE
1415 bool Genesis::InstallNatives() {
1421 Handle<Code> code = Handle<Code>(
1422 isolate()->builtins()->builtin(Builtins::kIllegal));
1423 Handle<JSFunction> builtins_fun =
1424 factory()->NewFunction(factory()->empty_symbol(),
1428 Handle<String> name = factory()->LookupAsciiSymbol(
"builtins");
1429 builtins_fun->shared()->set_instance_class_name(*name);
1432 Handle<JSBuiltinsObject> builtins =
1434 builtins->set_builtins(*builtins);
1435 builtins->set_global_context(*global_context());
1436 builtins->set_global_receiver(*builtins);
1444 Handle<String> global_symbol = factory()->LookupAsciiSymbol(
"global");
1445 Handle<Object> global_obj(global_context()->global());
1448 builtins, global_symbol, global_obj, attributes));
1454 Handle<JSFunction> bridge =
1455 factory()->NewFunction(factory()->empty_symbol(),
1456 factory()->undefined_value());
1457 ASSERT(bridge->context() == *isolate()->global_context());
1460 Handle<Context> context =
1462 context->set_global(*builtins);
1464 global_context()->set_runtime_context(*context);
1468 Handle<JSFunction> script_fun =
1470 isolate()->initial_object_prototype(),
1471 Builtins::kIllegal,
false);
1472 Handle<JSObject> prototype =
1473 factory()->NewJSObject(isolate()->object_function(),
TENURED);
1475 global_context()->set_script_function(*script_fun);
1480 Handle<Foreign> foreign_source =
1481 factory()->NewForeign(&Accessors::ScriptSource);
1482 Handle<DescriptorArray> script_descriptors =
1483 factory()->CopyAppendForeignDescriptor(
1484 factory()->empty_descriptor_array(),
1485 factory()->LookupAsciiSymbol(
"source"),
1488 Handle<Foreign> foreign_name =
1489 factory()->NewForeign(&Accessors::ScriptName);
1490 script_descriptors =
1491 factory()->CopyAppendForeignDescriptor(
1493 factory()->LookupAsciiSymbol(
"name"),
1496 Handle<Foreign> foreign_id = factory()->NewForeign(&Accessors::ScriptId);
1497 script_descriptors =
1498 factory()->CopyAppendForeignDescriptor(
1500 factory()->LookupAsciiSymbol(
"id"),
1503 Handle<Foreign> foreign_line_offset =
1504 factory()->NewForeign(&Accessors::ScriptLineOffset);
1505 script_descriptors =
1506 factory()->CopyAppendForeignDescriptor(
1508 factory()->LookupAsciiSymbol(
"line_offset"),
1509 foreign_line_offset,
1511 Handle<Foreign> foreign_column_offset =
1512 factory()->NewForeign(&Accessors::ScriptColumnOffset);
1513 script_descriptors =
1514 factory()->CopyAppendForeignDescriptor(
1516 factory()->LookupAsciiSymbol(
"column_offset"),
1517 foreign_column_offset,
1519 Handle<Foreign> foreign_data =
1520 factory()->NewForeign(&Accessors::ScriptData);
1521 script_descriptors =
1522 factory()->CopyAppendForeignDescriptor(
1524 factory()->LookupAsciiSymbol(
"data"),
1527 Handle<Foreign> foreign_type =
1528 factory()->NewForeign(&Accessors::ScriptType);
1529 script_descriptors =
1530 factory()->CopyAppendForeignDescriptor(
1532 factory()->LookupAsciiSymbol(
"type"),
1535 Handle<Foreign> foreign_compilation_type =
1536 factory()->NewForeign(&Accessors::ScriptCompilationType);
1537 script_descriptors =
1538 factory()->CopyAppendForeignDescriptor(
1540 factory()->LookupAsciiSymbol(
"compilation_type"),
1541 foreign_compilation_type,
1543 Handle<Foreign> foreign_line_ends =
1544 factory()->NewForeign(&Accessors::ScriptLineEnds);
1545 script_descriptors =
1546 factory()->CopyAppendForeignDescriptor(
1548 factory()->LookupAsciiSymbol(
"line_ends"),
1551 Handle<Foreign> foreign_context_data =
1552 factory()->NewForeign(&Accessors::ScriptContextData);
1553 script_descriptors =
1554 factory()->CopyAppendForeignDescriptor(
1556 factory()->LookupAsciiSymbol(
"context_data"),
1557 foreign_context_data,
1559 Handle<Foreign> foreign_eval_from_script =
1560 factory()->NewForeign(&Accessors::ScriptEvalFromScript);
1561 script_descriptors =
1562 factory()->CopyAppendForeignDescriptor(
1564 factory()->LookupAsciiSymbol(
"eval_from_script"),
1565 foreign_eval_from_script,
1567 Handle<Foreign> foreign_eval_from_script_position =
1568 factory()->NewForeign(&Accessors::ScriptEvalFromScriptPosition);
1569 script_descriptors =
1570 factory()->CopyAppendForeignDescriptor(
1572 factory()->LookupAsciiSymbol(
"eval_from_script_position"),
1573 foreign_eval_from_script_position,
1575 Handle<Foreign> foreign_eval_from_function_name =
1576 factory()->NewForeign(&Accessors::ScriptEvalFromFunctionName);
1577 script_descriptors =
1578 factory()->CopyAppendForeignDescriptor(
1580 factory()->LookupAsciiSymbol(
"eval_from_function_name"),
1581 foreign_eval_from_function_name,
1584 Handle<Map> script_map = Handle<Map>(script_fun->initial_map());
1585 script_map->set_instance_descriptors(*script_descriptors);
1588 Handle<Script> script = factory()->NewScript(factory()->empty_string());
1590 heap()->public_set_empty_script(*script);
1596 Handle<JSFunction> opaque_reference_fun =
1599 isolate()->initial_object_prototype(),
1600 Builtins::kIllegal,
false);
1601 Handle<JSObject> prototype =
1602 factory()->NewJSObject(isolate()->object_function(),
TENURED);
1604 global_context()->set_opaque_reference_function(*opaque_reference_fun);
1613 Handle<JSFunction> array_function =
1614 InstallFunction(builtins,
1618 isolate()->initial_object_prototype(),
1619 Builtins::kInternalArrayCode,
1621 Handle<JSObject> prototype =
1622 factory()->NewJSObject(isolate()->object_function(),
TENURED);
1625 array_function->shared()->set_construct_stub(
1626 isolate()->builtins()->builtin(Builtins::kArrayConstructCode));
1627 array_function->shared()->DontAdaptArguments();
1634 MaybeObject* maybe_map =
1635 array_function->initial_map()->CopyDropTransitions(
1638 if (!maybe_map->To(&new_map))
return false;
1640 array_function->set_initial_map(new_map);
1643 Handle<DescriptorArray> array_descriptors =
1644 factory()->CopyAppendForeignDescriptor(
1645 factory()->empty_descriptor_array(),
1646 factory()->length_symbol(),
1647 factory()->NewForeign(&Accessors::ArrayLength),
1650 array_function->initial_map()->set_instance_descriptors(
1651 *array_descriptors);
1653 global_context()->set_internal_array_function(*array_function);
1656 if (FLAG_disable_native_files) {
1657 PrintF(
"Warning: Running without installed natives!\n");
1665 if (!CompileBuiltin(isolate(), i))
return false;
1669 if (!InstallJSBuiltins(builtins))
return false;
1672 InstallNativeFunctions();
1676 Handle<JSFunction> string_function(global_context()->string_function());
1678 string_function->initial_map()->prototype())->HasFastProperties());
1679 global_context()->set_string_function_prototype_map(
1683 { Handle<String> key = factory()->function_class_symbol();
1684 Handle<JSFunction>
function =
1686 Handle<JSObject> proto =
1687 Handle<JSObject>(
JSObject::cast(function->instance_prototype()));
1690 Handle<JSFunction> call =
1691 InstallFunction(proto,
"call",
JS_OBJECT_TYPE, JSObject::kHeaderSize,
1692 Handle<JSObject>::null(),
1693 Builtins::kFunctionCall,
1695 Handle<JSFunction> apply =
1696 InstallFunction(proto,
"apply",
JS_OBJECT_TYPE, JSObject::kHeaderSize,
1697 Handle<JSObject>::null(),
1698 Builtins::kFunctionApply,
1704 call->shared()->DontAdaptArguments();
1705 ASSERT(call->is_compiled());
1708 apply->shared()->set_formal_parameter_count(2);
1711 call->shared()->set_length(1);
1712 apply->shared()->set_length(2);
1715 InstallBuiltinFunctionIds();
1723 Handle<JSFunction> array_constructor(global_context()->array_function());
1724 Handle<JSObject> array_prototype(
1728 Handle<Map> initial_map =
1730 initial_map->set_constructor(*array_constructor);
1733 initial_map->set_non_instance_prototype(
false);
1734 initial_map->set_prototype(*array_prototype);
1737 Handle<DescriptorArray> reresult_descriptors =
1738 factory()->NewDescriptorArray(3);
1739 DescriptorArray::WhitenessWitness witness(*reresult_descriptors);
1741 JSFunction* array_function = global_context()->array_function();
1742 Handle<DescriptorArray> array_descriptors(
1743 array_function->initial_map()->instance_descriptors());
1744 int index = array_descriptors->SearchWithCache(heap()->length_symbol());
1745 MaybeObject* copy_result =
1746 reresult_descriptors->CopyFrom(0, *array_descriptors, index, witness);
1747 if (copy_result->IsFailure())
return false;
1751 FieldDescriptor index_field(heap()->index_symbol(),
1755 reresult_descriptors->Set(1, &index_field, witness);
1759 FieldDescriptor input_field(heap()->input_symbol(),
1763 reresult_descriptors->Set(2, &input_field, witness);
1765 reresult_descriptors->Sort(witness);
1767 initial_map->set_inobject_properties(2);
1768 initial_map->set_pre_allocated_property_fields(2);
1769 initial_map->set_unused_property_fields(0);
1770 initial_map->set_instance_descriptors(*reresult_descriptors);
1772 global_context()->set_regexp_result_map(*initial_map);
1783 bool Genesis::InstallExperimentalNatives() {
1787 if (FLAG_harmony_proxies &&
1789 "native proxy.js") == 0) {
1790 if (!CompileExperimentalBuiltin(isolate(), i))
return false;
1792 if (FLAG_harmony_collections &&
1794 "native collection.js") == 0) {
1795 if (!CompileExperimentalBuiltin(isolate(), i))
return false;
1799 InstallExperimentalNativeFunctions();
1805 static Handle<JSObject> ResolveBuiltinIdHolder(
1806 Handle<Context> global_context,
1807 const char* holder_expr) {
1808 Factory* factory = global_context->GetIsolate()->factory();
1809 Handle<GlobalObject> global(global_context->global());
1810 const char* period_pos = strchr(holder_expr,
'.');
1811 if (period_pos ==
NULL) {
1813 GetProperty(global, factory->LookupAsciiSymbol(holder_expr)));
1816 Vector<const char> property(holder_expr,
1817 static_cast<int>(period_pos - holder_expr));
1819 GetProperty(global, factory->LookupSymbol(property)));
1824 static void InstallBuiltinFunctionId(Handle<JSObject> holder,
1825 const char* function_name,
1827 Factory* factory = holder->GetIsolate()->factory();
1828 Handle<String> name = factory->LookupAsciiSymbol(function_name);
1829 Object* function_object = holder->GetProperty(*name)->ToObjectUnchecked();
1831 function->shared()->set_function_data(
Smi::FromInt(
id));
1835 void Genesis::InstallBuiltinFunctionIds() {
1837 #define INSTALL_BUILTIN_ID(holder_expr, fun_name, name) \
1839 Handle<JSObject> holder = ResolveBuiltinIdHolder( \
1840 global_context(), #holder_expr); \
1841 BuiltinFunctionId id = k##name; \
1842 InstallBuiltinFunctionId(holder, #fun_name, id); \
1845 #undef INSTALL_BUILTIN_ID
1851 #define JSFUNCTION_RESULT_CACHE_LIST(F) \
1852 F(16, global_context()->regexp_function())
1855 static FixedArray* CreateCache(
int size, Handle<JSFunction> factory_function) {
1860 JSFunctionResultCache* cache =
reinterpret_cast<JSFunctionResultCache*
>(
1861 *factory->NewFixedArrayWithHoles(array_size,
TENURED));
1863 cache->MakeZeroSize();
1868 void Genesis::InstallJSFunctionResultCaches() {
1869 const int kNumberOfCaches = 0 +
1870 #define F(size, func) + 1
1875 Handle<FixedArray> caches =
FACTORY->NewFixedArray(kNumberOfCaches,
TENURED);
1879 #define F(size, func) do { \
1880 FixedArray* cache = CreateCache((size), Handle<JSFunction>(func)); \
1881 caches->set(index++, cache); \
1888 global_context()->set_jsfunction_result_caches(*caches);
1892 void Genesis::InitializeNormalizedMapCaches() {
1893 Handle<FixedArray> array(
1901 Isolate* isolate = global_context->GetIsolate();
1903 SaveContext saved_context(isolate);
1905 if (!Genesis::InstallExtensions(global_context, extensions))
return false;
1906 Genesis::InstallSpecialObjects(global_context);
1917 if (FLAG_expose_natives_as !=
NULL && strlen(FLAG_expose_natives_as) != 0) {
1927 if (Error->IsJSObject()) {
1933 stack_trace_limit,
NONE));
1936 #ifdef ENABLE_DEBUGGER_SUPPORT
1938 if (FLAG_expose_debug_as !=
NULL && strlen(FLAG_expose_debug_as) != 0) {
1939 Debug* debug = Isolate::Current()->debug();
1942 if (!debug->Load())
return;
1946 debug->debug_context()->set_security_token(
1947 global_context->security_token());
1949 Handle<String> debug_string =
1951 Handle<Object> global_proxy(debug->debug_context()->global_proxy());
1954 global, debug_string, global_proxy,
DONT_ENUM));
1959 static uint32_t Hash(RegisteredExtension* extension) {
1963 static bool MatchRegisteredExtensions(
void* key1,
void* key2) {
1964 return key1 == key2;
1967 Genesis::ExtensionStates::ExtensionStates()
1968 : map_(MatchRegisteredExtensions, 8) { }
1970 Genesis::ExtensionTraversalState Genesis::ExtensionStates::get_state(
1971 RegisteredExtension* extension) {
1972 i::HashMap::Entry* entry = map_.Lookup(extension, Hash(extension),
false);
1973 if (entry ==
NULL) {
1976 return static_cast<ExtensionTraversalState
>(
1977 reinterpret_cast<intptr_t
>(entry->value));
1980 void Genesis::ExtensionStates::set_state(RegisteredExtension* extension,
1981 ExtensionTraversalState state) {
1982 map_.Lookup(extension, Hash(extension),
true)->value =
1983 reinterpret_cast<void*
>(
static_cast<intptr_t
>(state));
1986 bool Genesis::InstallExtensions(Handle<Context> global_context,
1993 ExtensionStates extension_states;
1996 while (current !=
NULL) {
1998 InstallExtension(current, &extension_states);
1999 current = current->
next();
2002 if (FLAG_expose_gc) InstallExtension(
"v8/gc", &extension_states);
2003 if (FLAG_expose_externalize_string) {
2004 InstallExtension(
"v8/externalize", &extension_states);
2007 if (extensions ==
NULL)
return true;
2011 for (
int i = 0; i < count; i++) {
2012 if (!InstallExtension(names[i], &extension_states))
2022 bool Genesis::InstallExtension(
const char* name,
2023 ExtensionStates* extension_states) {
2026 while (current !=
NULL) {
2028 current = current->
next();
2031 if (current ==
NULL) {
2033 "v8::Context::New()",
"Cannot find required extension");
2036 return InstallExtension(current, extension_states);
2041 ExtensionStates* extension_states) {
2044 if (extension_states->get_state(current) == INSTALLED)
return true;
2047 if (extension_states->get_state(current) == VISITED) {
2049 "v8::Context::New()",
"Circular extension dependency");
2052 ASSERT(extension_states->get_state(current) == UNVISITED);
2053 extension_states->set_state(current, VISITED);
2057 if (!InstallExtension(extension->
dependencies()[i], extension_states))
2060 Isolate* isolate = Isolate::Current();
2061 Handle<String> source_code =
2062 isolate->factory()->NewExternalStringFromAscii(extension->
source());
2063 bool result = CompileScriptCached(
2066 isolate->bootstrapper()->extensions_cache(),
2068 Handle<Context>(isolate->context()),
2070 ASSERT(isolate->has_pending_exception() != result);
2078 isolate->clear_pending_exception();
2080 extension_states->set_state(current, INSTALLED);
2081 isolate->NotifyExtensionInstalled();
2086 bool Genesis::InstallJSBuiltins(Handle<JSBuiltinsObject> builtins) {
2088 Factory* factory = builtins->GetIsolate()->factory();
2092 Object* function_object = builtins->GetPropertyNoExceptionThrown(*name);
2093 Handle<JSFunction>
function
2095 builtins->set_javascript_builtin(
id, *
function);
2099 builtins->set_javascript_builtin_code(
id, function->shared()->code());
2105 bool Genesis::ConfigureGlobalObjects(
2107 Handle<JSObject> global_proxy(
2109 Handle<JSObject> inner_global(
JSObject::cast(global_context()->global()));
2111 if (!global_proxy_template.
IsEmpty()) {
2113 Handle<ObjectTemplateInfo> proxy_data =
2115 if (!ConfigureApiObject(global_proxy, proxy_data))
return false;
2118 Handle<FunctionTemplateInfo> proxy_constructor(
2120 if (!proxy_constructor->prototype_template()->IsUndefined()) {
2121 Handle<ObjectTemplateInfo> inner_data(
2123 if (!ConfigureApiObject(inner_global, inner_data))
return false;
2127 SetObjectPrototype(global_proxy, inner_global);
2132 bool Genesis::ConfigureApiObject(Handle<JSObject>
object,
2133 Handle<ObjectTemplateInfo> object_template) {
2134 ASSERT(!object_template.is_null());
2135 ASSERT(object->IsInstanceOf(
2138 bool pending_exception =
false;
2139 Handle<JSObject> obj =
2141 if (pending_exception) {
2142 ASSERT(isolate()->has_pending_exception());
2143 isolate()->clear_pending_exception();
2146 TransferObject(obj,
object);
2151 void Genesis::TransferNamedProperties(Handle<JSObject> from,
2152 Handle<JSObject> to) {
2153 if (from->HasFastProperties()) {
2154 Handle<DescriptorArray> descs =
2155 Handle<DescriptorArray>(from->map()->instance_descriptors());
2156 for (
int i = 0; i < descs->number_of_descriptors(); i++) {
2157 PropertyDetails details = descs->GetDetails(i);
2158 switch (details.type()) {
2161 Handle<String> key = Handle<String>(descs->GetKey(i));
2162 int index = descs->GetFieldIndex(i);
2163 Handle<Object> value = Handle<Object>(from->FastPropertyAt(index));
2166 to, key, value, details.attributes()));
2171 Handle<String> key = Handle<String>(descs->GetKey(i));
2172 Handle<JSFunction> fun =
2173 Handle<JSFunction>(descs->GetConstantFunction(i));
2176 to, key, fun, details.attributes()));
2180 LookupResult result(isolate());
2181 to->LocalLookup(descs->GetKey(i), &result);
2183 if (result.IsProperty())
continue;
2185 ASSERT(!to->HasFastProperties());
2187 Handle<String> key = Handle<String>(descs->GetKey(i));
2188 Handle<Object> callbacks(descs->GetCallbacksObject(i));
2190 PropertyDetails(details.attributes(),
CALLBACKS, details.index());
2209 Handle<StringDictionary> properties =
2210 Handle<StringDictionary>(from->property_dictionary());
2211 int capacity = properties->Capacity();
2212 for (
int i = 0; i < capacity; i++) {
2213 Object* raw_key(properties->KeyAt(i));
2214 if (properties->IsKey(raw_key)) {
2215 ASSERT(raw_key->IsString());
2217 LookupResult result(isolate());
2219 if (result.IsProperty())
continue;
2221 Handle<String> key = Handle<String>(
String::cast(raw_key));
2222 Handle<Object> value = Handle<Object>(properties->ValueAt(i));
2223 if (value->IsJSGlobalPropertyCell()) {
2226 PropertyDetails details = properties->DetailsAt(i);
2229 to, key, value, details.attributes()));
2236 void Genesis::TransferIndexedProperties(Handle<JSObject> from,
2237 Handle<JSObject> to) {
2239 Handle<FixedArray> from_elements =
2241 Handle<FixedArray> to_elements =
FACTORY->CopyFixedArray(from_elements);
2242 to->set_elements(*to_elements);
2246 void Genesis::TransferObject(Handle<JSObject> from, Handle<JSObject> to) {
2248 Factory* factory = from->GetIsolate()->factory();
2250 ASSERT(!from->IsJSArray());
2251 ASSERT(!to->IsJSArray());
2253 TransferNamedProperties(from, to);
2254 TransferIndexedProperties(from, to);
2257 Handle<Map> old_to_map = Handle<Map>(to->map());
2258 Handle<Map> new_to_map = factory->CopyMapDropTransitions(old_to_map);
2259 new_to_map->set_prototype(from->map()->prototype());
2260 to->set_map(*new_to_map);
2264 void Genesis::MakeFunctionInstancePrototypeWritable() {
2268 ASSERT(!function_instance_map_writable_prototype_.is_null());
2269 ASSERT(!strict_mode_function_instance_map_writable_prototype_.is_null());
2272 global_context()->set_function_map(
2273 *function_instance_map_writable_prototype_);
2274 global_context()->set_strict_mode_function_map(
2275 *strict_mode_function_instance_map_writable_prototype_);
2279 Genesis::Genesis(Isolate* isolate,
2280 Handle<Object> global_object,
2290 SaveContext saved_context(isolate);
2295 StackLimitCheck
check(Isolate::Current());
2296 if (
check.HasOverflowed())
return;
2299 if (!new_context.is_null()) {
2302 AddToWeakGlobalContextList(*global_context_);
2303 isolate->set_context(*global_context_);
2304 isolate->counters()->contexts_created_by_snapshot()->Increment();
2305 Handle<GlobalObject> inner_global;
2306 Handle<JSGlobalProxy> global_proxy =
2307 CreateNewGlobals(global_template,
2311 HookUpGlobalProxy(inner_global, global_proxy);
2312 HookUpInnerGlobal(inner_global);
2314 if (!ConfigureGlobalObjects(global_template))
return;
2318 Handle<JSFunction> empty_function = CreateEmptyFunction(isolate);
2319 CreateStrictModeFunctionMaps(empty_function);
2320 Handle<GlobalObject> inner_global;
2321 Handle<JSGlobalProxy> global_proxy =
2322 CreateNewGlobals(global_template, global_object, &inner_global);
2323 HookUpGlobalProxy(inner_global, global_proxy);
2324 if (!InitializeGlobal(inner_global, empty_function))
return;
2325 InstallJSFunctionResultCaches();
2326 InitializeNormalizedMapCaches();
2327 if (!InstallNatives())
return;
2329 MakeFunctionInstancePrototypeWritable();
2331 if (!ConfigureGlobalObjects(global_template))
return;
2332 isolate->counters()->contexts_created_from_scratch()->Increment();
2336 InitializeExperimentalGlobal();
2337 if (!InstallExperimentalNatives())
return;
2339 result_ = global_context_;
2347 return sizeof(NestingCounterType);
2353 *
reinterpret_cast<NestingCounterType*
>(to) = nesting_;
2355 return to +
sizeof(NestingCounterType);
2361 nesting_ = *
reinterpret_cast<NestingCounterType*
>(from);
2362 return from +
sizeof(NestingCounterType);
#define CHECK_NOT_EMPTY_HANDLE(isolate, call)
RegisteredExtension * next()
static bool Initialize(Deserializer *des)
Code * builtin(Name name)
static bool CompileLazy(Handle< JSFunction > function, ClearExceptionFlag flag)
char * ArchiveState(char *to)
Handle< String > NewExternalStringFromAscii(const ExternalAsciiString::Resource *resource)
static const int kEntries
static const int kGlobalFieldIndex
void PrintF(const char *format,...)
void Initialize(bool create_heap_objects)
char * AllocateAutoDeletedArray(int bytes)
static String * cast(Object *obj)
v8::internal::Handle< v8::internal::JSObject > value()
Handle< Context > result()
static Smi * FromInt(int value)
static ObjectTemplateInfo * cast(Object *obj)
static Vector< const char > GetRawScriptSource(int index)
value format" "after each garbage collection") DEFINE_bool(print_cumulative_gc_stat, false, "print cumulative GC statistics in name=value format on exit") DEFINE_bool(trace_gc_verbose, false, "print more details following each garbage collection") DEFINE_bool(trace_fragmentation, false, "report fragmentation for old pointer and data pages") DEFINE_bool(collect_maps, true, "garbage collect maps from which no objects can be reached") DEFINE_bool(flush_code, true, "flush code that we expect not to use again before full gc") DEFINE_bool(incremental_marking, true, "use incremental marking") DEFINE_bool(incremental_marking_steps, true, "do incremental marking steps") DEFINE_bool(trace_incremental_marking, false, "trace progress of the incremental marking") DEFINE_bool(use_idle_notification, true, "Use idle notification to reduce memory footprint.") DEFINE_bool(send_idle_notification, false, "Send idle notifcation between stress runs.") DEFINE_bool(use_ic, true, "use inline caching") DEFINE_bool(native_code_counters, false, "generate extra code for manipulating stats counters") DEFINE_bool(always_compact, false, "Perform compaction on every full GC") DEFINE_bool(lazy_sweeping, true, "Use lazy sweeping for old pointer and data spaces") DEFINE_bool(never_compact, false, "Never perform compaction on full GC-testing only") DEFINE_bool(compact_code_space, true, "Compact code space on full non-incremental collections") DEFINE_bool(cleanup_code_caches_at_gc, true, "Flush inline caches prior to mark compact collection and" "flush code caches in maps during mark compact cycle.") DEFINE_int(random_seed, 0, "Default seed for initializing random generator" "(0, the default, means to use system random).") DEFINE_bool(use_verbose_printer, true, "allows verbose printing") DEFINE_bool(allow_natives_syntax, false, "allow natives syntax") DEFINE_bool(trace_sim, false, "Trace simulator execution") DEFINE_bool(check_icache, false, "Check icache flushes in ARM and MIPS simulator") DEFINE_int(stop_sim_at, 0, "Simulator stop after x number of instructions") DEFINE_int(sim_stack_alignment, 8, "Stack alingment in bytes in simulator(4 or 8, 8 is default)") DEFINE_bool(trace_exception, false, "print stack trace when throwing exceptions") DEFINE_bool(preallocate_message_memory, false, "preallocate some memory to build stack traces.") DEFINE_bool(randomize_hashes, true, "randomize hashes to avoid predictable hash collisions" "(with snapshots this option cannot override the baked-in seed)") DEFINE_int(hash_seed, 0, "Fixed seed to use to hash property keys(0 means random)" "(with snapshots this option cannot override the baked-in seed)") DEFINE_bool(preemption, false, "activate a 100ms timer that switches between V8 threads") DEFINE_bool(regexp_optimization, true, "generate optimized regexp code") DEFINE_bool(testing_bool_flag, true, "testing_bool_flag") DEFINE_int(testing_int_flag, 13, "testing_int_flag") DEFINE_float(testing_float_flag, 2.5, "float-flag") DEFINE_string(testing_string_flag, "Hello, world!", "string-flag") DEFINE_int(testing_prng_seed, 42, "Seed used for threading test randomness") DEFINE_string(testing_serialization_file, "/tmp/serdes", "file in which to serialize heap") DEFINE_bool(help, false, "Print usage message, including flags, on console") DEFINE_bool(dump_counters, false, "Dump counters on exit") DEFINE_string(map_counters, "", "Map counters to a file") DEFINE_args(js_arguments, JSARGUMENTS_INIT, "Pass all remaining arguments to the script.Alias for\"--\".") DEFINE_bool(debug_compile_events, true,"Enable debugger compile events") DEFINE_bool(debug_script_collected_events, true,"Enable debugger script collected events") DEFINE_bool(gdbjit, false,"enable GDBJIT interface (disables compacting GC)") DEFINE_bool(gdbjit_full, false,"enable GDBJIT interface for all code objects") DEFINE_bool(gdbjit_dump, false,"dump elf objects with debug info to disk") DEFINE_string(gdbjit_dump_filter,"","dump only objects containing this substring") DEFINE_bool(force_marking_deque_overflows, false,"force overflows of marking deque by reducing it's size ""to 64 words") DEFINE_bool(stress_compaction, false,"stress the GC compactor to flush out bugs (implies ""--force_marking_deque_overflows)")#define FLAG DEFINE_bool(enable_slow_asserts, false,"enable asserts that are slow to execute") DEFINE_bool(trace_codegen, false,"print name of functions for which code is generated") DEFINE_bool(print_source, false,"pretty print source code") DEFINE_bool(print_builtin_source, false,"pretty print source code for builtins") DEFINE_bool(print_ast, false,"print source AST") DEFINE_bool(print_builtin_ast, false,"print source AST for builtins") DEFINE_string(stop_at,"","function name where to insert a breakpoint") DEFINE_bool(print_builtin_scopes, false,"print scopes for builtins") DEFINE_bool(print_scopes, false,"print scopes") DEFINE_bool(trace_contexts, false,"trace contexts operations") DEFINE_bool(gc_greedy, false,"perform GC prior to some allocations") DEFINE_bool(gc_verbose, false,"print stuff during garbage collection") DEFINE_bool(heap_stats, false,"report heap statistics before and after GC") DEFINE_bool(code_stats, false,"report code statistics after GC") DEFINE_bool(verify_heap, false,"verify heap pointers before and after GC") DEFINE_bool(print_handles, false,"report handles after GC") DEFINE_bool(print_global_handles, false,"report global handles after GC") DEFINE_bool(trace_ic, false,"trace inline cache state transitions") DEFINE_bool(print_interfaces, false,"print interfaces") DEFINE_bool(print_interface_details, false,"print interface inference details") DEFINE_int(print_interface_depth, 5,"depth for printing interfaces") DEFINE_bool(trace_normalization, false,"prints when objects are turned into dictionaries.") DEFINE_bool(trace_lazy, false,"trace lazy compilation") DEFINE_bool(collect_heap_spill_statistics, false,"report heap spill statistics along with heap_stats ""(requires heap_stats)") DEFINE_bool(trace_isolates, false,"trace isolate state changes") DEFINE_bool(log_state_changes, false,"Log state changes.") DEFINE_bool(regexp_possessive_quantifier, false,"enable possessive quantifier syntax for testing") DEFINE_bool(trace_regexp_bytecodes, false,"trace regexp bytecode execution") DEFINE_bool(trace_regexp_assembler, false,"trace regexp macro assembler calls.")#define FLAG DEFINE_bool(log, false,"Minimal logging (no API, code, GC, suspect, or handles samples).") DEFINE_bool(log_all, false,"Log all events to the log file.") DEFINE_bool(log_runtime, false,"Activate runtime system %Log call.") DEFINE_bool(log_api, false,"Log API events to the log file.") DEFINE_bool(log_code, false,"Log code events to the log file without profiling.") DEFINE_bool(log_gc, false,"Log heap samples on garbage collection for the hp2ps tool.") DEFINE_bool(log_handles, false,"Log global handle events.") DEFINE_bool(log_snapshot_positions, false,"log positions of (de)serialized objects in the snapshot.") DEFINE_bool(log_suspect, false,"Log suspect operations.") DEFINE_bool(prof, false,"Log statistical profiling information (implies --log-code).") DEFINE_bool(prof_auto, true,"Used with --prof, starts profiling automatically") DEFINE_bool(prof_lazy, false,"Used with --prof, only does sampling and logging"" when profiler is active (implies --noprof_auto).") DEFINE_bool(prof_browser_mode, true,"Used with --prof, turns on browser-compatible mode for profiling.") DEFINE_bool(log_regexp, false,"Log regular expression execution.") DEFINE_bool(sliding_state_window, false,"Update sliding state window counters.") DEFINE_string(logfile,"v8.log","Specify the name of the log file.") DEFINE_bool(ll_prof, false,"Enable low-level linux profiler.")#define FLAG DEFINE_bool(trace_elements_transitions, false,"trace elements transitions") DEFINE_bool(print_code_stubs, false,"print code stubs") DEFINE_bool(test_secondary_stub_cache, false,"test secondary stub cache by disabling the primary one") DEFINE_bool(test_primary_stub_cache, false,"test primary stub cache by disabling the secondary one") DEFINE_bool(print_code, false,"print generated code") DEFINE_bool(print_opt_code, false,"print optimized code") DEFINE_bool(print_unopt_code, false,"print unoptimized code before ""printing optimized code based on it") DEFINE_bool(print_code_verbose, false,"print more information for code") DEFINE_bool(print_builtin_code, false,"print generated code for builtins")#43"/Users/thlorenz/dev/dx/v8-perf/build/v8/src/flags.cc"2#define FLAG_MODE_DEFINE_DEFAULTS#1"/Users/thlorenz/dev/dx/v8-perf/build/v8/src/flag-definitions.h"1#define FLAG_FULL(ftype, ctype, nam, def, cmt)#define FLAG_READONLY(ftype, ctype, nam, def, cmt)#define DEFINE_implication(whenflag, thenflag)#define DEFINE_bool(nam, def, cmt)#define DEFINE_int(nam, def, cmt)#define DEFINE_float(nam, def, cmt)#define DEFINE_string(nam, def, cmt)#define DEFINE_args(nam, def, cmt)#define FLAG DEFINE_bool(use_strict, false,"enforce strict mode") DEFINE_bool(es5_readonly, false,"activate correct semantics for inheriting readonliness") DEFINE_bool(es52_globals, false,"activate new semantics for global var declarations") DEFINE_bool(harmony_typeof, false,"enable harmony semantics for typeof") DEFINE_bool(harmony_scoping, false,"enable harmony block scoping") DEFINE_bool(harmony_modules, false,"enable harmony modules (implies block scoping)") DEFINE_bool(harmony_proxies, false,"enable harmony proxies") DEFINE_bool(harmony_collections, false,"enable harmony collections (sets, maps, and weak maps)") DEFINE_bool(harmony, false,"enable all harmony features (except typeof)") DEFINE_implication(harmony, harmony_scoping) DEFINE_implication(harmony, harmony_modules) DEFINE_implication(harmony, harmony_proxies) DEFINE_implication(harmony, harmony_collections) DEFINE_implication(harmony_modules, harmony_scoping) DEFINE_bool(packed_arrays, false,"optimizes arrays that have no holes") DEFINE_bool(smi_only_arrays, true,"tracks arrays with only smi values") DEFINE_bool(clever_optimizations, true,"Optimize object size, Array shift, DOM strings and string +") DEFINE_bool(unbox_double_arrays, true,"automatically unbox arrays of doubles") DEFINE_bool(string_slices, true,"use string slices") DEFINE_bool(crankshaft, true,"use crankshaft") DEFINE_string(hydrogen_filter,"","optimization filter") DEFINE_bool(use_range, true,"use hydrogen range analysis") DEFINE_bool(eliminate_dead_phis, true,"eliminate dead phis") DEFINE_bool(use_gvn, true,"use hydrogen global value numbering") DEFINE_bool(use_canonicalizing, true,"use hydrogen instruction canonicalizing") DEFINE_bool(use_inlining, true,"use function inlining") DEFINE_int(max_inlined_source_size, 600,"maximum source size in bytes considered for a single inlining") DEFINE_int(max_inlined_nodes, 196,"maximum number of AST nodes considered for a single inlining") DEFINE_int(max_inlined_nodes_cumulative, 196,"maximum cumulative number of AST nodes considered for inlining") DEFINE_bool(loop_invariant_code_motion, true,"loop invariant code motion") DEFINE_bool(collect_megamorphic_maps_from_stub_cache, true,"crankshaft harvests type feedback from stub cache") DEFINE_bool(hydrogen_stats, false,"print statistics for hydrogen") DEFINE_bool(trace_hydrogen, false,"trace generated hydrogen to file") DEFINE_string(trace_phase,"Z","trace generated IR for specified phases") DEFINE_bool(trace_inlining, false,"trace inlining decisions") DEFINE_bool(trace_alloc, false,"trace register allocator") DEFINE_bool(trace_all_uses, false,"trace all use positions") DEFINE_bool(trace_range, false,"trace range analysis") DEFINE_bool(trace_gvn, false,"trace global value numbering") DEFINE_bool(trace_representation, false,"trace representation types") DEFINE_bool(stress_pointer_maps, false,"pointer map for every instruction") DEFINE_bool(stress_environments, false,"environment for every instruction") DEFINE_int(deopt_every_n_times, 0,"deoptimize every n times a deopt point is passed") DEFINE_bool(trap_on_deopt, false,"put a break point before deoptimizing") DEFINE_bool(deoptimize_uncommon_cases, true,"deoptimize uncommon cases") DEFINE_bool(polymorphic_inlining, true,"polymorphic inlining") DEFINE_bool(use_osr, true,"use on-stack replacement") DEFINE_bool(array_bounds_checks_elimination, false,"perform array bounds checks elimination") DEFINE_bool(array_index_dehoisting, false,"perform array index dehoisting") DEFINE_bool(trace_osr, false,"trace on-stack replacement") DEFINE_int(stress_runs, 0,"number of stress runs") DEFINE_bool(optimize_closures, true,"optimize closures") DEFINE_bool(inline_construct, true,"inline constructor calls") DEFINE_bool(inline_arguments, true,"inline functions with arguments object") DEFINE_int(loop_weight, 1,"loop weight for representation inference") DEFINE_bool(optimize_for_in, true,"optimize functions containing for-in loops") DEFINE_bool(experimental_profiler, true,"enable all profiler experiments") DEFINE_bool(watch_ic_patching, false,"profiler considers IC stability") DEFINE_int(frame_count, 1,"number of stack frames inspected by the profiler") DEFINE_bool(self_optimization, false,"primitive functions trigger their own optimization") DEFINE_bool(direct_self_opt, false,"call recompile stub directly when self-optimizing") DEFINE_bool(retry_self_opt, false,"re-try self-optimization if it failed") DEFINE_bool(count_based_interrupts, false,"trigger profiler ticks based on counting instead of timing") DEFINE_bool(interrupt_at_exit, false,"insert an interrupt check at function exit") DEFINE_bool(weighted_back_edges, false,"weight back edges by jump distance for interrupt triggering") DEFINE_int(interrupt_budget, 5900,"execution budget before interrupt is triggered") DEFINE_int(type_info_threshold, 15,"percentage of ICs that must have type info to allow optimization") DEFINE_int(self_opt_count, 130,"call count before self-optimization") DEFINE_implication(experimental_profiler, watch_ic_patching) DEFINE_implication(experimental_profiler, self_optimization) DEFINE_implication(experimental_profiler, retry_self_opt) DEFINE_implication(experimental_profiler, count_based_interrupts) DEFINE_implication(experimental_profiler, interrupt_at_exit) DEFINE_implication(experimental_profiler, weighted_back_edges) DEFINE_bool(trace_opt_verbose, false,"extra verbose compilation tracing") DEFINE_implication(trace_opt_verbose, trace_opt) DEFINE_bool(debug_code, false,"generate extra code (assertions) for debugging") DEFINE_bool(code_comments, false,"emit comments in code disassembly") DEFINE_bool(enable_sse2, true,"enable use of SSE2 instructions if available") DEFINE_bool(enable_sse3, true,"enable use of SSE3 instructions if available") DEFINE_bool(enable_sse4_1, true,"enable use of SSE4.1 instructions if available") DEFINE_bool(enable_cmov, true,"enable use of CMOV instruction if available") DEFINE_bool(enable_rdtsc, true,"enable use of RDTSC instruction if available") DEFINE_bool(enable_sahf, true,"enable use of SAHF instruction if available (X64 only)") DEFINE_bool(enable_vfp3, true,"enable use of VFP3 instructions if available - this implies ""enabling ARMv7 instructions (ARM only)") DEFINE_bool(enable_armv7, true,"enable use of ARMv7 instructions if available (ARM only)") DEFINE_bool(enable_fpu, true,"enable use of MIPS FPU instructions if available (MIPS only)") DEFINE_string(expose_natives_as, NULL,"expose natives in global object") DEFINE_string(expose_debug_as, NULL,"expose debug in global object") DEFINE_bool(expose_gc, false,"expose gc extension") DEFINE_bool(expose_externalize_string, false,"expose externalize string extension") DEFINE_int(stack_trace_limit, 10,"number of stack frames to capture") DEFINE_bool(builtins_in_stack_traces, false,"show built-in functions in stack traces") DEFINE_bool(disable_native_files, false,"disable builtin natives files") DEFINE_bool(inline_new, true,"use fast inline allocation") DEFINE_bool(stack_trace_on_abort, true,"print a stack trace if an assertion failure occurs") DEFINE_bool(trace, false,"trace function calls") DEFINE_bool(mask_constants_with_cookie, true,"use random jit cookie to mask large constants") DEFINE_bool(lazy, true,"use lazy compilation") DEFINE_bool(trace_opt, false,"trace lazy optimization") DEFINE_bool(trace_opt_stats, false,"trace lazy optimization statistics") DEFINE_bool(opt, true,"use adaptive optimizations") DEFINE_bool(always_opt, false,"always try to optimize functions") DEFINE_bool(prepare_always_opt, false,"prepare for turning on always opt") DEFINE_bool(trace_deopt, false,"trace deoptimization") DEFINE_int(min_preparse_length, 1024,"minimum length for automatic enable preparsing") DEFINE_bool(always_full_compiler, false,"try to use the dedicated run-once backend for all code") DEFINE_bool(trace_bailout, false,"print reasons for falling back to using the classic V8 backend") DEFINE_bool(compilation_cache, true,"enable compilation cache") DEFINE_bool(cache_prototype_transitions, true,"cache prototype transitions") DEFINE_bool(trace_debug_json, false,"trace debugging JSON request/response") DEFINE_bool(debugger_auto_break, true,"automatically set the debug break flag when debugger commands are ""in the queue") DEFINE_bool(enable_liveedit, true,"enable liveedit experimental feature") DEFINE_bool(break_on_abort, true,"always cause a debug break before aborting") DEFINE_int(stack_size, kPointerSize *123,"default size of stack region v8 is allowed to use (in kBytes)") DEFINE_int(max_stack_trace_source_length, 300,"maximum length of function source code printed in a stack trace.") DEFINE_bool(always_inline_smi_code, false,"always inline smi code in non-opt code") DEFINE_int(max_new_space_size, 0,"max size of the new generation (in kBytes)") DEFINE_int(max_old_space_size, 0,"max size of the old generation (in Mbytes)") DEFINE_int(max_executable_size, 0,"max size of executable memory (in Mbytes)") DEFINE_bool(gc_global, false,"always perform global GCs") DEFINE_int(gc_interval,-1,"garbage collect after <n> allocations") DEFINE_bool(trace_gc, false,"print one trace line following each garbage collection") DEFINE_bool(trace_gc_nvp, false,"print one detailed trace line in name=value format ""after each garbage collection") DEFINE_bool(print_cumulative_gc_stat, false,"print cumulative GC statistics in name=value format on exit") DEFINE_bool(trace_gc_verbose, false,"print more details following each garbage collection") DEFINE_bool(trace_fragmentation, false,"report fragmentation for old pointer and data pages") DEFINE_bool(collect_maps, true,"garbage collect maps from which no objects can be reached") DEFINE_bool(flush_code, true,"flush code that we expect not to use again before full gc") DEFINE_bool(incremental_marking, true,"use incremental marking") DEFINE_bool(incremental_marking_steps, true,"do incremental marking steps") DEFINE_bool(trace_incremental_marking, false,"trace progress of the incremental marking") DEFINE_bool(use_idle_notification, true,"Use idle notification to reduce memory footprint.") DEFINE_bool(send_idle_notification, false,"Send idle notifcation between stress runs.") DEFINE_bool(use_ic, true,"use inline caching") DEFINE_bool(native_code_counters, false,"generate extra code for manipulating stats counters") DEFINE_bool(always_compact, false,"Perform compaction on every full GC") DEFINE_bool(lazy_sweeping, true,"Use lazy sweeping for old pointer and data spaces") DEFINE_bool(never_compact, false,"Never perform compaction on full GC - testing only") DEFINE_bool(compact_code_space, true,"Compact code space on full non-incremental collections") DEFINE_bool(cleanup_code_caches_at_gc, true,"Flush inline caches prior to mark compact collection and ""flush code caches in maps during mark compact cycle.") DEFINE_int(random_seed, 0,"Default seed for initializing random generator ""(0, the default, means to use system random).") DEFINE_bool(use_verbose_printer, true,"allows verbose printing") DEFINE_bool(allow_natives_syntax, false,"allow natives syntax") DEFINE_bool(trace_sim, false,"Trace simulator execution") DEFINE_bool(check_icache, false,"Check icache flushes in ARM and MIPS simulator") DEFINE_int(stop_sim_at, 0,"Simulator stop after x number of instructions") DEFINE_int(sim_stack_alignment, 8,"Stack alingment in bytes in simulator (4 or 8, 8 is default)") DEFINE_bool(trace_exception, false,"print stack trace when throwing exceptions") DEFINE_bool(preallocate_message_memory, false,"preallocate some memory to build stack traces.") DEFINE_bool(randomize_hashes, true,"randomize hashes to avoid predictable hash collisions ""(with snapshots this option cannot override the baked-in seed)") DEFINE_int(hash_seed, 0,"Fixed seed to use to hash property keys (0 means random)""(with snapshots this option cannot override the baked-in seed)") DEFINE_bool(preemption, false,"activate a 100ms timer that switches between V8 threads") DEFINE_bool(regexp_optimization, true,"generate optimized regexp code") DEFINE_bool(testing_bool_flag, true,"testing_bool_flag") DEFINE_int(testing_int_flag, 13,"testing_int_flag") DEFINE_float(testing_float_flag, 2.5,"float-flag") DEFINE_string(testing_string_flag,"Hello, world!","string-flag") DEFINE_int(testing_prng_seed, 42,"Seed used for threading test randomness") DEFINE_string(testing_serialization_file,"/tmp/serdes","file in which to serialize heap") DEFINE_bool(help, false,"Print usage message, including flags, on console") DEFINE_bool(dump_counters, false,"Dump counters on exit") DEFINE_string(map_counters,"","Map counters to a file") DEFINE_args(js_arguments, JSARGUMENTS_INIT,"Pass all remaining arguments to the script. Alias for \"--\".") DEFINE_bool(debug_compile_events, true,"Enable debugger compile events") DEFINE_bool(debug_script_collected_events, true,"Enable debugger script collected events") DEFINE_bool(gdbjit, false,"enable GDBJIT interface (disables compacting GC)") DEFINE_bool(gdbjit_full, false,"enable GDBJIT interface for all code objects") DEFINE_bool(gdbjit_dump, false,"dump elf objects with debug info to disk") DEFINE_string(gdbjit_dump_filter,"","dump only objects containing this substring") DEFINE_bool(force_marking_deque_overflows, false,"force overflows of marking deque by reducing it's size ""to 64 words") DEFINE_bool(stress_compaction, false,"stress the GC compactor to flush out bugs (implies ""--force_marking_deque_overflows)")#define FLAG DEFINE_bool(enable_slow_asserts, false,"enable asserts that are slow to execute") DEFINE_bool(trace_codegen, false,"print name of functions for which code is generated") DEFINE_bool(print_source, false,"pretty print source code") DEFINE_bool(print_builtin_source, false,"pretty print source code for builtins") DEFINE_bool(print_ast, false,"print source AST") DEFINE_bool(print_builtin_ast, false,"print source AST for builtins") DEFINE_string(stop_at,"","function name where to insert a breakpoint") DEFINE_bool(print_builtin_scopes, false,"print scopes for builtins") DEFINE_bool(print_scopes, false,"print scopes") DEFINE_bool(trace_contexts, false,"trace contexts operations") DEFINE_bool(gc_greedy, false,"perform GC prior to some allocations") DEFINE_bool(gc_verbose, false,"print stuff during garbage collection") DEFINE_bool(heap_stats, false,"report heap statistics before and after GC") DEFINE_bool(code_stats, false,"report code statistics after GC") DEFINE_bool(verify_heap, false,"verify heap pointers before and after GC") DEFINE_bool(print_handles, false,"report handles after GC") DEFINE_bool(print_global_handles, false,"report global handles after GC") DEFINE_bool(trace_ic, false,"trace inline cache state transitions") DEFINE_bool(print_interfaces, false,"print interfaces") DEFINE_bool(print_interface_details, false,"print interface inference details") DEFINE_int(print_interface_depth, 5,"depth for printing interfaces") DEFINE_bool(trace_normalization, false,"prints when objects are turned into dictionaries.") DEFINE_bool(trace_lazy, false,"trace lazy compilation") DEFINE_bool(collect_heap_spill_statistics, false,"report heap spill statistics along with heap_stats ""(requires heap_stats)") DEFINE_bool(trace_isolates, false,"trace isolate state changes") DEFINE_bool(log_state_changes, false,"Log state changes.") DEFINE_bool(regexp_possessive_quantifier, false,"enable possessive quantifier syntax for testing") DEFINE_bool(trace_regexp_bytecodes, false,"trace regexp bytecode execution") DEFINE_bool(trace_regexp_assembler, false,"trace regexp macro assembler calls.")#define FLAG DEFINE_bool(log, false,"Minimal logging (no API, code, GC, suspect, or handles samples).") DEFINE_bool(log_all, false,"Log all events to the log file.") DEFINE_bool(log_runtime, false,"Activate runtime system %Log call.") DEFINE_bool(log_api, false,"Log API events to the log file.") DEFINE_bool(log_code, false,"Log code events to the log file without profiling.") DEFINE_bool(log_gc, false,"Log heap samples on garbage collection for the hp2ps tool.") DEFINE_bool(log_handles, false,"Log global handle events.") DEFINE_bool(log_snapshot_positions, false,"log positions of (de)serialized objects in the snapshot.") DEFINE_bool(log_suspect, false,"Log suspect operations.") DEFINE_bool(prof, false,"Log statistical profiling information (implies --log-code).") DEFINE_bool(prof_auto, true,"Used with --prof, starts profiling automatically") DEFINE_bool(prof_lazy, false,"Used with --prof, only does sampling and logging"" when profiler is active (implies --noprof_auto).") DEFINE_bool(prof_browser_mode, true,"Used with --prof, turns on browser-compatible mode for profiling.") DEFINE_bool(log_regexp, false,"Log regular expression execution.") DEFINE_bool(sliding_state_window, false,"Update sliding state window counters.") DEFINE_string(logfile,"v8.log","Specify the name of the log file.") DEFINE_bool(ll_prof, false,"Enable low-level linux profiler.")#define FLAG DEFINE_bool(trace_elements_transitions, false,"trace elements transitions") DEFINE_bool(print_code_stubs, false,"print code stubs") DEFINE_bool(test_secondary_stub_cache, false,"test secondary stub cache by disabling the primary one") DEFINE_bool(test_primary_stub_cache, false,"test primary stub cache by disabling the secondary one") DEFINE_bool(print_code, false,"print generated code") DEFINE_bool(print_opt_code, false,"print optimized code") DEFINE_bool(print_unopt_code, false,"print unoptimized code before ""printing optimized code based on it") DEFINE_bool(print_code_verbose, false,"print more information for code") DEFINE_bool(print_builtin_code, false,"print generated code for builtins")#47"/Users/thlorenz/dev/dx/v8-perf/build/v8/src/flags.cc"2 namespace{struct Flag{enum FlagType{TYPE_BOOL, TYPE_INT, TYPE_FLOAT, TYPE_STRING, TYPE_ARGS} name
static HeapObject * cast(Object *obj)
static Handle< T > cast(Handle< S > that)
static const int kSourceFieldIndex
static Vector< const char > GetScriptName(int index)
static AccessorPair * cast(Object *obj)
static const char ** GetNames(ExtensionConfiguration *that)
static int GetDebuggerCount()
static Handle< Context > NewContextFromSnapshot()
#define ASSERT(condition)
MUST_USE_RESULT MaybeObject * PreventExtensions()
char * RestoreState(char *from)
Handle< JSFunction > NewFunctionWithPrototype(Handle< String > name, InstanceType type, int instance_size, Handle< JSObject > prototype, Handle< Code > code, bool force_initial_map)
static const char * GetName(JavaScript id)
static Context * cast(Object *context)
Handle< Object > GetProperty(Handle< JSReceiver > obj, const char *name)
Handle< String > LookupAsciiSymbol(Vector< const char > str)
static const int kMultilineFieldIndex
void FreeThreadResources()
static int GetBuiltinsCount()
friend class NativesExternalStringResource
uint32_t ComputePointerHash(void *ptr)
static const int kArgumentsObjectSizeStrict
static JSGlobalProxy * cast(Object *obj)
static const int kFactoryIndex
static const int kInputIndex
#define INSTALL_BUILTIN_ID(holder_expr, fun_name, name)
friend class BootstrapperActive
Handle< Map > CopyMapDropTransitions(Handle< Map > map)
void set_context(Context *context)
const char * name() const
static int GetNameCount(ExtensionConfiguration *that)
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
static Handle< Object > SetLocalPropertyIgnoreAttributes(Handle< JSObject > object, Handle< String > key, Handle< Object > value, PropertyAttributes attributes)
static FunctionTemplateInfo * cast(Object *obj)
Handle< String > NativesSourceLookup(int index)
static int NumberOfJavaScriptBuiltins()
static const int kIgnoreCaseFieldIndex
static Handle< Object > Call(Handle< Object > callable, Handle< Object > receiver, int argc, Handle< Object > argv[], bool *pending_exception, bool convert_receiver=false)
Vector< const char > CStrVector(const char *data)
Handle< Context > CreateEnvironment(Isolate *isolate, Handle< Object > global_object, v8::Handle< v8::ObjectTemplate > global_template, v8::ExtensionConfiguration *extensions)
void Iterate(ObjectVisitor *v)
Isolate * isolate() const
Handle< JSFunction > NewFunctionWithoutPrototype(Handle< String > name, LanguageMode language_mode)
#define INSTALL_NATIVE(Type, name, var)
#define JSFUNCTION_RESULT_CACHE_LIST(F)
static const int kArgumentsLengthIndex
void DetachGlobal(Handle< Context > env)
const String::ExternalAsciiStringResource * source() const
void ReattachGlobal(Handle< Context > env, Handle< Object > global_object)
static JSGlobalPropertyCell * cast(Object *obj)
static RegisteredExtension * first_extension()
static const int kEntriesIndex
static Handle< SharedFunctionInfo > Compile(Handle< String > source, Handle< Object > script_name, int line_offset, int column_offset, v8::Extension *extension, ScriptDataImpl *pre_data, Handle< Object > script_data, NativesFlag is_natives_code)
static void PrintError(const char *format,...)
Handle< JSGlobalProxy > ReinitializeJSGlobalProxy(Handle< JSFunction > constructor, Handle< JSGlobalProxy > global)
static Handle< String > null()
TemplateHashMapImpl< FreeStoreAllocationPolicy > HashMap
#define ASSERT_EQ(v1, v2)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination trace on stack replacement optimize closures functions with arguments object optimize functions containing for in loops profiler considers IC stability primitive functions trigger their own optimization re try self optimization if it failed insert an interrupt check at function exit execution budget before interrupt is triggered call count before self optimization self_optimization count_based_interrupts weighted_back_edges trace_opt emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 enable use of ARMv7 instructions if enable use of MIPS FPU instructions if NULL
static const int kIndexIndex
const int kRandomStateSize
static Handle< JSObject > InstantiateObject(Handle< ObjectTemplateInfo > data, bool *exc)
static const int kArgumentsCalleeIndex
static FixedArray * cast(Object *obj)
static const int kHeaderSize
Object * SetNormalizedProperty(LookupResult *result, Object *value)
static bool ReportApiFailure(const char *location, const char *message)
void Add(const T &element, AllocationPolicy allocator=AllocationPolicy())
static VisitorId GetVisitorId(int instance_type, int instance_size)
Handle< Object > ForceSetProperty(Handle< JSObject > object, Handle< Object > key, Handle< Object > value, PropertyAttributes attributes)
static NormalizedMapCache * cast(Object *obj)
Handle< Object > SetPrototype(Handle< JSFunction > function, Handle< Object > prototype)
static const int kLastIndexFieldIndex
static GlobalObject * cast(Object *obj)
#define FUNCTIONS_WITH_ID_LIST(V)
NativesExternalStringResource(Bootstrapper *bootstrapper, const char *source, size_t length)
Handle< Map > NewMap(InstanceType type, int instance_size, ElementsKind elements_kind=TERMINAL_FAST_ELEMENTS_KIND)
Factory * factory() const
const char ** dependencies()
void check(i::Vector< const char > string)
static int ArchiveSpacePerThread()
static JSObject * cast(Object *obj)
static v8::internal::Handle< v8::internal::TemplateInfo > OpenHandle(const Template *that)
static JSGlobalObject * cast(Object *obj)
bool InstallExtensions(Handle< Context > global_context, v8::ExtensionConfiguration *extensions)
static JSFunction * cast(Object *obj)