17 #include "third_party/fdlibm/fdlibm.h"
22 NativesExternalStringResource::NativesExternalStringResource(
23 Bootstrapper* bootstrapper,
26 : data_(source), length_(length) {
27 if (bootstrapper->delete_these_non_arrays_on_tear_down_ ==
NULL) {
28 bootstrapper->delete_these_non_arrays_on_tear_down_ =
new List<char*>(2);
32 bootstrapper->delete_these_non_arrays_on_tear_down_->
33 Add(
reinterpret_cast<char*
>(
this));
37 Bootstrapper::Bootstrapper(Isolate* isolate)
40 extensions_cache_(Script::TYPE_EXTENSION),
41 delete_these_non_arrays_on_tear_down_(
NULL),
42 delete_these_arrays_on_tear_down_(
NULL) {
46 Handle<String> Bootstrapper::NativesSourceLookup(
int index) {
47 DCHECK(0 <= index && index < Natives::GetBuiltinsCount());
48 Heap* heap = isolate_->heap();
49 if (heap->natives_source_cache()->get(index)->IsUndefined()) {
51 Vector<const char> source = Natives::GetRawScriptSource(index);
52 NativesExternalStringResource* resource =
53 new NativesExternalStringResource(
this,
57 Handle<String> source_code = isolate_->factory()
58 ->NewExternalStringFromOneByte(resource)
60 heap->natives_source_cache()->set(index, *source_code);
62 Handle<Object> cached_source(heap->natives_source_cache()->get(index),
64 return Handle<String>::cast(cached_source);
68 void Bootstrapper::Initialize(
bool create_heap_objects) {
69 extensions_cache_.Initialize(isolate_, create_heap_objects);
74 bool flag_given = FLAG_expose_gc_as !=
NULL && strlen(FLAG_expose_gc_as) != 0;
75 return flag_given ? FLAG_expose_gc_as :
"gc";
86 void Bootstrapper::InitializeOncePerProcess() {
87 free_buffer_extension_ =
new FreeBufferExtension;
91 externalize_string_extension_ =
new ExternalizeStringExtension;
93 statistics_extension_ =
new StatisticsExtension;
95 trigger_failure_extension_ =
new TriggerFailureExtension;
100 void Bootstrapper::TearDownExtensions() {
101 delete free_buffer_extension_;
102 free_buffer_extension_ =
NULL;
103 delete gc_extension_;
104 gc_extension_ =
NULL;
105 delete externalize_string_extension_;
106 externalize_string_extension_ =
NULL;
107 delete statistics_extension_;
108 statistics_extension_ =
NULL;
109 delete trigger_failure_extension_;
110 trigger_failure_extension_ =
NULL;
114 char* Bootstrapper::AllocateAutoDeletedArray(
int bytes) {
115 char* memory =
new char[bytes];
116 if (memory !=
NULL) {
117 if (delete_these_arrays_on_tear_down_ ==
NULL) {
118 delete_these_arrays_on_tear_down_ =
new List<char*>(2);
120 delete_these_arrays_on_tear_down_->Add(memory);
126 void Bootstrapper::TearDown() {
127 if (delete_these_non_arrays_on_tear_down_ !=
NULL) {
128 int len = delete_these_non_arrays_on_tear_down_->length();
130 for (
int i = 0;
i < len;
i++) {
131 delete delete_these_non_arrays_on_tear_down_->at(
i);
132 delete_these_non_arrays_on_tear_down_->at(
i) =
NULL;
134 delete delete_these_non_arrays_on_tear_down_;
135 delete_these_non_arrays_on_tear_down_ =
NULL;
138 if (delete_these_arrays_on_tear_down_ !=
NULL) {
139 int len = delete_these_arrays_on_tear_down_->length();
141 for (
int i = 0;
i < len;
i++) {
142 delete[] delete_these_arrays_on_tear_down_->at(
i);
143 delete_these_arrays_on_tear_down_->at(
i) =
NULL;
145 delete delete_these_arrays_on_tear_down_;
146 delete_these_arrays_on_tear_down_ =
NULL;
149 extensions_cache_.Initialize(isolate_,
false);
162 Factory*
factory()
const {
return isolate_->factory(); }
280 return (function_mode == FUNCTION_WITH_WRITEABLE_PROTOTYPE ||
281 function_mode == FUNCTION_WITH_READONLY_PROTOTYPE);
305 SourceCodeCache* cache,
308 bool use_runtime_context);
324 friend class Bootstrapper;
329 extensions_cache_.Iterate(v);
330 v->Synchronize(VisitorSynchronization::kExtensions);
335 MaybeHandle<JSGlobalProxy> maybe_global_proxy,
340 isolate_, maybe_global_proxy, global_proxy_template, extensions);
342 if (env.is_null() || !InstallExtensions(env, extensions)) {
345 return scope.CloseAndEscape(env);
353 new_map->set_prototype(*proto);
354 JSObject::MigrateToMap(
object, new_map);
359 Factory* factory = env->GetIsolate()->factory();
361 global_proxy->set_native_context(*factory->null_value());
363 global_proxy->map()->set_constructor(*factory->null_value());
373 Isolate* isolate = target->GetIsolate();
374 Factory* factory = isolate->
factory();
379 ? factory->NewFunction(internalized_name, call_code, prototype,
381 : factory->NewFunctionWithoutPrototype(internalized_name, call_code);
383 if (target->IsJSBuiltinsObject()) {
389 JSObject::AddProperty(target, internalized_name,
function, attributes);
390 if (target->IsJSGlobalObject()) {
391 function->shared()->set_instance_class_name(*internalized_name);
393 function->shared()->set_native(
true);
398 void Genesis::SetFunctionInstanceDescriptor(
400 int size = IsFunctionModeWithPrototype(function_mode) ? 5 : 4;
401 Map::EnsureDescriptorSlack(
map,
size);
407 Accessors::FunctionLengthInfo(isolate(), attribs);
409 CallbacksDescriptor d(
Handle<Name>(Name::cast(length->name())),
411 map->AppendDescriptor(&d);
413 Handle<AccessorInfo>
name =
414 Accessors::FunctionNameInfo(isolate(), attribs);
416 CallbacksDescriptor d(Handle<Name>(Name::cast(
name->name())),
418 map->AppendDescriptor(&d);
420 Handle<AccessorInfo> args =
421 Accessors::FunctionArgumentsInfo(isolate(), attribs);
423 CallbacksDescriptor d(Handle<Name>(Name::cast(args->name())),
425 map->AppendDescriptor(&d);
427 Handle<AccessorInfo> caller =
428 Accessors::FunctionCallerInfo(isolate(), attribs);
430 CallbacksDescriptor d(Handle<Name>(Name::cast(caller->name())),
432 map->AppendDescriptor(&d);
434 if (IsFunctionModeWithPrototype(function_mode)) {
435 if (function_mode == FUNCTION_WITH_WRITEABLE_PROTOTYPE) {
438 Handle<AccessorInfo> prototype =
439 Accessors::FunctionPrototypeInfo(isolate(), attribs);
440 CallbacksDescriptor d(Handle<Name>(Name::cast(prototype->name())),
442 map->AppendDescriptor(&d);
447 Handle<Map> Genesis::CreateFunctionMap(FunctionMode function_mode) {
449 SetFunctionInstanceDescriptor(
map, function_mode);
450 map->set_function_with_prototype(IsFunctionModeWithPrototype(function_mode));
455 Handle<JSFunction> Genesis::CreateEmptyFunction(Isolate* isolate) {
461 Handle<Map> function_without_prototype_map =
462 CreateFunctionMap(FUNCTION_WITHOUT_PROTOTYPE);
463 native_context()->set_sloppy_function_without_prototype_map(
464 *function_without_prototype_map);
469 Handle<Map> function_map =
470 CreateFunctionMap(FUNCTION_WITH_READONLY_PROTOTYPE);
471 native_context()->set_sloppy_function_map(*function_map);
472 native_context()->set_sloppy_function_with_readonly_prototype_map(
477 sloppy_function_map_writable_prototype_ =
478 CreateFunctionMap(FUNCTION_WITH_WRITEABLE_PROTOTYPE);
480 Factory* factory = isolate->factory();
482 Handle<String> object_name = factory->Object_string();
485 Handle<JSFunction> object_fun = factory->NewFunction(object_name);
486 int unused = JSObject::kInitialGlobalObjectUnusedPropertiesCount;
487 int instance_size = JSObject::kHeaderSize +
kPointerSize * unused;
488 Handle<Map> object_function_map =
490 object_function_map->set_inobject_properties(unused);
491 JSFunction::SetInitialMap(object_fun, object_function_map,
492 isolate->factory()->null_value());
493 object_function_map->set_unused_property_fields(unused);
495 native_context()->set_object_function(*object_fun);
498 Handle<JSObject> prototype = factory->NewJSObject(
499 isolate->object_function(),
501 Handle<Map>
map = Map::Copy(
handle(prototype->map()));
502 map->set_is_prototype_map(
true);
503 prototype->set_map(*
map);
505 native_context()->set_initial_object_prototype(*prototype);
509 native_context()->set_initial_array_prototype(*prototype);
510 Accessors::FunctionSetPrototype(object_fun, prototype);
515 Handle<String> empty_string =
517 Handle<Code> code(isolate->builtins()->builtin(Builtins::kEmptyFunction));
518 Handle<JSFunction> empty_function = factory->NewFunctionWithoutPrototype(
522 Handle<Map> empty_function_map =
523 CreateFunctionMap(FUNCTION_WITHOUT_PROTOTYPE);
524 DCHECK(!empty_function_map->is_dictionary_map());
525 empty_function_map->set_prototype(
526 native_context()->object_function()->prototype());
527 empty_function_map->set_is_prototype_map(
true);
528 empty_function->set_map(*empty_function_map);
531 Handle<String> source = factory->NewStringFromStaticChars(
"() {}");
532 Handle<Script> script = factory->NewScript(source);
533 script->set_type(Smi::FromInt(Script::TYPE_NATIVE));
534 empty_function->shared()->set_script(*script);
535 empty_function->shared()->set_start_position(0);
536 empty_function->shared()->set_end_position(source->length());
537 empty_function->shared()->DontAdaptArguments();
540 native_context()->sloppy_function_map()->set_prototype(*empty_function);
541 native_context()->sloppy_function_without_prototype_map()->
542 set_prototype(*empty_function);
543 sloppy_function_map_writable_prototype_->set_prototype(*empty_function);
544 return empty_function;
548 void Genesis::SetStrictFunctionInstanceDescriptor(
549 Handle<Map>
map, FunctionMode function_mode) {
550 int size = IsFunctionModeWithPrototype(function_mode) ? 5 : 4;
551 Map::EnsureDescriptorSlack(
map,
size);
553 Handle<AccessorPair> arguments(factory()->NewAccessorPair());
554 Handle<AccessorPair> caller(factory()->NewAccessorPair());
561 if (function_mode == BOUND_FUNCTION) {
562 Handle<String> length_string = isolate()->factory()->length_string();
563 FieldDescriptor d(length_string, 0, ro_attribs, Representation::Tagged());
564 map->AppendDescriptor(&d);
566 DCHECK(function_mode == FUNCTION_WITH_WRITEABLE_PROTOTYPE ||
567 function_mode == FUNCTION_WITH_READONLY_PROTOTYPE ||
568 function_mode == FUNCTION_WITHOUT_PROTOTYPE);
569 Handle<AccessorInfo> length =
570 Accessors::FunctionLengthInfo(isolate(), ro_attribs);
571 CallbacksDescriptor d(Handle<Name>(Name::cast(length->name())),
573 map->AppendDescriptor(&d);
575 Handle<AccessorInfo>
name =
576 Accessors::FunctionNameInfo(isolate(), ro_attribs);
578 CallbacksDescriptor d(Handle<Name>(Name::cast(
name->name())),
580 map->AppendDescriptor(&d);
583 CallbacksDescriptor d(factory()->arguments_string(), arguments,
585 map->AppendDescriptor(&d);
588 CallbacksDescriptor d(factory()->caller_string(), caller, rw_attribs);
589 map->AppendDescriptor(&d);
591 if (IsFunctionModeWithPrototype(function_mode)) {
594 function_mode == FUNCTION_WITH_WRITEABLE_PROTOTYPE ? rw_attribs
596 Handle<AccessorInfo> prototype =
597 Accessors::FunctionPrototypeInfo(isolate(), attribs);
598 CallbacksDescriptor d(Handle<Name>(Name::cast(prototype->name())),
600 map->AppendDescriptor(&d);
606 Handle<JSFunction> Genesis::GetStrictPoisonFunction() {
607 if (strict_poison_function.is_null()) {
608 Handle<String>
name = factory()->InternalizeOneByteString(
610 Handle<Code> code(isolate()->builtins()->builtin(
611 Builtins::kStrictModePoisonPill));
612 strict_poison_function = factory()->NewFunctionWithoutPrototype(
name, code);
613 strict_poison_function->set_map(native_context()->sloppy_function_map());
614 strict_poison_function->shared()->DontAdaptArguments();
616 JSObject::PreventExtensions(strict_poison_function).Assert();
618 return strict_poison_function;
622 Handle<JSFunction> Genesis::GetGeneratorPoisonFunction() {
623 if (generator_poison_function.is_null()) {
624 Handle<String>
name = factory()->InternalizeOneByteString(
626 Handle<Code> code(isolate()->builtins()->builtin(
627 Builtins::kGeneratorPoisonPill));
628 generator_poison_function = factory()->NewFunctionWithoutPrototype(
630 generator_poison_function->set_map(native_context()->sloppy_function_map());
631 generator_poison_function->shared()->DontAdaptArguments();
633 JSObject::PreventExtensions(generator_poison_function).Assert();
635 return generator_poison_function;
639 Handle<Map> Genesis::CreateStrictFunctionMap(
640 FunctionMode function_mode,
641 Handle<JSFunction> empty_function) {
643 SetStrictFunctionInstanceDescriptor(
map, function_mode);
644 map->set_function_with_prototype(IsFunctionModeWithPrototype(function_mode));
645 map->set_prototype(*empty_function);
650 void Genesis::CreateStrictModeFunctionMaps(Handle<JSFunction> empty) {
652 Handle<Map> strict_function_without_prototype_map =
653 CreateStrictFunctionMap(FUNCTION_WITHOUT_PROTOTYPE, empty);
654 native_context()->set_strict_function_without_prototype_map(
655 *strict_function_without_prototype_map);
660 Handle<Map> strict_function_map =
661 CreateStrictFunctionMap(FUNCTION_WITH_READONLY_PROTOTYPE, empty);
662 native_context()->set_strict_function_map(*strict_function_map);
666 strict_function_map_writable_prototype_ =
667 CreateStrictFunctionMap(FUNCTION_WITH_WRITEABLE_PROTOTYPE, empty);
669 Handle<Map> bound_function_map =
670 CreateStrictFunctionMap(BOUND_FUNCTION, empty);
671 native_context()->set_bound_function_map(*bound_function_map);
674 PoisonArgumentsAndCaller(strict_function_without_prototype_map);
675 PoisonArgumentsAndCaller(strict_function_map);
676 PoisonArgumentsAndCaller(strict_function_map_writable_prototype_);
677 PoisonArgumentsAndCaller(bound_function_map);
685 int number = descs->SearchWithCache(*
name, *
map);
687 accessors->set_getter(*func);
688 accessors->set_setter(*func);
697 int idx = descriptors->SearchWithCache(*
name, *
map);
698 CallbacksDescriptor descriptor(
name, accessor_pair, attributes);
699 descriptors->
Replace(idx, &descriptor);
704 SetAccessors(
map, factory()->arguments_string(), GetStrictPoisonFunction());
705 SetAccessors(
map, factory()->caller_string(), GetStrictPoisonFunction());
714 DCHECK(context->
get(Context::NEXT_CONTEXT_LINK)->IsUndefined());
717 !current->IsUndefined();
718 current = Context::cast(current)->get(Context::NEXT_CONTEXT_LINK)) {
719 DCHECK(current != context);
728 void Genesis::CreateRoots() {
733 native_context_ = factory()->NewNativeContext();
735 isolate()->set_context(*native_context());
740 native_context()->set_message_listeners(*listeners.value());
745 Handle<JSGlobalProxy> Genesis::CreateNewGlobals(
747 MaybeHandle<JSGlobalProxy> maybe_global_proxy,
748 Handle<GlobalObject>* global_object_out) {
763 Handle<JSFunction> js_global_object_function;
764 Handle<ObjectTemplateInfo> js_global_object_template;
765 if (!global_proxy_template.
IsEmpty()) {
767 Handle<ObjectTemplateInfo> data =
769 Handle<FunctionTemplateInfo> global_constructor =
770 Handle<FunctionTemplateInfo>(
771 FunctionTemplateInfo::cast(data->constructor()));
772 Handle<Object> proto_template(global_constructor->prototype_template(),
774 if (!proto_template->IsUndefined()) {
775 js_global_object_template =
776 Handle<ObjectTemplateInfo>::cast(proto_template);
780 if (js_global_object_template.is_null()) {
781 Handle<String>
name = Handle<String>(heap()->empty_string());
782 Handle<Code> code = Handle<Code>(isolate()->builtins()->builtin(
783 Builtins::kIllegal));
784 Handle<JSObject> prototype =
785 factory()->NewFunctionPrototype(isolate()->object_function());
786 js_global_object_function = factory()->NewFunction(
789 LookupIterator it(prototype, factory()->constructor_string(),
790 LookupIterator::OWN_SKIP_INTERCEPTOR);
791 Handle<Object> value = JSReceiver::GetProperty(&it).ToHandleChecked();
793 DCHECK_EQ(*isolate()->object_function(), *value);
796 Handle<FunctionTemplateInfo> js_global_object_constructor(
797 FunctionTemplateInfo::cast(js_global_object_template->constructor()));
798 js_global_object_function =
799 factory()->CreateApiFunction(js_global_object_constructor,
800 factory()->the_hole_value(),
801 factory()->GlobalObjectType);
804 js_global_object_function->initial_map()->set_is_hidden_prototype();
805 js_global_object_function->initial_map()->set_dictionary_map(
true);
806 Handle<GlobalObject> global_object =
807 factory()->NewGlobalObject(js_global_object_function);
808 if (global_object_out !=
NULL) {
809 *global_object_out = global_object;
813 Handle<JSFunction> global_proxy_function;
814 if (global_proxy_template.
IsEmpty()) {
815 Handle<String>
name = Handle<String>(heap()->empty_string());
816 Handle<Code> code = Handle<Code>(isolate()->builtins()->builtin(
817 Builtins::kIllegal));
818 global_proxy_function = factory()->NewFunction(
821 Handle<ObjectTemplateInfo> data =
823 Handle<FunctionTemplateInfo> global_constructor(
824 FunctionTemplateInfo::cast(data->constructor()));
825 global_proxy_function =
826 factory()->CreateApiFunction(global_constructor,
827 factory()->the_hole_value(),
828 factory()->GlobalProxyType);
831 Handle<String> global_name = factory()->global_string();
832 global_proxy_function->shared()->set_instance_class_name(*global_name);
833 global_proxy_function->initial_map()->set_is_access_check_needed(
true);
838 Handle<JSGlobalProxy> global_proxy;
839 if (maybe_global_proxy.ToHandle(&global_proxy)) {
840 factory()->ReinitializeJSGlobalProxy(global_proxy, global_proxy_function);
842 global_proxy = Handle<JSGlobalProxy>::cast(
843 factory()->NewJSObject(global_proxy_function,
TENURED));
844 global_proxy->set_hash(heap()->undefined_value());
850 void Genesis::HookUpGlobalProxy(Handle<GlobalObject> global_object,
851 Handle<JSGlobalProxy> global_proxy) {
853 global_object->set_native_context(*native_context());
854 global_object->set_global_context(*native_context());
855 global_object->set_global_proxy(*global_proxy);
856 global_proxy->set_native_context(*native_context());
857 native_context()->set_global_proxy(*global_proxy);
861 void Genesis::HookUpGlobalObject(Handle<GlobalObject> global_object) {
862 Handle<GlobalObject> global_object_from_snapshot(
863 GlobalObject::cast(native_context()->extension()));
864 Handle<JSBuiltinsObject> builtins_global(native_context()->builtins());
865 native_context()->set_extension(*global_object);
866 native_context()->set_global_object(*global_object);
867 native_context()->set_security_token(*global_object);
870 Runtime::DefineObjectProperty(builtins_global, factory()->global_string(),
871 global_object, attributes).Assert();
873 JSGlobalObject::cast(*global_object)->set_builtins(*builtins_global);
874 TransferNamedProperties(global_object_from_snapshot, global_object);
875 TransferIndexedProperties(global_object_from_snapshot, global_object);
881 void Genesis::InitializeGlobal(Handle<GlobalObject> global_object,
882 Handle<JSFunction> empty_function) {
885 native_context()->set_closure(*empty_function);
886 native_context()->set_previous(
NULL);
888 native_context()->set_extension(*global_object);
889 native_context()->set_global_object(*global_object);
893 native_context()->set_security_token(*global_object);
895 Isolate* isolate = global_object->GetIsolate();
896 Factory* factory = isolate->factory();
897 Heap* heap = isolate->heap();
899 Handle<String> object_name = factory->Object_string();
900 JSObject::AddProperty(
901 global_object, object_name, isolate->object_function(),
DONT_ENUM);
903 Handle<JSObject> global(native_context()->global_object());
907 empty_function, Builtins::kIllegal);
910 Handle<JSFunction> array_function =
912 isolate->initial_object_prototype(),
914 array_function->shared()->DontAdaptArguments();
915 array_function->shared()->set_function_data(Smi::FromInt(
kArrayCode));
919 array_function->shared()->set_length(1);
921 Handle<Map> initial_map(array_function->initial_map());
926 Map::EnsureDescriptorSlack(initial_map, 1);
931 Handle<AccessorInfo> array_length =
932 Accessors::ArrayLengthInfo(isolate, attribs);
934 CallbacksDescriptor d(
935 Handle<Name>(Name::cast(array_length->name())),
936 array_length, attribs);
937 array_function->initial_map()->AppendDescriptor(&d);
944 native_context()->set_array_function(*array_function);
948 ArrayConstructorStub array_constructor_stub(isolate);
949 Handle<Code> code = array_constructor_stub.GetCode();
950 array_function->shared()->set_construct_stub(*code);
954 Handle<JSFunction> number_fun =
956 isolate->initial_object_prototype(),
958 native_context()->set_number_function(*number_fun);
962 Handle<JSFunction> boolean_fun =
964 isolate->initial_object_prototype(),
966 native_context()->set_boolean_function(*boolean_fun);
970 Handle<JSFunction> string_fun =
972 isolate->initial_object_prototype(),
974 string_fun->shared()->set_construct_stub(
975 isolate->builtins()->builtin(Builtins::kStringConstructCode));
976 native_context()->set_string_function(*string_fun);
978 Handle<Map> string_map =
979 Handle<Map>(native_context()->string_function()->initial_map());
980 Map::EnsureDescriptorSlack(string_map, 1);
984 Handle<AccessorInfo> string_length(
985 Accessors::StringLengthInfo(isolate, attribs));
988 CallbacksDescriptor d(factory->length_string(), string_length, attribs);
989 string_map->AppendDescriptor(&d);
997 isolate->initial_object_prototype(), Builtins::kIllegal);
998 native_context()->set_symbol_function(*symbol_fun);
1003 Handle<JSFunction> date_fun =
1005 isolate->initial_object_prototype(),
1006 Builtins::kIllegal);
1008 native_context()->set_date_function(*date_fun);
1014 Handle<JSFunction> regexp_fun =
1016 isolate->initial_object_prototype(),
1017 Builtins::kIllegal);
1018 native_context()->set_regexp_function(*regexp_fun);
1020 DCHECK(regexp_fun->has_initial_map());
1021 Handle<Map> initial_map(regexp_fun->initial_map());
1023 DCHECK_EQ(0, initial_map->inobject_properties());
1027 Map::EnsureDescriptorSlack(initial_map, 5);
1031 FieldDescriptor field(factory->source_string(),
1032 JSRegExp::kSourceFieldIndex,
1034 Representation::Tagged());
1035 initial_map->AppendDescriptor(&field);
1039 FieldDescriptor field(factory->global_string(),
1040 JSRegExp::kGlobalFieldIndex,
1042 Representation::Tagged());
1043 initial_map->AppendDescriptor(&field);
1047 FieldDescriptor field(factory->ignore_case_string(),
1048 JSRegExp::kIgnoreCaseFieldIndex,
1050 Representation::Tagged());
1051 initial_map->AppendDescriptor(&field);
1055 FieldDescriptor field(factory->multiline_string(),
1056 JSRegExp::kMultilineFieldIndex,
1058 Representation::Tagged());
1059 initial_map->AppendDescriptor(&field);
1065 FieldDescriptor field(factory->last_index_string(),
1066 JSRegExp::kLastIndexFieldIndex,
1068 Representation::Tagged());
1069 initial_map->AppendDescriptor(&field);
1072 initial_map->set_inobject_properties(5);
1073 initial_map->set_pre_allocated_property_fields(5);
1074 initial_map->set_unused_property_fields(0);
1075 initial_map->set_instance_size(
1077 initial_map->set_visitor_id(StaticVisitorBase::GetVisitorId(*initial_map));
1080 Handle<Map> proto_map = Map::Copy(initial_map);
1081 proto_map->set_prototype(native_context()->initial_object_prototype());
1082 Handle<JSObject> proto = factory->NewJSObjectFromMap(proto_map);
1083 proto->InObjectPropertyAtPut(JSRegExp::kSourceFieldIndex,
1084 heap->query_colon_string());
1085 proto->InObjectPropertyAtPut(JSRegExp::kGlobalFieldIndex,
1086 heap->false_value());
1087 proto->InObjectPropertyAtPut(JSRegExp::kIgnoreCaseFieldIndex,
1088 heap->false_value());
1089 proto->InObjectPropertyAtPut(JSRegExp::kMultilineFieldIndex,
1090 heap->false_value());
1091 proto->InObjectPropertyAtPut(JSRegExp::kLastIndexFieldIndex,
1094 proto_map->set_is_prototype_map(
true);
1095 initial_map->set_prototype(*proto);
1096 factory->SetRegExpIrregexpData(Handle<JSRegExp>::cast(proto),
1097 JSRegExp::IRREGEXP, factory->empty_string(),
1098 JSRegExp::Flags(0), 0);
1102 Handle<String>
name = factory->InternalizeUtf8String(
"JSON");
1103 Handle<JSFunction> cons = factory->NewFunction(
name);
1104 JSFunction::SetInstancePrototype(cons,
1105 Handle<Object>(native_context()->initial_object_prototype(), isolate));
1106 cons->SetInstanceClassName(*
name);
1107 Handle<JSObject> json_object = factory->NewJSObject(cons,
TENURED);
1108 DCHECK(json_object->IsJSObject());
1109 JSObject::AddProperty(global,
name, json_object,
DONT_ENUM);
1110 native_context()->set_json_object(*json_object);
1114 Handle<JSFunction> array_buffer_fun =
1117 JSArrayBuffer::kSizeWithInternalFields,
1118 isolate->initial_object_prototype(),
1119 Builtins::kIllegal);
1120 native_context()->set_array_buffer_fun(*array_buffer_fun);
1124 #define INSTALL_TYPED_ARRAY(Type, type, TYPE, ctype, size) \
1126 Handle<JSFunction> fun; \
1127 Handle<Map> external_map; \
1128 InstallTypedArray(#Type "Array", \
1132 native_context()->set_##type##_array_fun(*fun); \
1133 native_context()->set_##type##_array_external_map(*external_map); \
1136 #undef INSTALL_TYPED_ARRAY
1138 Handle<JSFunction> data_view_fun =
1141 JSDataView::kSizeWithInternalFields,
1142 isolate->initial_object_prototype(),
1143 Builtins::kIllegal);
1144 native_context()->set_data_view_fun(*data_view_fun);
1149 isolate->initial_object_prototype(), Builtins::kIllegal);
1153 isolate->initial_object_prototype(), Builtins::kIllegal);
1156 STATIC_ASSERT(JSGeneratorObject::kResultPropertyCount == 2);
1157 Handle<JSFunction> object_function(native_context()->object_function());
1158 Handle<Map> iterator_result_map =
1159 Map::Create(isolate, JSGeneratorObject::kResultPropertyCount);
1160 DCHECK_EQ(JSGeneratorObject::kResultSize,
1161 iterator_result_map->instance_size());
1162 DCHECK_EQ(JSGeneratorObject::kResultPropertyCount,
1163 iterator_result_map->inobject_properties());
1164 Map::EnsureDescriptorSlack(iterator_result_map,
1165 JSGeneratorObject::kResultPropertyCount);
1167 FieldDescriptor value_descr(factory->value_string(),
1168 JSGeneratorObject::kResultValuePropertyIndex,
1169 NONE, Representation::Tagged());
1170 iterator_result_map->AppendDescriptor(&value_descr);
1172 FieldDescriptor done_descr(factory->done_string(),
1173 JSGeneratorObject::kResultDonePropertyIndex,
1174 NONE, Representation::Tagged());
1175 iterator_result_map->AppendDescriptor(&done_descr);
1177 iterator_result_map->set_unused_property_fields(0);
1178 iterator_result_map->set_pre_allocated_property_fields(
1179 JSGeneratorObject::kResultPropertyCount);
1180 DCHECK_EQ(JSGeneratorObject::kResultSize,
1181 iterator_result_map->instance_size());
1182 native_context()->set_iterator_result_map(*iterator_result_map);
1187 isolate->initial_object_prototype(), Builtins::kIllegal);
1190 isolate->initial_object_prototype(), Builtins::kIllegal);
1196 Handle<String> arguments_string = factory->Arguments_string();
1197 Handle<Code> code(isolate->builtins()->builtin(Builtins::kIllegal));
1198 Handle<JSFunction>
function = factory->NewFunctionWithoutPrototype(
1199 arguments_string, code);
1200 function->shared()->set_instance_class_name(*arguments_string);
1203 factory->NewMap(
JS_OBJECT_TYPE, Heap::kSloppyArgumentsObjectSize);
1205 Map::EnsureDescriptorSlack(
map, 2);
1208 FieldDescriptor d(factory->length_string(), Heap::kArgumentsLengthIndex,
1210 map->AppendDescriptor(&d);
1213 FieldDescriptor d(factory->callee_string(), Heap::kArgumentsCalleeIndex,
1215 map->AppendDescriptor(&d);
1219 map->set_function_with_prototype(
true);
1220 map->set_pre_allocated_property_fields(2);
1221 map->set_inobject_properties(2);
1222 native_context()->set_sloppy_arguments_map(*
map);
1224 DCHECK(!function->has_initial_map());
1225 JSFunction::SetInitialMap(
function,
map,
1226 isolate->initial_object_prototype());
1228 DCHECK(
map->inobject_properties() > Heap::kArgumentsCalleeIndex);
1229 DCHECK(
map->inobject_properties() > Heap::kArgumentsLengthIndex);
1235 Handle<Map>
map = Map::Copy(isolate->sloppy_arguments_map());
1238 native_context()->set_aliased_arguments_map(*
map);
1246 Handle<AccessorPair> callee = factory->NewAccessorPair();
1247 Handle<AccessorPair> caller = factory->NewAccessorPair();
1249 Handle<JSFunction> poison = GetStrictPoisonFunction();
1252 callee->set_getter(*poison);
1253 callee->set_setter(*poison);
1254 caller->set_getter(*poison);
1255 caller->set_setter(*poison);
1259 Heap::kStrictArgumentsObjectSize);
1261 Map::EnsureDescriptorSlack(
map, 3);
1264 FieldDescriptor d(factory->length_string(), Heap::kArgumentsLengthIndex,
1266 map->AppendDescriptor(&d);
1269 CallbacksDescriptor d(factory->callee_string(), callee, attributes);
1270 map->AppendDescriptor(&d);
1273 CallbacksDescriptor d(factory->caller_string(), caller, attributes);
1274 map->AppendDescriptor(&d);
1278 map->set_function_with_prototype(
true);
1279 map->set_prototype(native_context()->object_function()->prototype());
1280 map->set_pre_allocated_property_fields(1);
1281 map->set_inobject_properties(1);
1284 map->set_constructor(
1285 native_context()->sloppy_arguments_map()->constructor());
1287 native_context()->set_strict_arguments_map(*
map);
1289 DCHECK(
map->inobject_properties() > Heap::kArgumentsLengthIndex);
1296 Handle<Code> code = Handle<Code>(
1297 isolate->builtins()->builtin(Builtins::kIllegal));
1298 Handle<JSFunction> context_extension_fun = factory->NewFunction(
1300 JSObject::kHeaderSize);
1302 Handle<String>
name = factory->InternalizeOneByteString(
1304 context_extension_fun->shared()->set_instance_class_name(*
name);
1305 native_context()->set_context_extension_function(*context_extension_fun);
1312 Handle<Code>(isolate->builtins()->builtin(
1313 Builtins::kHandleApiCallAsFunction));
1314 Handle<JSFunction> delegate = factory->NewFunction(
1315 factory->empty_string(), code,
JS_OBJECT_TYPE, JSObject::kHeaderSize);
1316 native_context()->set_call_as_function_delegate(*delegate);
1317 delegate->shared()->DontAdaptArguments();
1323 Handle<Code>(isolate->builtins()->builtin(
1324 Builtins::kHandleApiCallAsConstructor));
1325 Handle<JSFunction> delegate = factory->NewFunction(
1326 factory->empty_string(), code,
JS_OBJECT_TYPE, JSObject::kHeaderSize);
1327 native_context()->set_call_as_constructor_delegate(*delegate);
1328 delegate->shared()->DontAdaptArguments();
1332 Handle<FixedArray> embedder_data = factory->NewFixedArray(3);
1333 native_context()->set_embedder_data(*embedder_data);
1337 void Genesis::InstallTypedArray(
1340 Handle<JSFunction>* fun,
1341 Handle<Map>* external_map) {
1342 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object());
1345 isolate()->initial_object_prototype(), Builtins::kIllegal);
1347 Handle<Map> initial_map = isolate()->factory()->NewMap(
1349 JSTypedArray::kSizeWithInternalFields,
1351 JSFunction::SetInitialMap(result, initial_map,
1352 handle(initial_map->prototype(), isolate()));
1356 *external_map = Map::AsElementsKind(initial_map, external_kind);
1360 void Genesis::InitializeExperimentalGlobal() {
1363 Handle<JSObject> builtins(native_context()->builtins());
1365 Handle<HeapObject>
flag(
1366 FLAG_harmony_regexps ? heap()->true_value() : heap()->false_value());
1369 Runtime::DefineObjectProperty(builtins, factory()->harmony_regexps_string(),
1370 flag, attributes).Assert();
1374 bool Genesis::CompileBuiltin(Isolate* isolate,
int index) {
1375 Vector<const char>
name = Natives::GetScriptName(index);
1376 Handle<String> source_code =
1377 isolate->bootstrapper()->NativesSourceLookup(index);
1378 return CompileNative(isolate,
name, source_code);
1382 bool Genesis::CompileExperimentalBuiltin(Isolate* isolate,
int index) {
1383 Vector<const char>
name = ExperimentalNatives::GetScriptName(index);
1384 Factory* factory = isolate->factory();
1385 Handle<String> source_code;
1387 isolate, source_code, factory->NewStringFromAscii(
1388 ExperimentalNatives::GetRawScriptSource(index)),
1390 return CompileNative(isolate,
name, source_code);
1394 bool Genesis::CompileNative(Isolate* isolate,
1395 Vector<const char>
name,
1396 Handle<String> source) {
1397 HandleScope scope(isolate);
1398 SuppressDebug compiling_natives(isolate->debug());
1402 StackLimitCheck check(isolate);
1403 if (check.HasOverflowed())
return false;
1405 bool result = CompileScriptCached(isolate,
1410 Handle<Context>(isolate->context()),
1412 DCHECK(isolate->has_pending_exception() != result);
1413 if (!result) isolate->clear_pending_exception();
1418 bool Genesis::CompileScriptCached(Isolate* isolate,
1419 Vector<const char>
name,
1420 Handle<String> source,
1421 SourceCodeCache* cache,
1423 Handle<Context> top_context,
1424 bool use_runtime_context) {
1425 Factory* factory = isolate->factory();
1426 HandleScope scope(isolate);
1427 Handle<SharedFunctionInfo> function_info;
1431 if (cache ==
NULL || !cache->Lookup(
name, &function_info)) {
1432 DCHECK(source->IsOneByteRepresentation());
1433 Handle<String> script_name =
1434 factory->NewStringFromUtf8(
name).ToHandleChecked();
1435 function_info = Compiler::CompileScript(
1436 source, script_name, 0, 0,
false, top_context, extension,
NULL,
1437 ScriptCompiler::kNoCompileOptions,
1439 if (function_info.is_null())
return false;
1440 if (cache !=
NULL) cache->Add(
name, function_info);
1446 DCHECK(top_context->IsNativeContext());
1447 Handle<Context> context =
1448 Handle<Context>(use_runtime_context
1449 ? Handle<Context>(top_context->runtime_context())
1451 Handle<JSFunction> fun =
1452 factory->NewFunctionFromSharedFunctionInfo(function_info, context);
1456 Handle<Object> receiver =
1457 Handle<Object>(use_runtime_context
1458 ? top_context->builtins()
1459 : top_context->global_object(),
1461 return !Execution::Call(
1462 isolate, fun, receiver, 0,
NULL).is_null();
1467 const char* holder_expr) {
1468 Isolate* isolate = native_context->GetIsolate();
1469 Factory* factory = isolate->
factory();
1471 const char* period_pos = strchr(holder_expr,
'.');
1472 if (period_pos ==
NULL) {
1474 Object::GetPropertyOrElement(
1475 global, factory->InternalizeUtf8String(holder_expr))
1476 .ToHandleChecked());
1478 const char* inner = period_pos + 1;
1481 static_cast<int>(period_pos - holder_expr));
1482 Handle<String> property_string = factory->InternalizeUtf8String(property);
1485 Object::GetProperty(global, property_string).ToHandleChecked());
1486 if (strcmp(
"prototype", inner) == 0) {
1490 Handle<String> inner_string = factory->InternalizeUtf8String(inner);
1493 Object::GetProperty(
object, inner_string).ToHandleChecked();
1498 #define INSTALL_NATIVE(Type, name, var) \
1499 Handle<String> var##_name = \
1500 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR(name)); \
1501 Handle<Object> var##_native = \
1502 Object::GetProperty(handle(native_context()->builtins()), var##_name) \
1503 .ToHandleChecked(); \
1504 native_context()->set_##var(Type::cast(*var##_native));
1506 #define INSTALL_NATIVE_MATH(name) \
1508 Handle<Object> fun = \
1509 ResolveBuiltinIdHolder(native_context(), "Math." #name); \
1510 native_context()->set_math_##name##_fun(JSFunction::cast(*fun)); \
1513 void Genesis::InstallNativeFunctions() {
1514 HandleScope scope(isolate());
1519 INSTALL_NATIVE(JSFunction,
"ToDetailString", to_detail_string_fun);
1528 configure_instance_fun);
1529 INSTALL_NATIVE(JSFunction,
"GetStackTraceLine", get_stack_trace_line_fun);
1532 to_complete_property_descriptor);
1542 INSTALL_NATIVE(JSFunction,
"NotifyChange", observers_notify_change);
1543 INSTALL_NATIVE(JSFunction,
"EnqueueSpliceRecord", observers_enqueue_splice);
1545 observers_begin_perform_splice);
1547 observers_end_perform_splice);
1549 native_object_observe);
1551 native_object_get_notifier);
1553 native_object_notifier_perform_change);
1557 INSTALL_NATIVE(JSFunction,
"ArrayValues", array_values_iterator);
1581 void Genesis::InstallExperimentalNativeFunctions() {
1582 if (FLAG_harmony_proxies) {
1590 #undef INSTALL_NATIVE
1593 Handle<JSFunction> Genesis::InstallInternalArray(
1594 Handle<JSBuiltinsObject> builtins,
1603 Handle<JSObject> prototype =
1604 factory()->NewJSObject(isolate()->object_function(),
TENURED);
1607 prototype, Builtins::kInternalArrayCode);
1609 InternalArrayConstructorStub internal_array_constructor_stub(isolate());
1610 Handle<Code> code = internal_array_constructor_stub.GetCode();
1611 array_function->shared()->set_construct_stub(*code);
1612 array_function->shared()->DontAdaptArguments();
1614 Handle<Map> original_map(array_function->initial_map());
1615 Handle<Map> initial_map = Map::Copy(original_map);
1616 initial_map->set_elements_kind(elements_kind);
1617 JSFunction::SetInitialMap(array_function, initial_map, prototype);
1620 Map::EnsureDescriptorSlack(initial_map, 1);
1625 Handle<AccessorInfo> array_length =
1626 Accessors::ArrayLengthInfo(isolate(), attribs);
1628 CallbacksDescriptor d(
1629 Handle<Name>(Name::cast(array_length->name())), array_length, attribs);
1630 array_function->initial_map()->AppendDescriptor(&d);
1633 return array_function;
1637 bool Genesis::InstallNatives() {
1638 HandleScope scope(isolate());
1643 Handle<Code> code = Handle<Code>(
1644 isolate()->builtins()->builtin(Builtins::kIllegal));
1645 Handle<JSFunction> builtins_fun = factory()->NewFunction(
1647 JSBuiltinsObject::kSize);
1649 Handle<String>
name =
1651 builtins_fun->shared()->set_instance_class_name(*
name);
1652 builtins_fun->initial_map()->set_dictionary_map(
true);
1653 builtins_fun->initial_map()->set_prototype(heap()->null_value());
1656 Handle<JSBuiltinsObject> builtins =
1657 Handle<JSBuiltinsObject>::cast(factory()->NewGlobalObject(builtins_fun));
1658 builtins->set_builtins(*builtins);
1659 builtins->set_native_context(*native_context());
1660 builtins->set_global_context(*native_context());
1661 builtins->set_global_proxy(native_context()->global_proxy());
1670 Handle<String> global_string =
1672 Handle<Object> global_obj(native_context()->global_object(), isolate());
1673 JSObject::AddProperty(builtins, global_string, global_obj, attributes);
1674 Handle<String> builtins_string =
1676 JSObject::AddProperty(builtins, builtins_string, builtins, attributes);
1679 JSGlobalObject::cast(native_context()->global_object())->
1680 set_builtins(*builtins);
1683 Handle<JSFunction> bridge = factory()->NewFunction(factory()->empty_string());
1684 DCHECK(bridge->context() == *isolate()->native_context());
1687 Handle<Context> context =
1688 factory()->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, bridge);
1689 context->set_global_object(*builtins);
1691 native_context()->set_runtime_context(*context);
1697 isolate()->initial_object_prototype(), Builtins::kIllegal);
1698 Handle<JSObject> prototype =
1699 factory()->NewJSObject(isolate()->object_function(),
TENURED);
1700 Accessors::FunctionSetPrototype(script_fun, prototype);
1701 native_context()->set_script_function(*script_fun);
1703 Handle<Map> script_map = Handle<Map>(script_fun->initial_map());
1704 Map::EnsureDescriptorSlack(script_map, 14);
1709 Handle<AccessorInfo> script_column =
1710 Accessors::ScriptColumnOffsetInfo(isolate(), attribs);
1712 CallbacksDescriptor d(Handle<Name>(Name::cast(script_column->name())),
1713 script_column, attribs);
1714 script_map->AppendDescriptor(&d);
1717 Handle<AccessorInfo> script_id =
1718 Accessors::ScriptIdInfo(isolate(), attribs);
1720 CallbacksDescriptor d(Handle<Name>(Name::cast(script_id->name())),
1721 script_id, attribs);
1722 script_map->AppendDescriptor(&d);
1726 Handle<AccessorInfo> script_name =
1727 Accessors::ScriptNameInfo(isolate(), attribs);
1729 CallbacksDescriptor d(Handle<Name>(Name::cast(script_name->name())),
1730 script_name, attribs);
1731 script_map->AppendDescriptor(&d);
1734 Handle<AccessorInfo> script_line =
1735 Accessors::ScriptLineOffsetInfo(isolate(), attribs);
1737 CallbacksDescriptor d(Handle<Name>(Name::cast(script_line->name())),
1738 script_line, attribs);
1739 script_map->AppendDescriptor(&d);
1742 Handle<AccessorInfo> script_source =
1743 Accessors::ScriptSourceInfo(isolate(), attribs);
1745 CallbacksDescriptor d(Handle<Name>(Name::cast(script_source->name())),
1746 script_source, attribs);
1747 script_map->AppendDescriptor(&d);
1750 Handle<AccessorInfo> script_type =
1751 Accessors::ScriptTypeInfo(isolate(), attribs);
1753 CallbacksDescriptor d(Handle<Name>(Name::cast(script_type->name())),
1754 script_type, attribs);
1755 script_map->AppendDescriptor(&d);
1758 Handle<AccessorInfo> script_compilation_type =
1759 Accessors::ScriptCompilationTypeInfo(isolate(), attribs);
1761 CallbacksDescriptor d(
1762 Handle<Name>(Name::cast(script_compilation_type->name())),
1763 script_compilation_type, attribs);
1764 script_map->AppendDescriptor(&d);
1767 Handle<AccessorInfo> script_line_ends =
1768 Accessors::ScriptLineEndsInfo(isolate(), attribs);
1770 CallbacksDescriptor d(Handle<Name>(Name::cast(script_line_ends->name())),
1771 script_line_ends, attribs);
1772 script_map->AppendDescriptor(&d);
1775 Handle<AccessorInfo> script_context_data =
1776 Accessors::ScriptContextDataInfo(isolate(), attribs);
1778 CallbacksDescriptor d(
1779 Handle<Name>(Name::cast(script_context_data->name())),
1780 script_context_data, attribs);
1781 script_map->AppendDescriptor(&d);
1784 Handle<AccessorInfo> script_eval_from_script =
1785 Accessors::ScriptEvalFromScriptInfo(isolate(), attribs);
1787 CallbacksDescriptor d(
1788 Handle<Name>(Name::cast(script_eval_from_script->name())),
1789 script_eval_from_script, attribs);
1790 script_map->AppendDescriptor(&d);
1793 Handle<AccessorInfo> script_eval_from_script_position =
1794 Accessors::ScriptEvalFromScriptPositionInfo(isolate(), attribs);
1796 CallbacksDescriptor d(
1797 Handle<Name>(Name::cast(script_eval_from_script_position->name())),
1798 script_eval_from_script_position, attribs);
1799 script_map->AppendDescriptor(&d);
1802 Handle<AccessorInfo> script_eval_from_function_name =
1803 Accessors::ScriptEvalFromFunctionNameInfo(isolate(), attribs);
1805 CallbacksDescriptor d(
1806 Handle<Name>(Name::cast(script_eval_from_function_name->name())),
1807 script_eval_from_function_name, attribs);
1808 script_map->AppendDescriptor(&d);
1811 Handle<AccessorInfo> script_source_url =
1812 Accessors::ScriptSourceUrlInfo(isolate(), attribs);
1814 CallbacksDescriptor d(Handle<Name>(Name::cast(script_source_url->name())),
1815 script_source_url, attribs);
1816 script_map->AppendDescriptor(&d);
1819 Handle<AccessorInfo> script_source_mapping_url =
1820 Accessors::ScriptSourceMappingUrlInfo(isolate(), attribs);
1822 CallbacksDescriptor d(
1823 Handle<Name>(Name::cast(script_source_mapping_url->name())),
1824 script_source_mapping_url, attribs);
1825 script_map->AppendDescriptor(&d);
1829 Handle<Script> script = factory()->NewScript(factory()->empty_string());
1830 script->set_type(Smi::FromInt(Script::TYPE_NATIVE));
1831 heap()->public_set_empty_script(*script);
1839 isolate()->initial_object_prototype(), Builtins::kIllegal);
1840 Handle<JSObject> prototype =
1841 factory()->NewJSObject(isolate()->object_function(),
TENURED);
1842 Accessors::FunctionSetPrototype(opaque_reference_fun, prototype);
1843 native_context()->set_opaque_reference_function(*opaque_reference_fun);
1852 Handle<JSFunction> array_function =
1854 native_context()->set_internal_array_function(*array_function);
1858 InstallInternalArray(builtins,
"InternalPackedArray",
FAST_ELEMENTS);
1864 isolate()->initial_object_prototype(), Builtins::kIllegal);
1865 native_context()->set_set_iterator_map(
1866 set_iterator_function->initial_map());
1872 isolate()->initial_object_prototype(), Builtins::kIllegal);
1873 native_context()->set_map_iterator_map(
1874 map_iterator_function->initial_map());
1879 Handle<JSObject> builtins(native_context()->builtins());
1880 Handle<JSObject> generator_object_prototype =
1881 factory()->NewJSObject(isolate()->object_function(),
TENURED);
1882 Handle<JSFunction> generator_function_prototype =
1885 generator_object_prototype, Builtins::kIllegal);
1887 JSFunction::kSize, generator_function_prototype,
1888 Builtins::kIllegal);
1892 Handle<Map> generator_function_map =
1893 Map::Copy(sloppy_function_map_writable_prototype_);
1894 generator_function_map->set_prototype(*generator_function_prototype);
1895 native_context()->set_sloppy_generator_function_map(
1896 *generator_function_map);
1912 Handle<AccessorPair> poison_pair(factory()->NewAccessorPair());
1915 Handle<JSFunction> poison_function = GetGeneratorPoisonFunction();
1916 poison_pair->set_getter(*poison_function);
1917 poison_pair->set_setter(*poison_function);
1919 rw_attribs, poison_pair);
1921 rw_attribs, poison_pair);
1923 Handle<Map> strict_function_map(native_context()->strict_function_map());
1924 Handle<Map> strict_generator_function_map = Map::Copy(strict_function_map);
1926 strict_generator_function_map->set_prototype(*generator_function_prototype);
1927 native_context()->set_strict_generator_function_map(
1928 *strict_generator_function_map);
1930 Handle<JSFunction> object_function(native_context()->object_function());
1931 Handle<Map> generator_object_prototype_map = Map::Create(isolate(), 0);
1932 generator_object_prototype_map->set_prototype(*generator_object_prototype);
1933 native_context()->set_generator_object_prototype_map(
1934 *generator_object_prototype_map);
1937 if (FLAG_disable_native_files) {
1938 PrintF(
"Warning: Running without installed natives!\n");
1943 for (
int i = Natives::GetDebuggerCount();
1944 i < Natives::GetBuiltinsCount();
1946 if (!CompileBuiltin(isolate(),
i))
return false;
1950 if (!InstallJSBuiltins(builtins))
return false;
1953 InstallNativeFunctions();
1957 Handle<JSFunction> string_function(native_context()->string_function());
1959 string_function->initial_map()->prototype())->HasFastProperties());
1960 native_context()->set_string_function_prototype_map(
1961 HeapObject::cast(string_function->initial_map()->prototype())->map());
1965 Handle<String> key = factory()->Function_string();
1966 Handle<JSFunction>
function =
1967 Handle<JSFunction>::cast(Object::GetProperty(
1968 handle(native_context()->global_object()), key).ToHandleChecked());
1969 Handle<JSObject> proto =
1970 Handle<JSObject>(JSObject::cast(function->instance_prototype()));
1973 Handle<JSFunction> call =
1975 MaybeHandle<JSObject>(), Builtins::kFunctionCall);
1976 Handle<JSFunction> apply =
1978 MaybeHandle<JSObject>(), Builtins::kFunctionApply);
1979 if (FLAG_vector_ics) {
1983 factory()->NewTypeFeedbackVector(1);
1990 call->shared()->DontAdaptArguments();
1991 DCHECK(call->is_compiled());
1994 apply->shared()->set_formal_parameter_count(2);
1997 call->shared()->set_length(1);
1998 apply->shared()->set_length(2);
2001 InstallBuiltinFunctionIds();
2009 Handle<JSFunction> array_constructor(native_context()->array_function());
2010 Handle<JSObject> array_prototype(
2011 JSObject::cast(array_constructor->instance_prototype()));
2014 Handle<Map> initial_map =
2016 initial_map->set_constructor(*array_constructor);
2019 initial_map->set_non_instance_prototype(
false);
2020 initial_map->set_prototype(*array_prototype);
2023 Map::EnsureDescriptorSlack(initial_map, 3);
2026 JSFunction* array_function = native_context()->array_function();
2027 Handle<DescriptorArray> array_descriptors(
2028 array_function->initial_map()->instance_descriptors());
2029 Handle<String> length = factory()->length_string();
2030 int old = array_descriptors->SearchWithCache(
2031 *length, array_function->initial_map());
2032 DCHECK(old != DescriptorArray::kNotFound);
2033 CallbacksDescriptor desc(length,
2034 handle(array_descriptors->GetValue(old),
2036 array_descriptors->GetDetails(old).attributes());
2037 initial_map->AppendDescriptor(&desc);
2040 FieldDescriptor index_field(factory()->index_string(),
2041 JSRegExpResult::kIndexIndex,
2043 Representation::Tagged());
2044 initial_map->AppendDescriptor(&index_field);
2048 FieldDescriptor input_field(factory()->input_string(),
2049 JSRegExpResult::kInputIndex,
2051 Representation::Tagged());
2052 initial_map->AppendDescriptor(&input_field);
2055 initial_map->set_inobject_properties(2);
2056 initial_map->set_pre_allocated_property_fields(2);
2057 initial_map->set_unused_property_fields(0);
2059 native_context()->set_regexp_result_map(*initial_map);
2065 Handle<AccessorInfo> arguments_iterator =
2066 Accessors::ArgumentsIteratorInfo(isolate(), attribs);
2068 CallbacksDescriptor d(Handle<Name>(native_context()->iterator_symbol()),
2069 arguments_iterator, attribs);
2070 Handle<Map>
map(native_context()->sloppy_arguments_map());
2071 Map::EnsureDescriptorSlack(
map, 1);
2072 map->AppendDescriptor(&d);
2075 CallbacksDescriptor d(Handle<Name>(native_context()->iterator_symbol()),
2076 arguments_iterator, attribs);
2077 Handle<Map>
map(native_context()->aliased_arguments_map());
2078 Map::EnsureDescriptorSlack(
map, 1);
2079 map->AppendDescriptor(&d);
2082 CallbacksDescriptor d(Handle<Name>(native_context()->iterator_symbol()),
2083 arguments_iterator, attribs);
2084 Handle<Map>
map(native_context()->strict_arguments_map());
2085 Map::EnsureDescriptorSlack(
map, 1);
2086 map->AppendDescriptor(&d);
2091 builtins->ObjectVerify();
2098 #define INSTALL_EXPERIMENTAL_NATIVE(i, flag, file) \
2099 if (FLAG_harmony_##flag && \
2100 strcmp(ExperimentalNatives::GetScriptName(i).start(), \
2101 "native " file) == 0) { \
2102 if (!CompileExperimentalBuiltin(isolate(), i)) return false; \
2106 bool Genesis::InstallExperimentalNatives() {
2107 for (
int i = ExperimentalNatives::GetDebuggerCount();
2108 i < ExperimentalNatives::GetBuiltinsCount();
2116 InstallExperimentalNativeFunctions();
2122 const char* function_name,
2124 Isolate* isolate = holder->GetIsolate();
2126 Object::GetProperty(isolate, holder, function_name).ToHandleChecked();
2128 function->shared()->set_function_data(Smi::FromInt(
id));
2132 void Genesis::InstallBuiltinFunctionIds() {
2134 #define INSTALL_BUILTIN_ID(holder_expr, fun_name, name) \
2136 Handle<JSObject> holder = ResolveBuiltinIdHolder( \
2137 native_context(), #holder_expr); \
2138 BuiltinFunctionId id = k##name; \
2139 InstallBuiltinFunctionId(holder, #fun_name, id); \
2142 #undef INSTALL_BUILTIN_ID
2148 #define JSFUNCTION_RESULT_CACHE_LIST(F) \
2149 F(16, native_context()->regexp_function())
2153 Factory* factory = factory_function->GetIsolate()->factory();
2155 int array_size = JSFunctionResultCache::kEntriesIndex + 2 *
size;
2158 *factory->NewFixedArrayWithHoles(array_size,
TENURED));
2159 cache->
set(JSFunctionResultCache::kFactoryIndex, *factory_function);
2165 void Genesis::InstallJSFunctionResultCaches() {
2166 const int kNumberOfCaches = 0 +
2167 #define F(size, func) + 1
2173 factory()->NewFixedArray(kNumberOfCaches,
TENURED);
2177 #define F(size, func) do { \
2178 FixedArray* cache = CreateCache((size), Handle<JSFunction>(func)); \
2179 caches->set(index++, cache); \
2186 native_context()->set_jsfunction_result_caches(*caches);
2190 void Genesis::InitializeNormalizedMapCaches() {
2191 Handle<NormalizedMapCache> cache = NormalizedMapCache::New(isolate());
2192 native_context()->set_normalized_map_cache(*cache);
2196 bool Bootstrapper::InstallExtensions(Handle<Context> native_context,
2198 BootstrapperActive active(
this);
2199 SaveContext saved_context(isolate_);
2200 isolate_->set_context(*native_context);
2201 return Genesis::InstallExtensions(native_context, extensions) &&
2202 Genesis::InstallSpecialObjects(native_context);
2206 bool Genesis::InstallSpecialObjects(Handle<Context> native_context) {
2207 Isolate* isolate = native_context->GetIsolate();
2209 if (isolate->serializer_enabled())
return true;
2211 Factory* factory = isolate->factory();
2212 HandleScope scope(isolate);
2213 Handle<JSGlobalObject> global(JSGlobalObject::cast(
2214 native_context->global_object()));
2216 Handle<JSObject> Error = Handle<JSObject>::cast(
2217 Object::GetProperty(isolate, global,
"Error").ToHandleChecked());
2218 Handle<String>
name =
2220 Handle<Smi> stack_trace_limit(Smi::FromInt(FLAG_stack_trace_limit), isolate);
2221 JSObject::AddProperty(Error,
name, stack_trace_limit,
NONE);
2224 if (FLAG_expose_natives_as !=
NULL && strlen(FLAG_expose_natives_as) != 0) {
2225 Handle<String> natives =
2226 factory->InternalizeUtf8String(FLAG_expose_natives_as);
2228 if (natives->AsArrayIndex(&dummy_index))
return true;
2229 JSObject::AddProperty(global, natives,
handle(global->builtins()),
2235 JSObject::SetOwnPropertyIgnoreAttributes(
2236 handle(native_context->builtins(), isolate),
2237 factory->InternalizeOneByteString(
2239 factory->stack_trace_symbol(),
NONE),
2243 if (FLAG_expose_debug_as !=
NULL && strlen(FLAG_expose_debug_as) != 0) {
2246 Debug* debug = isolate->debug();
2247 if (!debug->Load())
return true;
2248 Handle<Context> debug_context = debug->debug_context();
2252 debug_context->set_security_token(native_context->security_token());
2253 Handle<String> debug_string =
2254 factory->InternalizeUtf8String(FLAG_expose_debug_as);
2256 if (debug_string->AsArrayIndex(&index))
return true;
2257 Handle<Object> global_proxy(debug_context->global_proxy(), isolate);
2258 JSObject::AddProperty(global, debug_string, global_proxy,
DONT_ENUM);
2269 Genesis::ExtensionStates::ExtensionStates() : map_(
HashMap::PointersMatch, 8) {}
2271 Genesis::ExtensionTraversalState Genesis::ExtensionStates::get_state(
2272 RegisteredExtension* extension) {
2273 i::HashMap::Entry* entry = map_.Lookup(extension,
Hash(extension),
false);
2274 if (entry ==
NULL) {
2277 return static_cast<ExtensionTraversalState
>(
2278 reinterpret_cast<intptr_t
>(entry->value));
2281 void Genesis::ExtensionStates::set_state(RegisteredExtension* extension,
2282 ExtensionTraversalState state) {
2283 map_.Lookup(extension,
Hash(extension),
true)->value =
2284 reinterpret_cast<void*
>(
static_cast<intptr_t
>(state));
2288 bool Genesis::InstallExtensions(Handle<Context> native_context,
2290 Isolate* isolate = native_context->GetIsolate();
2291 ExtensionStates extension_states;
2292 return InstallAutoExtensions(isolate, &extension_states) &&
2293 (!FLAG_expose_free_buffer ||
2294 InstallExtension(isolate,
"v8/free-buffer", &extension_states)) &&
2296 InstallExtension(isolate,
"v8/gc", &extension_states)) &&
2297 (!FLAG_expose_externalize_string ||
2298 InstallExtension(isolate,
"v8/externalize", &extension_states)) &&
2299 (!FLAG_track_gc_object_stats ||
2300 InstallExtension(isolate,
"v8/statistics", &extension_states)) &&
2301 (!FLAG_expose_trigger_failure ||
2302 InstallExtension(isolate,
"v8/trigger-failure", &extension_states)) &&
2303 InstallRequestedExtensions(isolate, extensions, &extension_states);
2307 bool Genesis::InstallAutoExtensions(Isolate* isolate,
2308 ExtensionStates* extension_states) {
2312 if (it->extension()->auto_enable() &&
2313 !InstallExtension(isolate, it, extension_states)) {
2321 bool Genesis::InstallRequestedExtensions(Isolate* isolate,
2323 ExtensionStates* extension_states) {
2324 for (
const char** it = extensions->
begin(); it != extensions->
end(); ++it) {
2325 if (!InstallExtension(isolate, *it, extension_states))
return false;
2333 bool Genesis::InstallExtension(Isolate* isolate,
2335 ExtensionStates* extension_states) {
2339 if (strcmp(
name, it->extension()->name()) == 0) {
2340 return InstallExtension(isolate, it, extension_states);
2344 "v8::Context::New()",
2345 "Cannot find required extension");
2349 bool Genesis::InstallExtension(Isolate* isolate,
2351 ExtensionStates* extension_states) {
2352 HandleScope scope(isolate);
2354 if (extension_states->get_state(current) == INSTALLED)
return true;
2358 "v8::Context::New()",
2359 "Circular extension dependency")) {
2362 DCHECK(extension_states->get_state(current) == UNVISITED);
2363 extension_states->set_state(current, VISITED);
2367 if (!InstallExtension(isolate,
2369 extension_states)) {
2374 Handle<String> source_code =
2376 ->NewExternalStringFromOneByte(extension->
source())
2378 bool result = CompileScriptCached(isolate,
2381 isolate->bootstrapper()->extensions_cache(),
2383 Handle<Context>(isolate->context()),
2385 DCHECK(isolate->has_pending_exception() != result);
2393 isolate->clear_pending_exception();
2395 extension_states->set_state(current, INSTALLED);
2396 isolate->NotifyExtensionInstalled();
2401 bool Genesis::InstallJSBuiltins(Handle<JSBuiltinsObject> builtins) {
2402 HandleScope scope(isolate());
2403 for (
int i = 0;
i < Builtins::NumberOfJavaScriptBuiltins();
i++) {
2404 Builtins::JavaScript
id =
static_cast<Builtins::JavaScript
>(
i);
2405 Handle<Object> function_object = Object::GetProperty(
2406 isolate(), builtins, Builtins::GetName(
id)).ToHandleChecked();
2407 Handle<JSFunction>
function = Handle<JSFunction>::cast(function_object);
2408 builtins->set_javascript_builtin(
id, *
function);
2412 function->shared()->set_optimization_disabled(
true);
2416 builtins->set_javascript_builtin_code(
id, function->shared()->code());
2422 bool Genesis::ConfigureGlobalObjects(
2424 Handle<JSObject> global_proxy(
2425 JSObject::cast(native_context()->global_proxy()));
2426 Handle<JSObject> global_object(
2427 JSObject::cast(native_context()->global_object()));
2429 if (!global_proxy_template.
IsEmpty()) {
2431 Handle<ObjectTemplateInfo> global_proxy_data =
2433 if (!ConfigureApiObject(global_proxy, global_proxy_data))
return false;
2436 Handle<FunctionTemplateInfo> proxy_constructor(
2437 FunctionTemplateInfo::cast(global_proxy_data->constructor()));
2438 if (!proxy_constructor->prototype_template()->IsUndefined()) {
2439 Handle<ObjectTemplateInfo> global_object_data(
2440 ObjectTemplateInfo::cast(proxy_constructor->prototype_template()));
2441 if (!ConfigureApiObject(global_object, global_object_data))
return false;
2447 native_context()->set_initial_array_prototype(
2448 JSArray::cast(native_context()->array_function()->prototype()));
2454 bool Genesis::ConfigureApiObject(Handle<JSObject>
object,
2455 Handle<ObjectTemplateInfo> object_template) {
2456 DCHECK(!object_template.is_null());
2457 DCHECK(FunctionTemplateInfo::cast(object_template->constructor())
2458 ->IsTemplateFor(object->map()));;
2460 MaybeHandle<JSObject> maybe_obj =
2461 Execution::InstantiateObject(object_template);
2462 Handle<JSObject> obj;
2463 if (!maybe_obj.ToHandle(&obj)) {
2464 DCHECK(isolate()->has_pending_exception());
2465 isolate()->clear_pending_exception();
2468 TransferObject(obj,
object);
2473 void Genesis::TransferNamedProperties(Handle<JSObject> from,
2474 Handle<JSObject>
to) {
2475 if (from->HasFastProperties()) {
2476 Handle<DescriptorArray> descs =
2477 Handle<DescriptorArray>(from->map()->instance_descriptors());
2478 for (
int i = 0;
i < from->map()->NumberOfOwnDescriptors();
i++) {
2479 PropertyDetails details = descs->GetDetails(
i);
2480 switch (details.type()) {
2482 HandleScope inner(isolate());
2483 Handle<Name> key = Handle<Name>(descs->GetKey(
i));
2484 FieldIndex index = FieldIndex::ForDescriptor(from->map(),
i);
2485 DCHECK(!descs->GetDetails(
i).representation().IsDouble());
2486 Handle<Object> value = Handle<Object>(from->RawFastPropertyAt(index),
2488 JSObject::AddProperty(
to, key, value, details.attributes());
2492 HandleScope inner(isolate());
2493 Handle<Name> key = Handle<Name>(descs->GetKey(
i));
2494 Handle<Object> constant(descs->GetConstant(
i), isolate());
2495 JSObject::AddProperty(
to, key, constant, details.attributes());
2499 Handle<Name> key(descs->GetKey(
i));
2500 LookupIterator it(
to, key, LookupIterator::OWN_SKIP_INTERCEPTOR);
2501 CHECK_NE(LookupIterator::ACCESS_CHECK, it.state());
2503 if (it.IsFound())
continue;
2504 HandleScope inner(isolate());
2507 Handle<Object> callbacks(descs->GetCallbacksObject(
i), isolate());
2508 PropertyDetails d = PropertyDetails(
2510 JSObject::SetNormalizedProperty(
to, key, callbacks, d);
2520 Handle<NameDictionary> properties =
2521 Handle<NameDictionary>(from->property_dictionary());
2522 int capacity = properties->Capacity();
2523 for (
int i = 0;
i < capacity;
i++) {
2524 Object* raw_key(properties->KeyAt(
i));
2525 if (properties->IsKey(raw_key)) {
2526 DCHECK(raw_key->IsName());
2528 Handle<Name> key(Name::cast(raw_key));
2529 LookupIterator it(
to, key, LookupIterator::OWN_SKIP_INTERCEPTOR);
2530 CHECK_NE(LookupIterator::ACCESS_CHECK, it.state());
2531 if (it.IsFound())
continue;
2533 Handle<Object> value = Handle<Object>(properties->ValueAt(
i),
2535 DCHECK(!value->IsCell());
2536 if (value->IsPropertyCell()) {
2537 value = Handle<Object>(PropertyCell::cast(*value)->value(),
2540 PropertyDetails details = properties->DetailsAt(
i);
2541 JSObject::AddProperty(
to, key, value, details.attributes());
2548 void Genesis::TransferIndexedProperties(Handle<JSObject> from,
2549 Handle<JSObject>
to) {
2551 Handle<FixedArray> from_elements =
2552 Handle<FixedArray>(FixedArray::cast(from->elements()));
2553 Handle<FixedArray> to_elements = factory()->CopyFixedArray(from_elements);
2554 to->set_elements(*to_elements);
2558 void Genesis::TransferObject(Handle<JSObject> from, Handle<JSObject>
to) {
2559 HandleScope outer(isolate());
2561 DCHECK(!from->IsJSArray());
2564 TransferNamedProperties(from,
to);
2565 TransferIndexedProperties(from,
to);
2568 Handle<Object> proto(from->map()->prototype(), isolate());
2573 void Genesis::MakeFunctionInstancePrototypeWritable() {
2577 DCHECK(!sloppy_function_map_writable_prototype_.is_null());
2578 DCHECK(!strict_function_map_writable_prototype_.is_null());
2581 native_context()->set_sloppy_function_map(
2582 *sloppy_function_map_writable_prototype_);
2583 native_context()->set_strict_function_map(
2584 *strict_function_map_writable_prototype_);
2591 : flag_(FLAG_track_double_fields) {
2595 FLAG_track_double_fields =
false;
2600 FLAG_track_double_fields = flag_;
2608 Genesis::Genesis(
Isolate* isolate,
2612 : isolate_(isolate),
2613 active_(isolate->bootstrapper()) {
2618 SaveContext saved_context(isolate);
2623 StackLimitCheck check(isolate);
2624 if (check.HasOverflowed())
return;
2634 if (!native_context().is_null()) {
2637 isolate->
counters()->contexts_created_by_snapshot()->Increment();
2638 Handle<GlobalObject> global_object;
2639 Handle<JSGlobalProxy> global_proxy = CreateNewGlobals(
2640 global_proxy_template, maybe_global_proxy, &global_object);
2642 HookUpGlobalProxy(global_object, global_proxy);
2643 HookUpGlobalObject(global_object);
2644 native_context()->builtins()->set_global_proxy(
2645 native_context()->global_proxy());
2647 if (!ConfigureGlobalObjects(global_proxy_template))
return;
2651 Handle<JSFunction> empty_function = CreateEmptyFunction(isolate);
2652 CreateStrictModeFunctionMaps(empty_function);
2653 Handle<GlobalObject> global_object;
2654 Handle<JSGlobalProxy> global_proxy = CreateNewGlobals(
2655 global_proxy_template, maybe_global_proxy, &global_object);
2656 HookUpGlobalProxy(global_object, global_proxy);
2657 InitializeGlobal(global_object, empty_function);
2658 InstallJSFunctionResultCaches();
2659 InitializeNormalizedMapCaches();
2660 if (!InstallNatives())
return;
2662 MakeFunctionInstancePrototypeWritable();
2664 if (!ConfigureGlobalObjects(global_proxy_template))
return;
2665 isolate->
counters()->contexts_created_from_scratch()->Increment();
2669 if (!InstallExperimentalNatives())
return;
2670 InitializeExperimentalGlobal();
2678 const int num_elems = 2;
2679 const int num_bytes = num_elems *
sizeof(
uint32_t);
2684 }
while (state[0] == 0 || state[1] == 0);
2687 reinterpret_cast<v8::Isolate*
>(isolate), state, num_bytes);
2690 Handle<JSBuiltinsObject> builtins(native_context()->builtins());
2696 const int constants_size =
arraysize(fdlibm::MathConstants::constants);
2697 const int table_num_bytes = constants_size *
kDoubleSize;
2700 const_cast<double*
>(fdlibm::MathConstants::constants), table_num_bytes);
2710 result_ = native_context();
2718 return sizeof(NestingCounterType);
2723 char* Bootstrapper::ArchiveState(
char*
to) {
2724 *
reinterpret_cast<NestingCounterType*
>(
to) = nesting_;
2726 return to +
sizeof(NestingCounterType);
2731 char* Bootstrapper::RestoreState(
char* from) {
2732 nesting_ = *
reinterpret_cast<NestingCounterType*
>(from);
2733 return from +
sizeof(NestingCounterType);
2738 void Bootstrapper::FreeThreadResources() {
#define INSTALL_NATIVE(Type, name, var)
#define INSTALL_TYPED_ARRAY(Type, type, TYPE, ctype, size)
#define INSTALL_EXPERIMENTAL_NATIVE(i, flag, file)
#define INSTALL_BUILTIN_ID(holder_expr, fun_name, name)
#define JSFUNCTION_RESULT_CACHE_LIST(F)
#define INSTALL_NATIVE_MATH(name)
static Local< ArrayBuffer > New(Isolate *isolate, size_t byte_length)
Create a new ArrayBuffer.
A container for extension names.
const char ** begin() const
const char ** end() const
const char * name() const
const String::ExternalOneByteStringResource * source() const
const char ** dependencies()
static Local< Float64Array > New(Handle< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
A stack-allocated class that governs a number of local handles.
An object reference managed by the v8 garbage collector.
bool IsEmpty() const
Returns true if the handle is empty.
Isolate represents an isolated instance of the V8 engine.
A light-weight stack-allocated object handle.
static RegisteredExtension * first_extension()
static Local< Uint32Array > New(Handle< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
static bool ApiCheck(bool condition, const char *location, const char *message)
static v8::internal::Handle< To > OpenHandle(v8::Local< From > handle)
static void PrintError(const char *format,...)
void set_state(RegisteredExtension *extension, ExtensionTraversalState state)
ExtensionTraversalState get_state(RegisteredExtension *extension)
DISALLOW_COPY_AND_ASSIGN(ExtensionStates)
static bool InstallExtension(Isolate *isolate, const char *name, ExtensionStates *extension_states)
void TransferObject(Handle< JSObject > from, Handle< JSObject > to)
bool InstallExperimentalNatives()
Handle< Map > CreateStrictFunctionMap(FunctionMode function_mode, Handle< JSFunction > empty_function)
static bool InstallExtensions(Handle< Context > native_context, v8::ExtensionConfiguration *extensions)
void HookUpGlobalProxy(Handle< GlobalObject > global_object, Handle< JSGlobalProxy > global_proxy)
Isolate * isolate() const
static bool IsFunctionModeWithPrototype(FunctionMode function_mode)
Handle< JSFunction > generator_poison_function
void InstallBuiltinFunctionIds()
void TransferNamedProperties(Handle< JSObject > from, Handle< JSObject > to)
void InstallExperimentalNativeFunctions()
Handle< Map > sloppy_function_map_writable_prototype_
Handle< Context > result_
Handle< JSFunction > CreateEmptyFunction(Isolate *isolate)
Handle< Map > strict_function_map_writable_prototype_
static bool CompileExperimentalBuiltin(Isolate *isolate, int index)
void InitializeNormalizedMapCaches()
static bool CompileScriptCached(Isolate *isolate, Vector< const char > name, Handle< String > source, SourceCodeCache *cache, v8::Extension *extension, Handle< Context > top_context, bool use_runtime_context)
static bool CompileNative(Isolate *isolate, Vector< const char > name, Handle< String > source)
Handle< JSGlobalProxy > CreateNewGlobals(v8::Handle< v8::ObjectTemplate > global_proxy_template, MaybeHandle< JSGlobalProxy > maybe_global_proxy, Handle< GlobalObject > *global_object_out)
bool ConfigureGlobalObjects(v8::Handle< v8::ObjectTemplate > global_proxy_template)
void PoisonArgumentsAndCaller(Handle< Map > map)
static bool InstallSpecialObjects(Handle< Context > native_context)
Genesis(Isolate *isolate, MaybeHandle< JSGlobalProxy > maybe_global_proxy, v8::Handle< v8::ObjectTemplate > global_proxy_template, v8::ExtensionConfiguration *extensions)
void TransferIndexedProperties(Handle< JSObject > from, Handle< JSObject > to)
Handle< JSFunction > InstallInternalArray(Handle< JSBuiltinsObject > builtins, const char *name, ElementsKind elements_kind)
static bool InstallRequestedExtensions(Isolate *isolate, v8::ExtensionConfiguration *extensions, ExtensionStates *extension_states)
static bool InstallExtension(Isolate *isolate, v8::RegisteredExtension *current, ExtensionStates *extension_states)
void InitializeExperimentalGlobal()
void SetStrictFunctionInstanceDescriptor(Handle< Map > map, FunctionMode function_mode)
Handle< Map > CreateFunctionMap(FunctionMode function_mode)
Handle< Context > native_context_
Factory * factory() const
Handle< Context > native_context()
void InstallNativeFunctions()
@ FUNCTION_WITHOUT_PROTOTYPE
@ FUNCTION_WITH_READONLY_PROTOTYPE
@ FUNCTION_WITH_WRITEABLE_PROTOTYPE
static bool CompileBuiltin(Isolate *isolate, int index)
void CreateStrictModeFunctionMaps(Handle< JSFunction > empty)
Handle< Context > result()
void InstallTypedArray(const char *name, ElementsKind elements_kind, Handle< JSFunction > *fun, Handle< Map > *external_map)
Handle< JSFunction > strict_poison_function
Handle< JSFunction > GetStrictPoisonFunction()
bool ConfigureApiObject(Handle< JSObject > object, Handle< ObjectTemplateInfo > object_template)
BootstrapperActive active_
void InitializeGlobal(Handle< GlobalObject > global_object, Handle< JSFunction > empty_function)
void HookUpGlobalObject(Handle< GlobalObject > global_object)
void InstallJSFunctionResultCaches()
void SetFunctionInstanceDescriptor(Handle< Map > map, FunctionMode function_mode)
void MakeFunctionInstancePrototypeWritable()
static bool InstallAutoExtensions(Isolate *isolate, ExtensionStates *extension_states)
Handle< JSFunction > GetGeneratorPoisonFunction()
bool InstallJSBuiltins(Handle< JSBuiltinsObject > builtins)
Code * builtin(Name name)
void Replace(int descriptor_number, Descriptor *descriptor)
Object * GetValue(int descriptor_number)
void set(int index, Object *value)
static Handle< T > null()
Isolate * GetIsolate() const
Object * native_contexts_list() const
void set_native_contexts_list(Object *object)
bool serializer_enabled() const
bool initialized_from_snapshot()
void set_context(Context *context)
base::RandomNumberGenerator * random_number_generator()
~NoTrackDoubleFieldsForSerializerScope()
NoTrackDoubleFieldsForSerializerScope(Isolate *isolate)
static MUST_USE_RESULT MaybeHandle< Object > DefineObjectProperty(Handle< JSObject > object, Handle< Object > key, Handle< Object > value, PropertyAttributes attr)
static Handle< Context > NewContextFromSnapshot(Isolate *isolate)
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf map
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS 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 enable alignment of csp to bytes on platforms which prefer the register to always be expose gc extension under the specified name show built in functions in stack traces use random jit cookie to mask large constants minimum length for automatic enable preparsing CPU profiler sampling interval in microseconds trace out of bounds accesses to external arrays default size of stack region v8 is allowed to maximum length of function source code printed in a stack trace min size of a semi the new space consists of two semi spaces print one trace line following each garbage collection do not print trace line after scavenger collection print cumulative GC statistics in only print modified registers Trace simulator debug messages Implied by trace sim abort randomize hashes to avoid predictable hash Fixed seed to use to hash property Print the time it takes to deserialize the snapshot A filename with extra code to be included in the A file to write the raw snapshot bytes to(mksnapshot only)") DEFINE_STRING(raw_context_file
enable harmony numeric enable harmony object literal extensions Optimize object size
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS 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 enable alignment of csp to bytes on platforms which prefer the register to always be expose gc extension under the specified name show built in functions in stack traces use random jit cookie to mask large constants minimum length for automatic enable preparsing CPU profiler sampling interval in microseconds trace out of bounds accesses to external arrays default size of stack region v8 is allowed to maximum length of function source code printed in a stack trace min size of a semi the new space consists of two semi spaces print one trace line following each garbage collection do not print trace line after scavenger collection print cumulative GC statistics in name
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS 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 enable alignment of csp to bytes on platforms which prefer the register to always be NULL
#define ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, dst, call, value)
#define RETURN_ON_EXCEPTION_VALUE(isolate, call, value)
#define CHECK_NE(unexpected, value)
#define DCHECK(condition)
#define DCHECK_EQ(v1, v2)
#define STATIC_ASSERT(test)
IN DWORD64 OUT PDWORD64 OUT PIMAGEHLP_SYMBOL64 Symbol
Vector< const char > CStrVector(const char *data)
static void InstallBuiltinFunctionId(Handle< JSObject > holder, const char *function_name, BuiltinFunctionId id)
static void AddToWeakNativeContextList(Context *context)
static int min(int a, int b)
static Handle< JSFunction > InstallFunction(Handle< JSObject > target, const char *name, InstanceType type, int instance_size, MaybeHandle< JSObject > maybe_prototype, Builtins::Name call)
Handle< Object > CacheInitialJSArrayMaps(Handle< Context > native_context, Handle< Map > initial_map)
kSerializedDataOffset Object
static void ReplaceAccessors(Handle< Map > map, Handle< String > name, PropertyAttributes attributes, Handle< AccessorPair > accessor_pair)
@ JS_CONTEXT_EXTENSION_OBJECT_TYPE
@ JS_BUILTINS_OBJECT_TYPE
@ SLOPPY_ARGUMENTS_ELEMENTS
Handle< T > handle(T *t, Isolate *isolate)
uint32_t ComputePointerHash(void *ptr)
TemplateHashMapImpl< FreeStoreAllocationPolicy > HashMap
ElementsKind GetNextTransitionElementsKind(ElementsKind kind)
static uint32_t Hash(RegisteredExtension *extension)
void PrintF(const char *format,...)
static const char * GCFunctionName()
static Handle< JSObject > ResolveBuiltinIdHolder(Handle< Context > native_context, const char *holder_expr)
kFeedbackVectorOffset flag
static int ArchiveSpacePerThread()
static void SetObjectPrototype(Handle< JSObject > object, Handle< Object > proto)
static void SetAccessors(Handle< Map > map, Handle< String > name, Handle< JSFunction > func)
static FixedArray * CreateCache(int size, Handle< JSFunction > factory_function)
ElementsKind GetInitialFastElementsKind()
bool IsFastObjectElementsKind(ElementsKind kind)
Debugger support for the V8 JavaScript engine.
static i::Handle< i::Context > CreateEnvironment(i::Isolate *isolate, v8::ExtensionConfiguration *extensions, v8::Handle< ObjectTemplate > global_template, v8::Handle< Value > maybe_global_proxy)
void RegisterExtension(Extension *that)
#define FUNCTIONS_WITH_ID_LIST(V)
#define STATIC_CHAR_VECTOR(x)