21 isolate()->heap()->Allocate(*
map,
space),
27 Handle<T> Factory::New(Handle<Map>
map,
29 Handle<AllocationSite> allocation_site) {
32 isolate()->heap()->Allocate(*
map,
space, *allocation_site),
37 Handle<HeapObject> Factory::NewFillerObject(
int size,
42 isolate()->heap()->AllocateFillerObject(
size, double_align,
space),
47 Handle<Box> Factory::NewBox(Handle<Object> value) {
49 result->set_value(*value);
54 Handle<Oddball> Factory::NewOddball(Handle<Map>
map,
55 const char* to_string,
56 Handle<Object> to_number,
68 isolate()->heap()->AllocateFixedArray(
size, pretenure),
73 Handle<FixedArray> Factory::NewFixedArrayWithHoles(
int size,
78 isolate()->heap()->AllocateFixedArrayWithFiller(
size,
85 Handle<FixedArray> Factory::NewUninitializedFixedArray(
int size) {
88 isolate()->heap()->AllocateUninitializedFixedArray(
size),
93 Handle<FixedArrayBase> Factory::NewFixedDoubleArray(
int size,
98 isolate()->heap()->AllocateUninitializedFixedDoubleArray(
size, pretenure),
103 Handle<FixedArrayBase> Factory::NewFixedDoubleArrayWithHoles(
107 Handle<FixedArrayBase> array = NewFixedDoubleArray(
size, pretenure);
109 Handle<FixedDoubleArray> double_array =
111 for (
int i = 0;
i <
size; ++
i) {
112 double_array->set_the_hole(
i);
119 Handle<ConstantPoolArray> Factory::NewConstantPoolArray(
120 const ConstantPoolArray::NumberOfEntries& small) {
121 DCHECK(small.total_count() > 0);
124 isolate()->heap()->AllocateConstantPoolArray(small),
129 Handle<ConstantPoolArray> Factory::NewExtendedConstantPoolArray(
130 const ConstantPoolArray::NumberOfEntries& small,
131 const ConstantPoolArray::NumberOfEntries& extended) {
132 DCHECK(small.total_count() > 0);
133 DCHECK(extended.total_count() > 0);
136 isolate()->heap()->AllocateExtendedConstantPoolArray(small, extended),
141 Handle<OrderedHashSet> Factory::NewOrderedHashSet() {
146 Handle<OrderedHashMap> Factory::NewOrderedHashMap() {
151 Handle<AccessorPair> Factory::NewAccessorPair() {
152 Handle<AccessorPair> accessors =
160 Handle<TypeFeedbackInfo> Factory::NewTypeFeedbackInfo() {
161 Handle<TypeFeedbackInfo> info =
163 info->initialize_storage();
169 Handle<String> Factory::InternalizeUtf8String(Vector<const char>
string) {
170 Utf8StringKey key(
string, isolate()->heap()->HashSeed());
171 return InternalizeStringWithKey(&key);
176 Handle<String> Factory::InternalizeString(Handle<String>
string) {
177 if (string->IsInternalizedString())
return string;
182 Handle<String> Factory::InternalizeOneByteString(Vector<const uint8_t>
string) {
183 OneByteStringKey key(
string, isolate()->heap()->HashSeed());
184 return InternalizeStringWithKey(&key);
188 Handle<String> Factory::InternalizeOneByteString(
189 Handle<SeqOneByteString>
string,
int from,
int length) {
190 SeqOneByteSubStringKey key(
string, from, length);
191 return InternalizeStringWithKey(&key);
195 Handle<String> Factory::InternalizeTwoByteString(Vector<const uc16>
string) {
196 TwoByteStringKey key(
string, isolate()->heap()->HashSeed());
197 return InternalizeStringWithKey(&key);
201 template<
class StringTableKey>
202 Handle<String> Factory::InternalizeStringWithKey(StringTableKey* key) {
207 MaybeHandle<String> Factory::NewStringFromOneByte(Vector<const uint8_t>
string,
209 int length =
string.length();
210 if (length == 1)
return LookupSingleCharacterStringFromCode(
string[0]);
211 Handle<SeqOneByteString> result;
215 NewRawOneByteString(
string.length(), pretenure),
220 CopyChars(SeqOneByteString::cast(*result)->GetChars(),
226 MaybeHandle<String> Factory::NewStringFromUtf8(Vector<const char>
string,
229 const char* start =
string.start();
230 int length =
string.length();
232 if (non_ascii_start >= length) {
239 Access<UnicodeCache::Utf8Decoder>
240 decoder(isolate()->unicode_cache()->utf8_decoder());
241 decoder->Reset(
string.start() + non_ascii_start,
242 length - non_ascii_start);
243 int utf16_length = decoder->Utf16Length();
246 Handle<SeqTwoByteString> result;
249 NewRawTwoByteString(non_ascii_start + utf16_length, pretenure),
252 uint16_t* data = result->GetChars();
253 const char* ascii_data =
string.start();
254 for (
int i = 0;
i < non_ascii_start;
i++) {
255 *data++ = *ascii_data++;
258 decoder->WriteUtf16(data, utf16_length);
263 MaybeHandle<String> Factory::NewStringFromTwoByte(Vector<const uc16>
string,
265 int length =
string.length();
266 const uc16* start =
string.start();
268 if (length == 1)
return LookupSingleCharacterStringFromCode(
string[0]);
269 Handle<SeqOneByteString> result;
273 NewRawOneByteString(length, pretenure),
275 CopyChars(result->GetChars(), start, length);
278 Handle<SeqTwoByteString> result;
282 NewRawTwoByteString(length, pretenure),
284 CopyChars(result->GetChars(), start, length);
290 Handle<String> Factory::NewInternalizedStringFromUtf8(Vector<const char> str,
295 isolate()->heap()->AllocateInternalizedStringFromUtf8(
296 str, chars, hash_field),
302 Vector<const uint8_t> str,
306 isolate()->heap()->AllocateOneByteInternalizedString(str, hash_field),
311 MUST_USE_RESULT Handle<String> Factory::NewOneByteInternalizedSubString(
312 Handle<SeqOneByteString>
string,
int offset,
int length,
315 isolate(), isolate()->heap()->AllocateOneByteInternalizedString(
316 Vector<const uint8_t>(string->GetChars() + offset, length),
323 Vector<const uc16> str,
327 isolate()->heap()->AllocateTwoByteInternalizedString(str, hash_field),
332 Handle<String> Factory::NewInternalizedStringImpl(
333 Handle<String>
string,
int chars,
uint32_t hash_field) {
336 isolate()->heap()->AllocateInternalizedStringImpl(
337 *
string, chars, hash_field),
342 MaybeHandle<Map> Factory::InternalizedStringMapForString(
343 Handle<String>
string) {
345 if (isolate()->heap()->InNewSpace(*
string))
return MaybeHandle<Map>();
348 switch (string->map()->instance_type()) {
349 case STRING_TYPE:
return internalized_string_map();
351 return one_byte_internalized_string_map();
354 return external_one_byte_internalized_string_map();
356 return external_internalized_string_with_one_byte_data_map();
358 return short_external_internalized_string_map();
360 return short_external_one_byte_internalized_string_map();
362 return short_external_internalized_string_with_one_byte_data_map();
363 default:
return MaybeHandle<Map>();
368 MaybeHandle<SeqOneByteString> Factory::NewRawOneByteString(
371 THROW_NEW_ERROR(isolate(), NewInvalidStringLengthError(), SeqOneByteString);
375 isolate()->heap()->AllocateRawOneByteString(length, pretenure),
380 MaybeHandle<SeqTwoByteString> Factory::NewRawTwoByteString(
383 THROW_NEW_ERROR(isolate(), NewInvalidStringLengthError(), SeqTwoByteString);
387 isolate()->heap()->AllocateRawTwoByteString(length, pretenure),
392 Handle<String> Factory::LookupSingleCharacterStringFromCode(
uint32_t code) {
396 Object* value = single_character_string_cache()->get(code);
397 if (value != *undefined_value()) {
398 return handle(String::cast(value), isolate());
402 buffer[0] =
static_cast<uint8_t
>(code);
403 Handle<String> result =
404 InternalizeOneByteString(Vector<const uint8_t>(buffer, 1));
405 single_character_string_cache()->set(code, *result);
410 Handle<SeqTwoByteString> result = NewRawTwoByteString(1).ToHandleChecked();
411 result->SeqTwoByteStringSet(0,
static_cast<uint16_t>(code));
419 return character - from <=
to - from;
443 isolate->
factory()->NewRawOneByteString(2).ToHandleChecked();
444 uint8_t* dest = str->GetChars();
445 dest[0] =
static_cast<uint8_t
>(c1);
446 dest[1] =
static_cast<uint8_t
>(c2);
450 isolate->
factory()->NewRawTwoByteString(2).ToHandleChecked();
451 uc16* dest = str->GetChars();
459 template<
typename SinkChar,
typename StringType>
464 SinkChar* sink = result->GetChars();
473 int left_length = left->length();
474 if (left_length == 0)
return right;
475 int right_length = right->length();
476 if (right_length == 0)
return left;
478 int length = left_length + right_length;
492 bool left_is_one_byte = left->IsOneByteRepresentation();
493 bool right_is_one_byte = right->IsOneByteRepresentation();
494 bool is_one_byte = left_is_one_byte && right_is_one_byte;
495 bool is_one_byte_data_in_two_byte_string =
false;
500 is_one_byte_data_in_two_byte_string =
501 left->HasOnlyOneByteChars() && right->HasOnlyOneByteChars();
502 if (is_one_byte_data_in_two_byte_string) {
503 isolate()->counters()->string_add_runtime_ext_to_one_byte()->Increment();
516 Handle<SeqOneByteString> result =
517 NewRawOneByteString(length).ToHandleChecked();
519 uint8_t* dest = result->GetChars();
522 left->IsExternalString()
525 for (
int i = 0;
i < left_length;
i++) *dest++ = src[
i];
527 src = right->IsExternalString()
530 for (
int i = 0;
i < right_length;
i++) *dest++ = src[
i];
534 return (is_one_byte_data_in_two_byte_string)
535 ? ConcatStringContent<uint8_t>(
536 NewRawOneByteString(length).ToHandleChecked(), left, right)
538 NewRawTwoByteString(length).ToHandleChecked(), left, right);
541 Handle<Map>
map = (is_one_byte || is_one_byte_data_in_two_byte_string)
542 ? cons_one_byte_string_map()
544 Handle<ConsString> result = New<ConsString>(
map,
NEW_SPACE);
550 result->set_length(length);
551 result->set_first(*left,
mode);
552 result->set_second(*right,
mode);
557 Handle<String> Factory::NewProperSubString(Handle<String> str,
561 if (FLAG_verify_heap) str->StringVerify();
563 DCHECK(begin > 0 || end < str->length());
567 int length = end - begin;
568 if (length <= 0)
return empty_string();
570 return LookupSingleCharacterStringFromCode(str->Get(begin));
582 if (str->IsOneByteRepresentation()) {
583 Handle<SeqOneByteString> result =
584 NewRawOneByteString(length).ToHandleChecked();
585 uint8_t* dest = result->GetChars();
590 Handle<SeqTwoByteString> result =
591 NewRawTwoByteString(length).ToHandleChecked();
592 uc16* dest = result->GetChars();
601 if (str->IsSlicedString()) {
603 str = Handle<String>(slice->parent(), isolate());
604 offset += slice->offset();
607 DCHECK(str->IsSeqString() || str->IsExternalString());
608 Handle<Map>
map = str->IsOneByteRepresentation()
609 ? sliced_one_byte_string_map()
610 : sliced_string_map();
611 Handle<SlicedString> slice = New<SlicedString>(
map,
NEW_SPACE);
614 slice->set_length(length);
615 slice->set_parent(*str);
616 slice->set_offset(offset);
621 MaybeHandle<String> Factory::NewExternalStringFromOneByte(
623 size_t length = resource->length();
628 Handle<Map>
map = external_one_byte_string_map();
629 Handle<ExternalOneByteString> external_string =
631 external_string->set_length(
static_cast<int>(length));
633 external_string->set_resource(resource);
635 return external_string;
639 MaybeHandle<String> Factory::NewExternalStringFromTwoByte(
641 size_t length = resource->length();
648 static const size_t kOneByteCheckLengthLimit = 32;
649 bool is_one_byte = length <= kOneByteCheckLengthLimit &&
651 Handle<Map>
map = is_one_byte ?
652 external_string_with_one_byte_data_map() : external_string_map();
653 Handle<ExternalTwoByteString> external_string =
655 external_string->set_length(
static_cast<int>(length));
657 external_string->set_resource(resource);
659 return external_string;
663 Handle<Symbol> Factory::NewSymbol() {
666 isolate()->heap()->AllocateSymbol(),
671 Handle<Symbol> Factory::NewPrivateSymbol() {
672 Handle<Symbol> symbol = NewSymbol();
673 symbol->set_is_private(
true);
678 Handle<Symbol> Factory::NewPrivateOwnSymbol() {
679 Handle<Symbol> symbol = NewSymbol();
680 symbol->set_is_private(
true);
681 symbol->set_is_own(
true);
686 Handle<Context> Factory::NewNativeContext() {
688 array->set_map_no_write_barrier(*native_context_map());
690 context->set_js_array_maps(*undefined_value());
691 DCHECK(context->IsNativeContext());
696 Handle<Context> Factory::NewGlobalContext(Handle<JSFunction>
function,
697 Handle<ScopeInfo> scope_info) {
698 Handle<FixedArray> array =
699 NewFixedArray(scope_info->ContextLength(),
TENURED);
700 array->set_map_no_write_barrier(*global_context_map());
702 context->set_closure(*
function);
703 context->set_previous(function->context());
704 context->set_extension(*scope_info);
705 context->set_global_object(function->context()->global_object());
706 DCHECK(context->IsGlobalContext());
711 Handle<Context> Factory::NewModuleContext(Handle<ScopeInfo> scope_info) {
712 Handle<FixedArray> array =
713 NewFixedArray(scope_info->ContextLength(),
TENURED);
714 array->set_map_no_write_barrier(*module_context_map());
722 Handle<Context> Factory::NewFunctionContext(
int length,
723 Handle<JSFunction>
function) {
725 Handle<FixedArray> array = NewFixedArray(length);
726 array->set_map_no_write_barrier(*function_context_map());
728 context->set_closure(*
function);
729 context->set_previous(function->context());
731 context->set_global_object(function->context()->global_object());
736 Handle<Context> Factory::NewCatchContext(Handle<JSFunction>
function,
737 Handle<Context> previous,
739 Handle<Object> thrown_object) {
742 array->set_map_no_write_barrier(*catch_context_map());
744 context->set_closure(*
function);
745 context->set_previous(*previous);
746 context->set_extension(*
name);
747 context->set_global_object(previous->global_object());
753 Handle<Context> Factory::NewWithContext(Handle<JSFunction>
function,
754 Handle<Context> previous,
755 Handle<JSReceiver> extension) {
757 array->set_map_no_write_barrier(*with_context_map());
759 context->set_closure(*
function);
760 context->set_previous(*previous);
761 context->set_extension(*extension);
762 context->set_global_object(previous->global_object());
767 Handle<Context> Factory::NewBlockContext(Handle<JSFunction>
function,
768 Handle<Context> previous,
769 Handle<ScopeInfo> scope_info) {
770 Handle<FixedArray> array =
771 NewFixedArrayWithHoles(scope_info->ContextLength());
772 array->set_map_no_write_barrier(*block_context_map());
774 context->set_closure(*
function);
775 context->set_previous(*previous);
776 context->set_extension(*scope_info);
777 context->set_global_object(previous->global_object());
785 isolate()->heap()->AllocateStruct(type),
790 Handle<CodeCache> Factory::NewCodeCache() {
791 Handle<CodeCache> code_cache =
799 Handle<AliasedArgumentsEntry> Factory::NewAliasedArgumentsEntry(
800 int aliased_context_slot) {
803 entry->set_aliased_context_slot(aliased_context_slot);
808 Handle<DeclaredAccessorDescriptor> Factory::NewDeclaredAccessorDescriptor() {
814 Handle<DeclaredAccessorInfo> Factory::NewDeclaredAccessorInfo() {
815 Handle<DeclaredAccessorInfo> info =
823 Handle<ExecutableAccessorInfo> Factory::NewExecutableAccessorInfo() {
824 Handle<ExecutableAccessorInfo> info =
832 Handle<Script> Factory::NewScript(Handle<String> source) {
834 Heap* heap = isolate()->heap();
835 int id = heap->last_script_id()->value() + 1;
840 Handle<Foreign> wrapper = NewForeign(0,
TENURED);
842 script->set_source(*source);
843 script->set_name(heap->undefined_value());
847 script->set_context_data(heap->undefined_value());
849 script->set_wrapper(*wrapper);
850 script->set_line_ends(heap->undefined_value());
851 script->set_eval_from_shared(heap->undefined_value());
852 script->set_eval_from_instructions_offset(
Smi::FromInt(0));
861 isolate()->heap()->AllocateForeign(addr, pretenure),
866 Handle<Foreign> Factory::NewForeign(
const AccessorDescriptor* desc) {
871 Handle<ByteArray> Factory::NewByteArray(
int length,
PretenureFlag pretenure) {
875 isolate()->heap()->AllocateByteArray(length, pretenure),
880 Handle<ExternalArray> Factory::NewExternalArray(
int length,
882 void* external_pointer,
887 isolate()->heap()->AllocateExternalArray(length,
895 Handle<FixedTypedArrayBase> Factory::NewFixedTypedArray(
902 isolate()->heap()->AllocateFixedTypedArray(length,
905 FixedTypedArrayBase);
909 Handle<Cell> Factory::NewCell(Handle<Object> value) {
913 isolate()->heap()->AllocateCell(*value),
918 Handle<PropertyCell> Factory::NewPropertyCellWithHole() {
921 isolate()->heap()->AllocatePropertyCell(),
926 Handle<PropertyCell> Factory::NewPropertyCell(Handle<Object> value) {
928 Handle<PropertyCell> cell = NewPropertyCellWithHole();
934 Handle<AllocationSite> Factory::NewAllocationSite() {
935 Handle<Map>
map = allocation_site_map();
940 site->set_weak_next(isolate()->heap()->allocation_sites_list());
941 isolate()->heap()->set_allocation_sites_list(*site);
951 isolate()->heap()->AllocateMap(type, instance_size, elements_kind),
956 Handle<JSObject> Factory::CopyJSObject(Handle<JSObject>
object) {
958 isolate()->heap()->CopyJSObject(*
object,
NULL),
963 Handle<JSObject> Factory::CopyJSObjectWithAllocationSite(
964 Handle<JSObject>
object,
965 Handle<AllocationSite> site) {
967 isolate()->heap()->CopyJSObject(
969 site.is_null() ?
NULL : *site),
974 Handle<FixedArray> Factory::CopyFixedArrayWithMap(Handle<FixedArray> array,
977 isolate()->heap()->CopyFixedArrayWithMap(*array, *
map),
982 Handle<FixedArray> Factory::CopyFixedArray(Handle<FixedArray> array) {
984 isolate()->heap()->CopyFixedArray(*array),
989 Handle<FixedArray> Factory::CopyAndTenureFixedCOWArray(
990 Handle<FixedArray> array) {
991 DCHECK(isolate()->heap()->InNewSpace(*array));
993 isolate()->heap()->CopyAndTenureFixedCOWArray(*array),
998 Handle<FixedDoubleArray> Factory::CopyFixedDoubleArray(
999 Handle<FixedDoubleArray> array) {
1001 isolate()->heap()->CopyFixedDoubleArray(*array),
1006 Handle<ConstantPoolArray> Factory::CopyConstantPoolArray(
1007 Handle<ConstantPoolArray> array) {
1009 isolate()->heap()->CopyConstantPoolArray(*array),
1014 Handle<Object> Factory::NewNumber(
double value,
1021 int int_value =
FastD2I(value);
1027 return NewHeapNumber(value,
IMMUTABLE, pretenure);
1031 Handle<Object> Factory::NewNumberFromInt(
int32_t value,
1039 Handle<Object> Factory::NewNumberFromUint(
uint32_t value,
1049 Handle<HeapNumber> Factory::NewHeapNumber(
double value,
1054 isolate()->heap()->AllocateHeapNumber(value,
mode, pretenure),
1059 MaybeHandle<Object> Factory::NewTypeError(
const char* message,
1060 Vector<Handle<Object> > args) {
1061 return NewError(
"MakeTypeError", message, args);
1065 MaybeHandle<Object> Factory::NewTypeError(Handle<String> message) {
1066 return NewError(
"$TypeError", message);
1070 MaybeHandle<Object> Factory::NewRangeError(
const char* message,
1071 Vector<Handle<Object> > args) {
1072 return NewError(
"MakeRangeError", message, args);
1076 MaybeHandle<Object> Factory::NewRangeError(Handle<String> message) {
1077 return NewError(
"$RangeError", message);
1081 MaybeHandle<Object> Factory::NewSyntaxError(
const char* message,
1082 Handle<JSArray> args) {
1083 return NewError(
"MakeSyntaxError", message, args);
1087 MaybeHandle<Object> Factory::NewSyntaxError(Handle<String> message) {
1088 return NewError(
"$SyntaxError", message);
1092 MaybeHandle<Object> Factory::NewReferenceError(
const char* message,
1093 Vector<Handle<Object> > args) {
1094 return NewError(
"MakeReferenceError", message, args);
1098 MaybeHandle<Object> Factory::NewReferenceError(
const char* message,
1099 Handle<JSArray> args) {
1100 return NewError(
"MakeReferenceError", message, args);
1104 MaybeHandle<Object> Factory::NewReferenceError(Handle<String> message) {
1105 return NewError(
"$ReferenceError", message);
1109 MaybeHandle<Object> Factory::NewError(
const char* maker,
const char* message,
1110 Vector<Handle<Object> > args) {
1113 Handle<FixedArray> array = NewFixedArray(args.length());
1114 for (
int i = 0;
i < args.length();
i++) {
1115 array->set(
i, *args[
i]);
1117 Handle<JSArray>
object = NewJSArrayWithElements(array);
1118 Handle<Object> result;
1120 NewError(maker, message,
object),
Object);
1121 return result.EscapeFrom(&scope);
1125 MaybeHandle<Object> Factory::NewEvalError(
const char* message,
1126 Vector<Handle<Object> > args) {
1127 return NewError(
"MakeEvalError", message, args);
1131 MaybeHandle<Object> Factory::NewError(
const char* message,
1132 Vector<Handle<Object> > args) {
1133 return NewError(
"MakeError", message, args);
1137 Handle<String> Factory::EmergencyNewError(
const char* message,
1138 Handle<JSArray> args) {
1142 char* p = &buffer[0];
1149 for (
int i = 0;
i < Smi::cast(args->length())->value();
i++) {
1156 SmartArrayPointer<char> arg = arg_str->ToCString();
1157 Vector<char> v2(p,
static_cast<int>(
space));
1173 MaybeHandle<Object> Factory::NewError(
const char* maker,
const char* message,
1174 Handle<JSArray> args) {
1175 Handle<String> make_str = InternalizeUtf8String(maker);
1177 isolate()->js_builtins_object(), make_str).ToHandleChecked();
1180 if (!fun_obj->IsJSFunction()) {
1181 return EmergencyNewError(message, args);
1184 Handle<Object> message_obj = InternalizeUtf8String(message);
1185 Handle<Object> argv[] = { message_obj, args };
1189 Handle<Object> result;
1190 MaybeHandle<Object> exception;
1191 if (!Execution::TryCall(fun,
1192 isolate()->js_builtins_object(),
1195 &exception).ToHandle(&result)) {
1202 MaybeHandle<Object> Factory::NewError(Handle<String> message) {
1203 return NewError(
"$Error", message);
1207 MaybeHandle<Object> Factory::NewError(
const char* constructor,
1208 Handle<String> message) {
1209 Handle<String> constr = InternalizeUtf8String(constructor);
1211 isolate()->js_builtins_object(), constr).ToHandleChecked());
1212 Handle<Object> argv[] = { message };
1216 Handle<Object> result;
1217 MaybeHandle<Object> exception;
1218 if (!Execution::TryCall(fun,
1219 isolate()->js_builtins_object(),
1222 &exception).ToHandle(&result)) {
1229 void Factory::InitializeFunction(Handle<JSFunction>
function,
1230 Handle<SharedFunctionInfo> info,
1231 Handle<Context> context) {
1232 function->initialize_properties();
1233 function->initialize_elements();
1234 function->set_shared(*info);
1235 function->set_code(info->code());
1236 function->set_context(*context);
1237 function->set_prototype_or_initial_map(*the_hole_value());
1238 function->set_literals_or_bindings(*empty_fixed_array());
1239 function->set_next_function_link(*undefined_value());
1244 Handle<SharedFunctionInfo> info,
1245 Handle<Context> context,
1248 Handle<JSFunction> result = New<JSFunction>(
map,
space);
1249 InitializeFunction(result, info, context);
1255 Handle<String>
name,
1256 MaybeHandle<Code> code) {
1257 Handle<Context> context(isolate()->native_context());
1258 Handle<SharedFunctionInfo> info = NewSharedFunctionInfo(
name, code);
1260 (
map.is_identical_to(isolate()->sloppy_function_map()) ||
1261 map.is_identical_to(
1262 isolate()->sloppy_function_without_prototype_map()) ||
1263 map.is_identical_to(
1264 isolate()->sloppy_function_with_readonly_prototype_map())));
1271 isolate()->sloppy_function_map(),
name, MaybeHandle<Code>());
1275 Handle<JSFunction> Factory::NewFunctionWithoutPrototype(Handle<String>
name,
1276 Handle<Code> code) {
1278 isolate()->sloppy_function_without_prototype_map(),
name, code);
1284 Handle<Object> prototype,
1287 ? isolate()->sloppy_function_with_readonly_prototype_map()
1288 : isolate()->sloppy_function_map();
1290 result->set_prototype_or_initial_map(*prototype);
1297 Handle<Object> prototype,
1307 Handle<Map> initial_map = NewMap(type, instance_size, elements_kind);
1308 if (prototype->IsTheHole() && !function->shared()->is_generator()) {
1309 prototype = NewFunctionPrototype(
function);
1322 int instance_size) {
1323 return NewFunction(
name, code, the_hole_value(), type, instance_size);
1327 Handle<JSObject> Factory::NewFunctionPrototype(Handle<JSFunction>
function) {
1330 Handle<Context> native_context(function->context()->native_context());
1331 Handle<Map> new_map;
1332 if (function->shared()->is_generator()) {
1335 new_map =
handle(native_context->generator_object_prototype_map());
1339 Handle<JSFunction> object_function(native_context->object_function());
1340 DCHECK(object_function->has_initial_map());
1341 new_map =
handle(object_function->initial_map());
1344 DCHECK(!new_map->is_prototype_map());
1345 Handle<JSObject> prototype = NewJSObjectFromMap(new_map);
1347 if (!function->shared()->is_generator()) {
1355 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo(
1356 Handle<SharedFunctionInfo> info,
1357 Handle<Context> context,
1360 Handle<Map>
map(Map::cast(context->native_context()->get(map_index)));
1361 Handle<JSFunction> result =
NewFunction(
map, info, context, pretenure);
1363 if (info->ic_age() != isolate()->heap()->global_ic_age()) {
1364 info->ResetForNewContext(isolate()->heap()->global_ic_age());
1367 int index = info->SearchOptimizedCodeMap(context->native_context(),
1369 if (!info->bound() && index < 0) {
1370 int number_of_literals = info->num_literals();
1371 Handle<FixedArray>
literals = NewFixedArray(number_of_literals, pretenure);
1372 if (number_of_literals > 0) {
1377 context->native_context());
1384 FixedArray*
literals = info->GetLiteralsFromOptimizedCodeMap(index);
1386 Code* code = info->GetCodeFromOptimizedCodeMap(index);
1387 DCHECK(!code->marked_for_deoptimization());
1388 result->ReplaceCode(code);
1392 if (isolate()->use_crankshaft() &&
1394 result->is_compiled() &&
1395 !info->is_toplevel() &&
1396 info->allows_lazy_compilation() &&
1397 !info->optimization_disabled() &&
1398 !isolate()->DebuggerHasBreakPoints()) {
1399 result->MarkForOptimization();
1405 Handle<ScopeInfo> Factory::NewScopeInfo(
int length) {
1406 Handle<FixedArray> array = NewFixedArray(length,
TENURED);
1407 array->set_map_no_write_barrier(*scope_info_map());
1413 Handle<JSObject> Factory::NewExternal(
void* value) {
1414 Handle<Foreign> foreign = NewForeign(
static_cast<Address>(value));
1415 Handle<JSObject> external = NewJSObjectFromMap(external_map());
1416 external->SetInternalField(0, *foreign);
1421 Handle<Code> Factory::NewCodeRaw(
int object_size,
bool immovable) {
1423 isolate()->heap()->AllocateCode(object_size, immovable),
1428 Handle<Code> Factory::NewCode(
const CodeDesc& desc,
1430 Handle<Object> self_ref,
1433 int prologue_offset,
1435 Handle<ByteArray> reloc_info = NewByteArray(desc.reloc_size,
TENURED);
1436 Handle<ConstantPoolArray> constant_pool =
1437 desc.origin->NewConstantPool(isolate());
1443 Handle<Code> code = NewCodeRaw(obj_size, immovable);
1445 !isolate()->code_range()->valid() ||
1446 isolate()->code_range()->contains(code->address()));
1452 code->set_ic_age(isolate()->heap()->global_ic_age());
1453 code->set_instruction_size(desc.instr_size);
1454 code->set_relocation_info(*reloc_info);
1455 code->set_flags(
flags);
1456 code->set_raw_kind_specific_flags1(0);
1457 code->set_raw_kind_specific_flags2(0);
1458 code->set_is_crankshafted(crankshafted);
1461 code->set_next_code_link(*undefined_value());
1463 code->set_prologue_offset(prologue_offset);
1464 if (code->kind() == Code::OPTIMIZED_FUNCTION) {
1465 code->set_marked_for_deoptimization(
false);
1469 DCHECK(code->kind() == Code::FUNCTION);
1470 code->set_has_debug_break_slots(
true);
1473 desc.origin->PopulateConstantPool(*constant_pool);
1474 code->set_constant_pool(*constant_pool);
1478 if (!self_ref.is_null()) *(self_ref.location()) = *code;
1485 code->CopyFrom(desc);
1488 if (FLAG_verify_heap) code->ObjectVerify();
1494 Handle<Code> Factory::CopyCode(Handle<Code> code) {
1496 isolate()->heap()->CopyCode(*code),
1501 Handle<Code> Factory::CopyCode(Handle<Code> code, Vector<byte> reloc_info) {
1503 isolate()->heap()->CopyCode(*code, reloc_info),
1508 Handle<JSObject> Factory::NewJSObject(Handle<JSFunction> constructor,
1513 isolate()->heap()->AllocateJSObject(*constructor, pretenure), JSObject);
1517 Handle<JSObject> Factory::NewJSObjectWithMemento(
1518 Handle<JSFunction> constructor,
1519 Handle<AllocationSite> site) {
1523 isolate()->heap()->AllocateJSObject(*constructor,
NOT_TENURED, *site),
1528 Handle<JSModule> Factory::NewJSModule(Handle<Context> context,
1529 Handle<ScopeInfo> scope_info) {
1533 Handle<JSModule> module =
1535 module->set_context(*context);
1536 module->set_scope_info(*scope_info);
1541 Handle<GlobalObject> Factory::NewGlobalObject(Handle<JSFunction> constructor) {
1542 DCHECK(constructor->has_initial_map());
1543 Handle<Map>
map(constructor->initial_map());
1549 DCHECK(
map->NextFreePropertyIndex() == 0);
1553 DCHECK(
map->unused_property_fields() == 0);
1554 DCHECK(
map->inobject_properties() == 0);
1562 int at_least_space_for =
map->NumberOfOwnDescriptors() * 2 + initial_size;
1563 Handle<NameDictionary> dictionary =
1568 Handle<DescriptorArray> descs(
map->instance_descriptors());
1569 for (
int i = 0;
i <
map->NumberOfOwnDescriptors();
i++) {
1570 PropertyDetails details = descs->GetDetails(
i);
1572 PropertyDetails d = PropertyDetails(details.attributes(),
CALLBACKS,
i + 1);
1573 Handle<Name>
name(descs->GetKey(
i));
1574 Handle<Object> value(descs->GetCallbacksObject(
i), isolate());
1575 Handle<PropertyCell> cell = NewPropertyCell(value);
1582 isolate()->heap()->InitializeJSObjectFromMap(*global, *dictionary, *
map);
1586 new_map->set_dictionary_map(
true);
1589 global->set_map(*new_map);
1590 global->set_properties(*dictionary);
1593 DCHECK(global->IsGlobalObject() && !global->HasFastProperties());
1598 Handle<JSObject> Factory::NewJSObjectFromMap(
1602 Handle<AllocationSite> allocation_site) {
1605 isolate()->heap()->AllocateJSObjectFromMap(
1609 allocation_site.is_null() ?
NULL : *allocation_site),
1614 Handle<JSArray> Factory::NewJSArray(
ElementsKind elements_kind,
1616 Context* native_context = isolate()->context()->native_context();
1617 JSFunction* array_function = native_context->array_function();
1618 Map*
map = array_function->initial_map();
1619 Map* transition_map = isolate()->get_initial_js_array_map(elements_kind);
1620 if (transition_map !=
NULL)
map = transition_map;
1625 Handle<JSArray> Factory::NewJSArray(
ElementsKind elements_kind,
1630 Handle<JSArray> array = NewJSArray(elements_kind, pretenure);
1631 NewJSArrayStorage(array, length, capacity,
mode);
1636 Handle<JSArray> Factory::NewJSArrayWithElements(Handle<FixedArrayBase> elements,
1640 DCHECK(length <= elements->length());
1641 Handle<JSArray> array = NewJSArray(elements_kind, pretenure);
1643 array->set_elements(*elements);
1650 void Factory::NewJSArrayStorage(Handle<JSArray> array,
1654 DCHECK(capacity >= length);
1656 if (capacity == 0) {
1658 array->set_elements(*empty_fixed_array());
1662 Handle<FixedArrayBase> elms;
1666 elms = NewFixedDoubleArray(capacity);
1669 elms = NewFixedDoubleArrayWithHoles(capacity);
1674 elms = NewUninitializedFixedArray(capacity);
1677 elms = NewFixedArrayWithHoles(capacity);
1681 array->set_elements(*elms);
1686 Handle<JSGeneratorObject> Factory::NewJSGeneratorObject(
1687 Handle<JSFunction>
function) {
1688 DCHECK(function->shared()->is_generator());
1690 Handle<Map>
map(function->initial_map());
1694 isolate()->heap()->AllocateJSObjectFromMap(*
map),
1699 Handle<JSArrayBuffer> Factory::NewJSArrayBuffer() {
1700 Handle<JSFunction> array_buffer_fun(
1701 isolate()->native_context()->array_buffer_fun());
1704 isolate()->heap()->AllocateJSObject(*array_buffer_fun),
1709 Handle<JSDataView> Factory::NewJSDataView() {
1710 Handle<JSFunction> data_view_fun(
1711 isolate()->native_context()->data_view_fun());
1714 isolate()->heap()->AllocateJSObject(*data_view_fun),
1723 #define TYPED_ARRAY_FUN(Type, type, TYPE, ctype, size) \
1724 case kExternal##Type##Array: \
1725 return native_context->type##_array_fun();
1728 #undef TYPED_ARRAY_FUN
1742 isolate()->heap()->AllocateJSObject(*typed_array_fun_handle),
1747 Handle<JSProxy> Factory::NewJSProxy(Handle<Object> handler,
1748 Handle<Object> prototype) {
1753 map->set_prototype(*prototype);
1758 result->set_handler(*handler);
1764 Handle<JSProxy> Factory::NewJSFunctionProxy(Handle<Object> handler,
1765 Handle<Object> call_trap,
1766 Handle<Object> construct_trap,
1767 Handle<Object> prototype) {
1772 map->set_prototype(*prototype);
1775 Handle<JSFunctionProxy> result = New<JSFunctionProxy>(
map,
NEW_SPACE);
1777 result->set_handler(*handler);
1779 result->set_call_trap(*call_trap);
1780 result->set_construct_trap(*construct_trap);
1785 void Factory::ReinitializeJSProxy(Handle<JSProxy> proxy,
InstanceType type,
1791 Handle<Map>
map = NewMap(type,
size);
1794 int size_difference = proxy->map()->instance_size() -
map->instance_size();
1795 DCHECK(size_difference >= 0);
1797 map->set_prototype(proxy->map()->prototype());
1800 int prop_size =
map->InitialPropertiesLength();
1801 Handle<FixedArray> properties = NewFixedArray(prop_size,
TENURED);
1803 Heap* heap = isolate()->heap();
1804 MaybeHandle<SharedFunctionInfo> shared;
1808 Handle<String>
name = InternalizeStringWithKey(&key);
1809 shared = NewSharedFunctionInfo(
name, MaybeHandle<Code>());
1817 if (size_difference > 0) {
1818 Address address = proxy->address();
1819 heap->CreateFillerObjectAt(address +
map->instance_size(), size_difference);
1824 proxy->synchronized_set_map(*
map);
1828 heap->InitializeJSObjectFromMap(*jsobj, *properties, *
map);
1833 Handle<Context> context(isolate()->native_context());
1837 map->set_function_with_prototype(
true);
1839 InitializeFunction(js_function, shared.ToHandleChecked(), context);
1842 map->set_constructor(context->object_function());
1847 void Factory::ReinitializeJSGlobalProxy(Handle<JSGlobalProxy>
object,
1848 Handle<JSFunction> constructor) {
1849 DCHECK(constructor->has_initial_map());
1850 Handle<Map>
map(constructor->initial_map(), isolate());
1853 Handle<Object> hash(object->hash(), isolate());
1857 DCHECK(
map->instance_size() == object->map()->instance_size());
1858 DCHECK(
map->instance_type() == object->map()->instance_type());
1861 int prop_size =
map->InitialPropertiesLength();
1862 Handle<FixedArray> properties = NewFixedArray(prop_size,
TENURED);
1869 object->synchronized_set_map(*
map);
1871 Heap* heap = isolate()->heap();
1873 heap->InitializeJSObjectFromMap(*
object, *properties, *
map);
1876 object->set_hash(*hash);
1880 void Factory::BecomeJSObject(Handle<JSProxy> proxy) {
1885 void Factory::BecomeJSFunction(Handle<JSProxy> proxy) {
1890 Handle<TypeFeedbackVector> Factory::NewTypeFeedbackVector(
int slot_count) {
1892 DCHECK_EQ(isolate()->heap()->uninitialized_symbol(),
1895 if (slot_count == 0) {
1900 isolate()->heap()->AllocateFixedArrayWithFiller(
1907 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo(
1909 Handle<Code> code, Handle<ScopeInfo> scope_info,
1912 Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(
name, code);
1913 shared->set_scope_info(*scope_info);
1915 shared->set_kind(kind);
1916 int literals_array_size = number_of_literals;
1920 if (number_of_literals > 0) {
1923 shared->set_num_literals(literals_array_size);
1925 shared->set_instance_class_name(isolate()->heap()->Generator_string());
1926 shared->DisableOptimization(kGenerator);
1932 Handle<JSMessageObject> Factory::NewJSMessageObject(
1933 Handle<String> type,
1934 Handle<JSArray> arguments,
1937 Handle<Object> script,
1938 Handle<Object> stack_frames) {
1939 Handle<Map>
map = message_object_map();
1940 Handle<JSMessageObject> message = New<JSMessageObject>(
map,
NEW_SPACE);
1942 message->initialize_elements();
1944 message->set_type(*type);
1945 message->set_arguments(*arguments);
1946 message->set_start_position(start_position);
1947 message->set_end_position(end_position);
1948 message->set_script(*script);
1949 message->set_stack_frames(*stack_frames);
1954 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo(
1955 Handle<String>
name,
1956 MaybeHandle<Code> maybe_code) {
1957 Handle<Map>
map = shared_function_info_map();
1958 Handle<SharedFunctionInfo> share = New<SharedFunctionInfo>(
map,
1962 share->set_name(*
name);
1964 if (!maybe_code.ToHandle(&code)) {
1965 code =
handle(isolate()->builtins()->builtin(Builtins::kIllegal));
1967 share->set_code(*code);
1970 Code* construct_stub =
1971 isolate()->builtins()->builtin(Builtins::kJSConstructStubGeneric);
1972 share->set_construct_stub(construct_stub);
1973 share->set_instance_class_name(*Object_string());
1978 Handle<TypeFeedbackVector>
feedback_vector = NewTypeFeedbackVector(0);
1980 share->set_profiler_ticks(0);
1981 share->set_ast_node_count(0);
1982 share->set_counters(0);
1985 share->set_length(0);
1986 share->set_formal_parameter_count(0);
1987 share->set_expected_nof_properties(0);
1988 share->set_num_literals(0);
1989 share->set_start_position_and_type(0);
1990 share->set_end_position(0);
1991 share->set_function_token_position(0);
1993 share->set_compiler_hints(0);
1994 share->set_opt_count_and_bailout_reason(0);
2002 int mask = (cache->length() >> 1) - 1;
2003 if (number->IsSmi()) {
2008 (
static_cast<int>(rep.
bits) ^
static_cast<int>(rep.
bits >> 32)) & mask;
2016 Object* key = number_string_cache()->get(hash * 2);
2017 if (key == *number || (key->IsHeapNumber() && number->IsHeapNumber() &&
2018 key->Number() == number->Number())) {
2020 String::cast(number_string_cache()->get(hash * 2 + 1)), isolate());
2022 return undefined_value();
2026 void Factory::SetNumberStringCache(Handle<Object> number,
2027 Handle<String>
string) {
2029 if (number_string_cache()->get(hash * 2) != *undefined_value()) {
2030 int full_size = isolate()->heap()->FullSizeNumberStringCacheLength();
2031 if (number_string_cache()->length() != full_size) {
2037 DCHECK(!isolate()->serializer_enabled() || FLAG_extra_code !=
NULL);
2038 Handle<FixedArray> new_cache = NewFixedArray(full_size,
TENURED);
2039 isolate()->heap()->set_number_string_cache(*new_cache);
2043 number_string_cache()->set(hash * 2, *number);
2044 number_string_cache()->set(hash * 2 + 1, *
string);
2048 Handle<String> Factory::NumberToString(Handle<Object> number,
2049 bool check_number_string_cache) {
2050 isolate()->counters()->number_to_string_runtime()->Increment();
2051 if (check_number_string_cache) {
2052 Handle<Object> cached = GetNumberStringCache(number);
2057 Vector<char> buffer(arr,
arraysize(arr));
2059 if (number->IsSmi()) {
2069 Handle<String> js_string = NewStringFromAsciiChecked(str,
TENURED);
2070 SetNumberStringCache(number, js_string);
2075 Handle<DebugInfo> Factory::NewDebugInfo(Handle<SharedFunctionInfo> shared) {
2077 Handle<Code> code(shared->code());
2081 Handle<Code> original_code(*Factory::CopyCode(code));
2086 Handle<FixedArray> break_points(
2092 Handle<DebugInfo> debug_info =
2094 debug_info->set_shared(*shared);
2095 debug_info->set_original_code(*original_code);
2096 debug_info->set_code(*code);
2097 debug_info->set_break_points(*break_points);
2100 shared->set_debug_info(*debug_info);
2106 Handle<JSObject> Factory::NewArgumentsObject(Handle<JSFunction> callee,
2108 bool strict_mode_callee = callee->shared()->strict_mode() ==
STRICT;
2109 Handle<Map>
map = strict_mode_callee ? isolate()->strict_arguments_map()
2110 : isolate()->sloppy_arguments_map();
2112 AllocationSiteUsageContext context(isolate(), Handle<AllocationSite>(),
2114 DCHECK(!isolate()->has_pending_exception());
2115 Handle<JSObject> result = NewJSObjectFromMap(
map);
2118 if (!strict_mode_callee) {
2125 Handle<JSFunction> Factory::CreateApiFunction(
2126 Handle<FunctionTemplateInfo> obj,
2127 Handle<Object> prototype,
2128 ApiInstanceType instance_type) {
2129 Handle<Code> code = isolate()->builtins()->HandleApiCall();
2130 Handle<Code> construct_stub = isolate()->builtins()->JSConstructStubApi();
2132 Handle<JSFunction> result;
2133 if (obj->remove_prototype()) {
2134 result = NewFunctionWithoutPrototype(empty_string(), code);
2137 if (!obj->instance_template()->IsUndefined()) {
2138 Handle<ObjectTemplateInfo> instance_template =
2139 Handle<ObjectTemplateInfo>(
2140 ObjectTemplateInfo::cast(obj->instance_template()));
2142 Smi::cast(instance_template->internal_field_count())->value();
2149 switch (instance_type) {
2150 case JavaScriptObjectType:
2154 case GlobalObjectType:
2158 case GlobalProxyType:
2168 result =
NewFunction(empty_string(), code, prototype, type,
2169 instance_size, obj->read_only_prototype());
2172 result->shared()->set_length(obj->length());
2173 Handle<Object> class_name(obj->class_name(), isolate());
2174 if (class_name->IsString()) {
2175 result->shared()->set_instance_class_name(*class_name);
2176 result->shared()->set_name(*class_name);
2178 result->shared()->set_function_data(*obj);
2179 result->shared()->set_construct_stub(*construct_stub);
2180 result->shared()->DontAdaptArguments();
2182 if (obj->remove_prototype()) {
2183 DCHECK(result->shared()->IsApiFunction());
2184 DCHECK(!result->has_initial_map());
2185 DCHECK(!result->has_prototype());
2189 if (prototype->IsTheHole()) {
2191 LookupIterator it(
handle(JSObject::cast(result->prototype())),
2192 constructor_string(),
2193 LookupIterator::OWN_SKIP_INTERCEPTOR);
2196 DCHECK(maybe_prop.ToHandleChecked().is_identical_to(result));
2200 constructor_string(), result,
DONT_ENUM);
2206 Handle<Map>
map(result->initial_map());
2209 if (obj->undetectable()) {
2210 map->set_is_undetectable();
2214 if (obj->hidden_prototype()) {
2215 map->set_is_hidden_prototype();
2219 if (obj->needs_access_check()) {
2220 map->set_is_access_check_needed(
true);
2224 if (!obj->named_property_handler()->IsUndefined()) {
2225 map->set_has_named_interceptor();
2227 if (!obj->indexed_property_handler()->IsUndefined()) {
2228 map->set_has_indexed_interceptor();
2232 if (!obj->instance_call_handler()->IsUndefined()) {
2233 map->set_has_instance_call_handler();
2238 int max_number_of_additional_properties = 0;
2239 int max_number_of_static_properties = 0;
2240 FunctionTemplateInfo* info = *obj;
2242 if (!info->instance_template()->IsUndefined()) {
2244 ObjectTemplateInfo::cast(
2245 info->instance_template())->property_accessors();
2246 if (!props->IsUndefined()) {
2247 Handle<Object> props_handle(props, isolate());
2248 NeanderArray props_array(props_handle);
2249 max_number_of_additional_properties += props_array.length();
2252 if (!info->property_accessors()->IsUndefined()) {
2253 Object* props = info->property_accessors();
2254 if (!props->IsUndefined()) {
2255 Handle<Object> props_handle(props, isolate());
2256 NeanderArray props_array(props_handle);
2257 max_number_of_static_properties += props_array.length();
2260 Object* parent = info->parent_template();
2261 if (parent->IsUndefined())
break;
2262 info = FunctionTemplateInfo::cast(parent);
2268 int valid_descriptors = 0;
2269 Handle<FixedArray> array;
2270 if (max_number_of_static_properties > 0) {
2271 array = NewFixedArray(max_number_of_static_properties);
2276 if (!obj->instance_template()->IsUndefined()) {
2277 Handle<ObjectTemplateInfo> instance =
2278 Handle<ObjectTemplateInfo>(
2279 ObjectTemplateInfo::cast(obj->instance_template()), isolate());
2280 Handle<Object> props = Handle<Object>(instance->property_accessors(),
2282 if (!props->IsUndefined()) {
2287 if (!obj->property_accessors()->IsUndefined()) {
2288 Handle<Object> props = Handle<Object>(obj->property_accessors(),
2294 Handle<Object> parent = Handle<Object>(obj->parent_template(), isolate());
2295 if (parent->IsUndefined())
break;
2300 for (
int i = 0;
i < valid_descriptors;
i++) {
2301 Handle<AccessorInfo> accessor(AccessorInfo::cast(array->get(
i)));
2305 DCHECK(result->shared()->IsApiFunction());
2310 Handle<MapCache> Factory::AddToMapCache(Handle<Context> context,
2311 Handle<FixedArray>
keys,
2313 Handle<MapCache> map_cache =
handle(MapCache::cast(context->map_cache()));
2315 context->set_map_cache(*result);
2320 Handle<Map> Factory::ObjectLiteralMapFromCache(Handle<Context> context,
2321 Handle<FixedArray>
keys) {
2322 if (context->map_cache()->IsUndefined()) {
2325 context->set_map_cache(*new_cache);
2328 Handle<MapCache> cache =
2329 Handle<MapCache>(MapCache::cast(context->map_cache()));
2330 Handle<Object> result = Handle<Object>(cache->Lookup(*
keys), isolate());
2332 int length =
keys->length();
2335 Handle<Map>
map = length == 0
2336 ?
handle(context->object_function()->initial_map())
2337 : Map::Create(isolate(), length);
2338 AddToMapCache(context,
keys,
map);
2343 void Factory::SetRegExpAtomData(Handle<JSRegExp> regexp,
2345 Handle<String> source,
2346 JSRegExp::Flags
flags,
2347 Handle<Object> data) {
2354 regexp->set_data(*store);
2357 void Factory::SetRegExpIrregexpData(Handle<JSRegExp> regexp,
2359 Handle<String> source,
2360 JSRegExp::Flags
flags,
2361 int capture_count) {
2374 regexp->set_data(*store);
2379 MaybeHandle<FunctionTemplateInfo> Factory::ConfigureInstance(
2380 Handle<FunctionTemplateInfo> desc, Handle<JSObject> instance) {
2383 Handle<Object> instance_template(desc->instance_template(), isolate());
2384 if (!instance_template->IsUndefined()) {
2387 Execution::ConfigureInstance(isolate(), instance, instance_template),
2388 FunctionTemplateInfo);
2394 Handle<Object> Factory::GlobalConstantFor(Handle<String>
name) {
2402 Handle<Object> Factory::ToBoolean(
bool value) {
2403 return value ? true_value() : false_value();
A HandleScope which first allocates a handle in the current scope which will be later filled with the...
An object reference managed by the v8 garbage collector.
Isolate represents an isolated instance of the V8 engine.
A JavaScript object (ECMA-262, 4.3.3)
static int AppendUnique(Handle< Object > descriptors, Handle< FixedArray > array, int valid_descriptors)
static int SizeFor(int body_size)
static const int kMinLength
static int FunctionMapIndex(StrictMode strict_mode, FunctionKind kind)
Context * native_context()
static const int kEstimatedNofBreakPointsInFunction
static MUST_USE_RESULT Handle< NameDictionary > New(Isolate *isolate, int at_least_space_for, PretenureFlag pretenure=NOT_TENURED)
static MUST_USE_RESULT Handle< NameDictionary > Add(Handle< NameDictionary > dictionary, Handle< Name > key, Handle< Object > value, PropertyDetails details)
v8::String::ExternalOneByteStringResource Resource
v8::String::ExternalStringResource Resource
static Handle< T > cast(Handle< S > that)
static Handle< T > null()
static MUST_USE_RESULT Handle< MapCache > New(Isolate *isolate, int at_least_space_for, MinimumCapacity capacity_option=USE_DEFAULT_MINIMUM_CAPACITY, PretenureFlag pretenure=NOT_TENURED)
static const int kLiteralNativeContextIndex
static void SetInitialMap(Handle< JSFunction > function, Handle< Map > map, Handle< Object > prototype)
static void EnsureHasInitialMap(Handle< JSFunction > function)
static const int kLiteralsPrefixSize
static MUST_USE_RESULT MaybeHandle< Object > SetAccessor(Handle< JSObject > object, Handle< AccessorInfo > info)
static const int kHeaderSize
static void AddProperty(Handle< JSObject > object, Handle< Name > key, Handle< Object > value, PropertyAttributes attributes)
static void ValidateElements(Handle< JSObject > object)
static const int kIrregexpUC16CodeSavedIndex
static const int kUninitializedValue
static const int kIrregexpCaptureCountIndex
static const int kFlagsIndex
static const int kIrregexpUC16CodeIndex
static const int kAtomPatternIndex
static const int kIrregexpMaxRegisterCountIndex
static const int kTagIndex
static const int kIrregexpLatin1CodeIndex
static const int kSourceIndex
static const int kIrregexpDataSize
static const int kAtomDataSize
static const int kIrregexpLatin1CodeSavedIndex
static Handle< MapCache > Put(Handle< MapCache > map_cache, Handle< FixedArray > key, Handle< Map > value)
static void EnsureDescriptorSlack(Handle< Map > map, int slack)
static Handle< Map > CopyDropDescriptors(Handle< Map > map)
static void AppendCallbackDescriptors(Handle< Map > map, Handle< Object > descriptors)
static const int kEmptyHashField
static MUST_USE_RESULT MaybeHandle< Object > GetElement(Isolate *isolate, Handle< Object > object, uint32_t index)
static MUST_USE_RESULT MaybeHandle< Object > GetProperty(LookupIterator *it)
static MUST_USE_RESULT MaybeHandle< Object > SetProperty(Handle< Object > object, Handle< Name > key, Handle< Object > value, StrictMode strict_mode, StoreFromKeyed store_mode=MAY_BE_STORE_FROM_KEYED)
static void Initialize(Isolate *isolate, Handle< Oddball > oddball, const char *to_string, Handle< Object > to_number, byte kind)
static Handle< OrderedHashSet > Allocate(Isolate *isolate, int capacity, PretenureFlag pretenure=NOT_TENURED)
static void SetValueInferType(Handle< PropertyCell > cell, Handle< Object > value)
static ScopeInfo * Empty(Isolate *isolate)
static const int kMinLength
static const int kMaxValue
static Smi * FromInt(int value)
static bool IsValid(intptr_t value)
static Handle< String > LookupString(Isolate *isolate, Handle< String > key)
static Handle< String > LookupKey(Isolate *isolate, HashTableKey *key)
static MUST_USE_RESULT MaybeHandle< String > LookupTwoCharsStringIfExists(Isolate *isolate, uint16_t c1, uint16_t c2)
static void WriteToFlat(String *source, sinkchar *sink, int from, int to)
static int NonAsciiStart(const char *chars, int length)
static const uint32_t kMaxOneByteCharCodeU
static const int kMaxLength
static const uint32_t kMaxUtf16CodeUnitU
static Handle< String > Flatten(Handle< String > string, PretenureFlag pretenure=NOT_TENURED)
static bool IsOneByte(const uc16 *chars, int length)
bool Equals(String *other)
static Handle< Object > UninitializedSentinel(Isolate *isolate)
static Vector< T > cast(Vector< S > input)
#define TYPED_ARRAY_FUN(Type, type, TYPE, ctype, 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 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 literals(0o77, 0b11)") DEFINE_BOOL(harmony_object_literals
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 mode(MIPS only)") DEFINE_BOOL(enable_always_align_csp
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 keys(0 means random)" "(with snapshots this option cannot override the baked-in seed)") DEFINE_BOOL(profile_deserialization
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 space(in MBytes)
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 CALL_HEAP_FUNCTION(ISOLATE, FUNCTION_CALL, TYPE)
#define ASSIGN_RETURN_ON_EXCEPTION(isolate, dst, call, T)
#define RETURN_ON_EXCEPTION(isolate, call, T)
#define THROW_NEW_ERROR(isolate, call, T)
#define DCHECK(condition)
#define DCHECK_EQ(v1, v2)
static const size_t kBufferSize
bool IsPowerOfTwo32(uint32_t value)
IN DWORD64 OUT PDWORD64 OUT PIMAGEHLP_SYMBOL64 Symbol
Vector< const char > CStrVector(const char *data)
void CopyChars(sinkchar *dest, const sourcechar *src, int chars)
void StrNCpy(Vector< char > dest, const char *src, size_t n)
static bool Between(uint32_t character, uint32_t from, uint32_t to)
static Handle< String > MakeOrFindTwoCharacterString(Isolate *isolate, uint16_t c1, uint16_t c2)
bool IsValidFunctionKind(FunctionKind kind)
kSerializedDataOffset kPrototypeTemplateOffset kIndexedPropertyHandlerOffset kInstanceCallHandlerOffset internal_field_count
Handle< String > ConcatStringContent(Handle< StringType > result, Handle< String > first, Handle< String > second)
PerThreadAssertScopeDebugOnly< HEAP_ALLOCATION_ASSERT, false > DisallowHeapAllocation
static LifetimePosition Min(LifetimePosition a, LifetimePosition b)
bool IsFastSmiOrObjectElementsKind(ElementsKind kind)
bool IsGeneratorFunction(FunctionKind kind)
kSerializedDataOffset Object
@ DECLARED_ACCESSOR_INFO_TYPE
@ DECLARED_ACCESSOR_DESCRIPTOR_TYPE
@ JS_GENERATOR_OBJECT_TYPE
@ EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE
@ EXECUTABLE_ACCESSOR_INFO_TYPE
@ ALIASED_ARGUMENTS_ENTRY_TYPE
@ SHORT_EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE
@ EXTERNAL_ONE_BYTE_STRING_TYPE
@ SHORT_EXTERNAL_ONE_BYTE_STRING_TYPE
@ SHORT_EXTERNAL_STRING_TYPE
@ TYPE_FEEDBACK_INFO_TYPE
@ FAST_HOLEY_SMI_ELEMENTS
bool IsFastDoubleElementsKind(ElementsKind kind)
Handle< T > handle(T *t, Isolate *isolate)
const intptr_t kObjectAlignment
kFeedbackVectorOffset kHiddenPrototypeBit read_only_prototype
static void RoundUp(Vector< char > buffer, int *length, int *decimal_point)
static int NumberCacheHash(Handle< FixedArray > cache, Handle< Object > number)
STATIC_ASSERT(sizeof(CPURegister)==sizeof(Register))
const char * DoubleToCString(double v, Vector< char > buffer)
double FastUI2D(unsigned x)
static bool IsMinusZero(double value)
const char * IntToCString(int n, Vector< char > buffer)
ArrayStorageAllocationMode
@ INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE
@ DONT_INITIALIZE_ARRAY_ELEMENTS
PerThreadAssertScopeDebugOnly< DEFERRED_HANDLE_DEREFERENCE_ASSERT, true > AllowDeferredHandleDereference
static JSFunction * GetTypedArrayFun(ExternalArrayType type, Isolate *isolate)
Debugger support for the V8 JavaScript engine.
#define T(name, string, precedence)
#define STATIC_CHAR_VECTOR(x)