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

Side by Side Diff: src/factory.cc

Issue 430503007: Rename ASSERT* to DCHECK*. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE and fixes Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/factory.h ('k') | src/fast-dtoa.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/factory.h" 5 #include "src/factory.h"
6 6
7 #include "src/allocation-site-scopes.h" 7 #include "src/allocation-site-scopes.h"
8 #include "src/conversions.h" 8 #include "src/conversions.h"
9 #include "src/isolate-inl.h" 9 #include "src/isolate-inl.h"
10 #include "src/macro-assembler.h" 10 #include "src/macro-assembler.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 const char* to_string, 54 const char* to_string,
55 Handle<Object> to_number, 55 Handle<Object> to_number,
56 byte kind) { 56 byte kind) {
57 Handle<Oddball> oddball = New<Oddball>(map, OLD_POINTER_SPACE); 57 Handle<Oddball> oddball = New<Oddball>(map, OLD_POINTER_SPACE);
58 Oddball::Initialize(isolate(), oddball, to_string, to_number, kind); 58 Oddball::Initialize(isolate(), oddball, to_string, to_number, kind);
59 return oddball; 59 return oddball;
60 } 60 }
61 61
62 62
63 Handle<FixedArray> Factory::NewFixedArray(int size, PretenureFlag pretenure) { 63 Handle<FixedArray> Factory::NewFixedArray(int size, PretenureFlag pretenure) {
64 ASSERT(0 <= size); 64 DCHECK(0 <= size);
65 CALL_HEAP_FUNCTION( 65 CALL_HEAP_FUNCTION(
66 isolate(), 66 isolate(),
67 isolate()->heap()->AllocateFixedArray(size, pretenure), 67 isolate()->heap()->AllocateFixedArray(size, pretenure),
68 FixedArray); 68 FixedArray);
69 } 69 }
70 70
71 71
72 Handle<FixedArray> Factory::NewFixedArrayWithHoles(int size, 72 Handle<FixedArray> Factory::NewFixedArrayWithHoles(int size,
73 PretenureFlag pretenure) { 73 PretenureFlag pretenure) {
74 ASSERT(0 <= size); 74 DCHECK(0 <= size);
75 CALL_HEAP_FUNCTION( 75 CALL_HEAP_FUNCTION(
76 isolate(), 76 isolate(),
77 isolate()->heap()->AllocateFixedArrayWithFiller(size, 77 isolate()->heap()->AllocateFixedArrayWithFiller(size,
78 pretenure, 78 pretenure,
79 *the_hole_value()), 79 *the_hole_value()),
80 FixedArray); 80 FixedArray);
81 } 81 }
82 82
83 83
84 Handle<FixedArray> Factory::NewUninitializedFixedArray(int size) { 84 Handle<FixedArray> Factory::NewUninitializedFixedArray(int size) {
85 CALL_HEAP_FUNCTION( 85 CALL_HEAP_FUNCTION(
86 isolate(), 86 isolate(),
87 isolate()->heap()->AllocateUninitializedFixedArray(size), 87 isolate()->heap()->AllocateUninitializedFixedArray(size),
88 FixedArray); 88 FixedArray);
89 } 89 }
90 90
91 91
92 Handle<FixedArrayBase> Factory::NewFixedDoubleArray(int size, 92 Handle<FixedArrayBase> Factory::NewFixedDoubleArray(int size,
93 PretenureFlag pretenure) { 93 PretenureFlag pretenure) {
94 ASSERT(0 <= size); 94 DCHECK(0 <= size);
95 CALL_HEAP_FUNCTION( 95 CALL_HEAP_FUNCTION(
96 isolate(), 96 isolate(),
97 isolate()->heap()->AllocateUninitializedFixedDoubleArray(size, pretenure), 97 isolate()->heap()->AllocateUninitializedFixedDoubleArray(size, pretenure),
98 FixedArrayBase); 98 FixedArrayBase);
99 } 99 }
100 100
101 101
102 Handle<FixedArrayBase> Factory::NewFixedDoubleArrayWithHoles( 102 Handle<FixedArrayBase> Factory::NewFixedDoubleArrayWithHoles(
103 int size, 103 int size,
104 PretenureFlag pretenure) { 104 PretenureFlag pretenure) {
105 ASSERT(0 <= size); 105 DCHECK(0 <= size);
106 Handle<FixedArrayBase> array = NewFixedDoubleArray(size, pretenure); 106 Handle<FixedArrayBase> array = NewFixedDoubleArray(size, pretenure);
107 if (size > 0) { 107 if (size > 0) {
108 Handle<FixedDoubleArray> double_array = 108 Handle<FixedDoubleArray> double_array =
109 Handle<FixedDoubleArray>::cast(array); 109 Handle<FixedDoubleArray>::cast(array);
110 for (int i = 0; i < size; ++i) { 110 for (int i = 0; i < size; ++i) {
111 double_array->set_the_hole(i); 111 double_array->set_the_hole(i);
112 } 112 }
113 } 113 }
114 return array; 114 return array;
115 } 115 }
116 116
117 117
118 Handle<ConstantPoolArray> Factory::NewConstantPoolArray( 118 Handle<ConstantPoolArray> Factory::NewConstantPoolArray(
119 const ConstantPoolArray::NumberOfEntries& small) { 119 const ConstantPoolArray::NumberOfEntries& small) {
120 ASSERT(small.total_count() > 0); 120 DCHECK(small.total_count() > 0);
121 CALL_HEAP_FUNCTION( 121 CALL_HEAP_FUNCTION(
122 isolate(), 122 isolate(),
123 isolate()->heap()->AllocateConstantPoolArray(small), 123 isolate()->heap()->AllocateConstantPoolArray(small),
124 ConstantPoolArray); 124 ConstantPoolArray);
125 } 125 }
126 126
127 127
128 Handle<ConstantPoolArray> Factory::NewExtendedConstantPoolArray( 128 Handle<ConstantPoolArray> Factory::NewExtendedConstantPoolArray(
129 const ConstantPoolArray::NumberOfEntries& small, 129 const ConstantPoolArray::NumberOfEntries& small,
130 const ConstantPoolArray::NumberOfEntries& extended) { 130 const ConstantPoolArray::NumberOfEntries& extended) {
131 ASSERT(small.total_count() > 0); 131 DCHECK(small.total_count() > 0);
132 ASSERT(extended.total_count() > 0); 132 DCHECK(extended.total_count() > 0);
133 CALL_HEAP_FUNCTION( 133 CALL_HEAP_FUNCTION(
134 isolate(), 134 isolate(),
135 isolate()->heap()->AllocateExtendedConstantPoolArray(small, extended), 135 isolate()->heap()->AllocateExtendedConstantPoolArray(small, extended),
136 ConstantPoolArray); 136 ConstantPoolArray);
137 } 137 }
138 138
139 139
140 Handle<OrderedHashSet> Factory::NewOrderedHashSet() { 140 Handle<OrderedHashSet> Factory::NewOrderedHashSet() {
141 return OrderedHashSet::Allocate(isolate(), 4); 141 return OrderedHashSet::Allocate(isolate(), 4);
142 } 142 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 // since UTF8 is backwards compatible with ASCII. 239 // since UTF8 is backwards compatible with ASCII.
240 return NewStringFromOneByte(Vector<const uint8_t>::cast(string), pretenure); 240 return NewStringFromOneByte(Vector<const uint8_t>::cast(string), pretenure);
241 } 241 }
242 242
243 // Non-ASCII and we need to decode. 243 // Non-ASCII and we need to decode.
244 Access<UnicodeCache::Utf8Decoder> 244 Access<UnicodeCache::Utf8Decoder>
245 decoder(isolate()->unicode_cache()->utf8_decoder()); 245 decoder(isolate()->unicode_cache()->utf8_decoder());
246 decoder->Reset(string.start() + non_ascii_start, 246 decoder->Reset(string.start() + non_ascii_start,
247 length - non_ascii_start); 247 length - non_ascii_start);
248 int utf16_length = decoder->Utf16Length(); 248 int utf16_length = decoder->Utf16Length();
249 ASSERT(utf16_length > 0); 249 DCHECK(utf16_length > 0);
250 // Allocate string. 250 // Allocate string.
251 Handle<SeqTwoByteString> result; 251 Handle<SeqTwoByteString> result;
252 ASSIGN_RETURN_ON_EXCEPTION( 252 ASSIGN_RETURN_ON_EXCEPTION(
253 isolate(), result, 253 isolate(), result,
254 NewRawTwoByteString(non_ascii_start + utf16_length, pretenure), 254 NewRawTwoByteString(non_ascii_start + utf16_length, pretenure),
255 String); 255 String);
256 // Copy ascii portion. 256 // Copy ascii portion.
257 uint16_t* data = result->GetChars(); 257 uint16_t* data = result->GetChars();
258 const char* ascii_data = string.start(); 258 const char* ascii_data = string.start();
259 for (int i = 0; i < non_ascii_start; i++) { 259 for (int i = 0; i < non_ascii_start; i++) {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 return handle(String::cast(value), isolate()); 390 return handle(String::cast(value), isolate());
391 } 391 }
392 } 392 }
393 uint8_t buffer[1]; 393 uint8_t buffer[1];
394 buffer[0] = static_cast<uint8_t>(code); 394 buffer[0] = static_cast<uint8_t>(code);
395 Handle<String> result = 395 Handle<String> result =
396 InternalizeOneByteString(Vector<const uint8_t>(buffer, 1)); 396 InternalizeOneByteString(Vector<const uint8_t>(buffer, 1));
397 single_character_string_cache()->set(code, *result); 397 single_character_string_cache()->set(code, *result);
398 return result; 398 return result;
399 } 399 }
400 ASSERT(code <= String::kMaxUtf16CodeUnitU); 400 DCHECK(code <= String::kMaxUtf16CodeUnitU);
401 401
402 Handle<SeqTwoByteString> result = NewRawTwoByteString(1).ToHandleChecked(); 402 Handle<SeqTwoByteString> result = NewRawTwoByteString(1).ToHandleChecked();
403 result->SeqTwoByteStringSet(0, static_cast<uint16_t>(code)); 403 result->SeqTwoByteStringSet(0, static_cast<uint16_t>(code));
404 return result; 404 return result;
405 } 405 }
406 406
407 407
408 // Returns true for a character in a range. Both limits are inclusive. 408 // Returns true for a character in a range. Both limits are inclusive.
409 static inline bool Between(uint32_t character, uint32_t from, uint32_t to) { 409 static inline bool Between(uint32_t character, uint32_t from, uint32_t to) {
410 // This makes uses of the the unsigned wraparound. 410 // This makes uses of the the unsigned wraparound.
(...skipping 11 matching lines...) Expand all
422 if (StringTable::LookupTwoCharsStringIfExists(isolate, c1, c2). 422 if (StringTable::LookupTwoCharsStringIfExists(isolate, c1, c2).
423 ToHandle(&result)) { 423 ToHandle(&result)) {
424 return result; 424 return result;
425 } 425 }
426 } 426 }
427 427
428 // Now we know the length is 2, we might as well make use of that fact 428 // Now we know the length is 2, we might as well make use of that fact
429 // when building the new string. 429 // when building the new string.
430 if (static_cast<unsigned>(c1 | c2) <= String::kMaxOneByteCharCodeU) { 430 if (static_cast<unsigned>(c1 | c2) <= String::kMaxOneByteCharCodeU) {
431 // We can do this. 431 // We can do this.
432 ASSERT(IsPowerOf2(String::kMaxOneByteCharCodeU + 1)); // because of this. 432 DCHECK(IsPowerOf2(String::kMaxOneByteCharCodeU + 1)); // because of this.
433 Handle<SeqOneByteString> str = 433 Handle<SeqOneByteString> str =
434 isolate->factory()->NewRawOneByteString(2).ToHandleChecked(); 434 isolate->factory()->NewRawOneByteString(2).ToHandleChecked();
435 uint8_t* dest = str->GetChars(); 435 uint8_t* dest = str->GetChars();
436 dest[0] = static_cast<uint8_t>(c1); 436 dest[0] = static_cast<uint8_t>(c1);
437 dest[1] = static_cast<uint8_t>(c2); 437 dest[1] = static_cast<uint8_t>(c2);
438 return str; 438 return str;
439 } else { 439 } else {
440 Handle<SeqTwoByteString> str = 440 Handle<SeqTwoByteString> str =
441 isolate->factory()->NewRawTwoByteString(2).ToHandleChecked(); 441 isolate->factory()->NewRawTwoByteString(2).ToHandleChecked();
442 uc16* dest = str->GetChars(); 442 uc16* dest = str->GetChars();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 left->HasOnlyOneByteChars() && right->HasOnlyOneByteChars(); 492 left->HasOnlyOneByteChars() && right->HasOnlyOneByteChars();
493 if (is_one_byte_data_in_two_byte_string) { 493 if (is_one_byte_data_in_two_byte_string) {
494 isolate()->counters()->string_add_runtime_ext_to_ascii()->Increment(); 494 isolate()->counters()->string_add_runtime_ext_to_ascii()->Increment();
495 } 495 }
496 } 496 }
497 497
498 // If the resulting string is small make a flat string. 498 // If the resulting string is small make a flat string.
499 if (length < ConsString::kMinLength) { 499 if (length < ConsString::kMinLength) {
500 // Note that neither of the two inputs can be a slice because: 500 // Note that neither of the two inputs can be a slice because:
501 STATIC_ASSERT(ConsString::kMinLength <= SlicedString::kMinLength); 501 STATIC_ASSERT(ConsString::kMinLength <= SlicedString::kMinLength);
502 ASSERT(left->IsFlat()); 502 DCHECK(left->IsFlat());
503 ASSERT(right->IsFlat()); 503 DCHECK(right->IsFlat());
504 504
505 STATIC_ASSERT(ConsString::kMinLength <= String::kMaxLength); 505 STATIC_ASSERT(ConsString::kMinLength <= String::kMaxLength);
506 if (is_one_byte) { 506 if (is_one_byte) {
507 Handle<SeqOneByteString> result = 507 Handle<SeqOneByteString> result =
508 NewRawOneByteString(length).ToHandleChecked(); 508 NewRawOneByteString(length).ToHandleChecked();
509 DisallowHeapAllocation no_gc; 509 DisallowHeapAllocation no_gc;
510 uint8_t* dest = result->GetChars(); 510 uint8_t* dest = result->GetChars();
511 // Copy left part. 511 // Copy left part.
512 const uint8_t* src = left->IsExternalString() 512 const uint8_t* src = left->IsExternalString()
513 ? Handle<ExternalAsciiString>::cast(left)->GetChars() 513 ? Handle<ExternalAsciiString>::cast(left)->GetChars()
(...skipping 28 matching lines...) Expand all
542 return result; 542 return result;
543 } 543 }
544 544
545 545
546 Handle<String> Factory::NewProperSubString(Handle<String> str, 546 Handle<String> Factory::NewProperSubString(Handle<String> str,
547 int begin, 547 int begin,
548 int end) { 548 int end) {
549 #if VERIFY_HEAP 549 #if VERIFY_HEAP
550 if (FLAG_verify_heap) str->StringVerify(); 550 if (FLAG_verify_heap) str->StringVerify();
551 #endif 551 #endif
552 ASSERT(begin > 0 || end < str->length()); 552 DCHECK(begin > 0 || end < str->length());
553 553
554 str = String::Flatten(str); 554 str = String::Flatten(str);
555 555
556 int length = end - begin; 556 int length = end - begin;
557 if (length <= 0) return empty_string(); 557 if (length <= 0) return empty_string();
558 if (length == 1) { 558 if (length == 1) {
559 return LookupSingleCharacterStringFromCode(str->Get(begin)); 559 return LookupSingleCharacterStringFromCode(str->Get(begin));
560 } 560 }
561 if (length == 2) { 561 if (length == 2) {
562 // Optimization for 2-byte strings often used as keys in a decompression 562 // Optimization for 2-byte strings often used as keys in a decompression
(...skipping 23 matching lines...) Expand all
586 } 586 }
587 587
588 int offset = begin; 588 int offset = begin;
589 589
590 if (str->IsSlicedString()) { 590 if (str->IsSlicedString()) {
591 Handle<SlicedString> slice = Handle<SlicedString>::cast(str); 591 Handle<SlicedString> slice = Handle<SlicedString>::cast(str);
592 str = Handle<String>(slice->parent(), isolate()); 592 str = Handle<String>(slice->parent(), isolate());
593 offset += slice->offset(); 593 offset += slice->offset();
594 } 594 }
595 595
596 ASSERT(str->IsSeqString() || str->IsExternalString()); 596 DCHECK(str->IsSeqString() || str->IsExternalString());
597 Handle<Map> map = str->IsOneByteRepresentation() ? sliced_ascii_string_map() 597 Handle<Map> map = str->IsOneByteRepresentation() ? sliced_ascii_string_map()
598 : sliced_string_map(); 598 : sliced_string_map();
599 Handle<SlicedString> slice = New<SlicedString>(map, NEW_SPACE); 599 Handle<SlicedString> slice = New<SlicedString>(map, NEW_SPACE);
600 600
601 slice->set_hash_field(String::kEmptyHashField); 601 slice->set_hash_field(String::kEmptyHashField);
602 slice->set_length(length); 602 slice->set_length(length);
603 slice->set_parent(*str); 603 slice->set_parent(*str);
604 slice->set_offset(offset); 604 slice->set_offset(offset);
605 return slice; 605 return slice;
606 } 606 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 symbol->set_is_private(true); 661 symbol->set_is_private(true);
662 return symbol; 662 return symbol;
663 } 663 }
664 664
665 665
666 Handle<Context> Factory::NewNativeContext() { 666 Handle<Context> Factory::NewNativeContext() {
667 Handle<FixedArray> array = NewFixedArray(Context::NATIVE_CONTEXT_SLOTS); 667 Handle<FixedArray> array = NewFixedArray(Context::NATIVE_CONTEXT_SLOTS);
668 array->set_map_no_write_barrier(*native_context_map()); 668 array->set_map_no_write_barrier(*native_context_map());
669 Handle<Context> context = Handle<Context>::cast(array); 669 Handle<Context> context = Handle<Context>::cast(array);
670 context->set_js_array_maps(*undefined_value()); 670 context->set_js_array_maps(*undefined_value());
671 ASSERT(context->IsNativeContext()); 671 DCHECK(context->IsNativeContext());
672 return context; 672 return context;
673 } 673 }
674 674
675 675
676 Handle<Context> Factory::NewGlobalContext(Handle<JSFunction> function, 676 Handle<Context> Factory::NewGlobalContext(Handle<JSFunction> function,
677 Handle<ScopeInfo> scope_info) { 677 Handle<ScopeInfo> scope_info) {
678 Handle<FixedArray> array = 678 Handle<FixedArray> array =
679 NewFixedArray(scope_info->ContextLength(), TENURED); 679 NewFixedArray(scope_info->ContextLength(), TENURED);
680 array->set_map_no_write_barrier(*global_context_map()); 680 array->set_map_no_write_barrier(*global_context_map());
681 Handle<Context> context = Handle<Context>::cast(array); 681 Handle<Context> context = Handle<Context>::cast(array);
682 context->set_closure(*function); 682 context->set_closure(*function);
683 context->set_previous(function->context()); 683 context->set_previous(function->context());
684 context->set_extension(*scope_info); 684 context->set_extension(*scope_info);
685 context->set_global_object(function->context()->global_object()); 685 context->set_global_object(function->context()->global_object());
686 ASSERT(context->IsGlobalContext()); 686 DCHECK(context->IsGlobalContext());
687 return context; 687 return context;
688 } 688 }
689 689
690 690
691 Handle<Context> Factory::NewModuleContext(Handle<ScopeInfo> scope_info) { 691 Handle<Context> Factory::NewModuleContext(Handle<ScopeInfo> scope_info) {
692 Handle<FixedArray> array = 692 Handle<FixedArray> array =
693 NewFixedArray(scope_info->ContextLength(), TENURED); 693 NewFixedArray(scope_info->ContextLength(), TENURED);
694 array->set_map_no_write_barrier(*module_context_map()); 694 array->set_map_no_write_barrier(*module_context_map());
695 // Instance link will be set later. 695 // Instance link will be set later.
696 Handle<Context> context = Handle<Context>::cast(array); 696 Handle<Context> context = Handle<Context>::cast(array);
697 context->set_extension(Smi::FromInt(0)); 697 context->set_extension(Smi::FromInt(0));
698 return context; 698 return context;
699 } 699 }
700 700
701 701
702 Handle<Context> Factory::NewFunctionContext(int length, 702 Handle<Context> Factory::NewFunctionContext(int length,
703 Handle<JSFunction> function) { 703 Handle<JSFunction> function) {
704 ASSERT(length >= Context::MIN_CONTEXT_SLOTS); 704 DCHECK(length >= Context::MIN_CONTEXT_SLOTS);
705 Handle<FixedArray> array = NewFixedArray(length); 705 Handle<FixedArray> array = NewFixedArray(length);
706 array->set_map_no_write_barrier(*function_context_map()); 706 array->set_map_no_write_barrier(*function_context_map());
707 Handle<Context> context = Handle<Context>::cast(array); 707 Handle<Context> context = Handle<Context>::cast(array);
708 context->set_closure(*function); 708 context->set_closure(*function);
709 context->set_previous(function->context()); 709 context->set_previous(function->context());
710 context->set_extension(Smi::FromInt(0)); 710 context->set_extension(Smi::FromInt(0));
711 context->set_global_object(function->context()->global_object()); 711 context->set_global_object(function->context()->global_object());
712 return context; 712 return context;
713 } 713 }
714 714
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 Foreign); 842 Foreign);
843 } 843 }
844 844
845 845
846 Handle<Foreign> Factory::NewForeign(const AccessorDescriptor* desc) { 846 Handle<Foreign> Factory::NewForeign(const AccessorDescriptor* desc) {
847 return NewForeign((Address) desc, TENURED); 847 return NewForeign((Address) desc, TENURED);
848 } 848 }
849 849
850 850
851 Handle<ByteArray> Factory::NewByteArray(int length, PretenureFlag pretenure) { 851 Handle<ByteArray> Factory::NewByteArray(int length, PretenureFlag pretenure) {
852 ASSERT(0 <= length); 852 DCHECK(0 <= length);
853 CALL_HEAP_FUNCTION( 853 CALL_HEAP_FUNCTION(
854 isolate(), 854 isolate(),
855 isolate()->heap()->AllocateByteArray(length, pretenure), 855 isolate()->heap()->AllocateByteArray(length, pretenure),
856 ByteArray); 856 ByteArray);
857 } 857 }
858 858
859 859
860 Handle<ExternalArray> Factory::NewExternalArray(int length, 860 Handle<ExternalArray> Factory::NewExternalArray(int length,
861 ExternalArrayType array_type, 861 ExternalArrayType array_type,
862 void* external_pointer, 862 void* external_pointer,
863 PretenureFlag pretenure) { 863 PretenureFlag pretenure) {
864 ASSERT(0 <= length && length <= Smi::kMaxValue); 864 DCHECK(0 <= length && length <= Smi::kMaxValue);
865 CALL_HEAP_FUNCTION( 865 CALL_HEAP_FUNCTION(
866 isolate(), 866 isolate(),
867 isolate()->heap()->AllocateExternalArray(length, 867 isolate()->heap()->AllocateExternalArray(length,
868 array_type, 868 array_type,
869 external_pointer, 869 external_pointer,
870 pretenure), 870 pretenure),
871 ExternalArray); 871 ExternalArray);
872 } 872 }
873 873
874 874
875 Handle<FixedTypedArrayBase> Factory::NewFixedTypedArray( 875 Handle<FixedTypedArrayBase> Factory::NewFixedTypedArray(
876 int length, 876 int length,
877 ExternalArrayType array_type, 877 ExternalArrayType array_type,
878 PretenureFlag pretenure) { 878 PretenureFlag pretenure) {
879 ASSERT(0 <= length && length <= Smi::kMaxValue); 879 DCHECK(0 <= length && length <= Smi::kMaxValue);
880 CALL_HEAP_FUNCTION( 880 CALL_HEAP_FUNCTION(
881 isolate(), 881 isolate(),
882 isolate()->heap()->AllocateFixedTypedArray(length, 882 isolate()->heap()->AllocateFixedTypedArray(length,
883 array_type, 883 array_type,
884 pretenure), 884 pretenure),
885 FixedTypedArrayBase); 885 FixedTypedArrayBase);
886 } 886 }
887 887
888 888
889 Handle<Cell> Factory::NewCell(Handle<Object> value) { 889 Handle<Cell> Factory::NewCell(Handle<Object> value) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 961
962 Handle<FixedArray> Factory::CopyFixedArray(Handle<FixedArray> array) { 962 Handle<FixedArray> Factory::CopyFixedArray(Handle<FixedArray> array) {
963 CALL_HEAP_FUNCTION(isolate(), 963 CALL_HEAP_FUNCTION(isolate(),
964 isolate()->heap()->CopyFixedArray(*array), 964 isolate()->heap()->CopyFixedArray(*array),
965 FixedArray); 965 FixedArray);
966 } 966 }
967 967
968 968
969 Handle<FixedArray> Factory::CopyAndTenureFixedCOWArray( 969 Handle<FixedArray> Factory::CopyAndTenureFixedCOWArray(
970 Handle<FixedArray> array) { 970 Handle<FixedArray> array) {
971 ASSERT(isolate()->heap()->InNewSpace(*array)); 971 DCHECK(isolate()->heap()->InNewSpace(*array));
972 CALL_HEAP_FUNCTION(isolate(), 972 CALL_HEAP_FUNCTION(isolate(),
973 isolate()->heap()->CopyAndTenureFixedCOWArray(*array), 973 isolate()->heap()->CopyAndTenureFixedCOWArray(*array),
974 FixedArray); 974 FixedArray);
975 } 975 }
976 976
977 977
978 Handle<FixedDoubleArray> Factory::CopyFixedDoubleArray( 978 Handle<FixedDoubleArray> Factory::CopyFixedDoubleArray(
979 Handle<FixedDoubleArray> array) { 979 Handle<FixedDoubleArray> array) {
980 CALL_HEAP_FUNCTION(isolate(), 980 CALL_HEAP_FUNCTION(isolate(),
981 isolate()->heap()->CopyFixedDoubleArray(*array), 981 isolate()->heap()->CopyFixedDoubleArray(*array),
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
1230 InitializeFunction(result, info, context); 1230 InitializeFunction(result, info, context);
1231 return result; 1231 return result;
1232 } 1232 }
1233 1233
1234 1234
1235 Handle<JSFunction> Factory::NewFunction(Handle<Map> map, 1235 Handle<JSFunction> Factory::NewFunction(Handle<Map> map,
1236 Handle<String> name, 1236 Handle<String> name,
1237 MaybeHandle<Code> code) { 1237 MaybeHandle<Code> code) {
1238 Handle<Context> context(isolate()->native_context()); 1238 Handle<Context> context(isolate()->native_context());
1239 Handle<SharedFunctionInfo> info = NewSharedFunctionInfo(name, code); 1239 Handle<SharedFunctionInfo> info = NewSharedFunctionInfo(name, code);
1240 ASSERT((info->strict_mode() == SLOPPY) && 1240 DCHECK((info->strict_mode() == SLOPPY) &&
1241 (map.is_identical_to(isolate()->sloppy_function_map()) || 1241 (map.is_identical_to(isolate()->sloppy_function_map()) ||
1242 map.is_identical_to( 1242 map.is_identical_to(
1243 isolate()->sloppy_function_without_prototype_map()) || 1243 isolate()->sloppy_function_without_prototype_map()) ||
1244 map.is_identical_to( 1244 map.is_identical_to(
1245 isolate()->sloppy_function_with_readonly_prototype_map()))); 1245 isolate()->sloppy_function_with_readonly_prototype_map())));
1246 return NewFunction(map, info, context); 1246 return NewFunction(map, info, context);
1247 } 1247 }
1248 1248
1249 1249
1250 Handle<JSFunction> Factory::NewFunction(Handle<String> name) { 1250 Handle<JSFunction> Factory::NewFunction(Handle<String> name) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1310 Handle<Context> native_context(function->context()->native_context()); 1310 Handle<Context> native_context(function->context()->native_context());
1311 Handle<Map> new_map; 1311 Handle<Map> new_map;
1312 if (function->shared()->is_generator()) { 1312 if (function->shared()->is_generator()) {
1313 // Generator prototypes can share maps since they don't have "constructor" 1313 // Generator prototypes can share maps since they don't have "constructor"
1314 // properties. 1314 // properties.
1315 new_map = handle(native_context->generator_object_prototype_map()); 1315 new_map = handle(native_context->generator_object_prototype_map());
1316 } else { 1316 } else {
1317 // Each function prototype gets a fresh map to avoid unwanted sharing of 1317 // Each function prototype gets a fresh map to avoid unwanted sharing of
1318 // maps between prototypes of different constructors. 1318 // maps between prototypes of different constructors.
1319 Handle<JSFunction> object_function(native_context->object_function()); 1319 Handle<JSFunction> object_function(native_context->object_function());
1320 ASSERT(object_function->has_initial_map()); 1320 DCHECK(object_function->has_initial_map());
1321 new_map = Map::Copy(handle(object_function->initial_map())); 1321 new_map = Map::Copy(handle(object_function->initial_map()));
1322 } 1322 }
1323 1323
1324 Handle<JSObject> prototype = NewJSObjectFromMap(new_map); 1324 Handle<JSObject> prototype = NewJSObjectFromMap(new_map);
1325 1325
1326 if (!function->shared()->is_generator()) { 1326 if (!function->shared()->is_generator()) {
1327 JSObject::AddProperty(prototype, constructor_string(), function, DONT_ENUM); 1327 JSObject::AddProperty(prototype, constructor_string(), function, DONT_ENUM);
1328 } 1328 }
1329 1329
1330 return prototype; 1330 return prototype;
(...skipping 26 matching lines...) Expand all
1357 context->native_context()); 1357 context->native_context());
1358 } 1358 }
1359 result->set_literals(*literals); 1359 result->set_literals(*literals);
1360 } 1360 }
1361 1361
1362 if (index > 0) { 1362 if (index > 0) {
1363 // Caching of optimized code enabled and optimized code found. 1363 // Caching of optimized code enabled and optimized code found.
1364 FixedArray* literals = info->GetLiteralsFromOptimizedCodeMap(index); 1364 FixedArray* literals = info->GetLiteralsFromOptimizedCodeMap(index);
1365 if (literals != NULL) result->set_literals(literals); 1365 if (literals != NULL) result->set_literals(literals);
1366 Code* code = info->GetCodeFromOptimizedCodeMap(index); 1366 Code* code = info->GetCodeFromOptimizedCodeMap(index);
1367 ASSERT(!code->marked_for_deoptimization()); 1367 DCHECK(!code->marked_for_deoptimization());
1368 result->ReplaceCode(code); 1368 result->ReplaceCode(code);
1369 return result; 1369 return result;
1370 } 1370 }
1371 1371
1372 if (isolate()->use_crankshaft() && 1372 if (isolate()->use_crankshaft() &&
1373 FLAG_always_opt && 1373 FLAG_always_opt &&
1374 result->is_compiled() && 1374 result->is_compiled() &&
1375 !info->is_toplevel() && 1375 !info->is_toplevel() &&
1376 info->allows_lazy_compilation() && 1376 info->allows_lazy_compilation() &&
1377 !info->optimization_disabled() && 1377 !info->optimization_disabled() &&
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1414 bool is_debug) { 1414 bool is_debug) {
1415 Handle<ByteArray> reloc_info = NewByteArray(desc.reloc_size, TENURED); 1415 Handle<ByteArray> reloc_info = NewByteArray(desc.reloc_size, TENURED);
1416 Handle<ConstantPoolArray> constant_pool = 1416 Handle<ConstantPoolArray> constant_pool =
1417 desc.origin->NewConstantPool(isolate()); 1417 desc.origin->NewConstantPool(isolate());
1418 1418
1419 // Compute size. 1419 // Compute size.
1420 int body_size = RoundUp(desc.instr_size, kObjectAlignment); 1420 int body_size = RoundUp(desc.instr_size, kObjectAlignment);
1421 int obj_size = Code::SizeFor(body_size); 1421 int obj_size = Code::SizeFor(body_size);
1422 1422
1423 Handle<Code> code = NewCodeRaw(obj_size, immovable); 1423 Handle<Code> code = NewCodeRaw(obj_size, immovable);
1424 ASSERT(isolate()->code_range() == NULL || 1424 DCHECK(isolate()->code_range() == NULL ||
1425 !isolate()->code_range()->valid() || 1425 !isolate()->code_range()->valid() ||
1426 isolate()->code_range()->contains(code->address())); 1426 isolate()->code_range()->contains(code->address()));
1427 1427
1428 // The code object has not been fully initialized yet. We rely on the 1428 // The code object has not been fully initialized yet. We rely on the
1429 // fact that no allocation will happen from this point on. 1429 // fact that no allocation will happen from this point on.
1430 DisallowHeapAllocation no_gc; 1430 DisallowHeapAllocation no_gc;
1431 code->set_gc_metadata(Smi::FromInt(0)); 1431 code->set_gc_metadata(Smi::FromInt(0));
1432 code->set_ic_age(isolate()->heap()->global_ic_age()); 1432 code->set_ic_age(isolate()->heap()->global_ic_age());
1433 code->set_instruction_size(desc.instr_size); 1433 code->set_instruction_size(desc.instr_size);
1434 code->set_relocation_info(*reloc_info); 1434 code->set_relocation_info(*reloc_info);
1435 code->set_flags(flags); 1435 code->set_flags(flags);
1436 code->set_raw_kind_specific_flags1(0); 1436 code->set_raw_kind_specific_flags1(0);
1437 code->set_raw_kind_specific_flags2(0); 1437 code->set_raw_kind_specific_flags2(0);
1438 code->set_is_crankshafted(crankshafted); 1438 code->set_is_crankshafted(crankshafted);
1439 code->set_deoptimization_data(*empty_fixed_array(), SKIP_WRITE_BARRIER); 1439 code->set_deoptimization_data(*empty_fixed_array(), SKIP_WRITE_BARRIER);
1440 code->set_raw_type_feedback_info(Smi::FromInt(0)); 1440 code->set_raw_type_feedback_info(Smi::FromInt(0));
1441 code->set_next_code_link(*undefined_value()); 1441 code->set_next_code_link(*undefined_value());
1442 code->set_handler_table(*empty_fixed_array(), SKIP_WRITE_BARRIER); 1442 code->set_handler_table(*empty_fixed_array(), SKIP_WRITE_BARRIER);
1443 code->set_prologue_offset(prologue_offset); 1443 code->set_prologue_offset(prologue_offset);
1444 if (code->kind() == Code::OPTIMIZED_FUNCTION) { 1444 if (code->kind() == Code::OPTIMIZED_FUNCTION) {
1445 code->set_marked_for_deoptimization(false); 1445 code->set_marked_for_deoptimization(false);
1446 } 1446 }
1447 1447
1448 if (is_debug) { 1448 if (is_debug) {
1449 ASSERT(code->kind() == Code::FUNCTION); 1449 DCHECK(code->kind() == Code::FUNCTION);
1450 code->set_has_debug_break_slots(true); 1450 code->set_has_debug_break_slots(true);
1451 } 1451 }
1452 1452
1453 desc.origin->PopulateConstantPool(*constant_pool); 1453 desc.origin->PopulateConstantPool(*constant_pool);
1454 code->set_constant_pool(*constant_pool); 1454 code->set_constant_pool(*constant_pool);
1455 1455
1456 // Allow self references to created code object by patching the handle to 1456 // Allow self references to created code object by patching the handle to
1457 // point to the newly allocated Code object. 1457 // point to the newly allocated Code object.
1458 if (!self_ref.is_null()) *(self_ref.location()) = *code; 1458 if (!self_ref.is_null()) *(self_ref.location()) = *code;
1459 1459
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1512 // Allocate the object based on the map. 1512 // Allocate the object based on the map.
1513 Handle<JSModule> module = 1513 Handle<JSModule> module =
1514 Handle<JSModule>::cast(NewJSObjectFromMap(map, TENURED)); 1514 Handle<JSModule>::cast(NewJSObjectFromMap(map, TENURED));
1515 module->set_context(*context); 1515 module->set_context(*context);
1516 module->set_scope_info(*scope_info); 1516 module->set_scope_info(*scope_info);
1517 return module; 1517 return module;
1518 } 1518 }
1519 1519
1520 1520
1521 Handle<GlobalObject> Factory::NewGlobalObject(Handle<JSFunction> constructor) { 1521 Handle<GlobalObject> Factory::NewGlobalObject(Handle<JSFunction> constructor) {
1522 ASSERT(constructor->has_initial_map()); 1522 DCHECK(constructor->has_initial_map());
1523 Handle<Map> map(constructor->initial_map()); 1523 Handle<Map> map(constructor->initial_map());
1524 ASSERT(map->is_dictionary_map()); 1524 DCHECK(map->is_dictionary_map());
1525 1525
1526 // Make sure no field properties are described in the initial map. 1526 // Make sure no field properties are described in the initial map.
1527 // This guarantees us that normalizing the properties does not 1527 // This guarantees us that normalizing the properties does not
1528 // require us to change property values to PropertyCells. 1528 // require us to change property values to PropertyCells.
1529 ASSERT(map->NextFreePropertyIndex() == 0); 1529 DCHECK(map->NextFreePropertyIndex() == 0);
1530 1530
1531 // Make sure we don't have a ton of pre-allocated slots in the 1531 // Make sure we don't have a ton of pre-allocated slots in the
1532 // global objects. They will be unused once we normalize the object. 1532 // global objects. They will be unused once we normalize the object.
1533 ASSERT(map->unused_property_fields() == 0); 1533 DCHECK(map->unused_property_fields() == 0);
1534 ASSERT(map->inobject_properties() == 0); 1534 DCHECK(map->inobject_properties() == 0);
1535 1535
1536 // Initial size of the backing store to avoid resize of the storage during 1536 // Initial size of the backing store to avoid resize of the storage during
1537 // bootstrapping. The size differs between the JS global object ad the 1537 // bootstrapping. The size differs between the JS global object ad the
1538 // builtins object. 1538 // builtins object.
1539 int initial_size = map->instance_type() == JS_GLOBAL_OBJECT_TYPE ? 64 : 512; 1539 int initial_size = map->instance_type() == JS_GLOBAL_OBJECT_TYPE ? 64 : 512;
1540 1540
1541 // Allocate a dictionary object for backing storage. 1541 // Allocate a dictionary object for backing storage.
1542 int at_least_space_for = map->NumberOfOwnDescriptors() * 2 + initial_size; 1542 int at_least_space_for = map->NumberOfOwnDescriptors() * 2 + initial_size;
1543 Handle<NameDictionary> dictionary = 1543 Handle<NameDictionary> dictionary =
1544 NameDictionary::New(isolate(), at_least_space_for); 1544 NameDictionary::New(isolate(), at_least_space_for);
1545 1545
1546 // The global object might be created from an object template with accessors. 1546 // The global object might be created from an object template with accessors.
1547 // Fill these accessors into the dictionary. 1547 // Fill these accessors into the dictionary.
1548 Handle<DescriptorArray> descs(map->instance_descriptors()); 1548 Handle<DescriptorArray> descs(map->instance_descriptors());
1549 for (int i = 0; i < map->NumberOfOwnDescriptors(); i++) { 1549 for (int i = 0; i < map->NumberOfOwnDescriptors(); i++) {
1550 PropertyDetails details = descs->GetDetails(i); 1550 PropertyDetails details = descs->GetDetails(i);
1551 ASSERT(details.type() == CALLBACKS); // Only accessors are expected. 1551 DCHECK(details.type() == CALLBACKS); // Only accessors are expected.
1552 PropertyDetails d = PropertyDetails(details.attributes(), CALLBACKS, i + 1); 1552 PropertyDetails d = PropertyDetails(details.attributes(), CALLBACKS, i + 1);
1553 Handle<Name> name(descs->GetKey(i)); 1553 Handle<Name> name(descs->GetKey(i));
1554 Handle<Object> value(descs->GetCallbacksObject(i), isolate()); 1554 Handle<Object> value(descs->GetCallbacksObject(i), isolate());
1555 Handle<PropertyCell> cell = NewPropertyCell(value); 1555 Handle<PropertyCell> cell = NewPropertyCell(value);
1556 // |dictionary| already contains enough space for all properties. 1556 // |dictionary| already contains enough space for all properties.
1557 USE(NameDictionary::Add(dictionary, name, cell, d)); 1557 USE(NameDictionary::Add(dictionary, name, cell, d));
1558 } 1558 }
1559 1559
1560 // Allocate the global object and initialize it with the backing store. 1560 // Allocate the global object and initialize it with the backing store.
1561 Handle<GlobalObject> global = New<GlobalObject>(map, OLD_POINTER_SPACE); 1561 Handle<GlobalObject> global = New<GlobalObject>(map, OLD_POINTER_SPACE);
1562 isolate()->heap()->InitializeJSObjectFromMap(*global, *dictionary, *map); 1562 isolate()->heap()->InitializeJSObjectFromMap(*global, *dictionary, *map);
1563 1563
1564 // Create a new map for the global object. 1564 // Create a new map for the global object.
1565 Handle<Map> new_map = Map::CopyDropDescriptors(map); 1565 Handle<Map> new_map = Map::CopyDropDescriptors(map);
1566 new_map->set_dictionary_map(true); 1566 new_map->set_dictionary_map(true);
1567 1567
1568 // Set up the global object as a normalized object. 1568 // Set up the global object as a normalized object.
1569 global->set_map(*new_map); 1569 global->set_map(*new_map);
1570 global->set_properties(*dictionary); 1570 global->set_properties(*dictionary);
1571 1571
1572 // Make sure result is a global object with properties in dictionary. 1572 // Make sure result is a global object with properties in dictionary.
1573 ASSERT(global->IsGlobalObject() && !global->HasFastProperties()); 1573 DCHECK(global->IsGlobalObject() && !global->HasFastProperties());
1574 return global; 1574 return global;
1575 } 1575 }
1576 1576
1577 1577
1578 Handle<JSObject> Factory::NewJSObjectFromMap( 1578 Handle<JSObject> Factory::NewJSObjectFromMap(
1579 Handle<Map> map, 1579 Handle<Map> map,
1580 PretenureFlag pretenure, 1580 PretenureFlag pretenure,
1581 bool alloc_props, 1581 bool alloc_props,
1582 Handle<AllocationSite> allocation_site) { 1582 Handle<AllocationSite> allocation_site) {
1583 CALL_HEAP_FUNCTION( 1583 CALL_HEAP_FUNCTION(
(...skipping 26 matching lines...) Expand all
1610 Handle<JSArray> array = NewJSArray(elements_kind, pretenure); 1610 Handle<JSArray> array = NewJSArray(elements_kind, pretenure);
1611 NewJSArrayStorage(array, length, capacity, mode); 1611 NewJSArrayStorage(array, length, capacity, mode);
1612 return array; 1612 return array;
1613 } 1613 }
1614 1614
1615 1615
1616 Handle<JSArray> Factory::NewJSArrayWithElements(Handle<FixedArrayBase> elements, 1616 Handle<JSArray> Factory::NewJSArrayWithElements(Handle<FixedArrayBase> elements,
1617 ElementsKind elements_kind, 1617 ElementsKind elements_kind,
1618 int length, 1618 int length,
1619 PretenureFlag pretenure) { 1619 PretenureFlag pretenure) {
1620 ASSERT(length <= elements->length()); 1620 DCHECK(length <= elements->length());
1621 Handle<JSArray> array = NewJSArray(elements_kind, pretenure); 1621 Handle<JSArray> array = NewJSArray(elements_kind, pretenure);
1622 1622
1623 array->set_elements(*elements); 1623 array->set_elements(*elements);
1624 array->set_length(Smi::FromInt(length)); 1624 array->set_length(Smi::FromInt(length));
1625 JSObject::ValidateElements(array); 1625 JSObject::ValidateElements(array);
1626 return array; 1626 return array;
1627 } 1627 }
1628 1628
1629 1629
1630 void Factory::NewJSArrayStorage(Handle<JSArray> array, 1630 void Factory::NewJSArrayStorage(Handle<JSArray> array,
1631 int length, 1631 int length,
1632 int capacity, 1632 int capacity,
1633 ArrayStorageAllocationMode mode) { 1633 ArrayStorageAllocationMode mode) {
1634 ASSERT(capacity >= length); 1634 DCHECK(capacity >= length);
1635 1635
1636 if (capacity == 0) { 1636 if (capacity == 0) {
1637 array->set_length(Smi::FromInt(0)); 1637 array->set_length(Smi::FromInt(0));
1638 array->set_elements(*empty_fixed_array()); 1638 array->set_elements(*empty_fixed_array());
1639 return; 1639 return;
1640 } 1640 }
1641 1641
1642 Handle<FixedArrayBase> elms; 1642 Handle<FixedArrayBase> elms;
1643 ElementsKind elements_kind = array->GetElementsKind(); 1643 ElementsKind elements_kind = array->GetElementsKind();
1644 if (IsFastDoubleElementsKind(elements_kind)) { 1644 if (IsFastDoubleElementsKind(elements_kind)) {
1645 if (mode == DONT_INITIALIZE_ARRAY_ELEMENTS) { 1645 if (mode == DONT_INITIALIZE_ARRAY_ELEMENTS) {
1646 elms = NewFixedDoubleArray(capacity); 1646 elms = NewFixedDoubleArray(capacity);
1647 } else { 1647 } else {
1648 ASSERT(mode == INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE); 1648 DCHECK(mode == INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE);
1649 elms = NewFixedDoubleArrayWithHoles(capacity); 1649 elms = NewFixedDoubleArrayWithHoles(capacity);
1650 } 1650 }
1651 } else { 1651 } else {
1652 ASSERT(IsFastSmiOrObjectElementsKind(elements_kind)); 1652 DCHECK(IsFastSmiOrObjectElementsKind(elements_kind));
1653 if (mode == DONT_INITIALIZE_ARRAY_ELEMENTS) { 1653 if (mode == DONT_INITIALIZE_ARRAY_ELEMENTS) {
1654 elms = NewUninitializedFixedArray(capacity); 1654 elms = NewUninitializedFixedArray(capacity);
1655 } else { 1655 } else {
1656 ASSERT(mode == INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE); 1656 DCHECK(mode == INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE);
1657 elms = NewFixedArrayWithHoles(capacity); 1657 elms = NewFixedArrayWithHoles(capacity);
1658 } 1658 }
1659 } 1659 }
1660 1660
1661 array->set_elements(*elms); 1661 array->set_elements(*elms);
1662 array->set_length(Smi::FromInt(length)); 1662 array->set_length(Smi::FromInt(length));
1663 } 1663 }
1664 1664
1665 1665
1666 Handle<JSGeneratorObject> Factory::NewJSGeneratorObject( 1666 Handle<JSGeneratorObject> Factory::NewJSGeneratorObject(
1667 Handle<JSFunction> function) { 1667 Handle<JSFunction> function) {
1668 ASSERT(function->shared()->is_generator()); 1668 DCHECK(function->shared()->is_generator());
1669 JSFunction::EnsureHasInitialMap(function); 1669 JSFunction::EnsureHasInitialMap(function);
1670 Handle<Map> map(function->initial_map()); 1670 Handle<Map> map(function->initial_map());
1671 ASSERT(map->instance_type() == JS_GENERATOR_OBJECT_TYPE); 1671 DCHECK(map->instance_type() == JS_GENERATOR_OBJECT_TYPE);
1672 CALL_HEAP_FUNCTION( 1672 CALL_HEAP_FUNCTION(
1673 isolate(), 1673 isolate(),
1674 isolate()->heap()->AllocateJSObjectFromMap(*map), 1674 isolate()->heap()->AllocateJSObjectFromMap(*map),
1675 JSGeneratorObject); 1675 JSGeneratorObject);
1676 } 1676 }
1677 1677
1678 1678
1679 Handle<JSArrayBuffer> Factory::NewJSArrayBuffer() { 1679 Handle<JSArrayBuffer> Factory::NewJSArrayBuffer() {
1680 Handle<JSFunction> array_buffer_fun( 1680 Handle<JSFunction> array_buffer_fun(
1681 isolate()->native_context()->array_buffer_fun()); 1681 isolate()->native_context()->array_buffer_fun());
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1758 result->set_hash(*undefined_value(), SKIP_WRITE_BARRIER); 1758 result->set_hash(*undefined_value(), SKIP_WRITE_BARRIER);
1759 result->set_call_trap(*call_trap); 1759 result->set_call_trap(*call_trap);
1760 result->set_construct_trap(*construct_trap); 1760 result->set_construct_trap(*construct_trap);
1761 return result; 1761 return result;
1762 } 1762 }
1763 1763
1764 1764
1765 void Factory::ReinitializeJSReceiver(Handle<JSReceiver> object, 1765 void Factory::ReinitializeJSReceiver(Handle<JSReceiver> object,
1766 InstanceType type, 1766 InstanceType type,
1767 int size) { 1767 int size) {
1768 ASSERT(type >= FIRST_JS_OBJECT_TYPE); 1768 DCHECK(type >= FIRST_JS_OBJECT_TYPE);
1769 1769
1770 // Allocate fresh map. 1770 // Allocate fresh map.
1771 // TODO(rossberg): Once we optimize proxies, cache these maps. 1771 // TODO(rossberg): Once we optimize proxies, cache these maps.
1772 Handle<Map> map = NewMap(type, size); 1772 Handle<Map> map = NewMap(type, size);
1773 1773
1774 // Check that the receiver has at least the size of the fresh object. 1774 // Check that the receiver has at least the size of the fresh object.
1775 int size_difference = object->map()->instance_size() - map->instance_size(); 1775 int size_difference = object->map()->instance_size() - map->instance_size();
1776 ASSERT(size_difference >= 0); 1776 DCHECK(size_difference >= 0);
1777 1777
1778 map->set_prototype(object->map()->prototype()); 1778 map->set_prototype(object->map()->prototype());
1779 1779
1780 // Allocate the backing storage for the properties. 1780 // Allocate the backing storage for the properties.
1781 int prop_size = map->InitialPropertiesLength(); 1781 int prop_size = map->InitialPropertiesLength();
1782 Handle<FixedArray> properties = NewFixedArray(prop_size, TENURED); 1782 Handle<FixedArray> properties = NewFixedArray(prop_size, TENURED);
1783 1783
1784 Heap* heap = isolate()->heap(); 1784 Heap* heap = isolate()->heap();
1785 MaybeHandle<SharedFunctionInfo> shared; 1785 MaybeHandle<SharedFunctionInfo> shared;
1786 if (type == JS_FUNCTION_TYPE) { 1786 if (type == JS_FUNCTION_TYPE) {
(...skipping 26 matching lines...) Expand all
1813 map->set_function_with_prototype(true); 1813 map->set_function_with_prototype(true);
1814 Handle<JSFunction> js_function = Handle<JSFunction>::cast(object); 1814 Handle<JSFunction> js_function = Handle<JSFunction>::cast(object);
1815 Handle<Context> context(isolate()->native_context()); 1815 Handle<Context> context(isolate()->native_context());
1816 InitializeFunction(js_function, shared.ToHandleChecked(), context); 1816 InitializeFunction(js_function, shared.ToHandleChecked(), context);
1817 } 1817 }
1818 } 1818 }
1819 1819
1820 1820
1821 void Factory::ReinitializeJSGlobalProxy(Handle<JSGlobalProxy> object, 1821 void Factory::ReinitializeJSGlobalProxy(Handle<JSGlobalProxy> object,
1822 Handle<JSFunction> constructor) { 1822 Handle<JSFunction> constructor) {
1823 ASSERT(constructor->has_initial_map()); 1823 DCHECK(constructor->has_initial_map());
1824 Handle<Map> map(constructor->initial_map(), isolate()); 1824 Handle<Map> map(constructor->initial_map(), isolate());
1825 1825
1826 // The proxy's hash should be retained across reinitialization. 1826 // The proxy's hash should be retained across reinitialization.
1827 Handle<Object> hash(object->hash(), isolate()); 1827 Handle<Object> hash(object->hash(), isolate());
1828 1828
1829 // Check that the already allocated object has the same size and type as 1829 // Check that the already allocated object has the same size and type as
1830 // objects allocated using the constructor. 1830 // objects allocated using the constructor.
1831 ASSERT(map->instance_size() == object->map()->instance_size()); 1831 DCHECK(map->instance_size() == object->map()->instance_size());
1832 ASSERT(map->instance_type() == object->map()->instance_type()); 1832 DCHECK(map->instance_type() == object->map()->instance_type());
1833 1833
1834 // Allocate the backing storage for the properties. 1834 // Allocate the backing storage for the properties.
1835 int prop_size = map->InitialPropertiesLength(); 1835 int prop_size = map->InitialPropertiesLength();
1836 Handle<FixedArray> properties = NewFixedArray(prop_size, TENURED); 1836 Handle<FixedArray> properties = NewFixedArray(prop_size, TENURED);
1837 1837
1838 // In order to keep heap in consistent state there must be no allocations 1838 // In order to keep heap in consistent state there must be no allocations
1839 // before object re-initialization is finished. 1839 // before object re-initialization is finished.
1840 DisallowHeapAllocation no_allocation; 1840 DisallowHeapAllocation no_allocation;
1841 1841
1842 // Reset the map for the object. 1842 // Reset the map for the object.
(...skipping 13 matching lines...) Expand all
1856 } 1856 }
1857 1857
1858 1858
1859 void Factory::BecomeJSFunction(Handle<JSReceiver> object) { 1859 void Factory::BecomeJSFunction(Handle<JSReceiver> object) {
1860 ReinitializeJSReceiver(object, JS_FUNCTION_TYPE, JSFunction::kSize); 1860 ReinitializeJSReceiver(object, JS_FUNCTION_TYPE, JSFunction::kSize);
1861 } 1861 }
1862 1862
1863 1863
1864 Handle<FixedArray> Factory::NewTypeFeedbackVector(int slot_count) { 1864 Handle<FixedArray> Factory::NewTypeFeedbackVector(int slot_count) {
1865 // Ensure we can skip the write barrier 1865 // Ensure we can skip the write barrier
1866 ASSERT_EQ(isolate()->heap()->uninitialized_symbol(), 1866 DCHECK_EQ(isolate()->heap()->uninitialized_symbol(),
1867 *TypeFeedbackInfo::UninitializedSentinel(isolate())); 1867 *TypeFeedbackInfo::UninitializedSentinel(isolate()));
1868 1868
1869 CALL_HEAP_FUNCTION( 1869 CALL_HEAP_FUNCTION(
1870 isolate(), 1870 isolate(),
1871 isolate()->heap()->AllocateFixedArrayWithFiller( 1871 isolate()->heap()->AllocateFixedArrayWithFiller(
1872 slot_count, 1872 slot_count,
1873 TENURED, 1873 TENURED,
1874 *TypeFeedbackInfo::UninitializedSentinel(isolate())), 1874 *TypeFeedbackInfo::UninitializedSentinel(isolate())),
1875 FixedArray); 1875 FixedArray);
1876 } 1876 }
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1997 Handle<String> string) { 1997 Handle<String> string) {
1998 int hash = NumberCacheHash(number_string_cache(), number); 1998 int hash = NumberCacheHash(number_string_cache(), number);
1999 if (number_string_cache()->get(hash * 2) != *undefined_value()) { 1999 if (number_string_cache()->get(hash * 2) != *undefined_value()) {
2000 int full_size = isolate()->heap()->FullSizeNumberStringCacheLength(); 2000 int full_size = isolate()->heap()->FullSizeNumberStringCacheLength();
2001 if (number_string_cache()->length() != full_size) { 2001 if (number_string_cache()->length() != full_size) {
2002 // The first time we have a hash collision, we move to the full sized 2002 // The first time we have a hash collision, we move to the full sized
2003 // number string cache. The idea is to have a small number string 2003 // number string cache. The idea is to have a small number string
2004 // cache in the snapshot to keep boot-time memory usage down. 2004 // cache in the snapshot to keep boot-time memory usage down.
2005 // If we expand the number string cache already while creating 2005 // If we expand the number string cache already while creating
2006 // the snapshot then that didn't work out. 2006 // the snapshot then that didn't work out.
2007 ASSERT(!isolate()->serializer_enabled() || FLAG_extra_code != NULL); 2007 DCHECK(!isolate()->serializer_enabled() || FLAG_extra_code != NULL);
2008 Handle<FixedArray> new_cache = NewFixedArray(full_size, TENURED); 2008 Handle<FixedArray> new_cache = NewFixedArray(full_size, TENURED);
2009 isolate()->heap()->set_number_string_cache(*new_cache); 2009 isolate()->heap()->set_number_string_cache(*new_cache);
2010 return; 2010 return;
2011 } 2011 }
2012 } 2012 }
2013 number_string_cache()->set(hash * 2, *number); 2013 number_string_cache()->set(hash * 2, *number);
2014 number_string_cache()->set(hash * 2 + 1, *string); 2014 number_string_cache()->set(hash * 2 + 1, *string);
2015 } 2015 }
2016 2016
2017 2017
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
2074 2074
2075 2075
2076 Handle<JSObject> Factory::NewArgumentsObject(Handle<JSFunction> callee, 2076 Handle<JSObject> Factory::NewArgumentsObject(Handle<JSFunction> callee,
2077 int length) { 2077 int length) {
2078 bool strict_mode_callee = callee->shared()->strict_mode() == STRICT; 2078 bool strict_mode_callee = callee->shared()->strict_mode() == STRICT;
2079 Handle<Map> map = strict_mode_callee ? isolate()->strict_arguments_map() 2079 Handle<Map> map = strict_mode_callee ? isolate()->strict_arguments_map()
2080 : isolate()->sloppy_arguments_map(); 2080 : isolate()->sloppy_arguments_map();
2081 2081
2082 AllocationSiteUsageContext context(isolate(), Handle<AllocationSite>(), 2082 AllocationSiteUsageContext context(isolate(), Handle<AllocationSite>(),
2083 false); 2083 false);
2084 ASSERT(!isolate()->has_pending_exception()); 2084 DCHECK(!isolate()->has_pending_exception());
2085 Handle<JSObject> result = NewJSObjectFromMap(map); 2085 Handle<JSObject> result = NewJSObjectFromMap(map);
2086 Handle<Smi> value(Smi::FromInt(length), isolate()); 2086 Handle<Smi> value(Smi::FromInt(length), isolate());
2087 Object::SetProperty(result, length_string(), value, STRICT).Assert(); 2087 Object::SetProperty(result, length_string(), value, STRICT).Assert();
2088 if (!strict_mode_callee) { 2088 if (!strict_mode_callee) {
2089 Object::SetProperty(result, callee_string(), callee, STRICT).Assert(); 2089 Object::SetProperty(result, callee_string(), callee, STRICT).Assert();
2090 } 2090 }
2091 return result; 2091 return result;
2092 } 2092 }
2093 2093
2094 2094
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2143 Handle<Object> class_name(obj->class_name(), isolate()); 2143 Handle<Object> class_name(obj->class_name(), isolate());
2144 if (class_name->IsString()) { 2144 if (class_name->IsString()) {
2145 result->shared()->set_instance_class_name(*class_name); 2145 result->shared()->set_instance_class_name(*class_name);
2146 result->shared()->set_name(*class_name); 2146 result->shared()->set_name(*class_name);
2147 } 2147 }
2148 result->shared()->set_function_data(*obj); 2148 result->shared()->set_function_data(*obj);
2149 result->shared()->set_construct_stub(*construct_stub); 2149 result->shared()->set_construct_stub(*construct_stub);
2150 result->shared()->DontAdaptArguments(); 2150 result->shared()->DontAdaptArguments();
2151 2151
2152 if (obj->remove_prototype()) { 2152 if (obj->remove_prototype()) {
2153 ASSERT(result->shared()->IsApiFunction()); 2153 DCHECK(result->shared()->IsApiFunction());
2154 ASSERT(!result->has_initial_map()); 2154 DCHECK(!result->has_initial_map());
2155 ASSERT(!result->has_prototype()); 2155 DCHECK(!result->has_prototype());
2156 return result; 2156 return result;
2157 } 2157 }
2158 2158
2159 if (prototype->IsTheHole()) { 2159 if (prototype->IsTheHole()) {
2160 #ifdef DEBUG 2160 #ifdef DEBUG
2161 LookupIterator it(handle(JSObject::cast(result->prototype())), 2161 LookupIterator it(handle(JSObject::cast(result->prototype())),
2162 constructor_string(), 2162 constructor_string(),
2163 LookupIterator::CHECK_OWN_REAL); 2163 LookupIterator::CHECK_OWN_REAL);
2164 MaybeHandle<Object> maybe_prop = Object::GetProperty(&it); 2164 MaybeHandle<Object> maybe_prop = Object::GetProperty(&it);
2165 ASSERT(it.IsFound()); 2165 DCHECK(it.IsFound());
2166 ASSERT(maybe_prop.ToHandleChecked().is_identical_to(result)); 2166 DCHECK(maybe_prop.ToHandleChecked().is_identical_to(result));
2167 #endif 2167 #endif
2168 } else { 2168 } else {
2169 JSObject::AddProperty(handle(JSObject::cast(result->prototype())), 2169 JSObject::AddProperty(handle(JSObject::cast(result->prototype())),
2170 constructor_string(), result, DONT_ENUM); 2170 constructor_string(), result, DONT_ENUM);
2171 } 2171 }
2172 2172
2173 // Down from here is only valid for API functions that can be used as a 2173 // Down from here is only valid for API functions that can be used as a
2174 // constructor (don't set the "remove prototype" flag). 2174 // constructor (don't set the "remove prototype" flag).
2175 2175
2176 Handle<Map> map(result->initial_map()); 2176 Handle<Map> map(result->initial_map());
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
2265 if (parent->IsUndefined()) break; 2265 if (parent->IsUndefined()) break;
2266 obj = Handle<FunctionTemplateInfo>::cast(parent); 2266 obj = Handle<FunctionTemplateInfo>::cast(parent);
2267 } 2267 }
2268 2268
2269 // Install accumulated static accessors 2269 // Install accumulated static accessors
2270 for (int i = 0; i < valid_descriptors; i++) { 2270 for (int i = 0; i < valid_descriptors; i++) {
2271 Handle<AccessorInfo> accessor(AccessorInfo::cast(array->get(i))); 2271 Handle<AccessorInfo> accessor(AccessorInfo::cast(array->get(i)));
2272 JSObject::SetAccessor(result, accessor).Assert(); 2272 JSObject::SetAccessor(result, accessor).Assert();
2273 } 2273 }
2274 2274
2275 ASSERT(result->shared()->IsApiFunction()); 2275 DCHECK(result->shared()->IsApiFunction());
2276 return result; 2276 return result;
2277 } 2277 }
2278 2278
2279 2279
2280 Handle<MapCache> Factory::AddToMapCache(Handle<Context> context, 2280 Handle<MapCache> Factory::AddToMapCache(Handle<Context> context,
2281 Handle<FixedArray> keys, 2281 Handle<FixedArray> keys,
2282 Handle<Map> map) { 2282 Handle<Map> map) {
2283 Handle<MapCache> map_cache = handle(MapCache::cast(context->map_cache())); 2283 Handle<MapCache> map_cache = handle(MapCache::cast(context->map_cache()));
2284 Handle<MapCache> result = MapCache::Put(map_cache, keys, map); 2284 Handle<MapCache> result = MapCache::Put(map_cache, keys, map);
2285 context->set_map_cache(*result); 2285 context->set_map_cache(*result);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
2365 return Handle<Object>::null(); 2365 return Handle<Object>::null();
2366 } 2366 }
2367 2367
2368 2368
2369 Handle<Object> Factory::ToBoolean(bool value) { 2369 Handle<Object> Factory::ToBoolean(bool value) {
2370 return value ? true_value() : false_value(); 2370 return value ? true_value() : false_value();
2371 } 2371 }
2372 2372
2373 2373
2374 } } // namespace v8::internal 2374 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/factory.h ('k') | src/fast-dtoa.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698