59 : data_(source), length_(length) {
60 if (bootstrapper->delete_these_non_arrays_on_tear_down_ ==
NULL) {
61 bootstrapper->delete_these_non_arrays_on_tear_down_ =
new List<char*>(2);
65 bootstrapper->delete_these_non_arrays_on_tear_down_->
66 Add(reinterpret_cast<char*>(
this));
70 Bootstrapper::Bootstrapper(
Isolate* isolate)
73 extensions_cache_(
Script::TYPE_EXTENSION),
74 delete_these_non_arrays_on_tear_down_(
NULL),
75 delete_these_arrays_on_tear_down_(
NULL) {
82 if (heap->natives_source_cache()->get(index)->IsUndefined()) {
93 heap->natives_source_cache()->set(index, *source_code);
95 Handle<Object> cached_source(heap->natives_source_cache()->get(index),
102 extensions_cache_.Initialize(isolate_, create_heap_objects);
106 static const char* GCFunctionName() {
107 bool flag_given = FLAG_expose_gc_as !=
NULL && strlen(FLAG_expose_gc_as) != 0;
108 return flag_given ? FLAG_expose_gc_as :
"gc";
134 delete free_buffer_extension_;
135 delete gc_extension_;
136 delete externalize_string_extension_;
137 delete statistics_extension_;
138 delete trigger_failure_extension_;
143 char*
memory =
new char[bytes];
144 if (memory !=
NULL) {
145 if (delete_these_arrays_on_tear_down_ ==
NULL) {
146 delete_these_arrays_on_tear_down_ =
new List<char*>(2);
148 delete_these_arrays_on_tear_down_->
Add(memory);
155 if (delete_these_non_arrays_on_tear_down_ !=
NULL) {
156 int len = delete_these_non_arrays_on_tear_down_->length();
158 for (
int i = 0; i < len; i++) {
159 delete delete_these_non_arrays_on_tear_down_->
at(i);
160 delete_these_non_arrays_on_tear_down_->
at(i) =
NULL;
162 delete delete_these_non_arrays_on_tear_down_;
163 delete_these_non_arrays_on_tear_down_ =
NULL;
166 if (delete_these_arrays_on_tear_down_ !=
NULL) {
167 int len = delete_these_arrays_on_tear_down_->length();
169 for (
int i = 0; i < len; i++) {
170 delete[] delete_these_arrays_on_tear_down_->
at(i);
171 delete_these_arrays_on_tear_down_->
at(i) =
NULL;
173 delete delete_these_arrays_on_tear_down_;
174 delete_these_arrays_on_tear_down_ =
NULL;
177 extensions_cache_.Initialize(isolate_,
false);
232 void InitializeExperimentalGlobal();
235 void InstallNativeFunctions();
236 void InstallExperimentalBuiltinFunctionIds();
237 void InstallExperimentalNativeFunctions();
241 bool InstallNatives();
245 bool InstallExperimentalNatives();
246 void InstallBuiltinFunctionIds();
247 void InstallJSFunctionResultCaches();
248 void InitializeNormalizedMapCaches();
250 enum ExtensionTraversalState {
251 UNVISITED, VISITED, INSTALLED
254 class ExtensionStates {
257 ExtensionTraversalState get_state(RegisteredExtension* extension);
258 void set_state(RegisteredExtension* extension,
259 ExtensionTraversalState state);
267 static bool InstallExtensions(Handle<Context> native_context,
269 static bool InstallAutoExtensions(Isolate* isolate,
270 ExtensionStates* extension_states);
271 static bool InstallRequestedExtensions(Isolate* isolate,
273 ExtensionStates* extension_states);
274 static bool InstallExtension(Isolate* isolate,
276 ExtensionStates* extension_states);
277 static bool InstallExtension(Isolate* isolate,
279 ExtensionStates* extension_states);
280 static bool InstallSpecialObjects(Handle<Context> native_context);
281 bool InstallJSBuiltins(Handle<JSBuiltinsObject> builtins);
282 bool ConfigureApiObject(Handle<JSObject>
object,
283 Handle<ObjectTemplateInfo> object_template);
289 void TransferObject(Handle<JSObject> from, Handle<JSObject> to);
290 void TransferNamedProperties(Handle<JSObject> from, Handle<JSObject> to);
291 void TransferIndexedProperties(Handle<JSObject> from, Handle<JSObject> to);
293 enum PrototypePropertyMode {
295 ADD_READONLY_PROTOTYPE,
296 ADD_WRITEABLE_PROTOTYPE
299 Handle<Map> CreateFunctionMap(PrototypePropertyMode prototype_mode);
301 void SetFunctionInstanceDescriptor(Handle<Map>
map,
302 PrototypePropertyMode prototypeMode);
303 void MakeFunctionInstancePrototypeWritable();
305 Handle<Map> CreateStrictFunctionMap(
306 PrototypePropertyMode prototype_mode,
307 Handle<JSFunction> empty_function);
309 void SetStrictFunctionInstanceDescriptor(Handle<Map>
map,
310 PrototypePropertyMode propertyMode);
312 static bool CompileBuiltin(Isolate* isolate,
int index);
313 static bool CompileExperimentalBuiltin(Isolate* isolate,
int index);
314 static bool CompileNative(Isolate* isolate,
315 Vector<const char>
name,
316 Handle<String> source);
317 static bool CompileScriptCached(Isolate* isolate,
318 Vector<const char>
name,
319 Handle<String> source,
320 SourceCodeCache* cache,
322 Handle<Context> top_context,
323 bool use_runtime_context);
326 Handle<Context> result_;
327 Handle<Context> native_context_;
333 Handle<Map> sloppy_function_map_writable_prototype_;
334 Handle<Map> strict_function_map_writable_prototype_;
335 Handle<JSFunction> throw_type_error_function;
337 BootstrapperActive active_;
343 extensions_cache_.Iterate(v);
344 v->Synchronize(VisitorSynchronization::kExtensions);
353 Genesis genesis(isolate_, global_object, global_template, extensions);
364 Factory* factory =
object->GetIsolate()->factory();
367 new_to_map->set_prototype(*proto);
368 object->set_map(*new_to_map);
375 global_proxy->set_native_context(*factory->null_value());
376 SetObjectPrototype(global_proxy, factory->null_value());
386 bool install_initial_map,
387 bool set_instance_class_name) {
388 Isolate* isolate = target->GetIsolate();
399 install_initial_map);
401 if (target->IsJSBuiltinsObject()) {
409 target, internalized_name,
function, attributes));
410 if (set_instance_class_name) {
411 function->shared()->set_instance_class_name(*internalized_name);
413 function->shared()->set_native(
true);
418 void Genesis::SetFunctionInstanceDescriptor(
419 Handle<Map>
map, PrototypePropertyMode prototypeMode) {
420 int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5;
421 Handle<DescriptorArray> descriptors(factory()->NewDescriptorArray(0, size));
422 DescriptorArray::WhitenessWitness witness(*descriptors);
424 Handle<Foreign> length(factory()->NewForeign(&Accessors::FunctionLength));
425 Handle<Foreign>
name(factory()->NewForeign(&Accessors::FunctionName));
426 Handle<Foreign> args(factory()->NewForeign(&Accessors::FunctionArguments));
427 Handle<Foreign> caller(factory()->NewForeign(&Accessors::FunctionCaller));
428 Handle<Foreign> prototype;
429 if (prototypeMode != DONT_ADD_PROTOTYPE) {
430 prototype = factory()->
NewForeign(&Accessors::FunctionPrototype);
434 map->set_instance_descriptors(*descriptors);
437 CallbacksDescriptor d(*factory()->length_string(), *length, attribs);
438 map->AppendDescriptor(&d, witness);
441 CallbacksDescriptor d(*factory()->name_string(), *name, attribs);
442 map->AppendDescriptor(&d, witness);
445 CallbacksDescriptor d(*factory()->arguments_string(), *args, attribs);
446 map->AppendDescriptor(&d, witness);
449 CallbacksDescriptor d(*factory()->caller_string(), *caller, attribs);
450 map->AppendDescriptor(&d, witness);
452 if (prototypeMode != DONT_ADD_PROTOTYPE) {
454 if (prototypeMode == ADD_WRITEABLE_PROTOTYPE) {
457 CallbacksDescriptor d(*factory()->prototype_string(), *prototype, attribs);
458 map->AppendDescriptor(&d, witness);
463 Handle<Map> Genesis::CreateFunctionMap(PrototypePropertyMode prototype_mode) {
465 SetFunctionInstanceDescriptor(map, prototype_mode);
466 map->set_function_with_prototype(prototype_mode != DONT_ADD_PROTOTYPE);
471 Handle<JSFunction> Genesis::CreateEmptyFunction(Isolate* isolate) {
477 Handle<Map> function_without_prototype_map =
478 CreateFunctionMap(DONT_ADD_PROTOTYPE);
479 native_context()->set_sloppy_function_without_prototype_map(
480 *function_without_prototype_map);
485 Handle<Map> function_map = CreateFunctionMap(ADD_READONLY_PROTOTYPE);
486 native_context()->set_sloppy_function_map(*function_map);
490 sloppy_function_map_writable_prototype_ =
491 CreateFunctionMap(ADD_WRITEABLE_PROTOTYPE);
493 Factory* factory = isolate->factory();
495 Handle<String> object_name = factory->Object_string();
498 Handle<JSFunction> object_fun =
499 factory->NewFunction(object_name, factory->null_value());
500 Handle<Map> object_function_map =
502 object_fun->set_initial_map(*object_function_map);
503 object_function_map->set_constructor(*object_fun);
505 native_context()->set_object_function(*object_fun);
508 Handle<JSObject> prototype = factory->NewJSObject(
509 isolate->object_function(),
512 native_context()->set_initial_object_prototype(*prototype);
516 native_context()->set_initial_array_prototype(*prototype);
522 Handle<String> empty_string =
524 Handle<JSFunction> empty_function =
525 factory->NewFunctionWithoutPrototype(empty_string,
SLOPPY);
529 Handle<Code>(isolate->builtins()->builtin(
530 Builtins::kEmptyFunction));
531 empty_function->set_code(*code);
532 empty_function->shared()->set_code(*code);
533 Handle<String> source =
535 Handle<Script> script = factory->NewScript(source);
537 empty_function->shared()->set_script(*script);
538 empty_function->shared()->set_start_position(0);
539 empty_function->shared()->set_end_position(source->length());
540 empty_function->shared()->DontAdaptArguments();
543 native_context()->sloppy_function_map()->set_prototype(*empty_function);
544 native_context()->sloppy_function_without_prototype_map()->
545 set_prototype(*empty_function);
546 sloppy_function_map_writable_prototype_->set_prototype(*empty_function);
549 Handle<Map> empty_function_map = CreateFunctionMap(DONT_ADD_PROTOTYPE);
550 empty_function_map->set_prototype(
551 native_context()->object_function()->prototype());
552 empty_function->set_map(*empty_function_map);
553 return empty_function;
557 void Genesis::SetStrictFunctionInstanceDescriptor(
558 Handle<Map> map, PrototypePropertyMode prototypeMode) {
559 int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5;
560 Handle<DescriptorArray> descriptors(factory()->NewDescriptorArray(0, size));
561 DescriptorArray::WhitenessWitness witness(*descriptors);
563 Handle<Foreign> length(factory()->NewForeign(&Accessors::FunctionLength));
564 Handle<Foreign>
name(factory()->NewForeign(&Accessors::FunctionName));
565 Handle<AccessorPair> arguments(factory()->NewAccessorPair());
566 Handle<AccessorPair> caller(factory()->NewAccessorPair());
567 Handle<Foreign> prototype;
568 if (prototypeMode != DONT_ADD_PROTOTYPE) {
569 prototype = factory()->NewForeign(&Accessors::FunctionPrototype);
575 map->set_instance_descriptors(*descriptors);
578 CallbacksDescriptor d(*factory()->length_string(), *length, ro_attribs);
579 map->AppendDescriptor(&d, witness);
582 CallbacksDescriptor d(*factory()->name_string(), *name, ro_attribs);
583 map->AppendDescriptor(&d, witness);
586 CallbacksDescriptor d(*factory()->arguments_string(), *arguments,
588 map->AppendDescriptor(&d, witness);
591 CallbacksDescriptor d(*factory()->caller_string(), *caller, rw_attribs);
592 map->AppendDescriptor(&d, witness);
594 if (prototypeMode != DONT_ADD_PROTOTYPE) {
597 prototypeMode == ADD_WRITEABLE_PROTOTYPE ? rw_attribs : ro_attribs;
598 CallbacksDescriptor d(*factory()->prototype_string(), *prototype, attribs);
599 map->AppendDescriptor(&d, witness);
605 Handle<JSFunction> Genesis::GetThrowTypeErrorFunction() {
606 if (throw_type_error_function.is_null()) {
607 Handle<String> name = factory()->InternalizeOneByteString(
609 throw_type_error_function =
610 factory()->NewFunctionWithoutPrototype(name,
SLOPPY);
611 Handle<Code>
code(isolate()->builtins()->builtin(
612 Builtins::kStrictModePoisonPill));
613 throw_type_error_function->set_map(native_context()->sloppy_function_map());
614 throw_type_error_function->set_code(*code);
615 throw_type_error_function->shared()->set_code(*code);
616 throw_type_error_function->shared()->DontAdaptArguments();
620 return throw_type_error_function;
624 Handle<Map> Genesis::CreateStrictFunctionMap(
625 PrototypePropertyMode prototype_mode,
626 Handle<JSFunction> empty_function) {
628 SetStrictFunctionInstanceDescriptor(map, prototype_mode);
629 map->set_function_with_prototype(prototype_mode != DONT_ADD_PROTOTYPE);
630 map->set_prototype(*empty_function);
635 void Genesis::CreateStrictModeFunctionMaps(Handle<JSFunction> empty) {
637 Handle<Map> strict_function_without_prototype_map =
638 CreateStrictFunctionMap(DONT_ADD_PROTOTYPE, empty);
639 native_context()->set_strict_function_without_prototype_map(
640 *strict_function_without_prototype_map);
645 Handle<Map> strict_function_map =
646 CreateStrictFunctionMap(ADD_READONLY_PROTOTYPE, empty);
647 native_context()->set_strict_function_map(*strict_function_map);
651 strict_function_map_writable_prototype_ =
652 CreateStrictFunctionMap(ADD_WRITEABLE_PROTOTYPE, empty);
655 PoisonArgumentsAndCaller(strict_function_without_prototype_map);
656 PoisonArgumentsAndCaller(strict_function_map);
657 PoisonArgumentsAndCaller(strict_function_map_writable_prototype_);
661 static void SetAccessors(Handle<Map> map,
663 Handle<JSFunction> func) {
664 DescriptorArray* descs = map->instance_descriptors();
665 int number = descs->SearchWithCache(*name, *map);
667 accessors->set_getter(*func);
668 accessors->set_setter(*func);
672 void Genesis::PoisonArgumentsAndCaller(Handle<Map> map) {
673 SetAccessors(map, factory()->arguments_string(), GetThrowTypeErrorFunction());
674 SetAccessors(map, factory()->caller_string(), GetThrowTypeErrorFunction());
678 static void AddToWeakNativeContextList(Context* context) {
679 ASSERT(context->IsNativeContext());
680 Heap* heap = context->GetIsolate()->heap();
685 for (
Object* current = heap->native_contexts_list();
686 !current->IsUndefined();
688 ASSERT(current != context);
693 heap->set_native_contexts_list(context);
697 void Genesis::CreateRoots() {
702 native_context_ = factory()->NewNativeContext();
703 AddToWeakNativeContextList(*native_context());
704 isolate()->set_context(*native_context());
709 native_context()->set_message_listeners(*listeners.value());
714 Handle<JSGlobalProxy> Genesis::CreateNewGlobals(
716 Handle<Object> global_object,
717 Handle<GlobalObject>* inner_global_out) {
731 Handle<JSFunction> js_global_function;
732 Handle<ObjectTemplateInfo> js_global_template;
733 if (!global_template.
IsEmpty()) {
735 Handle<ObjectTemplateInfo> data =
737 Handle<FunctionTemplateInfo> global_constructor =
738 Handle<FunctionTemplateInfo>(
740 Handle<Object> proto_template(global_constructor->prototype_template(),
742 if (!proto_template->IsUndefined()) {
748 if (js_global_template.is_null()) {
749 Handle<String> name = Handle<String>(heap()->empty_string());
750 Handle<Code> code = Handle<Code>(isolate()->builtins()->builtin(
751 Builtins::kIllegal));
757 Handle<JSObject> prototype =
762 prototype, factory()->constructor_string(),
763 isolate()->object_function(),
NONE));
765 Handle<FunctionTemplateInfo> js_global_constructor(
768 factory()->CreateApiFunction(js_global_constructor,
769 factory()->InnerGlobalObject);
772 js_global_function->initial_map()->set_is_hidden_prototype();
773 js_global_function->initial_map()->set_dictionary_map(
true);
774 Handle<GlobalObject> inner_global =
775 factory()->NewGlobalObject(js_global_function);
776 if (inner_global_out !=
NULL) {
777 *inner_global_out = inner_global;
781 Handle<JSFunction> global_proxy_function;
782 if (global_template.
IsEmpty()) {
783 Handle<String> name = Handle<String>(heap()->empty_string());
784 Handle<Code> code = Handle<Code>(isolate()->builtins()->builtin(
785 Builtins::kIllegal));
786 global_proxy_function =
790 Handle<ObjectTemplateInfo> data =
792 Handle<FunctionTemplateInfo> global_constructor(
794 global_proxy_function =
795 factory()->CreateApiFunction(global_constructor,
796 factory()->OuterGlobalObject);
799 Handle<String> global_name = factory()->InternalizeOneByteString(
801 global_proxy_function->shared()->set_instance_class_name(*global_name);
802 global_proxy_function->initial_map()->set_is_access_check_needed(
true);
807 if (global_object.location() !=
NULL) {
808 ASSERT(global_object->IsJSGlobalProxy());
810 global_proxy_function,
811 Handle<JSGlobalProxy>::cast(global_object));
814 factory()->NewJSObject(global_proxy_function,
TENURED));
819 void Genesis::HookUpGlobalProxy(Handle<GlobalObject> inner_global,
820 Handle<JSGlobalProxy> global_proxy) {
822 inner_global->set_native_context(*native_context());
823 inner_global->set_global_context(*native_context());
824 inner_global->set_global_receiver(*global_proxy);
825 global_proxy->set_native_context(*native_context());
826 native_context()->set_global_proxy(*global_proxy);
830 void Genesis::HookUpInnerGlobal(Handle<GlobalObject> inner_global) {
831 Handle<GlobalObject> inner_global_from_snapshot(
833 Handle<JSBuiltinsObject> builtins_global(native_context()->builtins());
834 native_context()->set_extension(*inner_global);
835 native_context()->set_global_object(*inner_global);
836 native_context()->set_security_token(*inner_global);
840 factory()->InternalizeOneByteString(
846 TransferNamedProperties(inner_global_from_snapshot, inner_global);
847 TransferIndexedProperties(inner_global_from_snapshot, inner_global);
853 void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
854 Handle<JSFunction> empty_function) {
857 native_context()->set_closure(*empty_function);
858 native_context()->set_previous(
NULL);
860 native_context()->set_extension(*inner_global);
861 native_context()->set_global_object(*inner_global);
866 native_context()->set_security_token(*inner_global);
868 Isolate* isolate = inner_global->GetIsolate();
869 Factory* factory = isolate->factory();
870 Heap* heap = isolate->heap();
872 Handle<String> object_name = factory->Object_string();
875 inner_global, object_name,
878 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object());
882 empty_function, Builtins::kIllegal,
true,
true);
885 Handle<JSFunction> array_function =
887 isolate->initial_object_prototype(),
889 array_function->shared()->DontAdaptArguments();
894 array_function->shared()->set_length(1);
896 Handle<Map> initial_map(array_function->initial_map());
902 Handle<DescriptorArray> array_descriptors(
903 factory->NewDescriptorArray(0, 1));
904 DescriptorArray::WhitenessWitness witness(*array_descriptors);
906 Handle<Foreign> array_length(factory->NewForeign(&Accessors::ArrayLength));
909 initial_map->set_instance_descriptors(*array_descriptors);
912 CallbacksDescriptor d(*factory->length_string(), *array_length, attribs);
913 array_function->initial_map()->AppendDescriptor(&d, witness);
920 native_context()->set_array_function(*array_function);
924 ArrayConstructorStub array_constructor_stub(isolate);
925 Handle<Code> code = array_constructor_stub.GetCode(isolate);
926 array_function->shared()->set_construct_stub(*code);
930 Handle<JSFunction> number_fun =
932 isolate->initial_object_prototype(),
933 Builtins::kIllegal,
true,
true);
934 native_context()->set_number_function(*number_fun);
938 Handle<JSFunction> boolean_fun =
940 isolate->initial_object_prototype(),
941 Builtins::kIllegal,
true,
true);
942 native_context()->set_boolean_function(*boolean_fun);
946 Handle<JSFunction> string_fun =
948 isolate->initial_object_prototype(),
949 Builtins::kIllegal,
true,
true);
950 string_fun->shared()->set_construct_stub(
951 isolate->builtins()->builtin(Builtins::kStringConstructCode));
952 native_context()->set_string_function(*string_fun);
954 Handle<Map> string_map =
955 Handle<Map>(native_context()->string_function()->initial_map());
956 Handle<DescriptorArray> string_descriptors(
957 factory->NewDescriptorArray(0, 1));
958 DescriptorArray::WhitenessWitness witness(*string_descriptors);
960 Handle<Foreign> string_length(
961 factory->NewForeign(&Accessors::StringLength));
964 string_map->set_instance_descriptors(*string_descriptors);
967 CallbacksDescriptor d(*factory->length_string(), *string_length, attribs);
968 string_map->AppendDescriptor(&d, witness);
974 Handle<JSFunction> date_fun =
976 isolate->initial_object_prototype(),
977 Builtins::kIllegal,
true,
true);
979 native_context()->set_date_function(*date_fun);
985 Handle<JSFunction> regexp_fun =
987 isolate->initial_object_prototype(),
988 Builtins::kIllegal,
true,
true);
989 native_context()->set_regexp_function(*regexp_fun);
991 ASSERT(regexp_fun->has_initial_map());
992 Handle<Map> initial_map(regexp_fun->initial_map());
994 ASSERT_EQ(0, initial_map->inobject_properties());
998 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(0, 5);
999 DescriptorArray::WhitenessWitness witness(*descriptors);
1000 initial_map->set_instance_descriptors(*descriptors);
1004 FieldDescriptor field(heap->source_string(),
1008 initial_map->AppendDescriptor(&field, witness);
1012 FieldDescriptor field(heap->global_string(),
1016 initial_map->AppendDescriptor(&field, witness);
1020 FieldDescriptor field(heap->ignore_case_string(),
1024 initial_map->AppendDescriptor(&field, witness);
1028 FieldDescriptor field(heap->multiline_string(),
1032 initial_map->AppendDescriptor(&field, witness);
1036 PropertyAttributes writable =
1038 FieldDescriptor field(heap->last_index_string(),
1042 initial_map->AppendDescriptor(&field, witness);
1045 initial_map->set_inobject_properties(5);
1046 initial_map->set_pre_allocated_property_fields(5);
1047 initial_map->set_unused_property_fields(0);
1048 initial_map->set_instance_size(
1053 Handle<Map> proto_map = factory->CopyMap(initial_map);
1054 proto_map->set_prototype(native_context()->initial_object_prototype());
1055 Handle<JSObject> proto = factory->NewJSObjectFromMap(proto_map);
1057 heap->query_colon_string());
1059 heap->false_value());
1061 heap->false_value());
1063 heap->false_value());
1067 initial_map->set_prototype(*proto);
1068 factory->SetRegExpIrregexpData(Handle<JSRegExp>::cast(proto),
1070 JSRegExp::Flags(0), 0);
1074 Handle<String> name = factory->InternalizeUtf8String(
"JSON");
1075 Handle<JSFunction> cons = factory->NewFunction(name,
1076 factory->the_hole_value());
1078 Handle<Object>(native_context()->initial_object_prototype(), isolate));
1079 cons->SetInstanceClassName(*name);
1080 Handle<JSObject> json_object = factory->NewJSObject(cons,
TENURED);
1081 ASSERT(json_object->IsJSObject());
1085 native_context()->set_json_object(*json_object);
1089 Handle<JSFunction> array_buffer_fun =
1093 isolate->initial_object_prototype(),
1094 Builtins::kIllegal,
true,
true);
1095 native_context()->set_array_buffer_fun(*array_buffer_fun);
1099 #define INSTALL_TYPED_ARRAY(Type, type, TYPE, ctype, size) \
1101 Handle<JSFunction> fun = InstallTypedArray(#Type "Array", \
1103 native_context()->set_##type##_array_fun(*fun); \
1106 #undef INSTALL_TYPED_ARRAY
1108 Handle<JSFunction> data_view_fun =
1112 isolate->initial_object_prototype(),
1113 Builtins::kIllegal,
true,
true);
1114 native_context()->set_data_view_fun(*data_view_fun);
1119 isolate->initial_object_prototype(),
1120 Builtins::kIllegal,
true,
true);
1125 isolate->initial_object_prototype(),
1126 Builtins::kIllegal,
true,
true);
1133 Handle<String> arguments_string = factory->InternalizeOneByteString(
1135 Handle<Code> code = Handle<Code>(
1136 isolate->builtins()->builtin(Builtins::kIllegal));
1137 Handle<JSObject> prototype =
1139 JSObject::cast(native_context()->object_function()->prototype()));
1141 Handle<JSFunction>
function =
1142 factory->NewFunctionWithPrototype(arguments_string,
1148 ASSERT(!function->has_initial_map());
1149 function->shared()->set_instance_class_name(*arguments_string);
1150 function->shared()->set_expected_nof_properties(2);
1151 Handle<JSObject> result = factory->NewJSObject(
function);
1153 native_context()->set_sloppy_arguments_boilerplate(*result);
1158 result, factory->length_string(),
1163 result, factory->callee_string(),
1168 LookupResult lookup(isolate);
1169 result->LocalLookup(heap->callee_string(), &lookup);
1170 ASSERT(lookup.IsField());
1173 result->LocalLookup(heap->length_string(), &lookup);
1174 ASSERT(lookup.IsField());
1181 ASSERT(result->HasFastProperties());
1182 ASSERT(result->HasFastObjectElements());
1188 Handle<FixedArray> elements = factory->NewFixedArray(2);
1189 elements->set_map(heap->sloppy_arguments_elements_map());
1190 Handle<FixedArray> array;
1191 array = factory->NewFixedArray(0);
1192 elements->set(0, *array);
1193 array = factory->NewFixedArray(0);
1194 elements->set(1, *array);
1196 Handle<Map> old_map(
1197 native_context()->sloppy_arguments_boilerplate()->
map());
1198 Handle<Map> new_map = factory->CopyMap(old_map);
1199 new_map->set_pre_allocated_property_fields(2);
1200 Handle<JSObject> result = factory->NewJSObjectFromMap(new_map);
1204 result->set_elements(*elements);
1205 ASSERT(result->HasSloppyArgumentsElements());
1206 native_context()->set_aliased_arguments_boilerplate(*result);
1210 const PropertyAttributes attributes =
1214 Handle<AccessorPair> callee = factory->NewAccessorPair();
1215 Handle<AccessorPair> caller = factory->NewAccessorPair();
1217 Handle<JSFunction> throw_function =
1218 GetThrowTypeErrorFunction();
1221 callee->set_getter(*throw_function);
1222 callee->set_setter(*throw_function);
1223 caller->set_getter(*throw_function);
1224 caller->set_setter(*throw_function);
1230 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(0, 3);
1231 DescriptorArray::WhitenessWitness witness(*descriptors);
1232 map->set_instance_descriptors(*descriptors);
1237 map->AppendDescriptor(&d, witness);
1240 CallbacksDescriptor d(*factory->callee_string(),
1243 map->AppendDescriptor(&d, witness);
1246 CallbacksDescriptor d(*factory->caller_string(),
1249 map->AppendDescriptor(&d, witness);
1252 map->set_function_with_prototype(
true);
1253 map->set_prototype(native_context()->object_function()->prototype());
1254 map->set_pre_allocated_property_fields(1);
1255 map->set_inobject_properties(1);
1258 map->set_constructor(
1259 native_context()->sloppy_arguments_boilerplate()->
map()->constructor());
1262 Handle<JSObject> result = factory->NewJSObjectFromMap(map);
1263 native_context()->set_strict_arguments_boilerplate(*result);
1268 result, factory->length_string(),
1269 factory->undefined_value(),
DONT_ENUM));
1272 LookupResult lookup(isolate);
1273 result->LocalLookup(heap->length_string(), &lookup);
1274 ASSERT(lookup.IsField());
1280 ASSERT(result->HasFastProperties());
1281 ASSERT(result->HasFastObjectElements());
1287 Handle<Code> code = Handle<Code>(
1288 isolate->builtins()->builtin(Builtins::kIllegal));
1289 Handle<JSFunction> context_extension_fun =
1290 factory->NewFunction(factory->empty_string(),
1296 Handle<String> name = factory->InternalizeOneByteString(
1298 context_extension_fun->shared()->set_instance_class_name(*name);
1299 native_context()->set_context_extension_function(*context_extension_fun);
1306 Handle<Code>(isolate->builtins()->builtin(
1307 Builtins::kHandleApiCallAsFunction));
1308 Handle<JSFunction> delegate =
1311 native_context()->set_call_as_function_delegate(*delegate);
1312 delegate->shared()->DontAdaptArguments();
1318 Handle<Code>(isolate->builtins()->builtin(
1319 Builtins::kHandleApiCallAsConstructor));
1320 Handle<JSFunction> delegate =
1323 native_context()->set_call_as_constructor_delegate(*delegate);
1324 delegate->shared()->DontAdaptArguments();
1328 Handle<FixedArray> embedder_data = factory->NewFixedArray(3);
1329 native_context()->set_embedder_data(*embedder_data);
1333 Handle<JSFunction> Genesis::InstallTypedArray(
1335 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object());
1338 Builtins::kIllegal,
false,
true);
1340 Handle<Map> initial_map = isolate()->factory()->NewMap(
1342 result->set_initial_map(*initial_map);
1343 initial_map->set_constructor(*result);
1348 void Genesis::InitializeExperimentalGlobal() {
1349 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object());
1354 if (FLAG_harmony_symbols) {
1356 Handle<JSFunction> symbol_fun =
1358 isolate()->initial_object_prototype(),
1359 Builtins::kIllegal,
true,
true);
1360 native_context()->set_symbol_function(*symbol_fun);
1363 if (FLAG_harmony_collections) {
1366 isolate()->initial_object_prototype(),
1367 Builtins::kIllegal,
true,
true);
1371 isolate()->initial_object_prototype(),
1372 Builtins::kIllegal,
true,
true);
1376 if (FLAG_harmony_generators) {
1378 Handle<JSObject> builtins(native_context()->builtins());
1379 Handle<JSObject> generator_object_prototype =
1380 factory()->NewJSObject(isolate()->object_function(),
TENURED);
1381 Handle<JSFunction> generator_function_prototype =
1382 InstallFunction(builtins,
"GeneratorFunctionPrototype",
1384 generator_object_prototype, Builtins::kIllegal,
1386 InstallFunction(builtins,
"GeneratorFunction",
1388 generator_function_prototype, Builtins::kIllegal,
1393 Handle<Map> function_map(native_context()->sloppy_function_map());
1394 Handle<Map> generator_function_map = factory()->CopyMap(function_map);
1395 generator_function_map->set_prototype(*generator_function_prototype);
1396 native_context()->set_sloppy_generator_function_map(
1397 *generator_function_map);
1399 Handle<Map> strict_mode_function_map(
1400 native_context()->strict_function_map());
1401 Handle<Map> strict_mode_generator_function_map = factory()->CopyMap(
1402 strict_mode_function_map);
1403 strict_mode_generator_function_map->set_prototype(
1404 *generator_function_prototype);
1405 native_context()->set_strict_generator_function_map(
1406 *strict_mode_generator_function_map);
1408 Handle<Map> object_map(native_context()->object_function()->initial_map());
1409 Handle<Map> generator_object_prototype_map = factory()->CopyMap(
1411 generator_object_prototype_map->set_prototype(
1412 *generator_object_prototype);
1413 native_context()->set_generator_object_prototype_map(
1414 *generator_object_prototype_map);
1417 ASSERT(object_map->inobject_properties() == 0);
1419 Handle<Map> generator_result_map = factory()->CopyMap(object_map,
1421 ASSERT(generator_result_map->inobject_properties() ==
1424 Handle<DescriptorArray> descriptors = factory()->NewDescriptorArray(0,
1426 DescriptorArray::WhitenessWitness witness(*descriptors);
1427 generator_result_map->set_instance_descriptors(*descriptors);
1429 Handle<String> value_string = factory()->InternalizeOneByteString(
1431 FieldDescriptor value_descr(*value_string,
1435 generator_result_map->AppendDescriptor(&value_descr, witness);
1437 Handle<String> done_string = factory()->InternalizeOneByteString(
1439 FieldDescriptor done_descr(*done_string,
1443 generator_result_map->AppendDescriptor(&done_descr, witness);
1445 generator_result_map->set_unused_property_fields(0);
1447 generator_result_map->instance_size());
1448 native_context()->set_generator_result_map(*generator_result_map);
1453 bool Genesis::CompileBuiltin(Isolate* isolate,
int index) {
1455 Handle<String> source_code =
1456 isolate->bootstrapper()->NativesSourceLookup(index);
1457 return CompileNative(isolate, name, source_code);
1461 bool Genesis::CompileExperimentalBuiltin(Isolate* isolate,
int index) {
1463 Factory* factory = isolate->factory();
1464 Handle<String> source_code =
1465 factory->NewStringFromAscii(
1468 return CompileNative(isolate, name, source_code);
1472 bool Genesis::CompileNative(Isolate* isolate,
1473 Vector<const char> name,
1474 Handle<String> source) {
1475 HandleScope scope(isolate);
1476 #ifdef ENABLE_DEBUGGER_SUPPORT
1477 isolate->debugger()->set_compiling_natives(
true);
1482 StackLimitCheck
check(isolate);
1483 if (
check.HasOverflowed())
return false;
1485 bool result = CompileScriptCached(isolate,
1490 Handle<Context>(isolate->context()),
1492 ASSERT(isolate->has_pending_exception() != result);
1493 if (!result) isolate->clear_pending_exception();
1494 #ifdef ENABLE_DEBUGGER_SUPPORT
1495 isolate->debugger()->set_compiling_natives(
false);
1501 bool Genesis::CompileScriptCached(Isolate* isolate,
1502 Vector<const char> name,
1503 Handle<String> source,
1504 SourceCodeCache* cache,
1506 Handle<Context> top_context,
1507 bool use_runtime_context) {
1508 Factory* factory = isolate->factory();
1509 HandleScope scope(isolate);
1510 Handle<SharedFunctionInfo> function_info;
1514 if (cache ==
NULL || !cache->Lookup(name, &function_info)) {
1515 ASSERT(source->IsOneByteRepresentation());
1516 Handle<String> script_name = factory->NewStringFromUtf8(name);
1517 ASSERT(!script_name.is_null());
1529 if (function_info.is_null())
return false;
1530 if (cache !=
NULL) cache->Add(name, function_info);
1536 ASSERT(top_context->IsNativeContext());
1537 Handle<Context> context =
1538 Handle<Context>(use_runtime_context
1539 ? Handle<Context>(top_context->runtime_context())
1541 Handle<JSFunction> fun =
1542 factory->NewFunctionFromSharedFunctionInfo(function_info, context);
1546 Handle<Object> receiver =
1547 Handle<Object>(use_runtime_context
1548 ? top_context->builtins()
1549 : top_context->global_object(),
1551 bool has_pending_exception;
1553 if (has_pending_exception)
return false;
1558 #define INSTALL_NATIVE(Type, name, var) \
1559 Handle<String> var##_name = \
1560 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR(name)); \
1561 Object* var##_native = \
1562 native_context()->builtins()->GetPropertyNoExceptionThrown( \
1564 native_context()->set_##var(Type::cast(var##_native));
1567 void Genesis::InstallNativeFunctions() {
1568 HandleScope scope(isolate());
1573 INSTALL_NATIVE(JSFunction,
"ToDetailString", to_detail_string_fun);
1582 configure_instance_fun);
1583 INSTALL_NATIVE(JSFunction,
"GetStackTraceLine", get_stack_trace_line_fun);
1586 to_complete_property_descriptor);
1595 INSTALL_NATIVE(JSFunction,
"NotifyChange", observers_notify_change);
1596 INSTALL_NATIVE(JSFunction,
"EnqueueSpliceRecord", observers_enqueue_splice);
1598 observers_begin_perform_splice);
1600 observers_end_perform_splice);
1604 void Genesis::InstallExperimentalNativeFunctions() {
1607 enqueue_external_microtask);
1609 if (FLAG_harmony_proxies) {
1617 #undef INSTALL_NATIVE
1620 Handle<JSFunction> Genesis::InstallInternalArray(
1621 Handle<JSBuiltinsObject> builtins,
1630 Handle<JSFunction> array_function =
1631 InstallFunction(builtins,
1635 isolate()->initial_object_prototype(),
1636 Builtins::kInternalArrayCode,
1638 Handle<JSObject> prototype =
1639 factory()->NewJSObject(isolate()->object_function(),
TENURED);
1642 InternalArrayConstructorStub internal_array_constructor_stub(isolate());
1643 Handle<Code> code = internal_array_constructor_stub.GetCode(isolate());
1644 array_function->shared()->set_construct_stub(*code);
1645 array_function->shared()->DontAdaptArguments();
1647 Handle<Map> original_map(array_function->initial_map());
1648 Handle<Map> initial_map = factory()->CopyMap(original_map);
1649 initial_map->set_elements_kind(elements_kind);
1650 array_function->set_initial_map(*initial_map);
1653 Handle<DescriptorArray> array_descriptors(
1654 factory()->NewDescriptorArray(0, 1));
1655 DescriptorArray::WhitenessWitness witness(*array_descriptors);
1657 Handle<Foreign> array_length(factory()->NewForeign(
1658 &Accessors::ArrayLength));
1659 PropertyAttributes attribs =
static_cast<PropertyAttributes
>(
1661 initial_map->set_instance_descriptors(*array_descriptors);
1664 CallbacksDescriptor d(
1665 *factory()->length_string(), *array_length, attribs);
1666 array_function->initial_map()->AppendDescriptor(&d, witness);
1669 return array_function;
1673 bool Genesis::InstallNatives() {
1674 HandleScope scope(isolate());
1679 Handle<Code> code = Handle<Code>(
1680 isolate()->builtins()->builtin(Builtins::kIllegal));
1681 Handle<JSFunction> builtins_fun =
1682 factory()->NewFunction(factory()->empty_string(),
1686 Handle<String> name =
1688 builtins_fun->shared()->set_instance_class_name(*name);
1689 builtins_fun->initial_map()->set_dictionary_map(
true);
1690 builtins_fun->initial_map()->set_prototype(heap()->null_value());
1693 Handle<JSBuiltinsObject> builtins =
1695 builtins->set_builtins(*builtins);
1696 builtins->set_native_context(*native_context());
1697 builtins->set_global_context(*native_context());
1698 builtins->set_global_receiver(*builtins);
1699 builtins->set_global_receiver(native_context()->global_proxy());
1706 static const PropertyAttributes attributes =
1708 Handle<String> global_string =
1710 Handle<Object> global_obj(native_context()->global_object(), isolate());
1713 builtins, global_string, global_obj, attributes));
1714 Handle<String> builtins_string =
1718 builtins, builtins_string, builtins, attributes));
1722 set_builtins(*builtins);
1725 Handle<JSFunction> bridge =
1726 factory()->NewFunction(factory()->empty_string(),
1727 factory()->undefined_value());
1728 ASSERT(bridge->context() == *isolate()->native_context());
1731 Handle<Context> context =
1733 context->set_global_object(*builtins);
1735 native_context()->set_runtime_context(*context);
1739 Handle<JSFunction> script_fun =
1741 isolate()->initial_object_prototype(),
1742 Builtins::kIllegal,
false,
false);
1743 Handle<JSObject> prototype =
1744 factory()->NewJSObject(isolate()->object_function(),
TENURED);
1746 native_context()->set_script_function(*script_fun);
1748 Handle<Map> script_map = Handle<Map>(script_fun->initial_map());
1750 Handle<DescriptorArray> script_descriptors(
1751 factory()->NewDescriptorArray(0, 13));
1752 DescriptorArray::WhitenessWitness witness(*script_descriptors);
1754 Handle<Foreign> script_source(
1755 factory()->NewForeign(&Accessors::ScriptSource));
1756 Handle<Foreign> script_name(factory()->NewForeign(&Accessors::ScriptName));
1757 Handle<String> id_string(factory()->InternalizeOneByteString(
1759 Handle<Foreign> script_id(factory()->NewForeign(&Accessors::ScriptId));
1760 Handle<String> line_offset_string(
1761 factory()->InternalizeOneByteString(
1763 Handle<Foreign> script_line_offset(
1764 factory()->NewForeign(&Accessors::ScriptLineOffset));
1765 Handle<String> column_offset_string(
1766 factory()->InternalizeOneByteString(
1768 Handle<Foreign> script_column_offset(
1769 factory()->NewForeign(&Accessors::ScriptColumnOffset));
1770 Handle<String> type_string(factory()->InternalizeOneByteString(
1772 Handle<Foreign> script_type(factory()->NewForeign(&Accessors::ScriptType));
1773 Handle<String> compilation_type_string(
1774 factory()->InternalizeOneByteString(
1776 Handle<Foreign> script_compilation_type(
1777 factory()->NewForeign(&Accessors::ScriptCompilationType));
1778 Handle<String> line_ends_string(factory()->InternalizeOneByteString(
1780 Handle<Foreign> script_line_ends(
1781 factory()->NewForeign(&Accessors::ScriptLineEnds));
1782 Handle<String> context_data_string(
1783 factory()->InternalizeOneByteString(
1785 Handle<Foreign> script_context_data(
1786 factory()->NewForeign(&Accessors::ScriptContextData));
1787 Handle<String> eval_from_script_string(
1788 factory()->InternalizeOneByteString(
1790 Handle<Foreign> script_eval_from_script(
1791 factory()->NewForeign(&Accessors::ScriptEvalFromScript));
1792 Handle<String> eval_from_script_position_string(
1793 factory()->InternalizeOneByteString(
1795 Handle<Foreign> script_eval_from_script_position(
1796 factory()->NewForeign(&Accessors::ScriptEvalFromScriptPosition));
1797 Handle<String> eval_from_function_name_string(
1798 factory()->InternalizeOneByteString(
1800 Handle<Foreign> script_eval_from_function_name(
1801 factory()->NewForeign(&Accessors::ScriptEvalFromFunctionName));
1802 PropertyAttributes attribs =
1804 script_map->set_instance_descriptors(*script_descriptors);
1807 CallbacksDescriptor d(
1808 *factory()->source_string(), *script_source, attribs);
1809 script_map->AppendDescriptor(&d, witness);
1813 CallbacksDescriptor d(*factory()->name_string(), *script_name, attribs);
1814 script_map->AppendDescriptor(&d, witness);
1818 CallbacksDescriptor d(*id_string, *script_id, attribs);
1819 script_map->AppendDescriptor(&d, witness);
1823 CallbacksDescriptor d(*line_offset_string, *script_line_offset, attribs);
1824 script_map->AppendDescriptor(&d, witness);
1828 CallbacksDescriptor d(
1829 *column_offset_string, *script_column_offset, attribs);
1830 script_map->AppendDescriptor(&d, witness);
1834 CallbacksDescriptor d(*type_string, *script_type, attribs);
1835 script_map->AppendDescriptor(&d, witness);
1839 CallbacksDescriptor d(
1840 *compilation_type_string, *script_compilation_type, attribs);
1841 script_map->AppendDescriptor(&d, witness);
1845 CallbacksDescriptor d(*line_ends_string, *script_line_ends, attribs);
1846 script_map->AppendDescriptor(&d, witness);
1850 CallbacksDescriptor d(
1851 *context_data_string, *script_context_data, attribs);
1852 script_map->AppendDescriptor(&d, witness);
1856 CallbacksDescriptor d(
1857 *eval_from_script_string, *script_eval_from_script, attribs);
1858 script_map->AppendDescriptor(&d, witness);
1862 CallbacksDescriptor d(
1863 *eval_from_script_position_string,
1864 *script_eval_from_script_position,
1866 script_map->AppendDescriptor(&d, witness);
1870 CallbacksDescriptor d(
1871 *eval_from_function_name_string,
1872 *script_eval_from_function_name,
1874 script_map->AppendDescriptor(&d, witness);
1878 Handle<Script> script = factory()->NewScript(factory()->empty_string());
1880 heap()->public_set_empty_script(*script);
1886 Handle<JSFunction> opaque_reference_fun =
1889 isolate()->initial_object_prototype(),
1890 Builtins::kIllegal,
false,
false);
1891 Handle<JSObject> prototype =
1892 factory()->NewJSObject(isolate()->object_function(),
TENURED);
1894 native_context()->set_opaque_reference_function(*opaque_reference_fun);
1903 Handle<JSFunction> array_function =
1905 native_context()->set_internal_array_function(*array_function);
1909 InstallInternalArray(builtins,
"InternalPackedArray",
FAST_ELEMENTS);
1912 if (FLAG_disable_native_files) {
1913 PrintF(
"Warning: Running without installed natives!\n");
1921 if (!CompileBuiltin(isolate(), i))
return false;
1925 if (!InstallJSBuiltins(builtins))
return false;
1928 InstallNativeFunctions();
1932 Handle<JSFunction> string_function(native_context()->string_function());
1934 string_function->initial_map()->prototype())->HasFastProperties());
1935 native_context()->set_string_function_prototype_map(
1939 { Handle<String> key = factory()->function_class_string();
1940 Handle<JSFunction>
function =
1942 GetProperty(isolate(), isolate()->global_object(), key));
1943 Handle<JSObject> proto =
1944 Handle<JSObject>(
JSObject::cast(function->instance_prototype()));
1947 Handle<JSFunction> call =
1948 InstallFunction(proto,
"call",
JS_OBJECT_TYPE, JSObject::kHeaderSize,
1949 Handle<JSObject>::null(),
1950 Builtins::kFunctionCall,
1952 Handle<JSFunction> apply =
1953 InstallFunction(proto,
"apply",
JS_OBJECT_TYPE, JSObject::kHeaderSize,
1954 Handle<JSObject>::null(),
1955 Builtins::kFunctionApply,
1961 call->shared()->DontAdaptArguments();
1962 ASSERT(call->is_compiled());
1965 apply->shared()->set_formal_parameter_count(2);
1968 call->shared()->set_length(1);
1969 apply->shared()->set_length(2);
1972 InstallBuiltinFunctionIds();
1980 Handle<JSFunction> array_constructor(native_context()->array_function());
1981 Handle<JSObject> array_prototype(
1985 Handle<Map> initial_map =
1987 initial_map->set_constructor(*array_constructor);
1990 initial_map->set_non_instance_prototype(
false);
1991 initial_map->set_prototype(*array_prototype);
1994 Handle<DescriptorArray> reresult_descriptors =
1995 factory()->NewDescriptorArray(0, 3);
1996 DescriptorArray::WhitenessWitness witness(*reresult_descriptors);
1997 initial_map->set_instance_descriptors(*reresult_descriptors);
2000 JSFunction* array_function = native_context()->array_function();
2001 Handle<DescriptorArray> array_descriptors(
2002 array_function->initial_map()->instance_descriptors());
2003 String* length = heap()->length_string();
2004 int old = array_descriptors->SearchWithCache(
2005 length, array_function->initial_map());
2007 CallbacksDescriptor desc(length,
2008 array_descriptors->GetValue(old),
2009 array_descriptors->GetDetails(old).attributes());
2010 initial_map->AppendDescriptor(&desc, witness);
2013 FieldDescriptor index_field(heap()->index_string(),
2017 initial_map->AppendDescriptor(&index_field, witness);
2021 FieldDescriptor input_field(heap()->input_string(),
2025 initial_map->AppendDescriptor(&input_field, witness);
2028 initial_map->set_inobject_properties(2);
2029 initial_map->set_pre_allocated_property_fields(2);
2030 initial_map->set_unused_property_fields(0);
2032 native_context()->set_regexp_result_map(*initial_map);
2043 #define INSTALL_EXPERIMENTAL_NATIVE(i, flag, file) \
2044 if (FLAG_harmony_##flag && \
2045 strcmp(ExperimentalNatives::GetScriptName(i).start(), \
2046 "native " file) == 0) { \
2047 if (!CompileExperimentalBuiltin(isolate(), i)) return false; \
2051 bool Genesis::InstallExperimentalNatives() {
2065 InstallExperimentalNativeFunctions();
2066 InstallExperimentalBuiltinFunctionIds();
2071 static Handle<JSObject> ResolveBuiltinIdHolder(
2072 Handle<Context> native_context,
2073 const char* holder_expr) {
2074 Isolate* isolate = native_context->GetIsolate();
2075 Factory* factory = isolate->factory();
2076 Handle<GlobalObject> global(native_context->global_object());
2077 const char* period_pos = strchr(holder_expr,
'.');
2078 if (period_pos ==
NULL) {
2080 isolate, global, factory->InternalizeUtf8String(holder_expr)));
2083 Vector<const char> property(holder_expr,
2084 static_cast<int>(period_pos - holder_expr));
2085 Handle<String> property_string = factory->InternalizeUtf8String(property);
2086 ASSERT(!property_string.is_null());
2093 static void InstallBuiltinFunctionId(Handle<JSObject> holder,
2094 const char* function_name,
2096 Factory* factory = holder->GetIsolate()->factory();
2097 Handle<String> name = factory->InternalizeUtf8String(function_name);
2098 Object* function_object = holder->GetProperty(*name)->ToObjectUnchecked();
2100 function->shared()->set_function_data(
Smi::FromInt(
id));
2104 void Genesis::InstallBuiltinFunctionIds() {
2105 HandleScope scope(isolate());
2106 #define INSTALL_BUILTIN_ID(holder_expr, fun_name, name) \
2108 Handle<JSObject> holder = ResolveBuiltinIdHolder( \
2109 native_context(), #holder_expr); \
2110 BuiltinFunctionId id = k##name; \
2111 InstallBuiltinFunctionId(holder, #fun_name, id); \
2114 #undef INSTALL_BUILTIN_ID
2118 void Genesis::InstallExperimentalBuiltinFunctionIds() {
2119 HandleScope scope(isolate());
2120 if (FLAG_harmony_maths) {
2121 Handle<JSObject> holder = ResolveBuiltinIdHolder(native_context(),
"Math");
2122 InstallBuiltinFunctionId(holder,
"clz32",
kMathClz32);
2129 #define JSFUNCTION_RESULT_CACHE_LIST(F) \
2130 F(16, native_context()->regexp_function())
2133 static FixedArray* CreateCache(
int size, Handle<JSFunction> factory_function) {
2138 JSFunctionResultCache* cache =
reinterpret_cast<JSFunctionResultCache*
>(
2139 *factory->NewFixedArrayWithHoles(array_size,
TENURED));
2141 cache->MakeZeroSize();
2146 void Genesis::InstallJSFunctionResultCaches() {
2147 const int kNumberOfCaches = 0 +
2148 #define F(size, func) + 1
2153 Handle<FixedArray> caches =
2154 factory()->NewFixedArray(kNumberOfCaches,
TENURED);
2158 #define F(size, func) do { \
2159 FixedArray* cache = CreateCache((size), Handle<JSFunction>(func)); \
2160 caches->set(index++, cache); \
2167 native_context()->set_jsfunction_result_caches(*caches);
2171 void Genesis::InitializeNormalizedMapCaches() {
2172 Handle<FixedArray> array(
2181 SaveContext saved_context(isolate_);
2183 return Genesis::InstallExtensions(native_context, extensions) &&
2184 Genesis::InstallSpecialObjects(native_context);
2195 if (FLAG_expose_natives_as !=
NULL && strlen(FLAG_expose_natives_as) != 0) {
2204 if (Error->IsJSObject()) {
2214 #ifdef ENABLE_DEBUGGER_SUPPORT
2216 if (FLAG_expose_debug_as !=
NULL && strlen(FLAG_expose_debug_as) != 0) {
2217 Debug* debug = isolate->debug();
2220 if (!debug->Load())
return true;
2224 debug->debug_context()->set_security_token(
2225 native_context->security_token());
2227 Handle<String> debug_string =
2229 Handle<Object> global_proxy(
2230 debug->debug_context()->global_proxy(), isolate);
2232 global, debug_string, global_proxy,
DONT_ENUM);
2240 static uint32_t Hash(RegisteredExtension* extension) {
2245 static bool MatchRegisteredExtensions(
void* key1,
void* key2) {
2246 return key1 == key2;
2249 Genesis::ExtensionStates::ExtensionStates()
2250 : map_(MatchRegisteredExtensions, 8) { }
2252 Genesis::ExtensionTraversalState Genesis::ExtensionStates::get_state(
2253 RegisteredExtension* extension) {
2254 i::HashMap::Entry* entry = map_.Lookup(extension, Hash(extension),
false);
2255 if (entry ==
NULL) {
2258 return static_cast<ExtensionTraversalState
>(
2259 reinterpret_cast<intptr_t
>(entry->value));
2262 void Genesis::ExtensionStates::set_state(RegisteredExtension* extension,
2263 ExtensionTraversalState state) {
2264 map_.Lookup(extension, Hash(extension),
true)->value =
2265 reinterpret_cast<void*
>(
static_cast<intptr_t
>(state));
2269 bool Genesis::InstallExtensions(Handle<Context> native_context,
2271 Isolate* isolate = native_context->GetIsolate();
2272 ExtensionStates extension_states;
2273 return InstallAutoExtensions(isolate, &extension_states) &&
2274 (!FLAG_expose_free_buffer ||
2275 InstallExtension(isolate,
"v8/free-buffer", &extension_states)) &&
2277 InstallExtension(isolate,
"v8/gc", &extension_states)) &&
2278 (!FLAG_expose_externalize_string ||
2279 InstallExtension(isolate,
"v8/externalize", &extension_states)) &&
2280 (!FLAG_track_gc_object_stats ||
2281 InstallExtension(isolate,
"v8/statistics", &extension_states)) &&
2282 (!FLAG_expose_trigger_failure ||
2283 InstallExtension(isolate,
"v8/trigger-failure", &extension_states)) &&
2284 InstallRequestedExtensions(isolate, extensions, &extension_states);
2288 bool Genesis::InstallAutoExtensions(Isolate* isolate,
2289 ExtensionStates* extension_states) {
2293 if (it->extension()->auto_enable() &&
2294 !InstallExtension(isolate, it, extension_states)) {
2302 bool Genesis::InstallRequestedExtensions(Isolate* isolate,
2304 ExtensionStates* extension_states) {
2305 for (
const char** it = extensions->
begin(); it != extensions->
end(); ++it) {
2306 if (!InstallExtension(isolate, *it, extension_states))
return false;
2314 bool Genesis::InstallExtension(Isolate* isolate,
2316 ExtensionStates* extension_states) {
2320 if (strcmp(name, it->extension()->name()) == 0) {
2321 return InstallExtension(isolate, it, extension_states);
2325 "v8::Context::New()",
2326 "Cannot find required extension");
2330 bool Genesis::InstallExtension(Isolate* isolate,
2332 ExtensionStates* extension_states) {
2333 HandleScope scope(isolate);
2335 if (extension_states->get_state(current) == INSTALLED)
return true;
2339 "v8::Context::New()",
2340 "Circular extension dependency")) {
2343 ASSERT(extension_states->get_state(current) == UNVISITED);
2344 extension_states->set_state(current, VISITED);
2348 if (!InstallExtension(isolate,
2350 extension_states)) {
2354 Handle<String> source_code =
2355 isolate->factory()->NewExternalStringFromAscii(extension->
source());
2358 bool result = CompileScriptCached(isolate,
2361 isolate->bootstrapper()->extensions_cache(),
2363 Handle<Context>(isolate->context()),
2365 ASSERT(isolate->has_pending_exception() != result);
2373 isolate->clear_pending_exception();
2375 extension_states->set_state(current, INSTALLED);
2376 isolate->NotifyExtensionInstalled();
2381 bool Genesis::InstallJSBuiltins(Handle<JSBuiltinsObject> builtins) {
2382 HandleScope scope(isolate());
2385 Handle<String> name =
2387 Object* function_object = builtins->GetPropertyNoExceptionThrown(*name);
2388 Handle<JSFunction>
function
2390 builtins->set_javascript_builtin(
id, *
function);
2394 builtins->set_javascript_builtin_code(
id, function->shared()->code());
2400 bool Genesis::ConfigureGlobalObjects(
2402 Handle<JSObject> global_proxy(
2404 Handle<JSObject> inner_global(
2407 if (!global_proxy_template.
IsEmpty()) {
2409 Handle<ObjectTemplateInfo> proxy_data =
2411 if (!ConfigureApiObject(global_proxy, proxy_data))
return false;
2414 Handle<FunctionTemplateInfo> proxy_constructor(
2416 if (!proxy_constructor->prototype_template()->IsUndefined()) {
2417 Handle<ObjectTemplateInfo> inner_data(
2419 if (!ConfigureApiObject(inner_global, inner_data))
return false;
2423 SetObjectPrototype(global_proxy, inner_global);
2425 native_context()->set_initial_array_prototype(
2426 JSArray::cast(native_context()->array_function()->prototype()));
2432 bool Genesis::ConfigureApiObject(Handle<JSObject>
object,
2433 Handle<ObjectTemplateInfo> object_template) {
2434 ASSERT(!object_template.is_null());
2436 ->IsTemplateFor(object->map()));;
2438 bool pending_exception =
false;
2439 Handle<JSObject>
obj =
2441 if (pending_exception) {
2442 ASSERT(isolate()->has_pending_exception());
2443 isolate()->clear_pending_exception();
2446 TransferObject(obj,
object);
2451 void Genesis::TransferNamedProperties(Handle<JSObject> from,
2452 Handle<JSObject> to) {
2453 if (from->HasFastProperties()) {
2454 Handle<DescriptorArray> descs =
2455 Handle<DescriptorArray>(from->map()->instance_descriptors());
2456 for (
int i = 0; i < from->map()->NumberOfOwnDescriptors(); i++) {
2457 PropertyDetails details = descs->GetDetails(i);
2458 switch (details.type()) {
2460 HandleScope inner(isolate());
2461 Handle<Name> key = Handle<Name>(descs->GetKey(i));
2462 int index = descs->GetFieldIndex(i);
2463 ASSERT(!descs->GetDetails(i).representation().IsDouble());
2464 Handle<Object> value = Handle<Object>(from->RawFastPropertyAt(index),
2468 to, key, value, details.attributes()));
2472 HandleScope inner(isolate());
2473 Handle<Name> key = Handle<Name>(descs->GetKey(i));
2474 Handle<Object> constant(descs->GetConstant(i), isolate());
2477 to, key, constant, details.attributes()));
2481 LookupResult result(isolate());
2482 to->LocalLookup(descs->GetKey(i), &result);
2484 if (result.IsFound())
continue;
2485 HandleScope inner(isolate());
2486 ASSERT(!to->HasFastProperties());
2488 Handle<Name> key = Handle<Name>(descs->GetKey(i));
2489 Handle<Object> callbacks(descs->GetCallbacksObject(i), isolate());
2490 PropertyDetails d = PropertyDetails(
2491 details.attributes(),
CALLBACKS, i + 1);
2507 Handle<NameDictionary> properties =
2508 Handle<NameDictionary>(from->property_dictionary());
2509 int capacity = properties->Capacity();
2510 for (
int i = 0; i < capacity; i++) {
2511 Object* raw_key(properties->KeyAt(i));
2512 if (properties->IsKey(raw_key)) {
2513 ASSERT(raw_key->IsName());
2515 LookupResult result(isolate());
2516 to->LocalLookup(
Name::cast(raw_key), &result);
2517 if (result.IsFound())
continue;
2519 Handle<Name> key = Handle<Name>(
Name::cast(raw_key));
2520 Handle<Object> value = Handle<Object>(properties->ValueAt(i),
2522 ASSERT(!value->IsCell());
2523 if (value->IsPropertyCell()) {
2527 PropertyDetails details = properties->DetailsAt(i);
2530 to, key, value, details.attributes()));
2537 void Genesis::TransferIndexedProperties(Handle<JSObject> from,
2538 Handle<JSObject> to) {
2540 Handle<FixedArray> from_elements =
2542 Handle<FixedArray> to_elements = factory()->
CopyFixedArray(from_elements);
2543 to->set_elements(*to_elements);
2547 void Genesis::TransferObject(Handle<JSObject> from, Handle<JSObject> to) {
2548 HandleScope outer(isolate());
2550 ASSERT(!from->IsJSArray());
2551 ASSERT(!to->IsJSArray());
2553 TransferNamedProperties(from, to);
2554 TransferIndexedProperties(from, to);
2557 Handle<Map> old_to_map = Handle<Map>(to->map());
2558 Handle<Map> new_to_map = factory()->
CopyMap(old_to_map);
2559 new_to_map->set_prototype(from->map()->prototype());
2560 to->set_map(*new_to_map);
2564 void Genesis::MakeFunctionInstancePrototypeWritable() {
2568 ASSERT(!sloppy_function_map_writable_prototype_.is_null());
2569 ASSERT(!strict_function_map_writable_prototype_.is_null());
2572 native_context()->set_sloppy_function_map(
2573 *sloppy_function_map_writable_prototype_);
2574 native_context()->set_strict_function_map(
2575 *strict_function_map_writable_prototype_);
2585 FLAG_track_double_fields =
false;
2590 FLAG_track_double_fields = flag_;
2599 Genesis::Genesis(
Isolate* isolate,
2603 : isolate_(isolate),
2604 active_(isolate->bootstrapper()) {
2612 SaveContext saved_context(isolate);
2617 StackLimitCheck
check(isolate);
2618 if (
check.HasOverflowed())
return;
2622 if (isolate->initialized_from_snapshot()) {
2625 native_context_ = Handle<Context>();
2628 if (!native_context().is_null()) {
2629 AddToWeakNativeContextList(*native_context());
2630 isolate->set_context(*native_context());
2631 isolate->counters()->contexts_created_by_snapshot()->Increment();
2632 Handle<GlobalObject> inner_global;
2633 Handle<JSGlobalProxy> global_proxy =
2634 CreateNewGlobals(global_template,
2638 HookUpGlobalProxy(inner_global, global_proxy);
2639 HookUpInnerGlobal(inner_global);
2640 native_context()->builtins()->set_global_receiver(
2641 native_context()->global_proxy());
2643 if (!ConfigureGlobalObjects(global_template))
return;
2647 Handle<JSFunction> empty_function = CreateEmptyFunction(isolate);
2648 CreateStrictModeFunctionMaps(empty_function);
2649 Handle<GlobalObject> inner_global;
2650 Handle<JSGlobalProxy> global_proxy =
2651 CreateNewGlobals(global_template, global_object, &inner_global);
2652 HookUpGlobalProxy(inner_global, global_proxy);
2653 InitializeGlobal(inner_global, empty_function);
2654 InstallJSFunctionResultCaches();
2655 InitializeNormalizedMapCaches();
2656 if (!InstallNatives())
return;
2658 MakeFunctionInstancePrototypeWritable();
2660 if (!ConfigureGlobalObjects(global_template))
return;
2661 isolate->counters()->contexts_created_from_scratch()->Increment();
2665 InitializeExperimentalGlobal();
2666 if (!InstallExperimentalNatives())
return;
2674 const int num_elems = 2;
2675 const int num_bytes = num_elems *
sizeof(uint32_t);
2676 uint32_t* state =
reinterpret_cast<uint32_t*
>(malloc(num_bytes));
2679 isolate->random_number_generator()->NextBytes(state, num_bytes);
2680 }
while (state[0] == 0 || state[1] == 0);
2683 reinterpret_cast<v8::Isolate*>(isolate), state, num_bytes);
2686 Handle<JSBuiltinsObject> builtins(native_context()->builtins());
2688 factory()->InternalizeOneByteString(
2696 reinterpret_cast<v8::Isolate*>(isolate),
2699 reinterpret_cast<v8::Isolate*>(isolate),
2707 factory()->InternalizeOneByteString(
2712 factory()->InternalizeOneByteString(
2717 factory()->InternalizeOneByteString(
2719 factory()->NewHeapNumber(
2723 factory()->InternalizeOneByteString(
2725 factory()->NewHeapNumber(
2730 result_ = native_context();
2738 return sizeof(NestingCounterType);
2744 *
reinterpret_cast<NestingCounterType*
>(to) = nesting_;
2746 return to +
sizeof(NestingCounterType);
2752 nesting_ = *
reinterpret_cast<NestingCounterType*
>(from);
2753 return from +
sizeof(NestingCounterType);
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter NULL
#define CHECK_NOT_EMPTY_HANDLE(isolate, call)
static bool Initialize(Deserializer *des)
Code * builtin(Name name)
#define INSTALL_TYPED_ARRAY(Type, type, TYPE, ctype, size)
char * ArchiveState(char *to)
Handle< String > NewExternalStringFromAscii(const ExternalAsciiString::Resource *resource)
static const int kResultPropertyCount
static const int kEntries
static Handle< SharedFunctionInfo > CompileScript(Handle< String > source, Handle< Object > script_name, int line_offset, int column_offset, bool is_shared_cross_origin, Handle< Context > context, v8::Extension *extension, ScriptDataImpl **cached_data, CachedDataMode cached_data_mode, NativesFlag is_natives_code)
static void * sin_table()
static const int kGlobalFieldIndex
Handle< Object > CacheInitialJSArrayMaps(Handle< Context > native_context, Handle< Map > initial_map)
void PrintF(const char *format,...)
void Initialize(bool create_heap_objects)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf map
static const int kResultValuePropertyIndex
char * AllocateAutoDeletedArray(int bytes)
Handle< Context > result()
static Smi * FromInt(int value)
void V8_EXPORT RegisterExtension(Extension *extension)
static ObjectTemplateInfo * cast(Object *obj)
const char ** begin() const
static Vector< const char > GetRawScriptSource(int index)
static void SetInstancePrototype(Handle< JSFunction > function, Handle< Object > value)
static HeapObject * cast(Object *obj)
static Handle< T > cast(Handle< S > that)
static const int kSourceFieldIndex
static Vector< const char > GetScriptName(int index)
enable upcoming ES6 features enable harmony block scoping enable harmony symbols(a.k.a.private names)") DEFINE_bool(harmony_proxies
static AccessorPair * cast(Object *obj)
static int GetDebuggerCount()
kSerializedDataOffset Object
static bool EnsureCompiled(Handle< JSFunction > function, ClearExceptionFlag flag)
#define ASSERT(condition)
static Handle< Object > SetLocalPropertyIgnoreAttributes(Handle< JSObject > object, Handle< Name > key, Handle< Object > value, PropertyAttributes attributes, ValueType value_type=OPTIMAL_REPRESENTATION, StoreMode mode=ALLOW_AS_CONSTANT, ExtensibilityCheck extensibility_check=PERFORM_EXTENSIBILITY_CHECK)
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 void * cos_x_interval_table()
bool InstallExtensions(Handle< Context > native_context, v8::ExtensionConfiguration *extensions)
static const char * GetName(JavaScript id)
static Context * cast(Object *context)
static Handle< Object > FunctionSetPrototype(Handle< JSFunction > object, Handle< Object > value)
Handle< Context > CreateEnvironment(Handle< Object > global_object, v8::Handle< v8::ObjectTemplate > global_template, v8::ExtensionConfiguration *extensions)
Handle< Object > GetProperty(Handle< JSReceiver > obj, const char *name)
static double samples_over_pi_half()
#define INSTALL_EXPERIMENTAL_NATIVE(i, flag, file)
#define RETURN_IF_EMPTY_HANDLE_VALUE(isolate, call, value)
v8::Isolate * GetIsolate()
static const int kMultilineFieldIndex
void FreeThreadResources()
GlobalObject * global_object()
static int GetBuiltinsCount()
friend class NativesExternalStringResource
uint32_t ComputePointerHash(void *ptr)
static const int kResultSize
Handle< Map > CopyMap(Handle< Map > map, int extra_inobject_props)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object size
static JSGlobalProxy * cast(Object *obj)
Handle< JSFunction > NewFunctionWithoutPrototype(Handle< String > name, StrictMode strict_mode)
static const int kFactoryIndex
STATIC_ASSERT(sizeof(CPURegister)==sizeof(Register))
static const int kInputIndex
#define INSTALL_BUILTIN_ID(holder_expr, fun_name, name)
friend class BootstrapperActive
~NoTrackDoubleFieldsForSerializerScope()
static Handle< Context > NewContextFromSnapshot(Isolate *isolate)
void set_context(Context *context)
void check(i::Vector< const uint8_t > string)
static int table_num_bytes()
const char * name() const
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra code(assertions) for debugging") DEFINE_bool(code_comments
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
static FunctionTemplateInfo * cast(Object *obj)
static Local< ArrayBuffer > New(Isolate *isolate, size_t byte_length)
Handle< String > NativesSourceLookup(int index)
static int NumberOfJavaScriptBuiltins()
static Local< Float64Array > New(Handle< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
bool has_pending_exception()
static const int kIgnoreCaseFieldIndex
static PropertyCell * cast(Object *obj)
NoTrackDoubleFieldsForSerializerScope()
#define STATIC_ASCII_VECTOR(x)
static v8::internal::Handle< To > OpenHandle(v8::Local< From > handle)
Handle< FixedArray > CopyFixedArray(Handle< FixedArray > array)
Vector< const char > CStrVector(const char *data)
static JSArray * cast(Object *obj)
static const int kSizeWithInternalFields
void Iterate(ObjectVisitor *v)
Isolate * isolate() const
static Local< Uint32Array > New(Handle< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
#define INSTALL_NATIVE(Type, name, var)
static const int kSizeWithInternalFields
Handle< String > InternalizeOneByteString(Vector< const uint8_t > str)
static Handle< Object > Call(Isolate *isolate, Handle< Object > callable, Handle< Object > receiver, int argc, Handle< Object > argv[], bool *pending_exception, bool convert_receiver=false)
#define JSFUNCTION_RESULT_CACHE_LIST(F)
static const int kResultDonePropertyIndex
V8_INLINE bool IsEmpty() const
static void SetNormalizedProperty(Handle< JSObject > object, const LookupResult *result, Handle< Object > value)
static void InitializeOncePerProcess()
static const int kArgumentsLengthIndex
void DetachGlobal(Handle< Context > env)
const String::ExternalAsciiStringResource * source() const
static RegisteredExtension * first_extension()
ElementsKind GetInitialFastElementsKind()
static const int kEntriesIndex
Handle< String > InternalizeUtf8String(Vector< const char > str)
static const int kSizeWithInternalFields
static void PrintError(const char *format,...)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable memory(in Mbytes)") DEFINE_bool(gc_global
Handle< JSGlobalProxy > ReinitializeJSGlobalProxy(Handle< JSFunction > constructor, Handle< JSGlobalProxy > global)
static Handle< T > null()
TemplateHashMapImpl< FreeStoreAllocationPolicy > HashMap
Handle< Foreign > NewForeign(Address addr, PretenureFlag pretenure=NOT_TENURED)
#define ASSERT_EQ(v1, v2)
static const int kIndexIndex
static Handle< JSObject > InstantiateObject(Handle< ObjectTemplateInfo > data, bool *exc)
static const int kArgumentsCalleeIndex
static FixedArray * cast(Object *obj)
static const int kHeaderSize
static Handle< Object > PreventExtensions(Handle< JSObject > object)
void Add(const T &element, AllocationPolicy allocator=AllocationPolicy())
static bool ApiCheck(bool condition, const char *location, const char *message)
static VisitorId GetVisitorId(int instance_type, int instance_size)
Handle< Object > ForceSetProperty(Handle< JSObject > object, Handle< Object > key, Handle< Object > value, PropertyAttributes attributes)
static Name * cast(Object *obj)
static NormalizedMapCache * cast(Object *obj)
const char ** end() const
static Representation Tagged()
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()
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in name
static const int kNotFound
static int ArchiveSpacePerThread()
static JSObject * cast(Object *obj)
static const int kStrictArgumentsObjectSize
Handle< T > CloseAndEscape(Handle< T > handle_value)
static void TearDownExtensions()
static JSGlobalObject * cast(Object *obj)
static JSFunction * cast(Object *obj)