55 #ifdef ENABLE_DISASSEMBLER
64 MUST_USE_RESULT static MaybeObject* CreateJSValue(JSFunction* constructor,
67 { MaybeObject* maybe_result =
68 constructor->GetHeap()->AllocateJSObject(constructor);
69 if (!maybe_result->ToObject(&result))
return maybe_result;
78 return CreateJSValue(native_context->number_function(),
this);
79 }
else if (IsBoolean()) {
80 return CreateJSValue(native_context->boolean_function(),
this);
81 }
else if (IsString()) {
82 return CreateJSValue(native_context->string_function(),
this);
83 }
else if (IsSymbol()) {
84 return CreateJSValue(native_context->symbol_function(),
this);
94 }
else if (IsNumber()) {
96 return CreateJSValue(native_context->number_function(),
this);
97 }
else if (IsBoolean()) {
99 return CreateJSValue(native_context->boolean_function(),
this);
100 }
else if (IsString()) {
102 return CreateJSValue(native_context->string_function(),
this);
103 }
else if (IsSymbol()) {
105 return CreateJSValue(native_context->symbol_function(),
this);
114 if (IsBoolean())
return IsTrue();
116 if (IsUndefined() || IsNull())
return false;
117 if (IsUndetectableObject())
return false;
126 while (fun->IsJSFunctionProxy()) {
129 return fun->IsJSFunction() ||
130 (fun->IsHeapObject() &&
137 if (IsJSReceiver()) {
142 holder = native_context->number_function()->instance_prototype();
143 }
else if (IsString()) {
144 holder = native_context->string_function()->instance_prototype();
145 }
else if (IsSymbol()) {
146 holder = native_context->symbol_function()->instance_prototype();
147 }
else if (IsBoolean()) {
148 holder = native_context->boolean_function()->instance_prototype();
150 result->isolate()->PushStackTraceAndDie(
164 LookupResult lookup(name->GetIsolate());
165 object->Lookup(*name, &lookup);
167 GetProperty(
object, receiver, &lookup, name, attributes);
178 MaybeObject* value =
GetProperty(receiver, &result, name, attributes);
189 if (IsHeapNumber()) {
204 *value =
static_cast<uint32_t
>(num);
208 if (IsHeapNumber()) {
220 if (!object->IsHeapObject())
return false;
229 Object* cons_obj = map->constructor();
230 if (!cons_obj->IsJSFunction())
return false;
234 for (
Object* type = fun->shared()->function_data();
235 type->IsFunctionTemplateInfo();
237 if (type ==
this)
return true;
244 template<
typename To>
245 static inline To* CheckedCast(
void *from) {
246 uintptr_t temp =
reinterpret_cast<uintptr_t
>(from);
247 ASSERT(temp %
sizeof(To) == 0);
248 return reinterpret_cast<To*
>(temp);
252 static MaybeObject* PerformCompare(
const BitmaskCompareDescriptor& descriptor,
255 uint32_t bitmask = descriptor.bitmask;
256 uint32_t compare_value = descriptor.compare_value;
258 switch (descriptor.size) {
260 value =
static_cast<uint32_t
>(*CheckedCast<uint8_t>(ptr));
261 compare_value &= 0xff;
265 value =
static_cast<uint32_t
>(*CheckedCast<uint16_t>(ptr));
266 compare_value &= 0xffff;
270 value = *CheckedCast<uint32_t>(ptr);
276 return heap->
ToBoolean((bitmask & value) == (bitmask & compare_value));
280 static MaybeObject* PerformCompare(
const PointerCompareDescriptor& descriptor,
283 uintptr_t compare_value =
284 reinterpret_cast<uintptr_t
>(descriptor.compare_value);
285 uintptr_t value = *CheckedCast<uintptr_t>(ptr);
286 return heap->ToBoolean(compare_value == value);
290 static MaybeObject* GetPrimitiveValue(
291 const PrimitiveValueDescriptor& descriptor,
295 switch (descriptor.data_type) {
297 int32_value = *CheckedCast<int8_t>(ptr);
300 int32_value = *CheckedCast<uint8_t>(ptr);
303 int32_value = *CheckedCast<int16_t>(ptr);
306 int32_value = *CheckedCast<uint16_t>(ptr);
309 int32_value = *CheckedCast<int32_t>(ptr);
312 uint32_t value = *CheckedCast<uint32_t>(ptr);
313 return heap->NumberFromUint32(value);
316 uint8_t
byte = *CheckedCast<uint8_t>(ptr);
317 return heap->ToBoolean(byte & (0x1 << descriptor.bool_offset));
320 float value = *CheckedCast<float>(ptr);
321 return heap->NumberFromDouble(value);
324 double value = *CheckedCast<double>(ptr);
325 return heap->NumberFromDouble(value);
328 return heap->NumberFromInt32(int32_value);
332 static MaybeObject* GetDeclaredAccessorProperty(
Object* receiver,
333 DeclaredAccessorInfo*
info,
335 char* current =
reinterpret_cast<char*
>(receiver);
336 DeclaredAccessorDescriptorIterator iterator(info->descriptor());
338 const DeclaredAccessorDescriptorData* data = iterator.Next();
339 switch (data->type) {
341 ASSERT(iterator.Complete());
342 current = *CheckedCast<char*>(current);
343 return *CheckedCast<Object*>(current);
346 ASSERT(!iterator.Complete());
347 current = *
reinterpret_cast<char**
>(current);
350 ASSERT(!iterator.Complete());
351 current += data->pointer_shift_descriptor.byte_offset;
354 ASSERT(!iterator.Complete());
355 Object*
object = CheckedCast<Object>(current);
356 int field = data->object_dereference_descriptor.internal_field;
359 current =
reinterpret_cast<char*
>(smi);
363 ASSERT(iterator.Complete());
364 return PerformCompare(data->bitmask_compare_descriptor,
368 ASSERT(iterator.Complete());
369 return PerformCompare(data->pointer_compare_descriptor,
373 ASSERT(iterator.Complete());
374 return GetPrimitiveValue(data->primitive_value_descriptor,
387 object->EnsureWritableFastElements(),
396 Isolate* isolate = name->GetIsolate();
400 if (structure->IsForeign()) {
405 (callback->
getter)(isolate, *receiver, callback->
data),
410 if (structure->IsAccessorInfo()) {
412 if (!accessor_info->IsCompatibleReceiver(*receiver)) {
418 isolate->
Throw(*error);
423 if (name->IsSymbol())
return isolate->
factory()->undefined_value();
424 if (structure->IsDeclaredAccessorInfo()) {
427 GetDeclaredAccessorProperty(*receiver,
436 v8::ToCData<v8::AccessorGetterCallback>(data->getter());
437 if (call_fun ==
NULL)
return isolate->
factory()->undefined_value();
442 LOG(isolate, ApiNamedPropertyAccess(
"load", *
self, *name));
447 if (result.IsEmpty()) {
448 return isolate->
factory()->undefined_value();
451 return_value->VerifyApiCallResultType();
458 if (getter->IsSpecFunction()) {
462 object->GetPropertyWithDefinedGetter(*receiver,
467 return isolate->
factory()->undefined_value();
479 if (name->
IsSymbol())
return isolate->
heap()->undefined_value();
483 "get", isolate->derived_get_trap(),
ARRAY_SIZE(args), args);
495 Isolate* isolate = name->GetIsolate();
496 if (name->AsArrayIndex(&index))
return GetElement(isolate,
object, index);
505 if (!maybe->To<
String>(&name))
return maybe;
515 Isolate* isolate = proxy->GetIsolate();
517 return SetPropertyWithHandler(
518 proxy, receiver, name, value,
NONE, strict_mode);
522 bool JSProxy::HasElementWithHandler(
Handle<JSProxy> proxy, uint32_t index) {
523 Isolate* isolate = proxy->GetIsolate();
525 return HasPropertyWithHandler(proxy, name);
535 #ifdef ENABLE_DEBUGGER_SUPPORT
536 Debug* debug = isolate->debug();
539 if (debug->StepInActive() && fun->IsJSFunction()) {
545 bool has_pending_exception;
547 isolate, fun,
self, 0,
NULL, &has_pending_exception,
true);
558 LookupResult* result,
561 Isolate* isolate = name->GetIsolate();
562 if (result->IsProperty()) {
563 switch (result->type()) {
566 Handle<Object> callback_obj(result->GetCallbackObject(), isolate);
567 if (callback_obj->IsAccessorInfo()) {
569 *attributes = result->GetAttributes();
571 }
else if (callback_obj->IsAccessorPair()) {
577 Handle<JSObject> holder(result->holder(), isolate);
584 LookupResult r(isolate);
585 result->holder()->LookupRealNamedPropertyInPrototypes(*name, &r);
586 if (r.IsProperty()) {
587 return GetPropertyWithFailedAccessCheck(
588 object, receiver, &r, name, attributes);
595 LookupResult r(isolate);
596 result->holder()->LookupRealNamedProperty(*name, &r);
597 if (r.IsProperty()) {
598 return GetPropertyWithFailedAccessCheck(
599 object, receiver, &r, name, attributes);
612 return isolate->
factory()->undefined_value();
618 LookupResult* result,
620 bool continue_search) {
621 if (result->IsProperty()) {
622 switch (result->type()) {
626 if (
obj->IsAccessorInfo()) {
628 if (info->all_can_read()) {
629 return result->GetAttributes();
631 }
else if (
obj->IsAccessorPair()) {
633 if (pair->all_can_read()) {
634 return result->GetAttributes();
643 if (!continue_search)
break;
645 LookupResult r(object->GetIsolate());
646 result->holder()->LookupRealNamedPropertyInPrototypes(*name, &r);
647 if (r.IsProperty()) {
649 object, &r, name, continue_search);
657 LookupResult r(object->GetIsolate());
658 if (continue_search) {
659 result->holder()->LookupRealNamedProperty(*name, &r);
661 result->holder()->LocalLookupRealNamedProperty(*name, &r);
663 if (!r.IsFound())
break;
665 object, &r, name, continue_search);
675 object->GetIsolate()->ReportFailedAccessCheckWrapper(
object,
v8::ACCESS_HAS);
683 if (IsGlobalObject()) {
686 ASSERT(!value->IsPropertyCell() && !value->IsCell());
692 const LookupResult* result,
694 ASSERT(!object->HasFastProperties());
696 if (object->IsGlobalObject()) {
698 property_dictionary->ValueAt(result->GetDictionaryEntry())));
701 property_dictionary->ValueAtPut(result->GetDictionaryEntry(), *value);
710 PropertyDetails details) {
712 dict->Add(*name, *value, details),
720 PropertyDetails details) {
721 ASSERT(!object->HasFastProperties());
724 if (!name->IsUniqueName()) {
725 name =
object->GetIsolate()->factory()->InternalizeString(
732 if (object->IsGlobalObject()) {
733 store_value =
object->GetIsolate()->factory()->NewPropertyCell(value);
743 int enumeration_index;
745 if (original_details.IsDeleted()) {
749 enumeration_index = original_details.dictionary_index();
750 ASSERT(enumeration_index > 0);
753 details = PropertyDetails(
754 details.attributes(), details.type(), enumeration_index);
756 if (object->IsGlobalObject()) {
778 ASSERT(!object->HasFastProperties());
779 Isolate* isolate =
object->GetIsolate();
781 int entry = dictionary->FindEntry(*name);
784 if (object->IsGlobalObject()) {
785 PropertyDetails details = dictionary->DetailsAt(entry);
786 if (details.IsDontDelete()) {
787 if (mode !=
FORCE_DELETION)
return isolate->factory()->false_value();
793 ASSERT(new_map->is_dictionary_map());
794 object->set_map(*new_map);
797 Handle<Object> value = isolate->factory()->the_hole_value();
799 dictionary->DetailsAtPut(entry, details.AsDeleted());
801 Handle<Object> deleted(dictionary->DeleteProperty(entry, mode), isolate);
802 if (*deleted == isolate->heap()->true_value()) {
803 Handle<NameDictionary> new_properties =
805 object->set_properties(*new_properties);
810 return isolate->factory()->true_value();
816 if (!cons_obj->IsJSFunction())
819 if (!fun->shared()->IsApiFunction())
831 LookupResult* result,
834 Isolate* isolate = result->isolate();
837 object->GetProperty(*receiver, result, *key, attributes),
844 LookupResult* result,
847 Isolate* isolate = result->isolate();
850 object->GetProperty(*receiver, result, *key, attributes));
856 LookupResult* result,
870 AssertNoContextChange ncc(isolate);
879 if (!result->IsHandler()) {
880 Object* last = result->IsProperty()
884 for (
Object* current =
this;
887 if (current->IsAccessCheckNeeded()) {
895 Handle<Object> value = JSObject::GetPropertyWithFailedAccessCheck(
897 handle(receiver, isolate),
908 if (current == last)
break;
912 if (!result->IsProperty()) {
914 return heap->undefined_value();
916 *attributes = result->GetAttributes();
918 switch (result->type()) {
920 value = result->holder()->GetNormalizedProperty(result);
921 ASSERT(!value->IsTheHole() || result->IsReadOnly());
922 return value->IsTheHole() ? heap->undefined_value() : value;
924 MaybeObject* maybe_result = result->holder()->FastPropertyAt(
925 result->representation(),
926 result->GetFieldIndex().field_index());
927 if (!maybe_result->To(&value))
return maybe_result;
928 ASSERT(!value->IsTheHole() || result->IsReadOnly());
929 return value->IsTheHole() ? heap->undefined_value() : value;
932 return result->GetConstant();
936 handle(result->holder(), isolate),
937 handle(receiver, isolate),
938 handle(result->GetCallbackObject(), isolate),
944 return result->proxy()->GetPropertyWithHandler(receiver, name);
948 handle(result->holder(), isolate),
949 handle(receiver, isolate),
973 for (holder =
object;
976 if (!holder->IsJSObject()) {
980 native_context->number_function()->instance_prototype(), isolate);
983 native_context->string_function()->instance_prototype(), isolate);
986 native_context->symbol_function()->instance_prototype(), isolate);
989 native_context->boolean_function()->instance_prototype(), isolate);
990 }
else if (holder->IsJSProxy()) {
998 return isolate->
factory()->undefined_value();
1008 if (js_object->IsAccessCheckNeeded()) {
1012 return isolate->
factory()->undefined_value();
1016 if (js_object->HasIndexedInterceptor()) {
1020 if (js_object->elements() != isolate->
heap()->empty_fixed_array()) {
1022 receiver, js_object, index);
1024 if (!result->IsTheHole())
return result;
1028 return isolate->
factory()->undefined_value();
1035 return context->number_function()->instance_prototype();
1042 if (heap_object->IsJSReceiver()) {
1043 return heap_object->
map()->prototype();
1047 if (heap_object->IsHeapNumber()) {
1048 return context->number_function()->instance_prototype();
1050 if (heap_object->IsString()) {
1051 return context->string_function()->instance_prototype();
1053 if (heap_object->IsSymbol()) {
1054 return context->symbol_function()->instance_prototype();
1056 if (heap_object->IsBoolean()) {
1057 return context->boolean_function()->instance_prototype();
1059 return isolate->
heap()->null_value();
1065 if (IsSmi())
return isolate->
heap()->heap_number_map();
1097 ASSERT(object->IsJSReceiver());
1103 if (other ==
this)
return true;
1107 if (IsNumber() && other->IsNumber()) {
1108 double this_value =
Number();
1109 double other_value = other->
Number();
1110 bool equal = this_value == other_value;
1114 return (this_value != 0) || ((1 / this_value) == (1 / other_value));
1116 if (IsString() && other->IsString()) {
1134 }
else if (IsFailure()) {
1153 accumulator->
Add(
"Failure(%p)", reinterpret_cast<void*>(value()));
1158 PrintF(out,
"Failure(%p)", reinterpret_cast<void*>(value()));
1167 static bool AnWord(
String* str) {
1168 if (str->
length() == 0)
return false;
1169 int c0 = str->Get(0);
1170 int c1 = str->
length() > 1 ? str->Get(1) : 0;
1175 }
else if (c0 ==
'A' || c0 ==
'E' || c0 ==
'I' || c0 ==
'O') {
1177 }
else if ((c1 == 0 || (c1 >=
'A' && c1 <=
'Z')) &&
1178 (c0 ==
'F' || c0 ==
'H' || c0 ==
'M' || c0 ==
'N' || c0 ==
'R' ||
1179 c0 ==
'S' || c0 ==
'X')) {
1186 MaybeObject* String::SlowTryFlatten(
PretenureFlag pretenure) {
1192 if (!AllowHeapAllocation::IsAllowed())
return this;
1196 switch (StringShape(
this).representation_tag()) {
1199 if (cs->second()->length() == 0) {
1210 { MaybeObject* maybe_object =
1211 heap->AllocateRawOneByteString(len, tenure);
1212 if (!maybe_object->ToObject(&
object))
return maybe_object;
1215 String* first = cs->first();
1216 int first_length = first->length();
1219 String* second = cs->second();
1221 dest + first_length,
1223 len - first_length);
1225 { MaybeObject* maybe_object =
1226 heap->AllocateRawTwoByteString(len, tenure);
1227 if (!maybe_object->ToObject(&
object))
return maybe_object;
1231 String* first = cs->first();
1232 int first_length = first->length();
1234 String* second = cs->second();
1236 dest + first_length,
1238 len - first_length);
1240 cs->set_first(result);
1253 ASSERT(!this->IsExternalString());
1254 #ifdef ENABLE_SLOW_ASSERTS
1260 ASSERT(memcmp(smart_chars.start(),
1262 resource->
length() *
sizeof(smart_chars[0])) == 0);
1271 bool is_internalized = this->IsInternalizedString();
1289 short_external_internalized_string_with_one_byte_data_map()
1290 : heap->short_external_internalized_string_map())
1292 ? heap->short_external_string_with_one_byte_data_map()
1293 : heap->short_external_string_map()));
1298 ? heap->external_internalized_string_with_one_byte_data_map()
1299 : heap->external_internalized_string_map())
1301 ? heap->external_string_with_one_byte_data_map()
1302 : heap->external_string_map()));
1305 self->set_resource(resource);
1306 if (is_internalized)
self->Hash();
1309 int new_size = this->
Size();
1317 #ifdef ENABLE_SLOW_ASSERTS
1330 resource->
length() *
sizeof(smart_chars[0])) == 0);
1338 bool is_internalized = this->IsInternalizedString();
1353 is_internalized ? heap->short_external_ascii_internalized_string_map()
1354 : heap->short_external_ascii_string_map());
1357 is_internalized ? heap->external_ascii_internalized_string_map()
1358 : heap->external_ascii_string_map());
1361 self->set_resource(resource);
1362 if (is_internalized)
self->Hash();
1365 int new_size = this->
Size();
1375 accumulator->
Add(
"<Very long string[%u]>", len);
1380 accumulator->
Add(
"<Invalid String>");
1387 bool truncated =
false;
1393 for (
int i = 0; i < len; i++) {
1396 if (c < 32 || c >= 127) {
1402 accumulator->
Add(
"<String[%u]: ",
length());
1403 for (
int i = 0; i < len; i++) {
1404 accumulator->
Put(static_cast<char>(stream.
GetNext()));
1406 accumulator->
Put(
'>');
1410 accumulator->
Add(
"<String[%u]\\: ",
length());
1411 for (
int i = 0; i < len; i++) {
1414 accumulator->
Add(
"\\n");
1415 }
else if (c ==
'\r') {
1416 accumulator->
Add(
"\\r");
1417 }
else if (c ==
'\\') {
1418 accumulator->
Add(
"\\\\");
1419 }
else if (c < 32 || c > 126) {
1420 accumulator->
Add(
"\\x%02x", c);
1422 accumulator->
Put(static_cast<char>(c));
1426 accumulator->
Put(
'.');
1427 accumulator->
Put(
'.');
1428 accumulator->
Put(
'.');
1430 accumulator->
Put(
'>');
1437 switch (
map()->instance_type()) {
1439 double length =
JSArray::cast(
this)->length()->IsUndefined()
1442 accumulator->
Add(
"<JS Array[%u]>", static_cast<uint32_t>(length));
1446 accumulator->
Add(
"<JS WeakMap>");
1450 accumulator->
Add(
"<JS WeakSet>");
1454 accumulator->
Add(
"<JS RegExp>");
1459 Object* fun_name =
function->shared()->DebugName();
1460 bool printed =
false;
1461 if (fun_name->IsString()) {
1464 accumulator->
Add(
"<JS Function ");
1465 accumulator->
Put(str);
1470 accumulator->
Add(
"<JS Function");
1472 accumulator->
Add(
" (SharedFunctionInfo %p)",
1473 reinterpret_cast<void*>(function->shared()));
1474 accumulator->
Put(
'>');
1478 accumulator->
Add(
"<JS Generator>");
1482 accumulator->
Add(
"<JS Module>");
1488 Map* map_of_this =
map();
1490 Object* constructor = map_of_this->constructor();
1491 bool printed =
false;
1492 if (constructor->IsHeapObject() &&
1494 accumulator->
Add(
"!!!INVALID CONSTRUCTOR!!!");
1496 bool global_object = IsJSGlobalProxy();
1497 if (constructor->IsJSFunction()) {
1499 accumulator->
Add(
"!!!INVALID SHARED ON CONSTRUCTOR!!!");
1503 if (constructor_name->IsString()) {
1506 bool vowel = AnWord(str);
1507 accumulator->
Add(
"<%sa%s ",
1508 global_object ?
"Global Object: " :
"",
1510 accumulator->
Put(str);
1511 accumulator->
Add(
" with %smap %p",
1520 accumulator->
Add(
"<JS %sObject", global_object ?
"Global " :
"");
1524 accumulator->
Add(
" value = ");
1527 accumulator->
Put(
'>');
1538 if (from_kind != to_kind) {
1539 PrintF(file,
"elements transition [");
1546 object->ShortPrint(file);
1548 from_elements->ShortPrint(file);
1550 to_elements->ShortPrint(file);
1561 bool constant_to_field,
1564 PrintF(file,
"[generalizing ");
1567 Name* name = instance_descriptors()->GetKey(modify_index);
1568 if (name->IsString()) {
1571 PrintF(file,
"{symbol %p}", static_cast<void*>(name));
1573 if (constant_to_field) {
1581 if (strlen(reason) > 0) {
1582 PrintF(file,
"%s", reason);
1584 PrintF(file,
"+%i maps", descriptors - split);
1595 PrintF(file,
"[migrating ");
1609 if (name->IsString()) {
1612 PrintF(file,
"{symbol %p}", static_cast<void*>(name));
1624 accumulator->
Add(
"!!!INVALID POINTER!!!");
1628 accumulator->
Add(
"!!!INVALID MAP!!!");
1632 accumulator->
Add(
"%p ",
this);
1642 switch (
map()->instance_type()) {
1644 accumulator->
Add(
"<Map(elements=%u)>",
Map::cast(
this)->elements_kind());
1650 accumulator->
Add(
"<FixedDoubleArray[%u]>",
1659 #define TYPED_ARRAY_SHORT_PRINT(Type, type, TYPE, ctype, size) \
1660 case EXTERNAL_##TYPE##_ARRAY_TYPE: \
1661 accumulator->Add("<External" #Type "Array[%u]>", \
1662 External##Type##Array::cast(this)->length()); \
1664 case FIXED_##TYPE##_ARRAY_TYPE: \
1665 accumulator->Add("<Fixed" #Type "Array[%u]>", \
1666 Fixed##Type##Array::cast(this)->length()); \
1670 #undef TYPED_ARRAY_SHORT_PRINT
1676 if (debug_name[0] != 0) {
1677 accumulator->
Add(
"<SharedFunctionInfo %s>", debug_name.
get());
1679 accumulator->
Add(
"<SharedFunctionInfo>");
1684 accumulator->
Add(
"<JSMessageObject>");
1686 #define MAKE_STRUCT_CASE(NAME, Name, name) \
1688 accumulator->Put('<'); \
1689 accumulator->Add(#Name); \
1690 accumulator->Put('>'); \
1693 #undef MAKE_STRUCT_CASE
1695 accumulator->
Add(
"<Code>");
1699 accumulator->
Add(
"<undefined>");
1700 else if (IsTheHole())
1701 accumulator->
Add(
"<the hole>");
1703 accumulator->
Add(
"<null>");
1705 accumulator->
Add(
"<true>");
1707 accumulator->
Add(
"<false>");
1709 accumulator->
Add(
"<Odd Oddball>");
1714 accumulator->
Add(
"<Symbol: %d", symbol->
Hash());
1715 if (!symbol->name()->IsUndefined()) {
1716 accumulator->
Add(
" ");
1717 String::cast(symbol->name())->StringShortPrint(accumulator);
1719 accumulator->
Add(
">");
1723 accumulator->
Add(
"<Number: ");
1725 accumulator->
Put(
'>');
1728 accumulator->
Add(
"<JSProxy>");
1731 accumulator->
Add(
"<JSFunctionProxy>");
1734 accumulator->
Add(
"<Foreign>");
1737 accumulator->
Add(
"Cell for ");
1741 accumulator->
Add(
"PropertyCell for ");
1745 accumulator->
Add(
"<Other heap object (%d)>",
map()->instance_type());
1777 ExternalAsciiStringIterateBody(v);
1780 ExternalTwoByteStringIterateBody(v);
1819 ->JSFunctionIterateBody(object_size, v);
1831 reinterpret_cast<Foreign*
>(
this)->ForeignIterateBody(v);
1837 reinterpret_cast<Code*
>(
this)->CodeIterateBody(v);
1846 Symbol::BodyDescriptor::IterateBody(
this, v);
1855 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
1856 case EXTERNAL_##TYPE##_ARRAY_TYPE: \
1857 case FIXED_##TYPE##_ARRAY_TYPE: \
1861 #undef TYPED_ARRAY_CASE
1868 #define MAKE_STRUCT_CASE(NAME, Name, name) \
1871 #undef MAKE_STRUCT_CASE
1879 PrintF(
"Unknown type: %d\n", type);
1887 #if __BYTE_ORDER == __LITTLE_ENDIAN
1889 #elif __BYTE_ORDER == __BIG_ENDIAN
1919 accumulator->
Add(
"%s", buffer.
start());
1924 if (IsJSFunction() && IsJSFunctionProxy()) {
1925 return GetHeap()->function_class_string();
1927 if (
map()->constructor()->IsJSFunction()) {
1929 return String::cast(constructor->shared()->instance_class_name());
1932 return GetHeap()->Object_string();
1937 if (constructor()->IsJSFunction()) {
1940 if (name->
length() > 0)
return name;
1941 String* inferred_name = constructor->shared()->inferred_name();
1942 if (inferred_name->
length() > 0)
return inferred_name;
1943 Object* proto = prototype();
1948 return GetHeap()->Object_string();
1968 static MaybeObject* CopyAddFieldDescriptor(Map*
map,
1972 Representation representation,
1975 FieldDescriptor new_field_desc(name, index, attributes, representation);
1976 MaybeObject* maybe_map = map->CopyAddDescriptor(&new_field_desc, flag);
1977 if (!maybe_map->To(&new_map))
return maybe_map;
1978 int unused_property_fields = map->unused_property_fields() - 1;
1979 if (unused_property_fields < 0) {
1982 new_map->set_unused_property_fields(unused_property_fields);
1987 static Handle<Map> CopyAddFieldDescriptor(Handle<Map> map,
1991 Representation representation,
1994 CopyAddFieldDescriptor(
1995 *map, *name, index, attributes, representation, flag),
2000 void JSObject::AddFastProperty(Handle<JSObject>
object,
2002 Handle<Object> value,
2004 StoreFromKeyed store_mode,
2005 ValueType value_type,
2007 ASSERT(!object->IsJSGlobalProxy());
2009 object->map()->instance_descriptors()->Search(
2010 *name, object->map()->NumberOfOwnDescriptors()));
2015 Isolate* isolate =
object->GetIsolate();
2016 if (!name->IsCacheable(isolate) ||
2017 object->TooManyFastProperties(store_mode)) {
2019 AddSlowProperty(
object, name, value, attributes);
2024 int index =
object->map()->NextFreePropertyIndex();
2027 if (object->IsJSContextExtensionObject()) value_type =
FORCE_TAGGED;
2028 Representation representation = value->OptimalRepresentation(value_type);
2029 Handle<Map> new_map = CopyAddFieldDescriptor(
2030 handle(object->map()), name, index, attributes, representation, flag);
2034 if (representation.IsDouble()) {
2036 if (value->IsUninitialized())
return;
2040 object->FastPropertyAtPut(index, *value);
2045 static MaybeObject* CopyAddConstantDescriptor(Map* map,
2050 ConstantDescriptor new_constant_desc(name, value, attributes);
2051 return map->CopyAddDescriptor(&new_constant_desc, flag);
2055 static Handle<Map> CopyAddConstantDescriptor(Handle<Map> map,
2057 Handle<Object> value,
2061 CopyAddConstantDescriptor(
2062 *map, *name, *value, attributes, flag),
2067 void JSObject::AddConstantProperty(Handle<JSObject>
object,
2069 Handle<Object> constant,
2074 (
object->IsGlobalObject() ||
2082 Handle<Map> new_map = CopyAddConstantDescriptor(
2083 handle(object->map()), name, constant, attributes, flag);
2089 void JSObject::AddSlowProperty(Handle<JSObject>
object,
2091 Handle<Object> value,
2093 ASSERT(!object->HasFastProperties());
2094 Isolate* isolate =
object->GetIsolate();
2095 Handle<NameDictionary> dict(object->property_dictionary());
2096 if (object->IsGlobalObject()) {
2098 int entry = dict->FindEntry(*name);
2104 int index = dict->NextEnumerationIndex();
2105 PropertyDetails details = PropertyDetails(attributes,
NORMAL, index);
2106 dict->SetNextEnumerationIndex(index + 1);
2107 dict->SetEntry(entry, *name, *cell, details);
2110 Handle<PropertyCell> cell = isolate->factory()->NewPropertyCell(value);
2114 PropertyDetails details = PropertyDetails(attributes,
NORMAL, 0);
2115 Handle<NameDictionary> result = NameDictionaryAdd(dict, name, value, details);
2116 if (*dict != *result)
object->set_properties(*result);
2120 Handle<Object> JSObject::AddProperty(Handle<JSObject>
object,
2122 Handle<Object> value,
2126 ExtensibilityCheck extensibility_check,
2127 ValueType value_type,
2130 ASSERT(!object->IsJSGlobalProxy());
2131 Isolate* isolate =
object->GetIsolate();
2133 if (!name->IsUniqueName()) {
2134 name = isolate->factory()->InternalizeString(
2139 !object->map()->is_extensible()) {
2140 if (strict_mode ==
SLOPPY) {
2143 Handle<Object> args[1] = { name };
2144 Handle<Object> error = isolate->factory()->NewTypeError(
2146 isolate->Throw(*error);
2147 return Handle<Object>();
2151 if (object->HasFastProperties()) {
2153 if (object->map()->NumberOfOwnDescriptors() <= kMaxNumberOfDescriptors) {
2158 if (value->IsJSFunction()) {
2159 AddConstantProperty(
object, name, value, attributes, transition_flag);
2161 AddFastProperty(
object, name, value, attributes, store_mode,
2162 value_type, transition_flag);
2168 AddSlowProperty(
object, name, value, attributes);
2171 AddSlowProperty(
object, name, value, attributes);
2174 if (object->map()->is_observed() &&
2175 *name != isolate->heap()->hidden_string()) {
2176 Handle<Object> old_value = isolate->factory()->the_hole_value();
2185 const char* type_str,
2188 Isolate* isolate =
object->GetIsolate();
2191 if (object->IsJSGlobalObject()) {
2195 int argc = name.
is_null() ? 2 : old_value->IsTheHole() ? 3 : 4;
2200 isolate->
factory()->undefined_value(),
2214 LookupResult result(object->GetIsolate());
2215 object->LocalLookupRealNamedProperty(*name, &result);
2216 if (!result.IsFound()) {
2217 object->map()->LookupTransition(*
object, *name, &result);
2219 if (result.IsFound()) {
2226 Handle<Object> result_object = SetPropertyViaPrototypes(
2227 object, name, value, attributes, strict_mode, &done);
2228 if (done)
return result_object;
2230 return AddProperty(
object, name, value, attributes, strict_mode);
2234 static void ReplaceSlowProperty(Handle<JSObject>
object,
2236 Handle<Object> value,
2238 NameDictionary* dictionary =
object->property_dictionary();
2239 int old_index = dictionary->FindEntry(*name);
2240 int new_enumeration_index = 0;
2241 if (old_index != -1) {
2243 new_enumeration_index = dictionary->DetailsAt(old_index).dictionary_index();
2246 PropertyDetails new_details(attributes,
NORMAL, new_enumeration_index);
2253 case kNone:
return "v";
2255 case kSmi:
return "s";
2267 static void ZapEndOfFixedArray(
Address new_end,
int to_trim) {
2271 for (
int i = 1; i < to_trim; i++) {
2277 template<Heap::InvocationMode mode>
2278 static void RightTrimFixedArray(Heap* heap, FixedArray* elms,
int to_trim) {
2279 ASSERT(elms->map() != heap->fixed_cow_array_map());
2281 ASSERT(!heap->lo_space()->Contains(elms));
2283 const int len = elms->length();
2290 ZapEndOfFixedArray(new_end, to_trim);
2298 heap->CreateFillerObjectAt(new_end, size_delta);
2300 elms->set_length(len - to_trim);
2302 heap->AdjustLiveBytes(elms->address(), -size_delta,
mode);
2306 HeapProfiler*
profiler = heap->isolate()->heap_profiler();
2307 if (profiler->is_tracking_allocations()) {
2308 profiler->UpdateObjectSizeEvent(elms->address(), elms->Size());
2314 int target_number_of_fields,
2315 int target_inobject,
2316 int target_unused) {
2319 ASSERT(target_number_of_fields >= number_of_fields);
2320 if (target_number_of_fields != number_of_fields)
return true;
2326 for (
int i = 0; i < limit; i++) {
2327 if (new_desc->
GetDetails(i).representation().IsDouble() &&
2328 !old_desc->
GetDetails(i).representation().IsDouble()) {
2340 if (target_number_of_fields <= target_inobject) {
2341 ASSERT(target_number_of_fields + target_unused == target_inobject);
2365 Isolate* isolate =
object->GetIsolate();
2367 int number_of_fields = new_map->NumberOfFields();
2368 int inobject = new_map->inobject_properties();
2369 int unused = new_map->unused_property_fields();
2373 if (!old_map->InstancesNeedRewriting(
2374 *new_map, number_of_fields, inobject, unused)) {
2375 object->set_map(*new_map);
2379 int total_size = number_of_fields + unused;
2380 int external = total_size - inobject;
2385 int old_nof = old_map->NumberOfOwnDescriptors();
2386 int new_nof = new_map->NumberOfOwnDescriptors();
2390 ASSERT(old_nof <= new_nof);
2392 for (
int i = 0; i < old_nof; i++) {
2393 PropertyDetails details = new_descriptors->GetDetails(i);
2394 if (details.type() !=
FIELD)
continue;
2395 PropertyDetails old_details = old_descriptors->GetDetails(i);
2397 ASSERT(details.representation().IsTagged());
2401 old_details.type() ==
FIELD);
2403 ? old_descriptors->GetValue(i)
2404 :
object->RawFastPropertyAt(old_descriptors->GetFieldIndex(i));
2406 if (!old_details.representation().IsDouble() &&
2407 details.representation().IsDouble()) {
2408 if (old_details.representation().IsNone()) {
2411 value = NewStorageFor(isolate, value, details.representation());
2413 ASSERT(!(details.representation().IsDouble() && value->IsSmi()));
2414 int target_index = new_descriptors->GetFieldIndex(i) - inobject;
2415 if (target_index < 0) target_index += total_size;
2416 array->set(target_index, *value);
2419 for (
int i = old_nof; i < new_nof; i++) {
2420 PropertyDetails details = new_descriptors->GetDetails(i);
2421 if (details.type() !=
FIELD)
continue;
2422 if (details.representation().IsDouble()) {
2423 int target_index = new_descriptors->GetFieldIndex(i) - inobject;
2424 if (target_index < 0) target_index += total_size;
2426 array->set(target_index, *box);
2435 int limit =
Min(inobject, number_of_fields);
2436 for (
int i = 0; i < limit; i++) {
2437 object->FastPropertyAtPut(i, array->get(external + i));
2441 int new_instance_size = new_map->instance_size();
2442 int instance_size_delta = old_map->instance_size() - new_instance_size;
2443 ASSERT(instance_size_delta >= 0);
2450 RightTrimFixedArray<Heap::FROM_MUTATOR>(isolate->
heap(), *array, inobject);
2451 object->set_properties(*array);
2454 object->set_map(*new_map);
2463 map->AddTransition(*key, *target, flag),
2473 handle(object->map()), modify_index, new_representation, store_mode);
2474 if (object->map() == *new_map)
return;
2493 const char* reason) {
2500 PropertyDetails details = descriptors->
GetDetails(modify_index);
2503 new_map->NumberOfFields(),
2506 d.SetSortedKeyIndex(details.pointer());
2507 descriptors->
Set(modify_index, &d);
2508 int unused_property_fields = new_map->unused_property_fields() - 1;
2509 if (unused_property_fields < 0) {
2512 new_map->set_unused_property_fields(unused_property_fields);
2515 if (FLAG_trace_generalization) {
2516 map->PrintGeneralization(stdout, reason, modify_index,
2517 new_map->NumberOfOwnDescriptors(),
2518 new_map->NumberOfOwnDescriptors(),
2547 int transition = transitions->
Search(key);
2557 Map* current =
this;
2559 while (current->instance_descriptors() == to_replace) {
2561 current->set_instance_descriptors(new_descriptors);
2563 if (next->IsUndefined())
break;
2575 if (back->IsUndefined())
return result;
2588 Map* current =
this;
2590 for (
int i = verbatim; i < length; i++) {
2594 int transition = transitions->
Search(name);
2596 current = transitions->
GetTarget(transition);
2597 PropertyDetails details = descriptors->
GetDetails(i);
2598 PropertyDetails target_details =
2599 current->instance_descriptors()->GetDetails(i);
2600 if (details.attributes() != target_details.attributes())
return NULL;
2604 current->instance_descriptors()->GetValue(i)) {
2607 }
else if (target_details.type() ==
CALLBACKS) {
2622 Map* current =
this;
2624 for (
int i = verbatim; i < length; i++) {
2628 int transition = transitions->
Search(name);
2636 PropertyDetails details = descriptors->
GetDetails(i);
2637 PropertyDetails next_details = next_descriptors->
GetDetails(i);
2638 if (details.type() != next_details.type())
break;
2639 if (details.attributes() != next_details.attributes())
break;
2640 if (!details.representation().Equals(next_details.representation()))
break;
2671 PropertyDetails old_details = old_descriptors->GetDetails(modify_index);
2672 Representation old_representation = old_details.representation();
2678 if (old_representation.
IsNone() &&
2679 !new_representation.
IsNone() &&
2681 old_descriptors->SetRepresentation(modify_index, new_representation);
2685 int descriptors = old_map->NumberOfOwnDescriptors();
2689 if (!old_map->EquivalentToForTransition(*root_map)) {
2691 old_details.attributes(),
"not equivalent");
2694 int verbatim = root_map->NumberOfOwnDescriptors();
2698 old_details.attributes(),
"root modification");
2702 verbatim, descriptors, *old_descriptors);
2703 if (raw_updated ==
NULL) {
2705 old_details.attributes(),
"incompatible");
2711 int valid = updated->NumberOfOwnDescriptors();
2715 if (updated_descriptors->IsMoreGeneralThan(
2716 verbatim, valid, descriptors, *old_descriptors) &&
2718 updated_descriptors->GetDetails(modify_index).type() ==
FIELD)) {
2720 updated_descriptors->GetDetails(modify_index).representation();
2721 if (new_representation.
fits_into(updated_representation))
return updated;
2725 updated_descriptors, verbatim, valid, descriptors, modify_index,
2726 store_mode, old_descriptors);
2728 new_descriptors->GetDetails(modify_index).type() ==
FIELD);
2730 old_representation =
2731 new_descriptors->GetDetails(modify_index).representation();
2733 new_representation.
generalize(old_representation);
2734 if (!updated_representation.
Equals(old_representation)) {
2735 new_descriptors->SetRepresentation(modify_index, updated_representation);
2739 verbatim, descriptors, *new_descriptors));
2741 int split_descriptors = split_map->NumberOfOwnDescriptors();
2744 ASSERT(descriptors != split_descriptors);
2746 int descriptor = split_descriptors;
2747 split_map->DeprecateTarget(
2748 old_descriptors->GetKey(descriptor), *new_descriptors);
2750 if (FLAG_trace_generalization) {
2751 old_map->PrintGeneralization(
2752 stdout,
"", modify_index, descriptor, descriptors,
2753 old_descriptors->GetDetails(modify_index).type() ==
CONSTANT &&
2755 old_representation, updated_representation);
2760 for (; descriptor < descriptors; descriptor++) {
2764 new_map->set_owns_descriptors(
true);
2774 for (
int i = 0; i < map->NumberOfOwnDescriptors(); i++) {
2775 PropertyDetails details = descriptors->GetDetails(i);
2776 if (details.type() ==
FIELD) {
2786 while (proto_map->prototype()->IsJSObject()) {
2788 if (holder->map()->is_deprecated()) {
2798 if (!map->is_deprecated())
return map;
2803 int descriptors = map->NumberOfOwnDescriptors();
2804 Map* root_map = map->FindRootMap();
2807 if (!map->EquivalentToForTransition(root_map))
return Handle<Map>();
2811 verbatim, descriptors, old_descriptors);
2814 DescriptorArray* updated_descriptors = updated->instance_descriptors();
2816 if (!updated_descriptors->IsMoreGeneralThan(
2817 verbatim, valid, descriptors, old_descriptors)) {
2832 if (name->IsSymbol())
return value;
2833 Isolate* isolate =
object->GetIsolate();
2836 if (!interceptor->setter()->IsUndefined()) {
2838 ApiNamedPropertyAccess(
"interceptor-named-set", *
object, *name));
2840 isolate, interceptor->data(), *object, *object);
2842 v8::ToCData<v8::NamedPropertySetterCallback>(interceptor->setter());
2849 if (!result.IsEmpty())
return value;
2852 SetPropertyPostInterceptor(
object, name, value, attributes, strict_mode);
2864 LookupResult result(object->GetIsolate());
2865 object->LocalLookup(*name, &result,
true);
2866 if (!result.IsFound()) {
2867 object->map()->LookupTransition(
JSObject::cast(*
object), *name, &result);
2869 return SetProperty(
object, &result, name, value, attributes, strict_mode,
2880 Isolate* isolate =
object->GetIsolate();
2884 ASSERT(!value->IsTheHole());
2889 if (structure->IsForeign()) {
2895 isolate, *
object, *value, callback->
data),
2902 if (structure->IsExecutableAccessorInfo()) {
2911 isolate->
Throw(*error);
2915 if (name->IsSymbol())
return value;
2916 Object* call_obj = data->setter();
2918 v8::ToCData<v8::AccessorSetterCallback>(call_obj);
2919 if (call_fun ==
NULL)
return value;
2921 LOG(isolate, ApiNamedPropertyAccess(
"store", *
object, *name));
2931 if (structure->IsAccessorPair()) {
2933 if (setter->IsSpecFunction()) {
2938 if (strict_mode ==
SLOPPY)
return value;
2943 isolate->
Throw(*error);
2949 if (structure->IsDeclaredAccessorInfo()) {
2962 Isolate* isolate =
object->GetIsolate();
2964 #ifdef ENABLE_DEBUGGER_SUPPORT
2965 Debug* debug = isolate->debug();
2968 if (debug->StepInActive() && setter->IsJSFunction()) {
2969 debug->HandleStepIn(
2974 bool has_pending_exception;
2977 isolate, setter,
object,
ARRAY_SIZE(argv), argv, &has_pending_exception);
2984 Handle<Object> JSObject::SetElementWithCallbackSetterInPrototypes(
2990 Isolate *isolate =
object->GetIsolate();
2993 proto =
handle(proto->GetPrototype(isolate), isolate)) {
2994 if (proto->IsJSProxy()) {
3005 if (!js_proto->HasDictionaryElements()) {
3008 Handle<SeededNumberDictionary> dictionary(js_proto->element_dictionary());
3009 int entry = dictionary->FindEntry(index);
3011 PropertyDetails details = dictionary->DetailsAt(entry);
3014 Handle<Object> structure(dictionary->ValueAt(entry), isolate);
3015 return SetElementWithCallback(
object, structure, index, value, js_proto,
3021 return isolate->
factory()->the_hole_value();
3025 Handle<Object> JSObject::SetPropertyViaPrototypes(Handle<JSObject>
object,
3027 Handle<Object> value,
3031 Isolate* isolate =
object->GetIsolate();
3037 LookupResult result(isolate);
3038 object->LookupRealNamedPropertyInPrototypes(*name, &result);
3039 if (result.IsFound()) {
3040 switch (result.type()) {
3044 *done = result.IsReadOnly();
3048 handle(result.holder()),
object, name,
true);
3054 Handle<Object> callback_object(result.GetCallbackObject(), isolate);
3056 handle(result.holder()), strict_mode);
3059 Handle<JSProxy> proxy(result.proxy());
3061 proxy,
object, name, value, attributes, strict_mode, done);
3072 if (strict_mode ==
SLOPPY)
return value;
3073 Handle<Object> args[] = {
name,
object };
3074 Handle<Object> error = isolate->factory()->NewTypeError(
3076 isolate->Throw(*error);
3077 return Handle<Object>();
3079 return isolate->factory()->the_hole_value();
3085 if (slack <= descriptors->NumberOfSlackDescriptors())
return;
3086 int number_of_descriptors = descriptors->number_of_descriptors();
3087 Isolate* isolate = map->GetIsolate();
3092 for (
int i = 0; i < number_of_descriptors; ++i) {
3093 new_descriptors->CopyFrom(i, *descriptors, i, witness);
3096 map->set_instance_descriptors(*new_descriptors);
3101 static int AppendUniqueCallbacks(
NeanderArray* callbacks,
3103 int valid_descriptors) {
3104 int nof_callbacks = callbacks->
length();
3106 Isolate* isolate = array->GetIsolate();
3110 for (
int i = 0; i < nof_callbacks; ++i) {
3112 if (entry->name()->IsUniqueName())
continue;
3116 entry->set_name(*key);
3122 for (
int i = nof_callbacks - 1; i >= 0; i--) {
3126 if (!T::Contains(key, entry, valid_descriptors, array)) {
3127 T::Insert(key, entry, valid_descriptors, array);
3128 valid_descriptors++;
3132 return valid_descriptors;
3139 int valid_descriptors,
3145 int valid_descriptors,
3148 array->Append(&desc);
3157 int valid_descriptors,
3159 for (
int i = 0; i < valid_descriptors; i++) {
3166 int valid_descriptors,
3168 array->set(valid_descriptors, entry);
3175 int nof = map->NumberOfOwnDescriptors();
3178 ASSERT(array->NumberOfSlackDescriptors() >= callbacks.length());
3179 nof = AppendUniqueCallbacks<DescriptorArrayAppender>(&callbacks, array, nof);
3180 map->SetNumberOfOwnDescriptors(nof);
3186 int valid_descriptors) {
3188 ASSERT(array->length() >= callbacks.
length() + valid_descriptors);
3189 return AppendUniqueCallbacks<FixedArrayAppender>(&callbacks,
3197 for (
int i = 0; i < maps->length(); ++i) {
3198 if (!maps->
at(i).is_null() && maps->
at(i).is_identical_to(map))
return true;
3205 static Handle<T> MaybeNull(
T* p) {
3207 return Handle<T>(p);
3220 MaybeNull(current_map->LookupElementsTransitionMap(kind));
3221 if (maybe_transitioned_map.
is_null())
break;
3222 if (ContainsMap(candidates, maybe_transitioned_map) &&
3224 transitioned_map = maybe_transitioned_map;
3227 current_map = maybe_transitioned_map;
3230 return transitioned_map;
3248 while (kind != target_kind) {
3257 if (next_map->elements_kind() == to_kind)
return next_map;
3266 Map* to_map = FindClosestElementsTransition(
this, to_kind);
3274 if (isolate->initial_array_prototype()->map() ==
this) {
3278 if (isolate->initial_object_prototype()->map() ==
this) {
3286 static MaybeObject* AddMissingElementsTransitions(
Map* map,
3295 MaybeObject* maybe_next_map =
3297 if (!maybe_next_map->To(¤t_map))
return maybe_next_map;
3302 if (kind != to_kind) {
3303 MaybeObject* maybe_next_map =
3305 if (!maybe_next_map->To(¤t_map))
return maybe_next_map;
3315 Isolate* isolate =
object->GetIsolate();
3317 object->GetElementsTransitionMap(isolate, to_kind),
3326 if (from_kind == to_kind) {
3330 bool allow_store_transition =
3333 !start_map->IsUndefined() && !start_map->
is_shared() &&
3338 allow_store_transition &=
3343 if (!allow_store_transition) {
3355 map->AsElementsKind(kind),
3361 Map* closest_map = FindClosestElementsTransition(
this, kind);
3367 return AddMissingElementsTransitions(closest_map, kind);
3373 if (IsJSGlobalProxy()) {
3375 if (proto->IsNull())
return result->NotFound();
3376 ASSERT(proto->IsJSGlobalObject());
3385 ASSERT(!result->IsFound() ||
3386 (result->holder() ==
this && result->IsFastPropertyType()));
3389 if (result->IsField() &&
3390 result->IsReadOnly() &&
3392 result->DisallowCaching();
3400 if (IsGlobalObject()) {
3402 if (d.IsDeleted()) {
3410 if (value->IsTheHole()) result->DisallowCaching();
3411 result->DictionaryResult(
this, entry);
3421 if (result->IsFound())
return;
3428 LookupResult* result) {
3432 pt != heap->null_value();
3433 pt = pt->GetPrototype(isolate)) {
3434 if (pt->IsJSProxy()) {
3439 if (result->IsFound())
return;
3448 LookupResult* result,
3451 bool check_prototype,
3453 if (check_prototype && !result->IsProperty()) {
3454 object->LookupRealNamedPropertyInPrototypes(*name, result);
3457 if (result->IsProperty()) {
3458 if (!result->IsReadOnly()) {
3459 switch (result->type()) {
3461 Object*
obj = result->GetCallbackObject();
3462 if (obj->IsAccessorInfo()) {
3464 if (info->all_can_write()) {
3469 handle(result->holder()),
3472 }
else if (obj->IsAccessorPair()) {
3474 if (pair->all_can_read()) {
3479 handle(result->holder()),
3488 LookupResult r(object->GetIsolate());
3489 object->LookupRealNamedProperty(*name, &r);
3490 if (r.IsProperty()) {
3491 return SetPropertyWithFailedAccessCheck(
object,
3507 Isolate* isolate =
object->GetIsolate();
3515 LookupResult* result,
3517 Handle<Object> value,
3520 StoreFromKeyed store_mode) {
3521 if (result->IsHandler()) {
3522 return JSProxy::SetPropertyWithHandler(
handle(result->proxy()),
3523 object, key, value, attributes, strict_mode);
3526 result, key, value, attributes, strict_mode, store_mode);
3531 bool JSProxy::HasPropertyWithHandler(Handle<JSProxy> proxy, Handle<Name> name) {
3532 Isolate* isolate = proxy->GetIsolate();
3535 if (name->IsSymbol())
return false;
3537 Handle<Object> args[] = { name };
3538 Handle<Object> result = proxy->CallTrap(
3539 "has", isolate->derived_has_trap(),
ARRAY_SIZE(args), args);
3540 if (isolate->has_pending_exception())
return false;
3542 return result->BooleanValue();
3546 Handle<Object> JSProxy::SetPropertyWithHandler(Handle<JSProxy> proxy,
3547 Handle<JSReceiver> receiver,
3549 Handle<Object> value,
3552 Isolate* isolate = proxy->GetIsolate();
3555 if (name->IsSymbol())
return value;
3557 Handle<Object> args[] = { receiver,
name, value };
3558 proxy->CallTrap(
"set", isolate->derived_set_trap(),
ARRAY_SIZE(args), args);
3559 if (isolate->has_pending_exception())
return Handle<Object>();
3573 Isolate* isolate = proxy->GetIsolate();
3577 if (name->IsSymbol()) {
3579 return isolate->
factory()->the_hole_value();
3590 return isolate->
factory()->the_hole_value();
3594 bool has_pending_exception;
3597 isolate, isolate->to_complete_property_descriptor(), result,
3598 ARRAY_SIZE(argv), argv, &has_pending_exception);
3609 if (configurable->
IsFalse()) {
3616 isolate->
Throw(*error);
3629 if (hasWritable->
IsTrue()) {
3638 if (!*done)
return isolate->
factory()->the_hole_value();
3639 if (strict_mode ==
SLOPPY)
return value;
3643 isolate->
Throw(*error);
3658 if (strict_mode ==
SLOPPY)
return value;
3662 isolate->
Throw(*error);
3669 Isolate* isolate = proxy->GetIsolate();
3672 if (name->IsSymbol())
return isolate->
factory()->false_value();
3687 isolate->
Throw(*error);
3688 return Handle<Object>();
3694 Handle<Object> JSProxy::DeleteElementWithHandler(
3695 Handle<JSProxy> proxy, uint32_t index, DeleteMode mode) {
3696 Isolate* isolate = proxy->GetIsolate();
3697 Handle<String> name = isolate->factory()->Uint32ToString(index);
3698 return JSProxy::DeletePropertyWithHandler(proxy, name, mode);
3706 Isolate* isolate = proxy->GetIsolate();
3710 if (name->IsSymbol())
return ABSENT;
3719 bool has_pending_exception;
3722 isolate, isolate->to_complete_property_descriptor(), result,
3723 ARRAY_SIZE(argv), argv, &has_pending_exception);
3724 if (has_pending_exception)
return NONE;
3747 if (configurable->
IsFalse()) {
3754 isolate->
Throw(*error);
3758 int attributes =
NONE;
3770 Isolate* isolate = proxy->GetIsolate();
3777 Isolate* isolate = proxy->GetIsolate();
3782 if (proxy->IsJSFunctionProxy()) {
3788 ASSERT(proxy->IsJSObject());
3791 if (hash->IsSmi()) {
3810 if (derived.is_null()) {
3814 isolate->
Throw(*error);
3832 ASSERT(object->map()->inobject_properties() == map->inobject_properties());
3833 ElementsKind obj_kind =
object->map()->elements_kind();
3835 if (map_kind != obj_kind) {
3846 map = MapAsElementsKind(map, to_kind);
3859 object->map()->set_migration_target(
true);
3860 if (FLAG_trace_migration) {
3861 object->PrintInstanceMigration(stdout, *original_map, object->map());
3871 if (FLAG_trace_migration) {
3872 object->PrintInstanceMigration(stdout, *original_map, object->map());
3880 LookupResult* lookup,
3884 Handle<Map> transition_map(lookup->GetTransitionTarget());
3885 int descriptor = transition_map->LastAdded();
3887 DescriptorArray* descriptors = transition_map->instance_descriptors();
3888 PropertyDetails details = descriptors->
GetDetails(descriptor);
3890 if (details.type() ==
CALLBACKS || attributes != details.attributes()) {
3894 return JSObject::AddProperty(
3895 object, name, value, attributes,
SLOPPY,
3904 if (!value->FitsRepresentation(details.representation()) ||
3906 descriptors->
GetValue(descriptor) != *value)) {
3908 descriptor, value->OptimalRepresentation(),
FORCE_FIELD);
3914 descriptors = transition_map->instance_descriptors();
3915 details = descriptors->
GetDetails(descriptor);
3917 if (details.type() !=
FIELD)
return value;
3920 if (details.representation().IsDouble()) {
3922 if (value->IsUninitialized())
return value;
3923 HeapNumber* box =
HeapNumber::cast(object->RawFastPropertyAt(field_index));
3926 object->FastPropertyAtPut(field_index, *value);
3933 static void SetPropertyToField(LookupResult* lookup,
3935 Handle<Object> value) {
3936 Representation representation = lookup->representation();
3937 if (!value->FitsRepresentation(representation) ||
3940 lookup->GetDescriptorIndex(),
3941 value->OptimalRepresentation(),
3943 DescriptorArray* desc = lookup->holder()->map()->instance_descriptors();
3944 int descriptor = lookup->GetDescriptorIndex();
3945 representation = desc->GetDetails(descriptor).representation();
3948 if (representation.IsDouble()) {
3949 HeapNumber* storage =
HeapNumber::cast(lookup->holder()->RawFastPropertyAt(
3950 lookup->GetFieldIndex().field_index()));
3951 storage->set_value(value->Number());
3955 lookup->holder()->FastPropertyAtPut(
3956 lookup->GetFieldIndex().field_index(), *value);
3960 static void ConvertAndSetLocalProperty(LookupResult* lookup,
3962 Handle<Object> value,
3964 Handle<JSObject> object(lookup->holder());
3965 if (object->TooManyFastProperties()) {
3969 if (!object->HasFastProperties()) {
3970 ReplaceSlowProperty(
object, name, value, attributes);
3974 int descriptor_index = lookup->GetDescriptorIndex();
3975 if (lookup->GetAttributes() == attributes) {
3979 Handle<Map> old_map(object->map());
3981 descriptor_index,
FORCE_FIELD, attributes,
"attributes mismatch");
3985 DescriptorArray* descriptors =
object->
map()->instance_descriptors();
3986 int index = descriptors->GetDetails(descriptor_index).field_index();
3987 object->FastPropertyAtPut(index, *value);
3991 static void SetPropertyToFieldWithAttributes(LookupResult* lookup,
3993 Handle<Object> value,
3995 if (lookup->GetAttributes() == attributes) {
3996 if (value->IsUninitialized())
return;
3997 SetPropertyToField(lookup, name, value);
3999 ConvertAndSetLocalProperty(lookup, name, value, attributes);
4005 LookupResult* lookup,
4011 Isolate* isolate =
object->GetIsolate();
4015 AssertNoContextChange ncc(isolate);
4020 if (name->IsString() && !name->IsInternalizedString() &&
4026 if (object->IsAccessCheckNeeded()) {
4028 return SetPropertyWithFailedAccessCheck(
object, lookup, name, value,
4033 if (object->IsJSGlobalProxy()) {
4035 if (proto->IsNull())
return value;
4036 ASSERT(proto->IsJSGlobalObject());
4038 lookup, name, value, attributes, strict_mode, store_mode);
4041 ASSERT(!lookup->IsFound() || lookup->holder() == *
object ||
4042 lookup->holder()->map()->is_hidden_prototype());
4044 if (!lookup->IsProperty() && !
object->IsJSContextExtensionObject()) {
4047 object, name, value, attributes, strict_mode, &done);
4048 if (done)
return result_object;
4051 if (!lookup->IsFound()) {
4054 object, name, value, attributes, strict_mode, store_mode);
4057 if (lookup->IsProperty() && lookup->IsReadOnly()) {
4058 if (strict_mode ==
STRICT) {
4062 isolate->
Throw(*error);
4070 bool is_observed =
object->map()->is_observed() &&
4072 if (is_observed && lookup->IsDataProperty()) {
4080 switch (lookup->type()) {
4085 SetPropertyToField(lookup, name, value);
4089 if (*value == lookup->GetConstant())
return value;
4090 SetPropertyToField(lookup, name, value);
4093 Handle<Object> callback_object(lookup->GetCallbackObject(), isolate);
4095 handle(lookup->holder()), strict_mode);
4099 attributes, strict_mode);
4102 result = SetPropertyUsingTransition(
handle(lookup->holder()), lookup,
4103 name, value, attributes);
4113 if (lookup->IsTransition()) {
4116 LookupResult new_lookup(isolate);
4117 object->LocalLookup(*name, &new_lookup,
true);
4118 if (new_lookup.IsDataProperty()) {
4121 if (!new_value->
SameValue(*old_value)) {
4149 Isolate* isolate =
object->GetIsolate();
4153 AssertNoContextChange ncc(isolate);
4155 LookupResult lookup(isolate);
4156 object->LocalLookup(*name, &lookup,
true);
4157 if (!lookup.IsFound()) {
4158 object->map()->LookupTransition(*
object, *name, &lookup);
4162 if (object->IsAccessCheckNeeded()) {
4164 return SetPropertyWithFailedAccessCheck(
object, &lookup, name, value,
4169 if (object->IsJSGlobalProxy()) {
4171 if (proto->IsNull())
return value;
4172 ASSERT(proto->IsJSGlobalObject());
4174 name, value, attributes, value_type, mode, extensibility_check);
4177 if (lookup.IsFound() &&
4179 object->LocalLookupRealNamedProperty(*name, &lookup);
4183 if (!lookup.IsFound()) {
4184 object->map()->LookupTransition(*
object, *name, &lookup);
4188 return AddProperty(
object, name, value, attributes,
SLOPPY,
4194 bool is_observed =
object->map()->is_observed() &&
4196 if (is_observed && lookup.IsProperty()) {
4197 if (lookup.IsDataProperty()) {
4201 old_attributes = lookup.GetAttributes();
4205 switch (lookup.type()) {
4207 ReplaceSlowProperty(
object, name, value, attributes);
4210 SetPropertyToFieldWithAttributes(&lookup, name, value, attributes);
4214 if (lookup.GetAttributes() != attributes ||
4215 *value != lookup.GetConstant()) {
4216 SetPropertyToFieldWithAttributes(&lookup, name, value, attributes);
4220 ConvertAndSetLocalProperty(&lookup, name, value, attributes);
4224 handle(lookup.holder()), &lookup, name, value, attributes);
4235 if (lookup.IsTransition()) {
4237 }
else if (old_value->IsTheHole()) {
4240 LookupResult new_lookup(isolate);
4241 object->LocalLookup(*name, &new_lookup,
true);
4242 bool value_changed =
false;
4243 if (new_lookup.IsDataProperty()) {
4246 value_changed = !old_value->
SameValue(*new_value);
4248 if (new_lookup.GetAttributes() != old_attributes) {
4249 if (!value_changed) old_value = isolate->
factory()->the_hole_value();
4251 }
else if (value_changed) {
4265 bool continue_search) {
4267 Isolate* isolate =
object->GetIsolate();
4268 LookupResult result(isolate);
4269 object->LocalLookupRealNamedProperty(*name, &result);
4270 if (result.IsFound())
return result.GetAttributes();
4272 if (continue_search) {
4275 if (!proto->IsNull()) {
4288 bool continue_search) {
4290 if (name->IsSymbol())
return ABSENT;
4292 Isolate* isolate =
object->GetIsolate();
4297 AssertNoContextChange ncc(isolate);
4301 isolate, interceptor->data(), *receiver, *object);
4302 if (!interceptor->query()->IsUndefined()) {
4304 v8::ToCData<v8::NamedPropertyQueryCallback>(interceptor->query());
4306 ApiNamedPropertyAccess(
"interceptor-named-has", *
object, *name));
4313 }
else if (!interceptor->getter()->IsUndefined()) {
4315 v8::ToCData<v8::NamedPropertyGetterCallback>(interceptor->getter());
4317 ApiNamedPropertyAccess(
"interceptor-named-get-has", *
object, *name));
4323 object, receiver, name, continue_search);
4332 if (object->IsJSObject() && key->AsArrayIndex(&index)) {
4337 LookupResult lookup(object->GetIsolate());
4338 object->Lookup(*key, &lookup);
4339 return GetPropertyAttributeForResult(
object, receiver, &lookup, key,
true);
4346 LookupResult* lookup,
4348 bool continue_search) {
4350 if (object->IsAccessCheckNeeded()) {
4351 Heap* heap =
object->GetHeap();
4355 obj, lookup, name, continue_search);
4358 if (lookup->IsFound()) {
4359 switch (lookup->type()) {
4364 return lookup->GetAttributes();
4367 handle(lookup->proxy()), receiver, name);
4371 handle(lookup->holder()),
4372 Handle<JSObject>::cast(receiver),
4388 if (object->IsJSObject() && name->AsArrayIndex(&index)) {
4392 LookupResult lookup(object->GetIsolate());
4393 object->LocalLookup(*name, &lookup,
true);
4394 return GetPropertyAttributeForResult(
object,
object, &lookup, name,
false);
4402 bool continue_search) {
4403 Isolate* isolate =
object->GetIsolate();
4406 if (object->IsAccessCheckNeeded()) {
4413 if (object->IsJSGlobalProxy()) {
4415 if (proto->IsNull())
return ABSENT;
4416 ASSERT(proto->IsJSGlobalObject());
4423 return JSObject::GetElementAttributeWithInterceptor(
4424 object, receiver, index, continue_search);
4427 return GetElementAttributeWithoutInterceptor(
4428 object, receiver, index, continue_search);
4436 bool continue_search) {
4437 Isolate* isolate =
object->GetIsolate();
4442 AssertNoContextChange ncc(isolate);
4446 isolate, interceptor->data(), *receiver, *object);
4447 if (!interceptor->query()->IsUndefined()) {
4449 v8::ToCData<v8::IndexedPropertyQueryCallback>(interceptor->query());
4451 ApiIndexedPropertyAccess(
"interceptor-indexed-has", *
object, index));
4454 return static_cast<PropertyAttributes>(result->
Int32Value());
4455 }
else if (!interceptor->getter()->IsUndefined()) {
4457 v8::ToCData<v8::IndexedPropertyGetterCallback>(interceptor->getter());
4459 ApiIndexedPropertyAccess(
4460 "interceptor-indexed-get-has", *
object, index));
4465 return GetElementAttributeWithoutInterceptor(
4466 object, receiver, index, continue_search);
4471 Handle<JSObject>
object,
4472 Handle<JSReceiver> receiver,
4474 bool continue_search) {
4476 *receiver, *
object, index);
4477 if (attr !=
ABSENT)
return attr;
4480 if (object->IsStringObjectWithCharacterAt(index)) {
4484 if (!continue_search)
return ABSENT;
4486 Handle<Object> proto(object->GetPrototype(),
object->GetIsolate());
4487 if (proto->IsJSProxy()) {
4490 Handle<JSProxy>::cast(proto), receiver, index);
4492 if (proto->IsNull())
return ABSENT;
4494 Handle<JSObject>::cast(proto), receiver, index,
true);
4501 int index = obj->map()->Hash() %
kEntries;
4503 if (result->IsMap() &&
4507 if (FLAG_verify_heap) {
4511 #ifdef ENABLE_SLOW_ASSERTS
4519 ASSERT(memcmp(fresh->address(),
4525 ASSERT(memcmp(fresh->address() + offset,
4533 Isolate* isolate = cache->GetIsolate();
4536 ASSERT(map->is_dictionary_map());
4537 cache->set(index, *map);
4538 isolate->
counters()->normalized_maps()->Increment();
4546 for (
int i = 0; i != entries; i++) {
4562 int expected_additional_properties) {
4563 if (!object->HasFastProperties())
return;
4566 ASSERT(!object->IsGlobalObject());
4568 ASSERT(!object->IsJSGlobalProxy());
4570 Isolate* isolate =
object->GetIsolate();
4575 int real_size = map->NumberOfOwnDescriptors();
4576 int property_count = real_size;
4577 if (expected_additional_properties > 0) {
4578 property_count += expected_additional_properties;
4580 property_count += 2;
4583 isolate->factory()->NewNameDictionary(property_count);
4586 for (
int i = 0; i < real_size; i++) {
4587 PropertyDetails details = descs->GetDetails(i);
4588 switch (details.type()) {
4592 PropertyDetails d = PropertyDetails(
4593 details.attributes(),
NORMAL, i + 1);
4594 dictionary = NameDictionaryAdd(dictionary, key, value, d);
4600 object->RawFastPropertyAt(descs->GetFieldIndex(i)), isolate);
4602 PropertyDetails(details.attributes(),
NORMAL, i + 1);
4603 dictionary = NameDictionaryAdd(dictionary, key, value, d);
4609 PropertyDetails d = PropertyDetails(
4610 details.attributes(),
CALLBACKS, i + 1);
4611 dictionary = NameDictionaryAdd(dictionary, key, value, d);
4626 dictionary->SetNextEnumerationIndex(real_size + 1);
4629 isolate->context()->native_context()->normalized_map_cache());
4631 ASSERT(new_map->is_dictionary_map());
4637 int new_instance_size = new_map->instance_size();
4638 int instance_size_delta = map->instance_size() - new_instance_size;
4639 ASSERT(instance_size_delta >= 0);
4640 Heap* heap = isolate->heap();
4642 instance_size_delta);
4644 -instance_size_delta,
4647 object->set_map(*new_map);
4648 map->NotifyLeafMapLayoutChange();
4650 object->set_properties(*dictionary);
4652 isolate->counters()->props_to_dictionary()->Increment();
4655 if (FLAG_trace_normalization) {
4656 PrintF(
"Object properties have been normalized:\n");
4664 int unused_property_fields) {
4665 if (object->HasFastProperties())
return;
4666 ASSERT(!object->IsGlobalObject());
4668 object->GetIsolate(),
4669 object->property_dictionary()->TransformPropertiesToFastFor(
4670 *
object, unused_property_fields));
4678 Isolate* isolate = array->GetIsolate();
4680 bool has_double_elements = array->IsFixedDoubleArray();
4681 for (
int i = 0; i < length; i++) {
4683 if (has_double_elements) {
4686 if (double_array->is_the_hole(i)) {
4687 value = factory->the_hole_value();
4689 value = factory->
NewHeapNumber(double_array->get_scalar(i));
4692 value =
handle(Handle<FixedArray>::cast(array)->
get(i), isolate);
4694 if (!value->IsTheHole()) {
4695 PropertyDetails details = PropertyDetails(
NONE,
NORMAL, 0);
4706 ASSERT(!object->HasExternalArrayElements() &&
4707 !
object->HasFixedTypedArrayElements());
4708 Isolate* isolate =
object->GetIsolate();
4709 Factory* factory = isolate->factory();
4714 (array->map() == isolate->heap()->sloppy_arguments_elements_map());
4721 ASSERT(object->HasFastSmiOrObjectElements() ||
4722 object->HasFastDoubleElements() ||
4723 object->HasFastArgumentsElements());
4725 int length =
object->IsJSArray()
4728 int old_capacity = 0;
4729 int used_elements = 0;
4730 object->GetElementsCapacityAndUsage(&old_capacity, &used_elements);
4734 dictionary = CopyFastElementsToDictionary(array, length, dictionary);
4746 object->set_elements(*dictionary);
4749 isolate->counters()->elements_to_dictionary()->Increment();
4752 if (FLAG_trace_normalization) {
4753 PrintF(
"Object elements have been normalized:\n");
4758 ASSERT(object->HasDictionaryElements() ||
4759 object->HasDictionaryArgumentsElements());
4774 }
while (hash_value == 0 && attempts < 30);
4775 hash_value = hash_value != 0 ? hash_value : 1;
4782 Isolate* isolate =
object->GetIsolate();
4787 Object* JSObject::GetIdentityHash() {
4789 return stored_value->IsSmi() ? stored_value :
GetHeap()->undefined_value();
4794 Handle<Object> hash(object->GetIdentityHash(),
object->GetIsolate());
4798 Isolate* isolate =
object->GetIsolate();
4800 hash =
handle(object->GenerateIdentityHash(), isolate);
4802 isolate->factory()->identity_hash_string(), hash);
4804 if (result->IsUndefined()) {
4813 Object* JSProxy::GetIdentityHash() {
4814 return this->hash();
4818 Handle<Object> JSProxy::GetOrCreateIdentityHash(Handle<JSProxy> proxy) {
4819 Isolate* isolate = proxy->GetIsolate();
4821 Handle<Object> hash(proxy->GetIdentityHash(), isolate);
4825 hash =
handle(proxy->GenerateIdentityHash(), isolate);
4826 proxy->set_hash(*hash);
4832 ASSERT(key->IsUniqueName());
4833 if (IsJSGlobalProxy()) {
4837 if (proxy_parent->IsNull())
return GetHeap()->the_hole_value();
4838 ASSERT(proxy_parent->IsJSGlobalObject());
4841 ASSERT(!IsJSGlobalProxy());
4842 Object* inline_value = GetHiddenPropertiesHashTable();
4844 if (inline_value->IsSmi()) {
4846 if (key ==
GetHeap()->identity_hash_string()) {
4847 return inline_value;
4849 return GetHeap()->the_hole_value();
4853 if (inline_value->IsUndefined())
return GetHeap()->the_hole_value();
4864 Isolate* isolate =
object->GetIsolate();
4866 ASSERT(key->IsUniqueName());
4867 if (object->IsJSGlobalProxy()) {
4871 if (proxy_parent->IsNull())
return isolate->
factory()->undefined_value();
4872 ASSERT(proxy_parent->IsJSGlobalObject());
4875 ASSERT(!object->IsJSGlobalProxy());
4877 Handle<Object> inline_value(object->GetHiddenPropertiesHashTable(), isolate);
4880 if (value->IsSmi() &&
4881 *key == *isolate->
factory()->identity_hash_string() &&
4882 (inline_value->IsUndefined() || inline_value->IsSmi())) {
4883 return JSObject::SetHiddenPropertiesHashTable(
object, value);
4887 GetOrCreateHiddenPropertiesHashtable(
object);
4892 if (*new_table != *hashtable) {
4895 SetHiddenPropertiesHashTable(
object, new_table);
4904 Isolate* isolate =
object->GetIsolate();
4905 ASSERT(key->IsUniqueName());
4907 if (object->IsJSGlobalProxy()) {
4909 if (proto->IsNull())
return;
4910 ASSERT(proto->IsJSGlobalObject());
4914 Object* inline_value =
object->GetHiddenPropertiesHashTable();
4917 ASSERT(*key != *isolate->
factory()->identity_hash_string());
4918 if (inline_value->IsUndefined() || inline_value->IsSmi())
return;
4926 Handle<Name> hidden =
object->GetIsolate()->factory()->hidden_string();
4928 object,
object, hidden,
false) !=
ABSENT;
4932 Object* JSObject::GetHiddenPropertiesHashTable() {
4933 ASSERT(!IsJSGlobalProxy());
4950 return GetHeap()->undefined_value();
4953 return GetHeap()->undefined_value();
4962 &attributes)->ToObjectUnchecked();
4966 Handle<ObjectHashTable> JSObject::GetOrCreateHiddenPropertiesHashtable(
4967 Handle<JSObject>
object) {
4968 Isolate* isolate =
object->GetIsolate();
4970 static const int kInitialCapacity = 4;
4971 Handle<Object> inline_value(object->GetHiddenPropertiesHashTable(), isolate);
4972 if (inline_value->IsHashTable()) {
4976 Handle<ObjectHashTable> hashtable = isolate->factory()->NewObjectHashTable(
4980 if (inline_value->IsSmi()) {
4984 isolate->factory()->identity_hash_string(),
4990 isolate->factory()->hidden_string(),
5001 Handle<Object> JSObject::SetHiddenPropertiesHashTable(Handle<JSObject>
object,
5002 Handle<Object> value) {
5003 ASSERT(!object->IsJSGlobalProxy());
5005 Isolate* isolate =
object->GetIsolate();
5010 if (object->HasFastProperties()) {
5015 DescriptorArray* descriptors =
object->
map()->instance_descriptors();
5016 if (descriptors->number_of_descriptors() > 0) {
5017 int sorted_index = descriptors->GetSortedKeyIndex(0);
5018 if (descriptors->GetKey(sorted_index) == isolate->heap()->hidden_string()
5019 && sorted_index <
object->map()->NumberOfOwnDescriptors()) {
5020 ASSERT(descriptors->GetType(sorted_index) ==
FIELD);
5021 object->FastPropertyAtPut(descriptors->GetFieldIndex(sorted_index),
5029 isolate->factory()->hidden_string(),
5039 Handle<Object> JSObject::DeletePropertyPostInterceptor(Handle<JSObject>
object,
5043 Isolate* isolate =
object->GetIsolate();
5044 LookupResult result(isolate);
5045 object->LocalLookupRealNamedProperty(*name, &result);
5046 if (!result.IsFound())
return isolate->factory()->true_value();
5051 return DeleteNormalizedProperty(
object, name, mode);
5055 Handle<Object> JSObject::DeletePropertyWithInterceptor(Handle<JSObject>
object,
5056 Handle<Name> name) {
5057 Isolate* isolate =
object->GetIsolate();
5060 if (name->IsSymbol())
return isolate->factory()->false_value();
5062 Handle<InterceptorInfo> interceptor(object->GetNamedInterceptor());
5063 if (!interceptor->deleter()->IsUndefined()) {
5065 v8::ToCData<v8::NamedPropertyDeleterCallback>(interceptor->deleter());
5067 ApiNamedPropertyAccess(
"interceptor-named-delete", *
object, *name));
5068 PropertyCallbackArguments args(
5069 isolate, interceptor->data(), *object, *object);
5073 if (!result.IsEmpty()) {
5074 ASSERT(result->IsBoolean());
5076 result_internal->VerifyApiCallResultType();
5078 return handle(*result_internal, isolate);
5081 Handle<Object> result =
5088 Handle<Object> JSObject::DeleteElementWithInterceptor(Handle<JSObject>
object,
5090 Isolate* isolate =
object->GetIsolate();
5091 Factory* factory = isolate->factory();
5095 AssertNoContextChange ncc(isolate);
5097 Handle<InterceptorInfo> interceptor(object->GetIndexedInterceptor());
5098 if (interceptor->deleter()->IsUndefined())
return factory->false_value();
5100 v8::ToCData<v8::IndexedPropertyDeleterCallback>(interceptor->deleter());
5102 ApiIndexedPropertyAccess(
"interceptor-indexed-delete", *
object, index));
5103 PropertyCallbackArguments args(
5104 isolate, interceptor->data(), *object, *object);
5107 if (!result.IsEmpty()) {
5108 ASSERT(result->IsBoolean());
5110 result_internal->VerifyApiCallResultType();
5112 return handle(*result_internal, isolate);
5114 Handle<Object> delete_result =
object->GetElementsAccessor()->Delete(
5117 return delete_result;
5121 Handle<Object> JSObject::DeleteElement(Handle<JSObject>
object,
5124 Isolate* isolate =
object->GetIsolate();
5125 Factory* factory = isolate->factory();
5128 if (object->IsAccessCheckNeeded() &&
5132 return factory->false_value();
5135 if (object->IsStringObjectWithCharacterAt(index)) {
5138 Handle<Object> name = factory->NewNumberFromUint(index);
5139 Handle<Object> args[2] = {
name,
object };
5140 Handle<Object> error =
5141 factory->NewTypeError(
"strict_delete_property",
5143 isolate->Throw(*error);
5144 return Handle<Object>();
5146 return factory->false_value();
5149 if (object->IsJSGlobalProxy()) {
5150 Handle<Object> proto(object->GetPrototype(), isolate);
5151 if (proto->IsNull())
return factory->false_value();
5152 ASSERT(proto->IsJSGlobalObject());
5153 return DeleteElement(Handle<JSObject>::cast(proto), index, mode);
5156 Handle<Object> old_value;
5157 bool should_enqueue_change_record =
false;
5158 if (object->map()->is_observed()) {
5160 if (should_enqueue_change_record) {
5161 if (object->GetLocalElementAccessorPair(index) !=
NULL) {
5170 Handle<Object> result;
5172 result = DeleteElementWithInterceptor(
object, index);
5174 result =
object->GetElementsAccessor()->Delete(
object, index, mode);
5177 if (should_enqueue_change_record && !
HasLocalElement(
object, index)) {
5178 Handle<String> name = factory->Uint32ToString(index);
5186 Handle<Object> JSObject::DeleteProperty(Handle<JSObject>
object,
5189 Isolate* isolate =
object->GetIsolate();
5194 if (object->IsAccessCheckNeeded() &&
5198 return isolate->factory()->false_value();
5201 if (object->IsJSGlobalProxy()) {
5202 Object* proto =
object->GetPrototype();
5203 if (proto->IsNull())
return isolate->factory()->false_value();
5204 ASSERT(proto->IsJSGlobalObject());
5205 return JSGlobalObject::DeleteProperty(
5210 if (name->AsArrayIndex(&index)) {
5211 return DeleteElement(
object, index, mode);
5214 LookupResult lookup(isolate);
5215 object->LocalLookup(*name, &lookup,
true);
5216 if (!lookup.IsFound())
return isolate->factory()->true_value();
5221 Handle<Object> args[2] = {
name,
object };
5222 Handle<Object> error = isolate->factory()->NewTypeError(
5224 isolate->Throw(*error);
5225 return Handle<Object>();
5227 return isolate->factory()->false_value();
5230 Handle<Object> old_value = isolate->factory()->the_hole_value();
5231 bool is_observed =
object->map()->is_observed() &&
5232 *name != isolate->heap()->hidden_string();
5233 if (is_observed && lookup.IsDataProperty()) {
5237 Handle<Object> result;
5240 if (lookup.IsInterceptor()) {
5243 result = DeletePropertyPostInterceptor(
object, name, mode);
5245 result = DeletePropertyWithInterceptor(
object, name);
5251 result = DeleteNormalizedProperty(
object, name, mode);
5265 if (object->IsJSProxy()) {
5266 return JSProxy::DeleteElementWithHandler(
5276 if (object->IsJSProxy()) {
5277 return JSProxy::DeletePropertyWithHandler(
5284 bool JSObject::ReferencesObjectFromElements(
FixedArray* elements,
5290 int length = IsJSArray()
5293 for (
int i = 0; i < length; ++i) {
5295 if (!element->IsTheHole() && element == object)
return true;
5300 if (!key->IsUndefined())
return true;
5308 Map* map_of_this =
map();
5313 if (map_of_this->constructor() ==
obj) {
5318 if (map_of_this->prototype() ==
obj) {
5324 if (!key->IsUndefined()) {
5333 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
5334 case EXTERNAL_##TYPE##_ELEMENTS: \
5335 case TYPE##_ELEMENTS: \
5339 #undef TYPED_ARRAY_CASE
5351 if (ReferencesObjectFromElements(elements, kind, obj))
return true;
5357 int length = parameter_map->
length();
5358 for (
int i = 2; i < length; ++i) {
5360 if (!value->IsTheHole() && value ==
obj)
return true;
5366 if (ReferencesObjectFromElements(arguments, kind, obj))
return true;
5372 if (IsJSFunction()) {
5376 sloppy_arguments_boilerplate();
5382 Context* context = f->context();
5390 if (context->
get(i)->IsJSObject()) {
5393 if (ctxobj->
map()->constructor() == arguments_function) {
5397 }
else if (ctxobj == obj) {
5421 Isolate* isolate =
object->GetIsolate();
5423 if (!object->map()->is_extensible())
return object;
5425 if (object->IsAccessCheckNeeded() &&
5427 isolate->
factory()->undefined_value(),
5431 return isolate->
factory()->false_value();
5434 if (object->IsJSGlobalProxy()) {
5436 if (proto->IsNull())
return object;
5437 ASSERT(proto->IsJSGlobalObject());
5442 if (object->HasExternalArrayElements() ||
5443 object->HasFixedTypedArrayElements()) {
5446 "cant_prevent_ext_external_array_elements",
5448 isolate->
Throw(*error);
5454 ASSERT(object->HasDictionaryElements() ||
5455 object->HasDictionaryArgumentsElements());
5458 dictionary->set_requires_slow_elements();
5465 new_map->set_is_extensible(
false);
5467 ASSERT(!object->map()->is_extensible());
5469 if (object->map()->is_observed()) {
5471 isolate->
factory()->the_hole_value());
5477 template<
typename Dictionary>
5478 static void FreezeDictionary(
Dictionary* dictionary) {
5479 int capacity = dictionary->
Capacity();
5480 for (
int i = 0; i < capacity; i++) {
5482 if (dictionary->
IsKey(k)) {
5483 PropertyDetails details = dictionary->
DetailsAt(i);
5487 !dictionary->
ValueAt(i)->IsAccessorPair()) {
5490 details = details.CopyAddAttributes(
5491 static_cast<PropertyAttributes>(attrs));
5500 ASSERT(!object->HasSloppyArgumentsElements());
5501 ASSERT(!object->map()->is_observed());
5503 if (object->map()->is_frozen())
return object;
5505 Isolate* isolate =
object->GetIsolate();
5506 if (object->IsAccessCheckNeeded() &&
5508 isolate->
factory()->undefined_value(),
5512 return isolate->
factory()->false_value();
5515 if (object->IsJSGlobalProxy()) {
5517 if (proto->IsNull())
return object;
5518 ASSERT(proto->IsJSGlobalObject());
5523 if (object->HasExternalArrayElements() ||
5524 object->HasFixedTypedArrayElements()) {
5527 "cant_prevent_ext_external_array_elements",
5529 isolate->
Throw(*error);
5534 if (!object->elements()->IsDictionary()) {
5535 int length =
object->IsJSArray()
5537 :
object->elements()->length();
5541 object->GetElementsCapacityAndUsage(&capacity, &used);
5542 new_element_dictionary =
5547 new_element_dictionary = CopyFastElementsToDictionary(
5548 handle(object->elements()), length, new_element_dictionary);
5551 new_element_dictionary =
5552 isolate->
factory()->empty_slow_element_dictionary();
5556 LookupResult result(isolate);
5558 old_map->LookupTransition(*
object, isolate->
heap()->frozen_symbol(), &result);
5559 if (result.IsTransition()) {
5560 Handle<Map> transition_map(result.GetTransitionTarget());
5561 ASSERT(transition_map->has_dictionary_elements());
5562 ASSERT(transition_map->is_frozen());
5563 ASSERT(!transition_map->is_extensible());
5565 }
else if (object->HasFastProperties() && old_map->CanHaveMoreTransitions()) {
5567 int num_descriptors = old_map->NumberOfOwnDescriptors();
5570 handle(old_map->instance_descriptors()), num_descriptors,
FROZEN);
5573 isolate->
factory()->frozen_symbol());
5575 new_map->set_is_extensible(
false);
5586 new_map->set_is_extensible(
false);
5591 FreezeDictionary(object->property_dictionary());
5594 ASSERT(object->map()->has_dictionary_elements());
5595 if (!new_element_dictionary.
is_null()) {
5596 object->set_elements(*new_element_dictionary);
5599 if (object->elements() != isolate->
heap()->empty_slow_element_dictionary()) {
5604 FreezeDictionary(dictionary);
5612 Isolate* isolate =
object->GetIsolate();
5614 if (object->map()->is_observed())
5617 LookupResult result(isolate);
5618 object->map()->LookupTransition(*
object,
5619 isolate->
heap()->observed_symbol(),
5623 if (result.IsTransition()) {
5624 new_map =
handle(result.GetTransitionTarget());
5625 ASSERT(new_map->is_observed());
5626 }
else if (object->map()->CanHaveMoreTransitions()) {
5630 new_map->set_is_observed();
5637 Isolate* isolate =
object->GetIsolate();
5643 template<
class ContextObject>
5648 : site_context_(site_context),
5660 return copy_of_value;
5669 ContextObject* site_context_;
5670 const bool copying_;
5675 template <
class ContextObject>
5678 Isolate* isolate = this->isolate();
5679 bool copying = this->copying();
5683 StackLimitCheck
check(isolate);
5685 if (check.HasOverflowed()) {
5691 if (object->map()->is_deprecated()) {
5698 if (site_context()->ShouldCreateMemento(
object)) {
5699 site_to_pass = site_context()->current();
5713 ASSERT(copying || copy.is_identical_to(
object));
5718 isolate->
heap()->fixed_cow_array_map()) {
5719 isolate->
counters()->cow_arrays_created_runtime()->Increment();
5726 if (copy->HasFastProperties()) {
5728 int limit = copy->map()->NumberOfOwnDescriptors();
5729 for (
int i = 0; i < limit; i++) {
5730 PropertyDetails details = descriptors->GetDetails(i);
5731 if (details.type() !=
FIELD)
continue;
5732 int index = descriptors->GetFieldIndex(i);
5734 if (value->IsJSObject()) {
5739 value = NewStorageFor(isolate, value, representation);
5742 copy->FastPropertyAtPut(index, *value);
5748 copy->GetLocalPropertyNames(*names, 0);
5749 for (
int i = 0; i < names->length(); i++) {
5750 ASSERT(names->get(i)->IsString());
5757 if (attributes !=
NONE)
continue;
5759 copy->GetProperty(*key_string, &attributes)->ToObjectUnchecked(),
5761 if (value->IsJSObject()) {
5776 ASSERT(!copy->HasExternalArrayElements());
5783 if (elements->map() == isolate->
heap()->fixed_cow_array_map()) {
5785 for (
int i = 0; i < elements->length(); i++) {
5786 ASSERT(!elements->get(i)->IsJSObject());
5790 for (
int i = 0; i < elements->length(); i++) {
5793 value->IsTheHole() ||
5795 if (value->IsJSObject()) {
5800 elements->set(i, *result);
5809 copy->element_dictionary());
5810 int capacity = element_dictionary->Capacity();
5811 for (
int i = 0; i < capacity; i++) {
5812 Object* k = element_dictionary->KeyAt(i);
5813 if (element_dictionary->IsKey(k)) {
5815 if (value->IsJSObject()) {
5820 element_dictionary->ValueAtPut(i, *result);
5832 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
5833 case EXTERNAL_##TYPE##_ELEMENTS: \
5834 case TYPE##_ELEMENTS: \
5837 #undef TYPED_ARRAY_CASE
5866 ASSERT(!copy.is_identical_to(
object));
5879 o != heap->null_value();
5881 if (!o->IsJSObject())
return false;
5884 if (enum_length == kInvalidEnumCacheSentinel)
return false;
5885 if (curr->IsAccessCheckNeeded())
return false;
5889 if (curr !=
this && enum_length != 0)
return false;
5896 if ((filter &
SYMBOLIC) && key->IsSymbol()) {
5905 if ((filter &
STRING) && !key->IsSymbol()) {
5920 for (
int i = 0; i < limit; i++) {
5921 if ((descs->
GetDetails(i).attributes() & filter) == 0 &&
5922 !FilterKey(descs->
GetKey(i), filter)) {
5934 for (
int i = 0; i < number_of_own_descriptors; i++) {
5937 if (current_index > max_index) max_index = current_index;
5940 return max_index + 1;
5947 for (
int i = 0; i < number_of_own_descriptors; i++) {
5957 Name* name, LookupResult* result,
bool search_hidden_prototypes) {
5962 if (IsJSGlobalProxy()) {
5964 if (proto->IsNull())
return result->NotFound();
5965 ASSERT(proto->IsJSGlobalObject());
5967 name, result, search_hidden_prototypes);
5977 if (IsAccessCheckNeeded()) {
5978 result->DisallowCaching();
5985 !heap->isolate()->bootstrapper()->IsActive()) {
5986 result->InterceptorResult(js_object);
5991 if (result->IsFound() || !search_hidden_prototypes)
return;
5994 if (!proto->IsJSReceiver())
return;
5997 receiver->
LocalLookup(name, result, search_hidden_prototypes);
6005 for (
Object* current =
this;
6006 current != heap->null_value();
6009 if (result->IsFound())
return;
6018 for (
Object* current =
this;
6019 current != heap->null_value() && current->IsJSObject();
6022 if (result->IsPropertyCallbacks())
return;
6030 static bool UpdateGetterSetterInDictionary(
6036 int entry = dictionary->
FindEntry(index);
6039 PropertyDetails details = dictionary->
DetailsAt(entry);
6040 if (details.type() ==
CALLBACKS && result->IsAccessorPair()) {
6041 ASSERT(!details.IsDontDelete());
6042 if (details.attributes() != attributes) {
6045 PropertyDetails(attributes,
CALLBACKS, index));
6055 void JSObject::DefineElementAccessor(Handle<JSObject>
object,
6057 Handle<Object> getter,
6058 Handle<Object> setter,
6061 switch (object->GetElementsKind()) {
6070 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
6071 case EXTERNAL_##TYPE##_ELEMENTS: \
6072 case TYPE##_ELEMENTS: \
6075 #undef TYPED_ARRAY_CASE
6080 if (UpdateGetterSetterInDictionary(object->element_dictionary(),
6093 uint32_t length = parameter_map->
length();
6095 index < (length - 2) ? parameter_map->get(index + 2) :
NULL;
6096 if (probe ==
NULL || probe->IsTheHole()) {
6098 if (arguments->IsDictionary()) {
6099 SeededNumberDictionary* dictionary =
6101 if (UpdateGetterSetterInDictionary(dictionary,
6114 Isolate* isolate =
object->GetIsolate();
6115 Handle<AccessorPair> accessors = isolate->factory()->NewAccessorPair();
6116 accessors->SetComponents(*getter, *setter);
6117 accessors->set_access_flags(access_control);
6119 SetElementCallback(
object, index, accessors, attributes);
6123 Handle<AccessorPair> JSObject::CreateAccessorPairFor(Handle<JSObject>
object,
6124 Handle<Name> name) {
6125 Isolate* isolate =
object->GetIsolate();
6126 LookupResult result(isolate);
6127 object->LocalLookupRealNamedProperty(*name, &result);
6128 if (result.IsPropertyCallbacks()) {
6135 Object* obj = result.GetCallbackObject();
6136 if (obj->IsAccessorPair()) {
6140 return isolate->factory()->NewAccessorPair();
6144 void JSObject::DefinePropertyAccessor(Handle<JSObject>
object,
6146 Handle<Object> getter,
6147 Handle<Object> setter,
6152 bool only_attribute_changes = getter->IsNull() && setter->IsNull();
6153 if (object->HasFastProperties() && !only_attribute_changes &&
6155 (
object->map()->NumberOfOwnDescriptors() <= kMaxNumberOfDescriptors)) {
6156 bool getterOk = getter->IsNull() ||
6157 DefineFastAccessor(
object, name,
ACCESSOR_GETTER, getter, attributes);
6158 bool setterOk = !getterOk || setter->IsNull() ||
6159 DefineFastAccessor(
object, name,
ACCESSOR_SETTER, setter, attributes);
6160 if (getterOk && setterOk)
return;
6163 Handle<AccessorPair> accessors = CreateAccessorPairFor(
object, name);
6164 accessors->SetComponents(*getter, *setter);
6165 accessors->set_access_flags(access_control);
6167 SetPropertyCallback(
object, name, accessors, attributes);
6171 bool JSObject::CanSetCallback(Handle<JSObject>
object, Handle<Name> name) {
6172 Isolate* isolate =
object->GetIsolate();
6173 ASSERT(!object->IsAccessCheckNeeded() ||
6182 LookupResult callback_result(isolate);
6183 object->LookupCallbackProperty(*name, &callback_result);
6184 if (callback_result.IsFound()) {
6185 Object* callback_obj = callback_result.GetCallbackObject();
6186 if (callback_obj->IsAccessorInfo()) {
6189 if (callback_obj->IsAccessorPair()) {
6204 for (
Object* prototype = this->prototype();
6205 prototype != heap->null_value();
6206 prototype = prototype->GetPrototype(
GetIsolate())) {
6207 if (prototype->IsJSProxy()) {
6226 Heap* heap =
object->GetHeap();
6227 PropertyDetails details = PropertyDetails(attributes,
CALLBACKS, 0);
6230 bool had_dictionary_elements =
object->HasDictionaryElements();
6232 ASSERT(object->HasDictionaryElements() ||
6233 object->HasDictionaryArgumentsElements());
6237 dictionary->set_requires_slow_elements();
6240 if (object->elements()->map() == heap->sloppy_arguments_elements_map()) {
6247 if (index < static_cast<uint32_t>(parameter_map->
length()) - 2) {
6248 parameter_map->
set(index + 2, heap->the_hole_value());
6250 parameter_map->
set(1, *dictionary);
6252 object->set_elements(*dictionary);
6254 if (!had_dictionary_elements) {
6262 void JSObject::SetPropertyCallback(Handle<JSObject>
object,
6264 Handle<Object> structure,
6271 if (object->IsGlobalObject()) {
6273 ASSERT(new_map->is_dictionary_map());
6274 object->set_map(*new_map);
6283 PropertyDetails details = PropertyDetails(attributes,
CALLBACKS, 0);
6294 Isolate* isolate =
object->GetIsolate();
6296 if (object->IsAccessCheckNeeded() &&
6302 if (object->IsJSGlobalProxy()) {
6304 if (proto->IsNull())
return;
6305 ASSERT(proto->IsJSGlobalObject());
6317 AssertNoContextChange ncc(isolate);
6322 if (!JSObject::CanSetCallback(
object, name))
return;
6325 bool is_element = name->AsArrayIndex(&index);
6328 bool is_observed =
object->map()->is_observed() &&
6330 bool preexists =
false;
6334 if (preexists && object->GetLocalElementAccessorPair(index) ==
NULL) {
6338 LookupResult lookup(isolate);
6339 object->LocalLookup(*name, &lookup,
true);
6340 preexists = lookup.IsProperty();
6341 if (preexists && lookup.IsDataProperty()) {
6349 DefineElementAccessor(
6350 object, index, getter, setter, attributes, access_control);
6352 DefinePropertyAccessor(
6353 object, name, getter, setter, attributes, access_control);
6357 const char* type = preexists ?
"reconfigure" :
"add";
6365 int target_descriptor,
6370 PropertyDetails details = descs->
GetDetails(target_descriptor);
6373 if (details.type() !=
CALLBACKS)
return false;
6375 if (!descriptor->IsAccessorPair())
return false;
6381 if (target_accessor == *accessor && target_attributes == attributes) {
6392 static MaybeObject* CopyInsertDescriptor(Map* map,
6394 AccessorPair* accessors,
6396 CallbacksDescriptor new_accessors_desc(name, accessors, attributes);
6401 static Handle<Map> CopyInsertDescriptor(Handle<Map> map,
6403 Handle<AccessorPair> accessors,
6406 CopyInsertDescriptor(*map, *name, *accessors, attributes),
6411 bool JSObject::DefineFastAccessor(Handle<JSObject>
object,
6414 Handle<Object> accessor,
6416 ASSERT(accessor->IsSpecFunction() || accessor->IsUndefined());
6417 Isolate* isolate =
object->GetIsolate();
6418 LookupResult result(isolate);
6419 object->LocalLookup(*name, &result);
6421 if (result.IsFound() && !result.IsPropertyCallbacks()) {
6426 AccessorPair* source_accessors =
NULL;
6427 if (result.IsPropertyCallbacks()) {
6428 Object* callback_value = result.GetCallbackObject();
6429 if (callback_value->IsAccessorPair()) {
6431 Object* entry = source_accessors->get(component);
6432 if (entry == *accessor && result.GetAttributes() == attributes) {
6439 int descriptor_number = result.GetDescriptorIndex();
6441 object->map()->LookupTransition(*
object, *name, &result);
6443 if (result.IsFound()) {
6444 Handle<Map> target(result.GetTransitionTarget());
6445 ASSERT(target->NumberOfOwnDescriptors() ==
6446 object->map()->NumberOfOwnDescriptors());
6448 ASSERT(object->map()->instance_descriptors()->
6449 GetKey(descriptor_number) == *
name);
6450 return TryAccessorTransition(
object, target, descriptor_number,
6451 component, accessor, attributes);
6455 object->map()->LookupTransition(*
object, *name, &result);
6458 if (result.IsFound()) {
6459 Handle<Map> target(result.GetTransitionTarget());
6460 int descriptor_number = target->LastAdded();
6461 ASSERT(target->instance_descriptors()->GetKey(descriptor_number)
6463 return TryAccessorTransition(
object, target, descriptor_number,
6464 component, accessor, attributes);
6471 Handle<AccessorPair> accessors = source_accessors !=
NULL
6473 : isolate->factory()->NewAccessorPair();
6474 accessors->set(component, *accessor);
6475 Handle<Map> new_map = CopyInsertDescriptor(Handle<Map>(object->map()),
6476 name, accessors, attributes);
6484 Isolate* isolate =
object->GetIsolate();
6489 if (object->IsAccessCheckNeeded() &&
6493 return factory->undefined_value();
6496 if (object->IsJSGlobalProxy()) {
6498 if (proto->IsNull())
return object;
6499 ASSERT(proto->IsJSGlobalObject());
6505 AssertNoContextChange ncc(isolate);
6510 if (!JSObject::CanSetCallback(
object, name)) {
6511 return factory->undefined_value();
6515 bool is_element = name->AsArrayIndex(&index);
6518 if (object->IsJSArray())
return factory->undefined_value();
6521 switch (object->GetElementsKind()) {
6530 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
6531 case EXTERNAL_##TYPE##_ELEMENTS: \
6532 case TYPE##_ELEMENTS: \
6535 #undef TYPED_ARRAY_CASE
6538 return factory->undefined_value();
6547 SetElementCallback(
object, index, info, info->property_attributes());
6550 LookupResult result(isolate);
6551 object->LocalLookup(*name, &result,
true);
6554 if (result.IsFound() && (result.IsReadOnly() || result.IsDontDelete())) {
6555 return factory->undefined_value();
6558 SetPropertyCallback(
object, name, info, info->property_attributes());
6568 Isolate* isolate =
object->GetIsolate();
6572 AssertNoContextChange ncc(isolate);
6575 if (object->IsAccessCheckNeeded() &&
6579 return isolate->
factory()->undefined_value();
6584 if (name->AsArrayIndex(&index)) {
6591 int entry = dictionary->
FindEntry(index);
6595 element->IsAccessorPair()) {
6606 LookupResult result(isolate);
6608 if (result.IsFound()) {
6609 if (result.IsReadOnly())
return isolate->
factory()->undefined_value();
6610 if (result.IsPropertyCallbacks()) {
6611 Object* obj = result.GetCallbackObject();
6612 if (obj->IsAccessorPair()) {
6620 return isolate->
factory()->undefined_value();
6628 for (
int i = 0; i < number_of_own_descriptors; i++) {
6631 if (descs->
GetDetails(i).representation().IsDouble()) {
6632 ASSERT(property->IsHeapNumber());
6633 if (value->IsNumber() &&
property->
Number() == value->
Number()) {
6636 }
else if (property == value) {
6645 return GetHeap()->undefined_value();
6653 int instance_size) {
6655 map->RawCopy(instance_size),
6662 MaybeObject* maybe_result =
6664 if (!maybe_result->To(&result))
return maybe_result;
6666 result->set_prototype(prototype());
6667 result->set_constructor(constructor());
6674 kInvalidEnumCacheSentinel);
6687 int new_instance_size = map->instance_size();
6689 new_instance_size -= map->inobject_properties() *
kPointerSize;
6695 result->set_inobject_properties(map->inobject_properties());
6699 result->set_dictionary_map(
true);
6700 result->set_migration_target(
false);
6703 if (FLAG_verify_heap && result->is_shared()) {
6704 result->SharedMapVerify();
6720 if (!maybe_result->To(&result))
return maybe_result;
6735 Descriptor* descriptor) {
6740 instance_descriptors()->number_of_descriptors());
6743 if (!maybe_result->To(&result))
return maybe_result;
6745 Name* name = descriptor->GetKey();
6748 MaybeObject* maybe_transitions =
6750 if (!maybe_transitions->To(&transitions))
return maybe_transitions;
6757 new_descriptors = descriptors;
6758 new_descriptors->
Append(descriptor);
6762 GetIsolate(), old_size, old_size < 4 ? 1 : old_size / 2);
6763 if (!maybe_descriptors->To(&new_descriptors))
return maybe_descriptors;
6768 for (
int i = 0; i < old_size; ++i) {
6769 new_descriptors->
CopyFrom(i, descriptors, i, witness);
6772 new_descriptors->
Append(descriptor, witness);
6789 !current->IsUndefined();
6792 if (map->instance_descriptors() != descriptors)
break;
6793 map->set_instance_descriptors(new_descriptors);
6796 set_instance_descriptors(new_descriptors);
6804 set_transitions(transitions);
6816 map->CopyReplaceDescriptors(*descriptors, flag, *name),
6825 ASSERT(descriptors->IsSortedNoDuplicates());
6829 if (!maybe_result->To(&result))
return maybe_result;
6831 result->InitializeDescriptors(descriptors);
6835 MaybeObject* maybe_transitions =
AddTransition(name, result, simple_flag);
6836 if (!maybe_transitions->To(&transitions))
return maybe_transitions;
6837 set_transitions(transitions);
6838 result->SetBackPointer(
this);
6852 ASSERT(descriptors->IsSortedNoDuplicates());
6856 result->InitializeDescriptors(*descriptors);
6857 result->SetNumberOfOwnDescriptors(new_descriptor + 1);
6859 int unused_property_fields = map->unused_property_fields();
6860 if (descriptors->GetDetails(new_descriptor).type() ==
FIELD) {
6861 unused_property_fields = map->unused_property_fields() - 1;
6862 if (unused_property_fields < 0) {
6867 result->set_unused_property_fields(unused_property_fields);
6868 result->set_owns_descriptors(
false);
6874 map->set_transitions(*transitions);
6875 result->SetBackPointer(*map);
6894 bool insert_transition =
6902 if (!maybe_new_map->To(&new_map))
return maybe_new_map;
6905 if (added_elements->IsFailure())
return added_elements;
6918 MaybeObject* maybe_new_map =
Copy();
6919 if (!maybe_new_map->To(&new_map))
return maybe_new_map;
6923 if (insert_transition) {
6925 if (added_elements->IsFailure())
return added_elements;
6934 ASSERT(!map->is_observed());
6936 Isolate* isolate = map->GetIsolate();
6941 if (map->owns_descriptors()) {
6951 map->set_transitions(*transitions);
6953 new_map->set_is_observed();
6955 if (map->owns_descriptors()) {
6956 new_map->InitializeDescriptors(map->instance_descriptors());
6957 map->set_owns_descriptors(
false);
6960 new_map->SetBackPointer(*map);
6970 ASSERT(constructor()->IsJSFunction());
6977 MaybeObject* maybe_descriptors =
6978 descriptors->
CopyUpTo(number_of_own_descriptors);
6979 if (!maybe_descriptors->To(&new_descriptors))
return maybe_descriptors;
6994 MaybeObject* maybe_descriptors =
6995 descriptors->
CopyUpTo(number_of_own_descriptors);
6996 if (!maybe_descriptors->To(&new_descriptors))
return maybe_descriptors;
7007 MaybeObject* maybe_failure = descriptor->KeyToUniqueName();
7008 if (maybe_failure->IsFailure())
return maybe_failure;
7011 int new_size = old_size + 1;
7020 MaybeObject* maybe_descriptors =
7022 if (!maybe_descriptors->To(&new_descriptors))
return maybe_descriptors;
7027 for (
int i = 0; i < old_size; ++i) {
7028 new_descriptors->
CopyFrom(i, descriptors, i, witness);
7033 new_descriptors->
Set(old_size, descriptor, witness);
7034 new_descriptors->
Sort();
7036 new_descriptors->
Append(descriptor, witness);
7039 Name* key = descriptor->GetKey();
7049 MaybeObject* maybe_result = descriptor->KeyToUniqueName();
7050 if (maybe_result->IsFailure())
return maybe_result;
7053 int index = old_descriptors->SearchWithCache(descriptor->GetKey(),
this);
7063 int enumeration_index,
7066 desc->CopyUpToAddAttributes(enumeration_index, attributes),
7073 if (enumeration_index == 0)
return GetHeap()->empty_descriptor_array();
7075 int size = enumeration_index;
7079 if (!maybe_descriptors->To(&descriptors))
return maybe_descriptors;
7082 if (attributes !=
NONE) {
7083 for (
int i = 0; i <
size; ++i) {
7088 if (details.type() !=
CALLBACKS || !value->IsAccessorPair()) {
7091 details = details.CopyAddAttributes(
7092 static_cast<PropertyAttributes>(attributes & mask));
7093 Descriptor desc(
GetKey(i), value, details);
7094 descriptors->
Set(i, &desc, witness);
7097 for (
int i = 0; i <
size; ++i) {
7098 descriptors->
CopyFrom(i,
this, i, witness);
7109 Descriptor* descriptor,
7110 int insertion_index,
7113 MaybeObject* maybe_failure = descriptor->KeyToUniqueName();
7114 if (maybe_failure->IsFailure())
return maybe_failure;
7116 Name* key = descriptor->GetKey();
7120 ASSERT(0 <= insertion_index && insertion_index < new_size);
7125 MaybeObject* maybe_descriptors =
7127 if (!maybe_descriptors->To(&new_descriptors))
return maybe_descriptors;
7130 for (
int i = 0; i < new_size; ++i) {
7131 if (i == insertion_index) {
7132 new_descriptors->
Set(i, descriptor, witness);
7134 new_descriptors->
CopyFrom(i, descriptors, i, witness);
7139 if (new_size != descriptors->
length()) new_descriptors->
Sort();
7152 Isolate* isolate = map->GetIsolate();
7154 map->UpdateCodeCache(*name, *code));
7160 if (code_cache()->IsFixedArray()) {
7163 if (!maybe_result->ToObject(&result))
return maybe_result;
7165 set_code_cache(result);
7175 if (!code_cache()->IsFixedArray()) {
7178 return GetHeap()->undefined_value();
7185 if (!code_cache()->IsFixedArray()) {
7195 ASSERT(!code_cache()->IsFixedArray());
7205 : transition_array_(transition_array) { }
7213 return (*TransitionArrayHeader())->IsSmi();
7220 while (index < number_of_transitions) {
7222 return transition_array_->
GetTarget(index);
7225 *TransitionArrayHeader() = transition_array_->
GetHeap()->fixed_array_map();
7230 Object** TransitionArrayHeader() {
7234 TransitionArray* transition_array_;
7243 : proto_trans_(proto_trans) { }
7251 return (*Header())->IsSmi();
7257 if (transitionNumber < NumberOfTransitions()) {
7259 return GetTransition(transitionNumber);
7261 *Header() = proto_trans_->
GetHeap()->fixed_array_map();
7270 int NumberOfTransitions() {
7271 FixedArray* proto_trans =
reinterpret_cast<FixedArray*
>(proto_trans_);
7276 Map* GetTransition(
int transitionNumber) {
7277 FixedArray* proto_trans =
reinterpret_cast<FixedArray*
>(proto_trans_);
7278 return Map::cast(proto_trans->get(IndexFor(transitionNumber)));
7281 int IndexFor(
int transitionNumber) {
7287 HeapObject* proto_trans_;
7342 if (!transition_array->
map()->IsSmi() &&
7343 !transition_array->IsTransitionArray()) {
7352 Map* next = proto_iterator.
Next();
7359 Map* next = transition_iterator.
Next();
7375 if (child !=
NULL) {
7381 callback(current, data);
7382 if (current ==
this)
break;
7395 if (normal_type_cache()->IsUndefined()) {
7397 { MaybeObject* maybe_result =
7400 if (!maybe_result->ToObject(&result))
return maybe_result;
7402 set_normal_type_cache(result);
7404 return UpdateNormalTypeCache(name, code);
7406 ASSERT(default_cache()->IsFixedArray());
7407 return UpdateDefaultCache(name, code);
7412 MaybeObject* CodeCache::UpdateDefaultCache(
Name* name,
Code*
code) {
7421 int length = cache->length();
7422 int deleted_index = -1;
7423 for (
int i = 0; i < length; i += kCodeCacheEntrySize) {
7424 Object* key = cache->get(i);
7425 if (key->IsNull()) {
7426 if (deleted_index < 0) deleted_index = i;
7429 if (key->IsUndefined()) {
7430 if (deleted_index >= 0) i = deleted_index;
7431 cache->set(i + kCodeCacheEntryNameOffset, name);
7432 cache->set(i + kCodeCacheEntryCodeOffset, code);
7439 cache->set(i + kCodeCacheEntryCodeOffset, code);
7447 if (deleted_index >= 0) {
7448 cache->set(deleted_index + kCodeCacheEntryNameOffset, name);
7449 cache->set(deleted_index + kCodeCacheEntryCodeOffset, code);
7455 int new_length = length + ((length >> 1)) + kCodeCacheEntrySize;
7456 new_length = new_length - new_length % kCodeCacheEntrySize;
7457 ASSERT((new_length % kCodeCacheEntrySize) == 0);
7459 { MaybeObject* maybe_result = cache->CopySize(new_length);
7460 if (!maybe_result->ToObject(&result))
return maybe_result;
7465 cache->set(length + kCodeCacheEntryNameOffset, name);
7466 cache->set(length + kCodeCacheEntryCodeOffset, code);
7467 set_default_cache(cache);
7472 MaybeObject* CodeCache::UpdateNormalTypeCache(Name* name, Code* code) {
7476 { MaybeObject* maybe_new_cache = cache->Put(name, code);
7477 if (!maybe_new_cache->ToObject(&new_cache))
return maybe_new_cache;
7479 set_normal_type_cache(new_cache);
7486 if (result->IsCode()) {
7488 return GetHeap()->undefined_value();
7490 return LookupNormalTypeCache(name, flags);
7496 int length = cache->
length();
7497 for (
int i = 0; i < length; i += kCodeCacheEntrySize) {
7498 Object* key = cache->
get(i + kCodeCacheEntryNameOffset);
7500 if (key->IsNull())
continue;
7501 if (key->IsUndefined())
return key;
7509 return GetHeap()->undefined_value();
7514 if (!normal_type_cache()->IsUndefined()) {
7516 return cache->Lookup(name, flags);
7518 return GetHeap()->undefined_value();
7525 if (normal_type_cache()->IsUndefined())
return -1;
7531 int len = array->
length();
7532 for (
int i = 0; i < len; i += kCodeCacheEntrySize) {
7533 if (array->
get(i + kCodeCacheEntryCodeOffset) ==
code)
return i + 1;
7541 ASSERT(!normal_type_cache()->IsUndefined());
7551 ASSERT_EQ(1, kCodeCacheEntryCodeOffset - kCodeCacheEntryNameOffset);
7565 : name_(name), flags_(flags), code_(
NULL) { }
7568 : name_(name), flags_(code->flags()), code_(code) { }
7572 if (!other->IsFixedArray())
return false;
7576 if (flags != flags_) {
7579 return name_->
Equals(name);
7599 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
7602 pair->
set(0, name_);
7603 pair->
set(1, code_);
7627 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
7636 if (!maybe_k->ToObject(&k))
return maybe_k;
7649 return (entry ==
kNotFound) ? -1 : entry;
7666 Isolate* isolate = cache->GetIsolate();
7675 if (cache()->IsUndefined()) {
7677 { MaybeObject* maybe_result =
7681 if (!maybe_result->ToObject(&result))
return maybe_result;
7687 ->
Lookup(maps, flags)->IsUndefined());
7692 { MaybeObject* maybe_new_cache = hash_table->
Put(maps, flags, code);
7693 if (!maybe_new_cache->ToObject(&new_cache))
return maybe_new_cache;
7695 set_cache(new_cache);
7702 if (!cache()->IsUndefined()) {
7720 code_flags_(code_flags) {}
7725 FromObject(other, &other_flags, &other_maps);
7726 if (code_flags_ != other_flags)
return false;
7727 if (maps_->length() != other_maps.length())
return false;
7731 if (this_hash != other_hash)
return false;
7736 for (
int i = 0; i < maps_->length(); ++i) {
7737 bool match_found =
false;
7738 for (
int j = 0; j < other_maps.length(); ++j) {
7739 if (*(maps_->
at(i)) == *(other_maps.
at(j))) {
7744 if (!match_found)
return false;
7750 uint32_t hash = code_flags;
7751 for (
int i = 0; i < maps->length(); ++i) {
7752 hash ^= maps->
at(i)->Hash();
7764 FromObject(obj, &other_flags, &other_maps);
7773 { MaybeObject* maybe_obj =
7775 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
7779 for (
int i = 0; i < maps_->length(); ++i) {
7780 list->
set(i + 1, *maps_->
at(i));
7792 for (
int i = 1; i < list->
length(); ++i) {
7819 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
7825 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
7836 if (new_length <
length()) {
7837 RightTrimFixedArray<Heap::FROM_MUTATOR>(
7845 MaybeObject* maybe_result =
7848 if (!maybe_result->To<
FixedArray>(&result))
return maybe_result;
7849 #ifdef ENABLE_SLOW_ASSERTS
7851 for (
int i = 0; i < result->
length(); i++) {
7853 ASSERT(current->IsNumber() || current->IsName());
7863 MaybeObject* maybe_result =
7866 if (!maybe_result->To(&result))
return maybe_result;
7867 #ifdef ENABLE_SLOW_ASSERTS
7869 for (
int i = 0; i < result->
length(); i++) {
7871 ASSERT(current->IsNumber() || current->IsName());
7881 if (new_length == 0)
return heap->empty_fixed_array();
7884 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
7890 if (new_length < len) len = new_length;
7895 for (
int i = 0; i < len; i++) {
7896 result->
set(i,
get(i), mode);
7905 for (
int index = 0; index < len; index++) {
7906 dest->
set(dest_pos+index,
get(pos+index), mode);
7912 bool FixedArray::IsEqualTo(
FixedArray* other) {
7914 for (
int i = 0 ; i <
length(); ++i) {
7915 if (
get(i) != other->
get(i))
return false;
7923 int number_of_descriptors,
7927 int size = number_of_descriptors + slack;
7928 if (size == 0)
return heap->empty_descriptor_array();
7932 if (!maybe_array->To(&result))
return maybe_array;
7947 Object* new_index_cache) {
7949 ASSERT(new_index_cache->IsSmi() || new_index_cache->IsFixedArray());
7965 PropertyDetails details = src->
GetDetails(src_index);
7966 Descriptor desc(src->
GetKey(src_index), value, details);
7967 Set(dst_index, &desc, witness);
7979 desc->Merge(verbatim, valid, new_size, modify_index,
7980 store_mode, *other),
8000 ASSERT(verbatim <= valid);
8001 ASSERT(valid <= new_size);
8009 if (!maybe_descriptors->To(&result))
return maybe_descriptors;
8020 int current_offset = 0;
8021 for (descriptor = 0; descriptor < verbatim; descriptor++) {
8023 result->
CopyFrom(descriptor, other, descriptor, witness);
8027 for (; descriptor < valid; descriptor++) {
8029 PropertyDetails details =
GetDetails(descriptor);
8030 PropertyDetails other_details = other->
GetDetails(descriptor);
8032 if (details.type() ==
FIELD || other_details.type() ==
FIELD ||
8033 (store_mode ==
FORCE_FIELD && descriptor == modify_index) ||
8035 other_details.type() ==
CONSTANT &&
8038 details.representation().
generalize(other_details.representation());
8041 other_details.attributes(),
8043 result->
Set(descriptor, &d, witness);
8045 result->
CopyFrom(descriptor, other, descriptor, witness);
8050 for (; descriptor < new_size; descriptor++) {
8051 PropertyDetails details = other->
GetDetails(descriptor);
8052 if (details.type() ==
FIELD ||
8053 (store_mode ==
FORCE_FIELD && descriptor == modify_index)) {
8057 details.attributes(),
8058 details.representation());
8059 result->
Set(descriptor, &d, witness);
8061 result->
CopyFrom(descriptor, other, descriptor, witness);
8075 ASSERT(verbatim <= valid);
8076 ASSERT(valid <= new_size);
8077 if (valid != new_size)
return false;
8079 for (
int descriptor = verbatim; descriptor < valid; descriptor++) {
8080 PropertyDetails details =
GetDetails(descriptor);
8081 PropertyDetails other_details = other->
GetDetails(descriptor);
8082 if (!other_details.representation().fits_into(details.representation())) {
8086 if (other_details.type() !=
CONSTANT)
return false;
8106 const int max_parent_index = (len / 2) - 1;
8107 for (
int i = max_parent_index; i >= 0; --i) {
8108 int parent_index = i;
8110 while (parent_index <= max_parent_index) {
8111 int child_index = 2 * parent_index + 1;
8113 if (child_index + 1 < len) {
8115 if (right_child_hash > child_hash) {
8117 child_hash = right_child_hash;
8120 if (child_hash <= parent_hash)
break;
8121 SwapSortedKeys(parent_index, child_index);
8123 parent_index = child_index;
8128 for (
int i = len - 1; i > 0; --i) {
8130 SwapSortedKeys(0, i);
8132 int parent_index = 0;
8134 const int max_parent_index = (i / 2) - 1;
8135 while (parent_index <= max_parent_index) {
8136 int child_index = parent_index * 2 + 1;
8138 if (child_index + 1 < i) {
8140 if (right_child_hash > child_hash) {
8142 child_hash = right_child_hash;
8145 if (child_hash <= parent_hash)
break;
8146 SwapSortedKeys(parent_index, child_index);
8147 parent_index = child_index;
8150 ASSERT(IsSortedNoDuplicates());
8156 copy->set_getter(pair->getter());
8157 copy->set_setter(pair->setter());
8163 Object* accessor =
get(component);
8164 return accessor->IsTheHole() ?
GetHeap()->undefined_value() : accessor;
8169 int deopt_entry_count,
8171 ASSERT(deopt_entry_count > 0);
8178 int number_of_deopt_points,
8180 if (number_of_deopt_points == 0)
return isolate->
heap()->empty_fixed_array();
8189 if (other->
IsEmpty())
return false;
8191 for (
int i = 0; i <
length(); ++i) {
8192 if (
get(i) != other->
get(i))
return false;
8199 static bool IsIdentifier(UnicodeCache* cache, Name* name) {
8201 if (!name->IsString())
return false;
8203 if (string->length() == 0)
return true;
8204 ConsStringIteratorOp op;
8205 StringCharacterStream stream(
string, &op);
8206 if (!cache->IsIdentifierStart(stream.GetNext())) {
8209 while (stream.HasMore()) {
8210 if (!cache->IsIdentifierPart(stream.GetNext())) {
8219 return IsSymbol() || IsIdentifier(isolate->
unicode_cache(),
this);
8224 if (!
GetIsolate()->heap()->Contains(
this))
return false;
8230 ASSERT(!AllowHeapAllocation::IsAllowed());
8231 int length = this->
length();
8232 StringShape shape(
this);
8240 string = cons->
first();
8241 shape = StringShape(
string);
8245 offset = slice->
offset();
8246 string = slice->
parent();
8247 shape = StringShape(
string);
8252 const uint8_t* start;
8276 int* length_return) {
8283 if (length < 0) length =
kMaxInt - offset;
8289 int character_position = offset;
8292 while (stream.HasMore() && character_position++ < offset +
length) {
8293 uint16_t character = stream.GetNext();
8298 if (length_return) {
8299 *length_return = utf8_bytes;
8302 char* result = NewArray<char>(utf8_bytes + 1);
8305 stream.Reset(
this, offset);
8306 character_position = offset;
8307 int utf8_byte_position = 0;
8309 while (stream.HasMore() && character_position++ < offset +
length) {
8310 uint16_t character = stream.GetNext();
8314 utf8_byte_position +=
8318 result[utf8_byte_position] = 0;
8325 int* length_return) {
8326 return ToCString(allow_nulls, robust_flag, 0, -1, length_return);
8332 switch (StringShape(
this).representation_tag()) {
8337 ExternalTwoByteStringGetData(start);
8364 while (stream.HasMore()) {
8365 uint16_t character = stream.GetNext();
8366 result[i++] = character;
8374 return reinterpret_cast<uc16*
>(
8379 void Relocatable::PostGarbageCollectionProcessing(
Isolate* isolate) {
8380 Relocatable* current = isolate->relocatable_top();
8381 while (current !=
NULL) {
8382 current->PostGarbageCollection();
8383 current = current->prev_;
8389 int Relocatable::ArchiveSpacePerThread() {
8390 return sizeof(Relocatable*);
8395 char* Relocatable::ArchiveState(Isolate* isolate,
char* to) {
8396 *
reinterpret_cast<Relocatable**
>(to) = isolate->relocatable_top();
8397 isolate->set_relocatable_top(
NULL);
8398 return to + ArchiveSpacePerThread();
8403 char* Relocatable::RestoreState(Isolate* isolate,
char* from) {
8404 isolate->set_relocatable_top(*reinterpret_cast<Relocatable**>(from));
8405 return from + ArchiveSpacePerThread();
8409 char* Relocatable::Iterate(ObjectVisitor* v,
char* thread_storage) {
8410 Relocatable* top = *
reinterpret_cast<Relocatable**
>(thread_storage);
8412 return thread_storage + ArchiveSpacePerThread();
8416 void Relocatable::Iterate(Isolate* isolate, ObjectVisitor* v) {
8417 Iterate(v, isolate->relocatable_top());
8421 void Relocatable::Iterate(ObjectVisitor* v, Relocatable* top) {
8422 Relocatable* current = top;
8423 while (current !=
NULL) {
8424 current->IterateInstance(v);
8425 current = current->prev_;
8431 : Relocatable(isolate),
8432 str_(str.location()),
8433 length_(str->length()) {
8439 : Relocatable(isolate),
8442 length_(input.length()),
8443 start_(input.start()) { }
8447 if (str_ ==
NULL)
return;
8454 is_ascii_ = content.
IsAscii();
8464 unsigned* offset_out,
8466 unsigned* length_out) {
8467 ASSERT(string->IsConsString());
8470 root_ = cons_string;
8471 consumed_ = *offset_out;
8473 return Search(offset_out, type_out, length_out);
8477 String* ConsStringIteratorOp::Search(
unsigned* offset_out,
8479 unsigned* length_out) {
8484 frames_[0] = cons_string;
8485 const unsigned consumed = consumed_;
8486 unsigned offset = 0;
8490 unsigned length =
string->
length();
8492 if (consumed < offset + length) {
8495 type =
string->map()->instance_type();
8498 PushLeft(cons_string);
8502 AdjustMaximumDepth();
8508 string = cons_string->
second();
8512 PushRight(cons_string);
8517 length =
string->length();
8526 AdjustMaximumDepth();
8532 consumed_ = offset + length;
8533 *offset_out = consumed - offset;
8535 *length_out = length;
8543 String* ConsStringIteratorOp::NextLeaf(
bool* blew_stack,
8545 unsigned* length_out) {
8549 *blew_stack =
false;
8553 if (maximum_depth_ - depth_ == kStackSize) {
8558 ConsString* cons_string = frames_[OffsetForDepth(depth_ - 1)];
8559 String*
string = cons_string->
second();
8560 int32_t type =
string->map()->instance_type();
8564 unsigned length =
static_cast<unsigned>(
string->length());
8566 if (length == 0)
continue;
8567 *length_out = length;
8569 consumed_ += length;
8574 PushRight(cons_string);
8578 string = cons_string->first();
8579 type =
string->map()->instance_type();
8581 AdjustMaximumDepth();
8582 unsigned length =
static_cast<unsigned>(
string->length());
8584 *length_out = length;
8586 consumed_ += length;
8590 PushLeft(cons_string);
8604 return left->Get(index);
8610 if (StringShape(
string).IsCons()) {
8613 if (left->
length() > index) {
8617 string = cons_string->
second();
8620 return string->Get(index);
8634 template <
typename sink
char>
8643 ASSERT(0 <= from && from <= to && to <= source->
length());
8644 switch (StringShape(source).full_representation_tag()) {
8675 int boundary = first->
length();
8676 if (to - boundary >= boundary - from) {
8678 if (from < boundary) {
8680 sink += boundary - from;
8686 source = cons_string->
second();
8689 if (to > boundary) {
8694 if (to - boundary == 1) {
8695 sink[boundary - from] =
static_cast<sinkchar
>(second->Get(0));
8696 }
else if (second->IsSeqOneByteString()) {
8702 sink + boundary - from,
8715 unsigned offset = slice->
offset();
8726 template <
typename Char>
8727 static inline bool CompareRawStringContents(
const Char*
const a,
8728 const Char*
const b,
8731 #ifndef V8_HOST_CAN_READ_UNALIGNED
8735 const int kAlignmentMask =
sizeof(uint32_t) - 1;
8736 uint32_t pa_addr =
reinterpret_cast<uint32_t
>(a);
8737 uint32_t pb_addr =
reinterpret_cast<uint32_t
>(b);
8738 if (((pa_addr & kAlignmentMask) | (pb_addr & kAlignmentMask)) == 0) {
8740 const int kStepSize =
sizeof(int) /
sizeof(Char);
8741 int endpoint = length - kStepSize;
8743 for (; i <= endpoint; i += kStepSize) {
8744 uint32_t wa = *
reinterpret_cast<const uint32_t*
>(a + i);
8745 uint32_t wb = *
reinterpret_cast<const uint32_t*
>(b + i);
8750 #ifndef V8_HOST_CAN_READ_UNALIGNED
8754 for (; i < length; i++) {
8763 template<
typename Chars1,
typename Chars2>
8766 static inline bool compare(
const Chars1* a,
const Chars2* b,
int len) {
8767 ASSERT(
sizeof(Chars1) !=
sizeof(Chars2));
8768 for (
int i = 0; i < len; i++) {
8782 return CompareRawStringContents(a, b, len);
8790 static inline bool compare(
const uint8_t* a,
const uint8_t* b,
int len) {
8791 return CompareRawStringContents(a, b, len);
8800 : op_(op), is_one_byte_(
true), length_(0), buffer8_(
NULL) {}
8802 inline void Init(
String*
string,
unsigned len) {
8804 int32_t type =
string->map()->instance_type();
8808 inline void VisitOneByteString(
const uint8_t* chars,
unsigned length) {
8809 is_one_byte_ =
true;
8814 inline void VisitTwoByteString(
const uint16_t* chars,
unsigned length) {
8815 is_one_byte_ =
false;
8820 void Advance(
unsigned consumed) {
8821 ASSERT(consumed <= length_);
8823 if (length_ != consumed) {
8825 buffer8_ += consumed;
8827 buffer16_ += consumed;
8829 length_ -= consumed;
8835 unsigned length = 0;
8836 String* next = op_->ContinueOperation(&type, &length);
8846 const uint8_t* buffer8_;
8861 template<
typename Chars1,
typename Chars2>
8862 static inline bool Equals(State* state_1, State* state_2,
unsigned to_check) {
8863 const Chars1* a =
reinterpret_cast<const Chars1*
>(state_1->buffer8_);
8864 const Chars2* b =
reinterpret_cast<const Chars2*
>(state_2->buffer8_);
8870 state_1_.Init(string_1, length);
8871 state_2_.Init(string_2, length);
8873 unsigned to_check =
Min(state_1_.length_, state_2_.length_);
8874 ASSERT(to_check > 0 && to_check <= length);
8876 if (state_1_.is_one_byte_) {
8877 if (state_2_.is_one_byte_) {
8878 is_equal = Equals<uint8_t, uint8_t>(&state_1_, &state_2_, to_check);
8880 is_equal = Equals<uint8_t, uint16_t>(&state_1_, &state_2_, to_check);
8883 if (state_2_.is_one_byte_) {
8884 is_equal = Equals<uint16_t, uint8_t>(&state_1_, &state_2_, to_check);
8886 is_equal = Equals<uint16_t, uint16_t>(&state_1_, &state_2_, to_check);
8890 if (!is_equal)
return false;
8893 if (length == 0)
return true;
8894 state_1_.Advance(to_check);
8895 state_2_.Advance(to_check);
8906 bool String::SlowEquals(
String* other) {
8909 if (len != other->length())
return false;
8910 if (len == 0)
return true;
8915 #ifdef ENABLE_SLOW_ASSERTS
8917 if (
Hash() != other->Hash()) {
8918 bool found_difference =
false;
8919 for (
int i = 0; i < len; i++) {
8920 if (Get(i) != other->Get(i)) {
8921 found_difference =
true;
8925 ASSERT(found_difference);
8929 if (
Hash() != other->Hash())
return false;
8934 if (this->Get(0) != other->Get(0))
return false;
8937 String* rhs = other->TryFlattenGetString();
8940 if (StringShape(lhs).IsSequentialAscii() &&
8941 StringShape(rhs).IsSequentialAscii()) {
8944 return CompareRawStringContents(str1, str2, len);
8948 StringComparator comparator(isolate->objects_string_compare_iterator_a(),
8949 isolate->objects_string_compare_iterator_b());
8951 return comparator.Equals(static_cast<unsigned>(len), lhs, rhs);
8956 if (StringShape(
this).IsInternalized())
return false;
8960 if (map == heap->string_map()) {
8961 this->
set_map(heap->undetectable_string_map());
8963 }
else if (map == heap->ascii_string_map()) {
8964 this->
set_map(heap->undetectable_ascii_string_map());
8975 int str_len = str.
length();
8976 if (!allow_prefix_match &&
8982 unsigned remaining_in_str =
static_cast<unsigned>(str_len);
8983 const uint8_t* utf8_data =
reinterpret_cast<const uint8_t*
>(str.
start());
8984 for (i = 0; i < slen && remaining_in_str > 0; i++) {
8985 unsigned cursor = 0;
8987 ASSERT(cursor > 0 && cursor <= remaining_in_str);
8989 if (i > slen - 1)
return false;
8993 if (Get(i) != r)
return false;
8995 utf8_data += cursor;
8996 remaining_in_str -= cursor;
8998 return (allow_prefix_match || i == slen) && remaining_in_str == 0;
9004 if (str.
length() != slen)
return false;
9009 str.
start(), slen) == 0;
9011 for (
int i = 0; i < slen; i++) {
9012 if (Get(i) !=
static_cast<uint16_t>(str[i]))
return false;
9020 if (str.
length() != slen)
return false;
9026 for (
int i = 0; i < slen; i++) {
9027 if (Get(i) != str[i])
return false;
9036 const unsigned len =
static_cast<unsigned>(
string->length());
9041 int32_t type =
string->map()->instance_type();
9045 if (hasher.consumed_ == len) {
9046 ASSERT(!string->IsConsString());
9049 ASSERT(string->IsConsString());
9052 unsigned offset = 0;
9053 unsigned leaf_length = len;
9054 string = op.
Operate(
string, &offset, &type, &leaf_length);
9056 ASSERT(hasher.consumed_ < len);
9057 String::Visit(
string, 0, hasher, null_op, type, leaf_length);
9058 if (hasher.consumed_ == len)
break;
9059 string = op.ContinueOperation(&type, &leaf_length);
9067 consumed_ += length;
9071 consumed_ += length;
9079 DISALLOW_COPY_AND_ASSIGN(IteratingStringHasher);
9083 uint32_t String::ComputeAndSetHash() {
9100 int length = this->
length();
9115 if (d < 0 || d > 9)
return false;
9116 uint32_t result = d;
9119 if (d < 0 || d > 9)
return false;
9121 if (result > 429496729
U - ((d > 5) ? 1 : 0))
return false;
9122 result = (result * 10) + d;
9130 bool String::SlowAsArrayIndex(uint32_t* index) {
9145 int new_size, old_size;
9146 int old_length =
string->length();
9147 if (old_length <= new_length)
return string;
9149 if (string->IsSeqOneByteString()) {
9153 ASSERT(string->IsSeqTwoByteString());
9158 int delta = old_size - new_size;
9159 string->set_length(new_length);
9161 Address start_of_string =
string->address();
9165 Heap* heap =
string->GetHeap();
9167 if (newspace->
Contains(start_of_string) &&
9168 newspace->
top() == start_of_string + old_size) {
9170 newspace->
set_top(start_of_string + new_size);
9178 if (new_length == 0)
return heap->
isolate()->
factory()->empty_string();
9203 if (is_array_index_) {
9216 int* utf16_length_out) {
9217 int vector_length = chars.
length();
9219 if (vector_length <= 1) {
9220 ASSERT(vector_length == 0 ||
9221 static_cast<uint8_t>(chars.
start()[0]) <=
9223 *utf16_length_out = vector_length;
9229 unsigned remaining =
static_cast<unsigned>(vector_length);
9230 const uint8_t* stream =
reinterpret_cast<const uint8_t*
>(chars.
start());
9231 int utf16_length = 0;
9232 bool is_index =
true;
9233 ASSERT(hasher.is_array_index_);
9234 while (remaining > 0) {
9235 unsigned consumed = 0;
9237 ASSERT(consumed > 0 && consumed <= remaining);
9239 remaining -= consumed;
9241 utf16_length += is_two_characters ? 2 : 1;
9244 if (is_two_characters) {
9247 hasher.AddCharacter(c1);
9248 hasher.AddCharacter(c2);
9249 if (is_index) is_index = hasher.UpdateIndex(c1);
9250 if (is_index) is_index = hasher.UpdateIndex(c2);
9252 hasher.AddCharacter(c);
9253 if (is_index) is_index = hasher.UpdateIndex(c);
9256 *utf16_length_out =
static_cast<int>(utf16_length);
9258 hasher.length_ = utf16_length;
9264 int length = this->
length();
9265 for (
int i = 0; i <
length; i++) {
9266 PrintF(file,
"%c", Get(i));
9273 if (live_enum == kInvalidEnumCacheSentinel) {
9280 int to_trim = enum_cache->
length() - live_enum;
9281 if (to_trim <= 0)
return;
9282 RightTrimFixedArray<Heap::FROM_GC>(
9287 RightTrimFixedArray<Heap::FROM_GC>(heap, enum_indices_cache, to_trim);
9291 static void TrimDescriptorArray(Heap* heap,
9293 DescriptorArray* descriptors,
9294 int number_of_own_descriptors) {
9295 int number_of_descriptors = descriptors->number_of_descriptors_storage();
9296 int to_trim = number_of_descriptors - number_of_own_descriptors;
9297 if (to_trim == 0)
return;
9299 RightTrimFixedArray<Heap::FROM_GC>(
9301 descriptors->SetNumberOfDescriptors(number_of_own_descriptors);
9303 if (descriptors->HasEnumCache()) TrimEnumCache(heap, map, descriptors);
9304 descriptors->Sort();
9310 static bool ClearBackPointer(Heap* heap, Map* target) {
9311 if (Marking::MarkBitFrom(target).Get())
return false;
9329 int transition_index = 0;
9332 bool descriptors_owner_died =
false;
9337 if (ClearBackPointer(heap, target)) {
9338 if (target->instance_descriptors() == descriptors) {
9339 descriptors_owner_died =
true;
9342 if (i != transition_index) {
9344 t->
SetKey(transition_index, key);
9346 collector->RecordSlot(key_slot, key_slot, key);
9361 if (descriptors_owner_died) {
9362 if (number_of_own_descriptors > 0) {
9363 TrimDescriptorArray(heap,
this, descriptors, number_of_own_descriptors);
9384 int hash = (
static_cast<uint32_t
>(
9385 reinterpret_cast<uintptr_t
>(constructor())) >> 2);
9390 hash ^= (
static_cast<uint32_t
>(
9391 reinterpret_cast<uintptr_t
>(prototype())) << 2);
9397 static bool CheckEquivalent(
Map* first,
Map* second) {
9399 first->constructor() == second->constructor() &&
9400 first->prototype() == second->prototype() &&
9410 return CheckEquivalent(
this, other);
9447 code()->optimizable());
9448 ASSERT(!shared()->is_generator());
9450 GetIsolate()->builtins()->builtin(Builtins::kCompileOptimized));
9459 ASSERT(!shared()->is_generator());
9461 if (FLAG_trace_concurrent_recompilation) {
9464 PrintF(
" for concurrent recompilation.\n");
9467 GetIsolate()->builtins()->builtin(Builtins::kCompileOptimizedConcurrent));
9479 if (FLAG_trace_concurrent_recompilation) {
9482 PrintF(
" for concurrent recompilation.\n");
9485 GetIsolate()->builtins()->builtin(Builtins::kInOptimizationQueue));
9497 shared->GetIsolate(),
9498 shared->AddToOptimizedCodeMap(
9499 *native_context, *code, *literals, osr_ast_id));
9507 ASSERT(code->
kind() == Code::OPTIMIZED_FUNCTION);
9512 Object* value = optimized_code_map();
9514 if (value->IsSmi()) {
9519 if (!maybe->To(&new_code_map))
return maybe;
9528 int old_length = old_code_map->
length();
9530 MaybeObject* maybe = old_code_map->
CopySize(new_length);
9531 if (!maybe->To(&new_code_map))
return maybe;
9547 Code::OPTIMIZED_FUNCTION);
9552 set_optimized_code_map(new_code_map);
9553 return new_code_map;
9563 return cached_literals;
9594 const char* reason) {
9595 if (optimized_code_map()->IsSmi())
return;
9599 int length = code_map->
length();
9601 ASSERT(code_map->
get(src)->IsNativeContext());
9604 if (FLAG_trace_opt) {
9605 PrintF(
"[evicting entry from optimizing code map (%s) for ", reason);
9611 PrintF(
" (osr ast id %d)]\n", osr.ToInt());
9629 if (dst != length) {
9631 RightTrimFixedArray<Heap::FROM_MUTATOR>(
GetHeap(), code_map, length - dst);
9642 RightTrimFixedArray<Heap::FROM_GC>(
GetHeap(), code_map, shrink_by);
9650 if (object->IsGlobalObject())
return;
9654 if (!object->HasFastProperties()) {
9665 MaybeObject* maybe_maps =
9668 if (!maybe_maps->To(&maps))
return maybe_maps;
9670 Map* current_map = initial_map;
9673 maps->
set(kind, current_map);
9682 MaybeObject* maybe_new_map =
9684 if (!maybe_new_map->To(&new_map))
return maybe_new_map;
9686 maps->
set(next_kind, new_map);
9687 current_map = new_map;
9689 native_context->set_js_array_maps(maps);
9697 CacheInitialJSArrayMaps(*native_context, *initial_map),
9704 ASSERT(value->IsJSReceiver());
9708 if (value->IsJSObject()) {
9714 if (function->has_initial_map()) {
9719 if (function->shared()->IsInobjectSlackTrackingInProgress()) {
9720 function->shared()->CompleteInobjectSlackTracking();
9723 new_map->set_prototype(*value);
9729 if (array_function->IsJSFunction() &&
9731 CacheInitialJSArrayMaps(
handle(native_context), new_map);
9734 function->set_initial_map(*new_map);
9739 function->set_prototype_or_initial_map(*value);
9741 function->GetHeap()->ClearInstanceofCache();
9747 ASSERT(function->should_have_prototype());
9754 if (!value->IsJSReceiver()) {
9761 new_map->set_constructor(*value);
9762 new_map->set_non_instance_prototype(
true);
9763 Isolate* isolate = new_map->GetIsolate();
9764 construct_prototype =
handle(
9768 function->map()->set_non_instance_prototype(
false);
9777 Map* no_prototype_map = shared()->strict_mode() ==
SLOPPY
9778 ? native_context->sloppy_function_without_prototype_map()
9779 : native_context->strict_function_without_prototype_map();
9781 if (
map() == no_prototype_map)
return;
9784 ? native_context->sloppy_function_map()
9785 : native_context->strict_function_map()));
9788 set_prototype_or_initial_map(no_prototype_map->
GetHeap()->the_hole_value());
9793 if (function->has_initial_map())
return;
9794 Isolate* isolate =
function->GetIsolate();
9800 int in_object_properties;
9801 if (function->shared()->is_generator()) {
9804 in_object_properties = 0;
9807 instance_size =
function->shared()->CalculateInstanceSize();
9808 in_object_properties =
function->shared()->CalculateInObjectProperties();
9814 if (function->has_instance_prototype()) {
9815 prototype =
handle(function->instance_prototype(), isolate);
9819 map->set_inobject_properties(in_object_properties);
9820 map->set_unused_property_fields(in_object_properties);
9821 map->set_prototype(*prototype);
9822 ASSERT(map->has_fast_object_elements());
9824 if (!function->shared()->is_generator()) {
9825 function->shared()->StartInobjectSlackTracking(*map);
9829 function->set_initial_map(*map);
9830 map->set_constructor(*
function);
9835 shared()->set_instance_class_name(name);
9858 if (*raw_filter ==
'*')
return true;
9859 String* name = shared()->DebugName();
9862 if (filter[0] ==
'-') {
9864 if (filter.
length() == 1) {
9865 return (name->
length() != 0);
9869 if (filter[filter.
length() - 1] ==
'*' &&
9878 if (filter[filter.
length() - 1] ==
'*' &&
9887 const char* to_string,
9890 String* internalized_to_string;
9891 { MaybeObject* maybe_string =
9894 if (!maybe_string->To(&internalized_to_string))
return maybe_string;
9896 set_to_string(internalized_to_string);
9897 set_to_number(to_number);
9911 return !script()->IsUndefined() &&
9912 !
reinterpret_cast<Script*
>(script())->source()->IsUndefined();
9926 if (!script()->IsScript())
return false;
9927 if (optimization_disabled())
return false;
9929 if (
code()->kind() != Code::FUNCTION)
return true;
9930 return code()->optimizable();
9946 return instance_size;
9961 accumulator->
Add(
"<No Source>");
9972 accumulator->
Add(
"<Invalid Source>");
9976 if (!is_toplevel()) {
9977 accumulator->
Add(
"function ");
9985 if (len <= max_length || max_length < 0) {
9988 accumulator->
Put(script_source,
9991 accumulator->
Add(
"...\n");
9996 static bool IsCodeEquivalent(
Code* code,
Code* recompiled) {
9998 ByteArray* code_relocation = code->relocation_info();
9999 ByteArray* recompiled_relocation = recompiled->relocation_info();
10000 int length = code_relocation->
length();
10001 if (length != recompiled_relocation->
length())
return false;
10005 return compare == 0;
10013 if (IsCodeEquivalent(code, recompiled)) {
10015 code->set_deoptimization_data(recompiled->deoptimization_data());
10036 set_optimization_disabled(
true);
10041 if (
code()->kind() == Code::FUNCTION) {
10042 code()->set_optimizable(
false);
10047 if (FLAG_trace_opt) {
10048 PrintF(
"[disabled optimization for ");
10069 if (!FLAG_clever_optimizations)
return;
10072 if (live_objects_may_exist())
return;
10073 set_live_objects_may_exist(
true);
10085 set_initial_map(map);
10089 set_construct_stub(builtins->
builtin(Builtins::kJSConstructStubCountdown));
10095 Map* map =
reinterpret_cast<Map*
>(initial_map());
10107 set_initial_map(heap->undefined_value());
10109 ASSERT_EQ(builtins->builtin(Builtins::kJSConstructStubCountdown),
10111 set_construct_stub(builtins->builtin(Builtins::kJSConstructStubGeneric));
10113 set_live_objects_may_exist(
false);
10123 set_initial_map(map);
10127 set_construct_stub(builtins->
builtin(Builtins::kJSConstructStubCountdown));
10129 set_live_objects_may_exist(
true);
10134 code()->ClearInlineCaches();
10136 if (
code()->kind() == Code::FUNCTION) {
10137 code()->set_profiler_ticks(0);
10138 if (optimization_disabled() &&
10141 set_optimization_disabled(
false);
10142 code()->set_optimizable(
true);
10150 static void GetMinInobjectSlack(
Map* map,
void* data) {
10152 if (*reinterpret_cast<int*>(data) > slack) {
10153 *
reinterpret_cast<int*
>(data) = slack;
10158 static void ShrinkInstanceSize(Map* map,
void* data) {
10159 int slack = *
reinterpret_cast<int*
>(data);
10160 map->set_inobject_properties(map->inobject_properties() - slack);
10161 map->set_unused_property_fields(map->unused_property_fields() - slack);
10162 map->set_instance_size(map->instance_size() - slack *
kPointerSize);
10174 set_initial_map(heap->undefined_value());
10176 ASSERT_EQ(builtins->builtin(Builtins::kJSConstructStubCountdown),
10178 set_construct_stub(builtins->builtin(Builtins::kJSConstructStubGeneric));
10196 if (!FLAG_cache_optimized_code)
return -1;
10197 Object* value = optimized_code_map();
10198 if (!value->IsSmi()) {
10200 int length = optimized_code_map->
length();
10208 if (FLAG_trace_opt) {
10209 PrintF(
"[didn't find optimized code in optimized code map for ");
10218 #define DECLARE_TAG(ignore1, name, ignore2) name,
10226 #define DECLARE_TAG(ignore1, ignore2, name) name,
10234 void ObjectVisitor::VisitCodeTarget(RelocInfo* rinfo) {
10235 ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode()));
10237 Object* old_target = target;
10238 VisitPointer(&target);
10243 void ObjectVisitor::VisitCodeAgeSequence(RelocInfo* rinfo) {
10244 ASSERT(RelocInfo::IsCodeAgeSequence(rinfo->rmode()));
10245 Object* stub = rinfo->code_age_stub();
10247 VisitPointer(&stub);
10252 void ObjectVisitor::VisitCodeEntry(
Address entry_address) {
10255 VisitPointer(&code);
10256 if (code != old_code) {
10262 void ObjectVisitor::VisitCell(RelocInfo* rinfo) {
10263 ASSERT(rinfo->rmode() == RelocInfo::CELL);
10264 Object* cell = rinfo->target_cell();
10265 Object* old_cell = cell;
10266 VisitPointer(&cell);
10267 if (cell != old_cell) {
10268 rinfo->set_target_cell(reinterpret_cast<Cell*>(cell));
10273 void ObjectVisitor::VisitDebugTarget(RelocInfo* rinfo) {
10274 ASSERT((RelocInfo::IsJSReturn(rinfo->rmode()) &&
10275 rinfo->IsPatchedReturnSequence()) ||
10276 (RelocInfo::IsDebugBreakSlot(rinfo->rmode()) &&
10277 rinfo->IsPatchedDebugBreakSlotSequence()));
10279 Object* old_target = target;
10280 VisitPointer(&target);
10285 void ObjectVisitor::VisitEmbeddedPointer(RelocInfo* rinfo) {
10286 ASSERT(rinfo->rmode() == RelocInfo::EMBEDDED_OBJECT);
10287 Object* p = rinfo->target_object();
10292 void ObjectVisitor::VisitExternalReference(RelocInfo* rinfo) {
10293 Address p = rinfo->target_reference();
10294 VisitExternalReference(&p);
10299 set_relocation_info(
GetHeap()->empty_byte_array());
10305 Cell* undefined_cell =
GetHeap()->undefined_cell();
10306 int mode_mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) |
10307 RelocInfo::ModeMask(RelocInfo::CELL);
10309 RelocInfo::Mode mode = it.rinfo()->rmode();
10310 if (mode == RelocInfo::EMBEDDED_OBJECT) {
10312 }
else if (mode == RelocInfo::CELL) {
10321 it.rinfo()->apply(delta);
10328 ASSERT(Marking::Color(
this) == Marking::WHITE_OBJECT);
10341 int mode_mask = RelocInfo::kCodeTargetMask |
10342 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) |
10343 RelocInfo::ModeMask(RelocInfo::CELL) |
10345 RelocInfo::kApplyMask;
10350 RelocInfo::Mode mode = it.rinfo()->rmode();
10351 if (mode == RelocInfo::EMBEDDED_OBJECT) {
10354 }
else if (mode == RelocInfo::CELL) {
10357 }
else if (RelocInfo::IsCodeTarget(mode)) {
10364 }
else if (RelocInfo::IsRuntimeEntry(mode)) {
10365 Address p = it.rinfo()->target_runtime_entry(origin);
10367 }
else if (mode == RelocInfo::CODE_AGE_SEQUENCE) {
10370 it.rinfo()->set_code_age_stub(code);
10372 it.rinfo()->apply(delta);
10385 int position = RelocInfo::kNoPosition;
10391 while (!it.
done()) {
10396 int dist =
static_cast<int>(pc - it.
rinfo()->pc());
10397 int pos =
static_cast<int>(it.
rinfo()->data());
10401 if ((dist < distance) ||
10402 (dist == distance && pos > position)) {
10420 int statement_position = 0;
10422 while (!it.
done()) {
10423 if (RelocInfo::IsStatementPosition(it.
rinfo()->rmode())) {
10424 int p =
static_cast<int>(it.
rinfo()->data());
10425 if (statement_position < p && p <= position) {
10426 statement_position = p;
10431 return statement_position;
10436 SafepointTable table(
this);
10437 return table.FindEntry(pc);
10444 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
10446 RelocInfo* info = it.rinfo();
10447 Object*
object = info->target_object();
10448 if (object->IsHeapObject()) {
10450 if (--n == 0)
return object;
10473 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
10475 int current_pattern = 0;
10477 RelocInfo* info = it.rinfo();
10478 Object*
object = info->target_object();
10479 if (object->IsHeapObject()) {
10481 if (map == *pattern.find_[current_pattern]) {
10482 info->set_target_object(*pattern.replace_[current_pattern]);
10483 if (++current_pattern == pattern.count_)
return;
10494 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
10496 RelocInfo* info = it.rinfo();
10497 Object*
object = info->target_object();
10506 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
10508 RelocInfo* info = it.rinfo();
10509 Object*
object = info->target_object();
10510 if (object->IsMap()) {
10512 types->
Add(IC::MapToType<HeapType>(map, map->GetIsolate()));
10521 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET);
10523 RelocInfo* info = it.rinfo();
10534 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET);
10537 if (i == length)
return true;
10538 RelocInfo* info = it.rinfo();
10546 return i == length;
10553 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
10555 RelocInfo* info = it.rinfo();
10556 Object*
object = info->target_object();
10557 if (object->IsName())
return Name::cast(
object);
10574 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET) |
10575 RelocInfo::ModeMask(RelocInfo::CONSTRUCT_CALL) |
10576 RelocInfo::ModeMask(RelocInfo::CODE_TARGET_WITH_ID);
10578 RelocInfo* info = it.rinfo();
10580 if (target->is_inline_cache_stub()) {
10581 if (kind ==
NULL || *kind == target->kind()) {
10583 info->host()->constant_pool());
10591 if (
kind() != FUNCTION)
return;
10593 if (raw_info->IsTypeFeedbackInfo()) {
10596 for (
int i = 0; i < feedback_vector->
length(); i++) {
10598 if (!obj->IsAllocationSite()) {
10600 feedback_vector->
set(i,
10612 for (uint32_t i = 0; i < back_edges.
length(); i++) {
10613 if (back_edges.
pc_offset(i) == pc_offset)
return back_edges.
ast_id(i);
10623 for (uint32_t i = 0; i < back_edges.
length(); i++) {
10655 byte* sequence = FindCodeAgeSequence();
10656 if (sequence !=
NULL) {
10659 GetCodeAgeAndParity(sequence, &age, &code_parity);
10660 age = EffectiveAge(age);
10661 if (age !=
kLastCodeAge && code_parity != current_parity) {
10664 static_cast<Age>(age + 1),
10676 byte* Code::FindCodeAgeSequence() {
10677 return FLAG_age_code &&
10679 (
kind() == OPTIMIZED_FUNCTION ||
10692 byte* sequence = FindCodeAgeSequence();
10693 if (sequence ==
NULL) {
10698 GetCodeAgeAndParity(sequence, &age, &parity);
10703 void Code::GetCodeAgeAndParity(
Code* code, Age* age,
10708 #define HANDLE_CODE_AGE(AGE) \
10709 stub = *builtins->Make##AGE##CodeYoungAgainEvenMarking(); \
10710 if (code == stub) { \
10711 *age = k##AGE##CodeAge; \
10712 *parity = EVEN_MARKING_PARITY; \
10715 stub = *builtins->Make##AGE##CodeYoungAgainOddMarking(); \
10716 if (code == stub) { \
10717 *age = k##AGE##CodeAge; \
10718 *parity = ODD_MARKING_PARITY; \
10722 #undef HANDLE_CODE_AGE
10723 stub = *builtins->MarkCodeAsExecutedOnce();
10724 if (code == stub) {
10729 stub = *builtins->MarkCodeAsExecutedTwice();
10730 if (code == stub) {
10739 Code* Code::GetCodeAgeStub(Isolate* isolate, Age age,
MarkingParity parity) {
10740 Builtins* builtins = isolate->builtins();
10742 #define HANDLE_CODE_AGE(AGE) \
10743 case k##AGE##CodeAge: { \
10744 Code* stub = parity == EVEN_MARKING_PARITY \
10745 ? *builtins->Make##AGE##CodeYoungAgainEvenMarking() \
10746 : *builtins->Make##AGE##CodeYoungAgainOddMarking(); \
10750 #undef HANDLE_CODE_AGE
10753 return *builtins->MarkCodeAsExecutedOnce();
10757 return *builtins->MarkCodeAsExecutedTwice();
10768 const char* last_comment =
NULL;
10769 int mask = RelocInfo::ModeMask(RelocInfo::COMMENT)
10772 RelocInfo* info = it.rinfo();
10773 if (info->rmode() == RelocInfo::COMMENT) {
10774 last_comment =
reinterpret_cast<const char*
>(info->data());
10775 }
else if (last_comment !=
NULL) {
10780 CHECK(RelocInfo::IsRuntimeEntry(info->rmode()));
10781 PrintF(out,
" %s\n", last_comment);
10793 for (
int i = 0; i < deopt_data->
DeoptCount(); i++) {
10794 if (deopt_data->Pc(i)->value() == -1)
continue;
10795 Address address = code_start_address + deopt_data->Pc(i)->value();
10796 if (address == pc)
return true;
10805 #define CASE(name) case name: return #name;
10815 #ifdef ENABLE_DISASSEMBLER
10817 void DeoptimizationInputData::DeoptimizationInputDataPrint(FILE* out) {
10820 PrintF(out,
"Deoptimization Input Data (deopt points = %d)\n", deopt_count);
10821 if (0 == deopt_count)
return;
10823 PrintF(out,
"%6s %6s %6s %6s %12s\n",
"index",
"ast id",
"argc",
"pc",
10824 FLAG_print_code_verbose ?
"commands" :
"");
10825 for (
int i = 0; i < deopt_count; i++) {
10826 PrintF(out,
"%6d %6d %6d %6d",
10829 ArgumentsStackHeight(i)->value(),
10832 if (!FLAG_print_code_verbose) {
10837 int translation_index = TranslationIndex(i)->value();
10838 TranslationIterator iterator(TranslationByteArray(), translation_index);
10841 ASSERT(Translation::BEGIN == opcode);
10842 int frame_count = iterator.Next();
10843 int jsframe_count = iterator.Next();
10844 PrintF(out,
" %s {frame count=%d, js frame count=%d}\n",
10845 Translation::StringFor(opcode),
10849 while (iterator.HasNext() &&
10850 Translation::BEGIN !=
10852 PrintF(out,
"%24s %s ",
"", Translation::StringFor(opcode));
10855 case Translation::BEGIN:
10859 case Translation::JS_FRAME: {
10860 int ast_id = iterator.Next();
10861 int function_id = iterator.Next();
10862 unsigned height = iterator.Next();
10863 PrintF(out,
"{ast_id=%d, function=", ast_id);
10864 if (function_id != Translation::kSelfLiteralId) {
10865 Object*
function = LiteralArray()->get(function_id);
10870 PrintF(out,
", height=%u}", height);
10874 case Translation::COMPILED_STUB_FRAME: {
10876 PrintF(out,
"{kind=%d}", stub_kind);
10880 case Translation::ARGUMENTS_ADAPTOR_FRAME:
10881 case Translation::CONSTRUCT_STUB_FRAME: {
10882 int function_id = iterator.Next();
10883 JSFunction*
function =
10885 unsigned height = iterator.Next();
10886 PrintF(out,
"{function=");
10887 function->PrintName(out);
10888 PrintF(out,
", height=%u}", height);
10892 case Translation::GETTER_STUB_FRAME:
10893 case Translation::SETTER_STUB_FRAME: {
10894 int function_id = iterator.Next();
10895 JSFunction*
function =
10897 PrintF(out,
"{function=");
10898 function->PrintName(out);
10904 int reg_code = iterator.Next();
10909 case Translation::INT32_REGISTER: {
10910 int reg_code = iterator.Next();
10915 case Translation::UINT32_REGISTER: {
10916 int reg_code = iterator.Next();
10917 PrintF(out,
"{input=%s (unsigned)}",
10922 case Translation::DOUBLE_REGISTER: {
10923 int reg_code = iterator.Next();
10924 PrintF(out,
"{input=%s}",
10929 case Translation::STACK_SLOT: {
10930 int input_slot_index = iterator.Next();
10931 PrintF(out,
"{input=%d}", input_slot_index);
10935 case Translation::INT32_STACK_SLOT: {
10936 int input_slot_index = iterator.Next();
10937 PrintF(out,
"{input=%d}", input_slot_index);
10941 case Translation::UINT32_STACK_SLOT: {
10942 int input_slot_index = iterator.Next();
10943 PrintF(out,
"{input=%d (unsigned)}", input_slot_index);
10947 case Translation::DOUBLE_STACK_SLOT: {
10948 int input_slot_index = iterator.Next();
10949 PrintF(out,
"{input=%d}", input_slot_index);
10953 case Translation::LITERAL: {
10954 unsigned literal_index = iterator.Next();
10955 PrintF(out,
"{literal_id=%u}", literal_index);
10959 case Translation::DUPLICATED_OBJECT: {
10960 int object_index = iterator.Next();
10961 PrintF(out,
"{object_index=%d}", object_index);
10965 case Translation::ARGUMENTS_OBJECT:
10966 case Translation::CAPTURED_OBJECT: {
10967 int args_length = iterator.Next();
10968 PrintF(out,
"{length=%d}", args_length);
10978 void DeoptimizationOutputData::DeoptimizationOutputDataPrint(FILE* out) {
10979 PrintF(out,
"Deoptimization Output Data (deopt points = %d)\n",
10983 PrintF(out,
"%6s %8s %s\n",
"ast id",
"pc",
"state");
10986 PrintF(out,
"%6d %8d %s\n",
10987 this->
AstId(i).ToInt(),
11003 case GENERIC:
return "GENERIC";
11011 const char* Code::StubType2String(StubType type) {
11013 case NORMAL:
return "NORMAL";
11014 case FAST:
return "FAST";
11021 void Code::PrintExtraICState(FILE* out, Kind kind,
ExtraICState extra) {
11022 PrintF(out,
"extra_ic_state = ");
11023 const char* name =
NULL;
11026 case KEYED_STORE_IC:
11027 if (extra ==
STRICT) name =
"STRICT";
11032 if (name !=
NULL) {
11033 PrintF(out,
"%s\n", name);
11035 PrintF(out,
"%d\n", extra);
11040 void Code::Disassemble(
const char* name, FILE* out) {
11043 PrintF(out,
"major_key = %s\n",
11044 CodeStub::MajorName(CodeStub::GetMajorKey(
this),
true));
11050 PrintF(out,
"type = %s\n", StubType2String(
type()));
11057 &handler_state, &op);
11058 PrintF(out,
"compare_state = %s*%s -> %s\n",
11065 if ((name !=
NULL) && (name[0] !=
'\0')) {
11066 PrintF(out,
"name = %s\n", name);
11068 if (
kind() == OPTIMIZED_FUNCTION) {
11076 if (
kind() == FUNCTION) {
11077 DeoptimizationOutputData* data =
11079 data->DeoptimizationOutputDataPrint(out);
11080 }
else if (
kind() == OPTIMIZED_FUNCTION) {
11081 DeoptimizationInputData* data =
11083 data->DeoptimizationInputDataPrint(out);
11088 SafepointTable table(
this);
11089 PrintF(out,
"Safepoints (size = %u)\n", table.size());
11090 for (
unsigned i = 0; i < table.length(); i++) {
11091 unsigned pc_offset = table.GetPcOffset(i);
11093 table.PrintEntry(i, out);
11094 PrintF(out,
" (sp -> fp)");
11095 SafepointEntry entry = table.GetEntry(i);
11096 if (entry.deoptimization_index() != Safepoint::kNoDeoptimizationIndex) {
11097 PrintF(out,
" %6d", entry.deoptimization_index());
11101 if (entry.argument_count() > 0) {
11102 PrintF(out,
" argc: %d", entry.argument_count());
11107 }
else if (
kind() == FUNCTION) {
11113 BackEdgeTable back_edges(
this, &no_gc);
11115 PrintF(out,
"Back edges (size = %u)\n", back_edges.length());
11116 PrintF(out,
"ast_id pc_offset loop_depth\n");
11118 for (uint32_t i = 0; i < back_edges.length(); i++) {
11119 PrintF(out,
"%6d %9u %10u\n", back_edges.ast_id(i).ToInt(),
11120 back_edges.pc_offset(i),
11121 back_edges.loop_depth(i));
11126 #ifdef OBJECT_PRINT
11140 #endif // ENABLE_DISASSEMBLER
11149 ASSERT(!object->HasExternalArrayElements());
11153 object->GetIsolate()->factory()->NewUninitializedFixedArray(capacity);
11155 ElementsKind elements_kind =
object->GetElementsKind();
11159 bool has_fast_smi_elements =
11162 if (has_fast_smi_elements) {
11177 accessor->CopyElements(
object, new_elements, elements_kind);
11180 Handle<Map> new_map = (new_elements_kind != elements_kind)
11182 :
handle(object->map());
11183 object->ValidateElements();
11184 object->set_map_and_elements(*new_map, *new_elements);
11187 JSObject::UpdateAllocationSite(
object, new_elements_kind);
11190 parameter_map->set(1, *new_elements);
11193 if (FLAG_trace_elements_transitions) {
11195 object->GetElementsKind(), new_elements);
11198 if (object->IsJSArray()) {
11201 return new_elements;
11209 ASSERT(!object->HasExternalArrayElements());
11212 object->GetIsolate()->factory()->NewFixedDoubleArray(capacity);
11214 ElementsKind elements_kind =
object->GetElementsKind();
11227 accessor->CopyElements(
object, elems, elements_kind);
11229 object->ValidateElements();
11230 object->set_map_and_elements(*new_map, *elems);
11232 if (FLAG_trace_elements_transitions) {
11234 object->GetElementsKind(), elems);
11237 if (object->IsJSArray()) {
11246 array->GetIsolate()->factory()->NewJSArrayStorage(
11260 static bool GetOldValue(
Isolate* isolate,
11270 if (object->GetLocalElementAccessorPair(index) !=
NULL) {
11275 old_values->Add(value);
11276 indices->
Add(index);
11280 static void EnqueueSpliceRecord(Handle<JSArray>
object,
11282 Handle<JSArray> deleted,
11283 uint32_t add_count) {
11284 Isolate* isolate =
object->GetIsolate();
11285 HandleScope scope(isolate);
11286 Handle<Object> index_object = isolate->factory()->NewNumberFromUint(index);
11287 Handle<Object> add_count_object =
11288 isolate->factory()->NewNumberFromUint(add_count);
11290 Handle<Object> args[] =
11291 { object, index_object, deleted, add_count_object };
11295 Handle<JSFunction>(isolate->observers_enqueue_splice()),
11296 isolate->factory()->undefined_value(),
ARRAY_SIZE(args), args,
11302 static void BeginPerformSplice(Handle<JSArray>
object) {
11303 Isolate* isolate =
object->GetIsolate();
11304 HandleScope scope(isolate);
11305 Handle<Object> args[] = {
object };
11309 Handle<JSFunction>(isolate->observers_begin_perform_splice()),
11310 isolate->factory()->undefined_value(),
ARRAY_SIZE(args), args,
11316 static void EndPerformSplice(Handle<JSArray>
object) {
11317 Isolate* isolate =
object->GetIsolate();
11318 HandleScope scope(isolate);
11319 Handle<Object> args[] = {
object };
11323 Handle<JSFunction>(isolate->observers_end_perform_splice()),
11324 isolate->factory()->undefined_value(),
ARRAY_SIZE(args), args,
11333 ASSERT(array->AllowsSetElementsLength());
11334 if (!array->map()->is_observed()) {
11335 return array->GetElementsAccessor()->SetLength(array, new_length_handle);
11338 Isolate* isolate = array->GetIsolate();
11342 uint32_t old_length = 0;
11343 CHECK(old_length_handle->ToArrayIndex(&old_length));
11344 uint32_t new_length = 0;
11348 int num_elements = array->NumberOfLocalElements(kNoAttrFilter);
11349 if (num_elements > 0) {
11350 if (old_length == static_cast<uint32_t>(num_elements)) {
11352 for (uint32_t i = old_length - 1; i + 1 > new_length; --i) {
11353 if (!GetOldValue(isolate, array, i, &old_values, &indices))
break;
11360 array->GetLocalElementKeys(*keys, kNoAttrFilter);
11361 while (num_elements-- > 0) {
11363 if (index < new_length)
break;
11364 if (!GetOldValue(isolate, array, index, &old_values, &indices))
break;
11370 array->GetElementsAccessor()->SetLength(array, new_length_handle);
11373 CHECK(array->length()->ToArrayIndex(&new_length));
11374 if (old_length == new_length)
return hresult;
11376 BeginPerformSplice(array);
11378 for (
int i = 0; i < indices.length(); ++i) {
11387 array,
"update", isolate->
factory()->length_string(),
11388 old_length_handle);
11390 EndPerformSplice(array);
11392 uint32_t index =
Min(old_length, new_length);
11393 uint32_t add_count = new_length > old_length ? new_length - old_length : 0;
11394 uint32_t delete_count = new_length < old_length ? old_length - new_length : 0;
11396 if (delete_count > 0) {
11397 for (
int i = indices.length() - 1; i >= 0; i--) {
11400 if (old_values[i]->IsTheHole())
continue;
11410 EnqueueSpliceRecord(array, index, deleted, add_count);
11418 FixedArray* cache = map->GetPrototypeTransitions();
11419 int number_of_transitions = map->NumberOfProtoTransitions();
11420 const int proto_offset =
11424 for (
int i = 0; i < number_of_transitions; i++) {
11425 if (cache->
get(proto_offset + i * step) == *prototype) {
11426 Object* result = cache->
get(map_offset + i * step);
11437 ASSERT(target_map->IsMap());
11440 if (map->is_shared() || !FLAG_cache_prototype_transitions)
return map;
11446 int capacity = (cache->length() - header) / step;
11447 int transitions = map->NumberOfProtoTransitions() + 1;
11449 if (transitions > capacity) {
11453 Factory* factory = map->GetIsolate()->factory();
11457 map->SetPrototypeTransitions(*cache),
11463 int last = map->NumberOfProtoTransitions();
11464 int entry = header + last * step;
11468 map->SetNumberOfProtoTransitions(last + 1);
11480 int length = transition_array->
length();
11481 for (
int i = 0; i < length; i++) {
11482 data[i] = the_hole;
11491 proto_transitions->
length());
11519 start_indexes_[0] = 0;
11522 start_indexes_[g] = start_indexes_[g - 1] + count;
11544 int start = starts.
at(group);
11545 int end = starts.
at(group + 1);
11548 for (
int i = start; i < end; i++) {
11549 if (entries->object_at(i) == *object)
return entries;
11551 if (entries->length() < kCodesStartIndex + number_of_entries + 1) {
11552 Factory* factory = entries->GetIsolate()->factory();
11553 int capacity = kCodesStartIndex + number_of_entries + 1;
11554 if (capacity > 5) capacity = capacity * 5 / 4;
11559 start = starts.
at(group);
11560 end = starts.
at(group + 1);
11563 entries->clear_at(i);
11567 if (number_of_entries == 0) {
11569 new_entries->set_number_of_entries(static_cast<DependencyGroup>(g), 0);
11572 entries = new_entries;
11574 entries->ExtendGroup(group);
11575 entries->set_object_at(end, *
object);
11576 entries->set_number_of_entries(group, end + 1 - start);
11588 int start = starts.
at(group);
11589 int end = starts.
at(group + 1);
11590 for (
int i = start; i < end; i++) {
11598 for (
int i = start; i < end; i++) {
11611 int start = starts.
at(group);
11612 int end = starts.
at(group + 1);
11615 for (
int i = start; i < end; i++) {
11621 if (info_pos == -1)
return;
11622 int gap = info_pos;
11625 int last_of_group = starts.
at(i + 1) - 1;
11626 ASSERT(last_of_group >= gap);
11627 if (last_of_group == gap)
continue;
11628 copy(last_of_group, gap);
11629 gap = last_of_group;
11636 for (
int i = start; i < end - 1; i++) {
11645 int start = starts.
at(group);
11646 int end = starts.
at(group + 1);
11647 for (
int i = start; i < end; i++) {
11659 int start = starts.
at(group);
11660 int end = starts.
at(group + 1);
11662 if (start == end)
return false;
11665 bool marked =
false;
11666 for (
int i = start; i < end; i++) {
11679 for (
int src = end, dst = start; src < code_entries; src++, dst++) {
11683 int removed = end - start;
11684 for (
int i = code_entries - removed; i < code_entries; i++) {
11695 ASSERT(AllowCodeDependencyChange::IsAllowed());
11705 bool skip_hidden_prototypes) {
11707 int size =
object->Size();
11710 Isolate* isolate =
object->GetIsolate();
11714 if (!value->IsJSReceiver() && !value->
IsNull())
return value;
11724 if (!object->map()->is_extensible()) {
11728 isolate->
Throw(*error);
11736 for (
Object* pt = *value;
11737 pt != heap->null_value();
11738 pt = pt->GetPrototype(isolate)) {
11742 "cyclic_proto", HandleVector<Object>(
NULL, 0));
11743 isolate->
Throw(*error);
11748 bool dictionary_elements_in_chain =
11749 object->map()->DictionaryElementsInPrototypeChainOnly();
11752 if (skip_hidden_prototypes) {
11755 Object* current_proto = real_receiver->GetPrototype();
11756 while (current_proto->IsJSObject() &&
11767 if (map->prototype() == *value)
return value;
11769 if (value->IsJSObject()) {
11777 new_map->set_prototype(*value);
11779 ASSERT(new_map->prototype() == *value);
11782 if (!dictionary_elements_in_chain &&
11783 new_map->DictionaryElementsInPrototypeChainOnly()) {
11787 object->GetHeap()->ClearAllICsByKind(Code::KEYED_STORE_IC);
11791 ASSERT(size == object->Size());
11798 uint32_t first_arg,
11799 uint32_t arg_count,
11804 return EnsureCanContainElements(
11805 object, args->arguments() - first_arg - (arg_count - 1), arg_count, mode);
11810 uint32_t index = 0;
11812 return GetLocalElementAccessorPair(index);
11816 LocalLookupRealNamedProperty(name, &lookup);
11818 if (lookup.IsPropertyCallbacks() &&
11819 lookup.GetCallbackObject()->IsAccessorPair()) {
11827 if (IsJSGlobalProxy()) {
11829 if (proto->IsNull())
return NULL;
11830 ASSERT(proto->IsJSGlobalObject());
11835 if (HasIndexedInterceptor())
return NULL;
11837 return GetElementsAccessor()->GetAccessorPair(
this,
this, index);
11847 bool check_prototype,
11849 Isolate* isolate =
object->GetIsolate();
11853 AssertNoContextChange ncc(isolate);
11856 if (!interceptor->setter()->IsUndefined()) {
11858 v8::ToCData<v8::IndexedPropertySetterCallback>(interceptor->setter());
11860 ApiIndexedPropertyAccess(
"interceptor-indexed-set", *
object, index));
11866 if (!result.IsEmpty())
return value;
11869 return SetElementWithoutInterceptor(
object, index, value, attributes,
11876 MaybeObject* JSObject::GetElementWithCallback(
Object* receiver,
11881 ASSERT(!structure->IsForeign());
11884 if (structure->IsExecutableAccessorInfo()) {
11885 Handle<ExecutableAccessorInfo> data(
11887 Object* fun_obj = data->getter();
11889 v8::ToCData<v8::AccessorGetterCallback>(fun_obj);
11890 if (call_fun ==
NULL)
return isolate->heap()->undefined_value();
11891 HandleScope scope(isolate);
11894 Handle<Object> number = isolate->factory()->NewNumberFromUint(index);
11895 Handle<String> key = isolate->factory()->NumberToString(number);
11896 LOG(isolate, ApiNamedPropertyAccess(
"load", *
self, *key));
11897 PropertyCallbackArguments
11898 args(isolate, data->data(), *
self, *holder_handle);
11901 if (result.IsEmpty())
return isolate->heap()->undefined_value();
11903 result_internal->VerifyApiCallResultType();
11904 return *result_internal;
11908 if (structure->IsAccessorPair()) {
11910 if (getter->IsSpecFunction()) {
11915 return isolate->heap()->undefined_value();
11918 if (structure->IsDeclaredAccessorInfo()) {
11919 return GetDeclaredAccessorProperty(receiver,
11929 Handle<Object> JSObject::SetElementWithCallback(Handle<JSObject>
object,
11930 Handle<Object> structure,
11932 Handle<Object> value,
11933 Handle<JSObject> holder,
11935 Isolate* isolate =
object->GetIsolate();
11939 ASSERT(!value->IsTheHole());
11944 ASSERT(!structure->IsForeign());
11946 if (structure->IsExecutableAccessorInfo()) {
11948 Handle<ExecutableAccessorInfo> data =
11950 Object* call_obj = data->setter();
11952 v8::ToCData<v8::AccessorSetterCallback>(call_obj);
11953 if (call_fun ==
NULL)
return value;
11954 Handle<Object> number = isolate->factory()->NewNumberFromUint(index);
11955 Handle<String> key(isolate->factory()->NumberToString(number));
11956 LOG(isolate, ApiNamedPropertyAccess(
"store", *
object, *key));
11957 PropertyCallbackArguments
11958 args(isolate, data->data(), *object, *holder);
11959 args.Call(call_fun,
11966 if (structure->IsAccessorPair()) {
11968 if (setter->IsSpecFunction()) {
11970 return SetPropertyWithDefinedSetter(
11971 object, Handle<JSReceiver>::cast(setter), value);
11973 if (strict_mode ==
SLOPPY)
return value;
11974 Handle<Object> key(isolate->factory()->NewNumberFromUint(index));
11975 Handle<Object> args[2] = { key, holder };
11976 Handle<Object> error = isolate->factory()->NewTypeError(
11978 isolate->Throw(*error);
11979 return Handle<Object>();
11984 if (structure->IsDeclaredAccessorInfo())
return value;
11987 return Handle<Object>();
11993 if (!elements()->IsFixedArray())
return false;
11995 if (elements->
map() != heap->sloppy_arguments_elements_map()) {
11999 return !arguments->IsDictionary();
12005 if (!elements()->IsFixedArray())
return false;
12007 if (elements->
map() != heap->sloppy_arguments_elements_map()) {
12011 return arguments->IsDictionary();
12022 bool check_prototype) {
12023 ASSERT(object->HasFastSmiOrObjectElements() ||
12024 object->HasFastArgumentsElements());
12026 Isolate* isolate =
object->GetIsolate();
12031 if (isolate->is_initial_object_prototype(*
object) ||
12032 isolate->is_initial_array_prototype(*
object)) {
12033 object->map()->dependent_code()->DeoptimizeDependentCodeGroup(isolate,
12038 if (backing_store->map() ==
12039 isolate->heap()->sloppy_arguments_elements_map()) {
12042 backing_store = EnsureWritableFastElements(
object);
12044 uint32_t capacity =
static_cast<uint32_t
>(backing_store->length());
12046 if (check_prototype &&
12047 (index >= capacity || backing_store->get(index)->IsTheHole())) {
12049 Handle<Object> result = SetElementWithCallbackSetterInPrototypes(
12050 object, index, value, &found, strict_mode);
12051 if (found)
return result;
12054 uint32_t new_capacity = capacity;
12056 uint32_t array_length = 0;
12057 bool must_update_array_length =
false;
12058 bool introduces_holes =
true;
12059 if (object->IsJSArray()) {
12061 introduces_holes = index > array_length;
12062 if (index >= array_length) {
12063 must_update_array_length =
true;
12064 array_length = index + 1;
12067 introduces_holes = index >= capacity;
12072 ElementsKind elements_kind =
object->GetElementsKind();
12073 if (introduces_holes &&
12077 TransitionElementsKind(
object, transitioned_kind);
12082 if (index >= capacity) {
12083 bool convert_to_slow =
true;
12084 if ((index - capacity) < kMaxGap) {
12085 new_capacity = NewElementsCapacity(index + 1);
12086 ASSERT(new_capacity > index);
12087 if (!object->ShouldConvertToSlowElements(new_capacity)) {
12088 convert_to_slow =
false;
12091 if (convert_to_slow) {
12092 NormalizeElements(
object);
12093 return SetDictionaryElement(
object, index, value,
NONE, strict_mode,
12098 if (object->HasFastSmiElements() && !value->IsSmi() && value->
IsNumber()) {
12104 UpdateAllocationSite(
object, to_kind);
12106 SetFastDoubleElementsCapacityAndLength(
object, new_capacity, array_length);
12108 object->ValidateElements();
12112 if (object->HasFastSmiElements() && !value->IsSmi()) {
12117 UpdateAllocationSite(
object, kind);
12118 Handle<Map> new_map = GetElementsTransitionMap(
object, kind);
12123 if (new_capacity != capacity) {
12125 value->IsSmi() &&
object->HasFastSmiElements()
12126 ? kAllowSmiElements
12127 : kDontAllowSmiElements;
12129 SetFastElementsCapacityAndLength(
object, new_capacity, array_length,
12131 new_elements->set(index, *value);
12132 object->ValidateElements();
12137 ASSERT(object->elements()->IsFixedArray());
12138 backing_store->set(index, *value);
12139 if (must_update_array_length) {
12151 bool check_prototype,
12153 ASSERT(object->HasDictionaryElements() ||
12154 object->HasDictionaryArgumentsElements());
12155 Isolate* isolate =
object->GetIsolate();
12159 bool is_arguments =
12160 (elements->
map() == isolate->heap()->sloppy_arguments_elements_map());
12165 int entry = dictionary->FindEntry(index);
12168 PropertyDetails details = dictionary->DetailsAt(entry);
12170 return SetElementWithCallback(
object, element, index, value,
object,
12173 dictionary->UpdateMaxNumberKey(index);
12178 details = PropertyDetails(
12179 attributes,
NORMAL, details.dictionary_index());
12180 dictionary->DetailsAtPut(entry, details);
12181 }
else if (details.IsReadOnly() && !element->IsTheHole()) {
12182 if (strict_mode ==
SLOPPY) {
12183 return isolate->factory()->undefined_value();
12185 Handle<Object> number = isolate->factory()->NewNumberFromUint(index);
12186 Handle<Object> args[2] = { number,
object };
12187 Handle<Object> error =
12188 isolate->factory()->NewTypeError(
"strict_read_only_property",
12190 isolate->Throw(*error);
12191 return Handle<Object>();
12195 if (is_arguments && element->IsAliasedArgumentsEntry()) {
12196 Handle<AliasedArgumentsEntry> entry =
12199 int context_index = entry->aliased_context_slot();
12200 ASSERT(!context->get(context_index)->IsTheHole());
12201 context->set(context_index, *value);
12203 if (!details.IsReadOnly()) value = element;
12205 dictionary->ValueAtPut(entry, *value);
12210 if (check_prototype) {
12212 Handle<Object> result = SetElementWithCallbackSetterInPrototypes(
object,
12213 index, value, &found, strict_mode);
12214 if (found)
return result;
12219 if (!object->map()->is_extensible()) {
12220 if (strict_mode ==
SLOPPY) {
12221 return isolate->factory()->undefined_value();
12223 Handle<Object> number = isolate->factory()->NewNumberFromUint(index);
12224 Handle<String> name = isolate->factory()->NumberToString(number);
12225 Handle<Object> args[1] = { name };
12226 Handle<Object> error =
12227 isolate->factory()->NewTypeError(
"object_not_extensible",
12229 isolate->Throw(*error);
12230 return Handle<Object>();
12234 PropertyDetails details = PropertyDetails(attributes,
NORMAL, 0);
12235 Handle<SeededNumberDictionary> new_dictionary =
12238 if (*dictionary != *new_dictionary) {
12239 if (is_arguments) {
12240 elements->
set(1, *new_dictionary);
12242 object->set_elements(*new_dictionary);
12244 dictionary = new_dictionary;
12249 if (object->IsJSArray()) {
12255 if (object->ShouldConvertToFastElements()) {
12256 uint32_t new_length = 0;
12257 if (object->IsJSArray()) {
12260 new_length = dictionary->max_number_key() + 1;
12262 SetFastElementsCapacitySmiMode smi_mode = FLAG_smi_only_arrays
12263 ? kAllowSmiElements
12264 : kDontAllowSmiElements;
12265 bool has_smi_only_elements =
false;
12266 bool should_convert_to_fast_double_elements =
12267 object->ShouldConvertToFastDoubleElements(&has_smi_only_elements);
12268 if (has_smi_only_elements) {
12269 smi_mode = kForceSmiElements;
12272 if (should_convert_to_fast_double_elements) {
12273 SetFastDoubleElementsCapacityAndLength(
object, new_length, new_length);
12275 SetFastElementsCapacityAndLength(
object, new_length, new_length,
12278 object->ValidateElements();
12280 if (FLAG_trace_normalization) {
12281 PrintF(
"Object elements are fast case again:\n");
12289 Handle<Object> JSObject::SetFastDoubleElement(
12290 Handle<JSObject>
object,
12292 Handle<Object> value,
12294 bool check_prototype) {
12295 ASSERT(object->HasFastDoubleElements());
12298 uint32_t elms_length =
static_cast<uint32_t
>(base_elms->length());
12302 if (check_prototype &&
12303 (index >= elms_length ||
12304 Handle<FixedDoubleArray>::cast(base_elms)->
is_the_hole(index))) {
12306 Handle<Object> result = SetElementWithCallbackSetterInPrototypes(
object,
12307 index, value, &found, strict_mode);
12308 if (found)
return result;
12313 bool value_is_smi = value->IsSmi();
12314 bool introduces_holes =
true;
12315 uint32_t length = elms_length;
12316 if (object->IsJSArray()) {
12318 introduces_holes = index >
length;
12320 introduces_holes = index >= elms_length;
12323 if (!value->IsNumber()) {
12324 SetFastElementsCapacityAndLength(
object, elms_length, length,
12325 kDontAllowSmiElements);
12326 Handle<Object> result = SetFastElement(
object, index, value, strict_mode,
12330 object->ValidateElements();
12334 double double_value = value_is_smi
12336 : Handle<HeapNumber>::cast(value)->value();
12340 ElementsKind elements_kind =
object->GetElementsKind();
12343 TransitionElementsKind(
object, transitioned_kind);
12347 if (index < elms_length) {
12349 elms->set(index, double_value);
12350 if (object->IsJSArray()) {
12352 uint32_t array_length = 0;
12355 if (index >= array_length) {
12363 if ((index - elms_length) < kMaxGap) {
12365 int new_capacity = NewElementsCapacity(index+1);
12366 if (!object->ShouldConvertToSlowElements(new_capacity)) {
12367 ASSERT(static_cast<uint32_t>(new_capacity) > index);
12368 SetFastDoubleElementsCapacityAndLength(
object, new_capacity, index + 1);
12370 object->ValidateElements();
12376 ASSERT(object->HasFastDoubleElements());
12377 ASSERT(object->map()->has_fast_double_elements());
12378 ASSERT(object->elements()->IsFixedDoubleArray() ||
12379 object->elements()->length() == 0);
12381 NormalizeElements(
object);
12382 ASSERT(object->HasDictionaryElements());
12383 return SetElement(
object, index, value,
NONE, strict_mode, check_prototype);
12392 if (object->IsJSProxy()) {
12393 return JSProxy::SetElementWithHandler(
12405 ASSERT(!object->HasExternalArrayElements());
12415 bool check_prototype,
12417 Isolate* isolate =
object->GetIsolate();
12419 if (object->HasExternalArrayElements() ||
12420 object->HasFixedTypedArrayElements()) {
12422 bool has_exception;
12431 if (object->IsAccessCheckNeeded()) {
12439 if (object->IsJSGlobalProxy()) {
12441 if (proto->IsNull())
return value;
12442 ASSERT(proto->IsJSGlobalObject());
12450 if ((object->HasExternalArrayElements() ||
12451 object->HasFixedTypedArrayElements()) &&
12457 isolate->
Throw(*error);
12465 dictionary->set_requires_slow_elements();
12468 if (!object->map()->is_observed()) {
12469 return object->HasIndexedInterceptor()
12470 ? SetElementWithInterceptor(
object, index, value, attributes, strict_mode,
12473 : SetElementWithoutInterceptor(
object, index, value, attributes,
12485 if (old_attributes !=
ABSENT) {
12486 if (object->GetLocalElementAccessorPair(index) ==
NULL) {
12489 }
else if (object->IsJSArray()) {
12497 ? SetElementWithInterceptor(
object, index, value, attributes, strict_mode,
12500 : SetElementWithoutInterceptor(
object, index, value, attributes,
12508 if (old_attributes ==
ABSENT) {
12509 if (object->IsJSArray() &&
12514 uint32_t old_length = 0;
12515 uint32_t new_length = 0;
12520 EnqueueChangeRecord(
object,
"add", name, old_value);
12521 EnqueueChangeRecord(
object,
"update", isolate->
factory()->length_string(),
12522 old_length_handle);
12526 new_length - old_length);
12528 EnqueueChangeRecord(
object,
"add", name, old_value);
12530 }
else if (old_value->IsTheHole()) {
12531 EnqueueChangeRecord(
object,
"reconfigure", name, old_value);
12535 bool value_changed = !old_value->
SameValue(*new_value);
12536 if (old_attributes != new_attributes) {
12537 if (!value_changed) old_value = isolate->
factory()->the_hole_value();
12538 EnqueueChangeRecord(
object,
"reconfigure", name, old_value);
12539 }
else if (value_changed) {
12540 EnqueueChangeRecord(
object,
"update", name, old_value);
12554 bool check_prototype,
12556 ASSERT(object->HasDictionaryElements() ||
12557 object->HasDictionaryArgumentsElements() ||
12559 Isolate* isolate =
object->GetIsolate();
12560 if (FLAG_trace_external_array_abuse &&
12564 if (FLAG_trace_js_array_abuse &&
12566 if (object->IsJSArray()) {
12570 switch (object->GetElementsKind()) {
12575 return SetFastElement(
object, index, value, strict_mode, check_prototype);
12578 return SetFastDoubleElement(
object, index, value, strict_mode,
12581 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
12582 case EXTERNAL_##TYPE##_ELEMENTS: { \
12583 Handle<External##Type##Array> array( \
12584 External##Type##Array::cast(object->elements())); \
12585 return External##Type##Array::SetValue(array, index, value); \
12587 case TYPE##_ELEMENTS: { \
12588 Handle<Fixed##Type##Array> array( \
12589 Fixed##Type##Array::cast(object->elements())); \
12590 return Fixed##Type##Array::SetValue(array, index, value); \
12595 #undef TYPED_ARRAY_CASE
12598 return SetDictionaryElement(
object, index, value, attributes, strict_mode,
12603 uint32_t length = parameter_map->
length();
12604 Handle<Object> probe = index < length - 2 ?
12605 Handle<Object>(parameter_map->
get(index + 2), isolate) :
12607 if (!probe.is_null() && !probe->IsTheHole()) {
12610 ASSERT(!context->get(context_index)->IsTheHole());
12611 context->set(context_index, *value);
12618 isolate->factory()->NewAliasedArgumentsEntry(context_index));
12622 if (arguments->IsDictionary()) {
12623 return SetDictionaryElement(
object, index, value, attributes,
12628 return SetFastElement(
object, index, value, strict_mode,
12636 return isolate->factory()->null_value();
12644 set_pretenure_decision(kUndecided);
12645 set_memento_found_count(0);
12646 set_memento_create_count(0);
12658 ASSERT(FLAG_trace_track_allocation_sites);
12660 while (current->IsAllocationSite()) {
12662 if (current_site->nested_site() ==
this) {
12665 current = current_site->weak_next();
12673 Isolate* isolate = site->GetIsolate();
12675 if (site->SitePointsToLiteral() && site->transition_info()->IsJSArray()) {
12678 ElementsKind kind = transition_info->GetElementsKind();
12686 uint32_t length = 0;
12687 CHECK(transition_info->length()->ToArrayIndex(&length));
12688 if (length <= kMaximumArrayBytesToPretransition) {
12689 if (FLAG_trace_track_allocation_sites) {
12690 bool is_nested = site->IsNestedSite();
12692 "AllocationSite: JSArray %p boilerplate %s updated %s->%s\n",
12693 reinterpret_cast<void*>(*site),
12694 is_nested ?
"(nested)" :
"",
12699 site->dependent_code()->DeoptimizeDependentCodeGroup(
12710 if (FLAG_trace_track_allocation_sites) {
12711 PrintF(
"AllocationSite: JSArray %p site updated %s->%s\n",
12712 reinterpret_cast<void*>(*site),
12716 site->SetElementsKind(to_kind);
12717 site->dependent_code()->DeoptimizeDependentCodeGroup(
12732 if (*codes != site->dependent_code()) site->set_dependent_code(*codes);
12739 if (!object->IsJSArray())
return;
12741 Heap* heap =
object->GetHeap();
12750 Address object_address =
object->address();
12754 last_memento_word_address)) {
12762 ASSERT(memento_address == top ||
12764 if (memento_address == top)
return;
12767 if (candidate->map() != heap->allocation_memento_map())
return;
12770 if (!memento->IsValid())
return;
12773 site =
handle(memento->GetAllocationSite());
12781 ElementsKind from_kind =
object->map()->elements_kind();
12787 if (from_kind == to_kind)
return;
12790 UpdateAllocationSite(
object, to_kind);
12793 Isolate* isolate =
object->GetIsolate();
12794 if (object->elements() == isolate->
heap()->empty_fixed_array() ||
12802 Handle<Map> new_map = GetElementsTransitionMap(
object, to_kind);
12803 MigrateToMap(
object, new_map);
12804 if (FLAG_trace_elements_transitions) {
12806 PrintElementsTransition(stdout,
object, from_kind, elms, to_kind, elms);
12812 uint32_t capacity =
static_cast<uint32_t
>(elms->length());
12813 uint32_t length = capacity;
12815 if (object->IsJSArray()) {
12817 if (raw_length->IsUndefined()) {
12828 SetFastDoubleElementsCapacityAndLength(
object, capacity, length);
12829 object->ValidateElements();
12835 SetFastElementsCapacityAndLength(
object, capacity, length,
12836 kDontAllowSmiElements);
12837 object->ValidateElements();
12865 array->JSArrayUpdateLengthFromIndex(index, *value));
12871 uint32_t old_len = 0;
12875 if (index >= old_len && index != 0xffffffff) {
12877 { MaybeObject* maybe_len =
12879 if (!maybe_len->ToObject(&len))
return maybe_len;
12890 Isolate* isolate =
object->GetIsolate();
12894 AssertNoContextChange ncc(isolate);
12897 if (!interceptor->getter()->IsUndefined()) {
12899 v8::ToCData<v8::IndexedPropertyGetterCallback>(interceptor->getter());
12901 ApiIndexedPropertyAccess(
"interceptor-indexed-get", *
object, index));
12903 args(isolate, interceptor->data(), *receiver, *object);
12906 if (!result.IsEmpty()) {
12908 result_internal->VerifyApiCallResultType();
12917 if (!result->IsTheHole())
return result;
12920 if (proto->IsNull())
return isolate->
factory()->undefined_value();
12925 bool JSObject::HasDenseElements() {
12928 GetElementsCapacityAndUsage(&capacity, &used);
12929 return (capacity == 0) || (used > (capacity / 2));
12933 void JSObject::GetElementsCapacityAndUsage(
int* capacity,
int* used) {
12938 FixedArray* backing_store =
NULL;
12939 switch (GetElementsKind()) {
12941 backing_store_base =
12944 if (backing_store->IsDictionary()) {
12945 SeededNumberDictionary* dictionary =
12947 *capacity = dictionary->Capacity();
12948 *used = dictionary->NumberOfElements();
12955 *capacity = backing_store_base->length();
12963 *capacity = backing_store->length();
12964 for (
int i = 0; i < *capacity; ++i) {
12965 if (!backing_store->get(i)->IsTheHole()) ++(*used);
12969 SeededNumberDictionary* dictionary = element_dictionary();
12970 *capacity = dictionary->Capacity();
12971 *used = dictionary->NumberOfElements();
12976 *capacity = backing_store_base->length();
12982 *capacity = elements()->
length();
12983 if (*capacity == 0)
break;
12985 for (
int i = 0; i < *capacity; i++) {
12986 if (!elms->is_the_hole(i)) ++(*used);
12991 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
12992 case EXTERNAL_##TYPE##_ELEMENTS: \
12993 case TYPE##_ELEMENTS: \
12996 #undef TYPED_ARRAY_CASE
13000 *capacity = external_array->length();
13001 *used = external_array->length();
13012 uint32_t capacity =
static_cast<uint32_t
>(backing_store->length());
13013 if (index >= capacity) {
13014 if ((index - capacity) >= kMaxGap)
return true;
13015 uint32_t new_capacity = NewElementsCapacity(index + 1);
13016 return ShouldConvertToSlowElements(new_capacity);
13025 kMaxUncheckedFastElementsLength);
13026 if (new_capacity <= kMaxUncheckedOldFastElementsLength ||
13027 (new_capacity <= kMaxUncheckedFastElementsLength &&
13028 GetHeap()->InNewSpace(
this))) {
13034 int old_capacity = 0;
13035 int used_elements = 0;
13036 GetElementsCapacityAndUsage(&old_capacity, &used_elements);
13039 return 3 * dictionary_size <= new_capacity;
13044 ASSERT(HasDictionaryElements() || HasDictionaryArgumentsElements());
13046 if (!HasDenseElements())
return false;
13049 if (IsAccessCheckNeeded())
return false;
13052 if (
map()->is_observed())
return false;
13056 if (elements->
map() ==
GetHeap()->sloppy_arguments_elements_map()) {
13067 uint32_t array_size = 0;
13073 uint32_t dictionary_size =
static_cast<uint32_t
>(dictionary->
Capacity()) *
13075 return 2 * dictionary_size >= array_size;
13080 bool* has_smi_only_elements) {
13081 *has_smi_only_elements =
false;
13082 if (HasSloppyArgumentsElements())
return false;
13083 if (FLAG_unbox_double_arrays) {
13084 ASSERT(HasDictionaryElements());
13086 bool found_double =
false;
13087 for (
int i = 0; i < dictionary->
Capacity(); i++) {
13089 if (key->IsNumber()) {
13091 if (!value->IsNumber())
return false;
13092 if (!value->IsSmi()) {
13093 found_double =
true;
13097 *has_smi_only_elements = !found_double;
13098 return found_double;
13110 #ifdef OBJECT_PRINT
13111 template<
typename Shape,
typename Key>
13114 for (
int i = 0; i < capacity; i++) {
13118 if (k->IsString()) {
13124 ValueAt(i)->ShortPrint(out);
13132 template<
typename Shape,
typename Key>
13138 for (
int i = 0; i < capacity; i++) {
13141 elements->
set(pos++, ValueAt(i), mode);
13149 ASSERT(
map()->has_named_interceptor());
13151 ASSERT(constructor->shared()->IsApiFunction());
13153 constructor->shared()->get_api_func_data()->named_property_handler();
13159 ASSERT(
map()->has_indexed_interceptor());
13161 ASSERT(constructor->shared()->IsApiFunction());
13163 constructor->shared()->get_api_func_data()->indexed_property_handler();
13174 Isolate* isolate =
object->GetIsolate();
13175 LookupResult lookup(isolate);
13176 object->LocalLookupRealNamedProperty(*name, &lookup);
13178 if (lookup.IsFound()) {
13179 result =
GetProperty(
object, receiver, &lookup, name, attributes);
13184 if (prototype->IsNull())
return isolate->
factory()->undefined_value();
13197 LocalLookupRealNamedProperty(name, &result);
13198 if (result.IsFound()) {
13199 return GetProperty(receiver, &result, name, attributes);
13201 return GetHeap()->undefined_value();
13210 Isolate* isolate =
object->GetIsolate();
13213 if (name->IsSymbol())
return isolate->
factory()->undefined_value();
13218 if (!interceptor->getter()->IsUndefined()) {
13220 v8::ToCData<v8::NamedPropertyGetterCallback>(interceptor->getter());
13222 ApiNamedPropertyAccess(
"interceptor-named-get", *
object, *name));
13224 args(isolate, interceptor->data(), *receiver, *object);
13228 if (!result.IsEmpty()) {
13229 *attributes =
NONE;
13231 result_internal->VerifyApiCallResultType();
13233 return handle(*result_internal, isolate);
13237 return GetPropertyPostInterceptor(
object, receiver, name, attributes);
13243 Isolate* isolate =
object->GetIsolate();
13244 SealHandleScope shs(isolate);
13246 if (object->IsAccessCheckNeeded()) {
13253 LookupResult result(isolate);
13254 object->LocalLookupRealNamedProperty(*key, &result);
13255 return result.IsFound() && !result.IsInterceptor();
13260 Isolate* isolate =
object->GetIsolate();
13263 if (object->IsAccessCheckNeeded()) {
13270 if (object->IsJSGlobalProxy()) {
13273 if (proto->IsNull())
return false;
13274 ASSERT(proto->IsJSGlobalObject());
13278 return GetElementAttributeWithoutInterceptor(
13279 object,
object, index,
false) !=
ABSENT;
13285 Isolate* isolate =
object->GetIsolate();
13286 SealHandleScope shs(isolate);
13288 if (object->IsAccessCheckNeeded()) {
13295 LookupResult result(isolate);
13296 object->LocalLookupRealNamedProperty(*key, &result);
13297 return result.IsPropertyCallbacks();
13302 if (HasFastProperties()) {
13307 if (result != kInvalidEnumCacheSentinel)
return result;
13311 return property_dictionary()->NumberOfElementsFilterAttributes(filter);
13319 if (
this != numbers) {
13320 temp = numbers->
get(i);
13327 static void InsertionSortPairs(
FixedArray* content,
13330 for (
int i = 1; i < len; i++) {
13347 for (
int i = 1; i < len; ++i) {
13348 int child_index = i;
13349 while (child_index > 0) {
13350 int parent_index = ((child_index + 1) >> 1) - 1;
13353 if (parent_value < child_value) {
13354 content->
SwapPairs(numbers, parent_index, child_index);
13358 child_index = parent_index;
13363 for (
int i = len - 1; i > 0; --i) {
13367 int parent_index = 0;
13369 int child_index = ((parent_index + 1) << 1) - 1;
13370 if (child_index >= i)
break;
13374 if (child_index + 1 >= i || child1_value > child2_value) {
13375 if (parent_value > child1_value)
break;
13376 content->
SwapPairs(numbers, parent_index, child_index);
13377 parent_index = child_index;
13379 if (parent_value > child2_value)
break;
13380 content->
SwapPairs(numbers, parent_index, child_index + 1);
13381 parent_index = child_index + 1;
13393 InsertionSortPairs(
this, numbers, len);
13398 uint32_t max_index = min_index;
13400 for (i = 1; i < len; i++) {
13407 if (max_index - min_index + 1 == len) {
13411 for (i = 0; i < len; i++) {
13433 ASSERT(storage->
length() >= (NumberOfLocalProperties(filter) - index));
13434 if (HasFastProperties()) {
13437 for (
int i = 0; i < real_size; i++) {
13438 if ((descs->
GetDetails(i).attributes() & filter) == 0 &&
13439 !FilterKey(descs->
GetKey(i), filter)) {
13440 storage->
set(index++, descs->
GetKey(i));
13444 property_dictionary()->CopyKeysTo(storage,
13453 return GetLocalElementKeys(
NULL, filter);
13459 if (!IsJSValue() && HasFastObjectElements()) {
13460 uint32_t length = IsJSArray() ?
13461 static_cast<uint32_t
>(
13464 if (length == 0)
return 0;
13467 return NumberOfLocalElements(static_cast<PropertyAttributes>(
DONT_ENUM));
13474 switch (GetElementsKind()) {
13479 int length = IsJSArray() ?
13482 for (
int i = 0; i <
length; i++) {
13484 if (storage !=
NULL) {
13495 int length = IsJSArray() ?
13498 for (
int i = 0; i <
length; i++) {
13500 if (storage !=
NULL) {
13510 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
13511 case EXTERNAL_##TYPE##_ELEMENTS: \
13512 case TYPE##_ELEMENTS: \
13515 #undef TYPED_ARRAY_CASE
13518 while (counter < length) {
13519 if (storage !=
NULL) {
13529 if (storage !=
NULL) {
13530 element_dictionary()->CopyKeysTo(storage,
13534 counter += element_dictionary()->NumberOfElementsFilterAttributes(filter);
13539 int mapped_length = parameter_map->
length() - 2;
13541 if (arguments->IsDictionary()) {
13546 if (storage !=
NULL) {
13551 for (
int i = 0; i < mapped_length; ++i) {
13552 if (!parameter_map->
get(i + 2)->IsTheHole()) {
13560 int backing_length = arguments->
length();
13562 for (; i < mapped_length; ++i) {
13563 if (!parameter_map->
get(i + 2)->IsTheHole()) {
13566 }
else if (i < backing_length && !arguments->
get(i)->IsTheHole()) {
13571 for (; i < backing_length; ++i) {
13580 if (this->IsJSValue()) {
13582 if (val->IsString()) {
13585 for (
int i = 0; i < str->
length(); i++) {
13589 counter += str->
length();
13598 return GetLocalElementKeys(storage,
13599 static_cast<PropertyAttributes>(
DONT_ENUM));
13608 hash_(HashForObject(string)) { }
13613 if (hash_ != HashForObject(
string)) {
13636 int scope_position)
13639 strict_mode_(strict_mode),
13640 scope_position_(scope_position) { }
13643 if (!other->IsFixedArray())
return false;
13646 if (shared != shared_)
return false;
13647 int strict_unchecked =
Smi::cast(other_array->
get(2))->value();
13650 if (strict_mode != strict_mode_)
return false;
13651 int scope_position =
Smi::cast(other_array->
get(3))->value();
13652 if (scope_position != scope_position_)
return false;
13654 return source->
Equals(source_);
13660 int scope_position) {
13661 uint32_t hash = source->
Hash();
13670 if (strict_mode ==
STRICT) hash ^= 0x8000;
13671 hash += scope_position;
13677 return StringSharedHashHelper(
13678 source_, shared_, strict_mode_, scope_position_);
13685 int strict_unchecked =
Smi::cast(other_array->
get(2))->value();
13688 int scope_position =
Smi::cast(other_array->
get(3))->value();
13689 return StringSharedHashHelper(
13690 source, shared, strict_mode, scope_position);
13696 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
13699 other_array->
set(0, shared_);
13700 other_array->
set(1, source_);
13703 return other_array;
13710 int scope_position_;
13719 flags_(
Smi::FromInt(flags.value())) { }
13731 uint32_t
Hash() {
return RegExpHash(string_, flags_); }
13747 return string->Hash() + flags->
value();
13756 if (hash_field_ == 0) Hash();
13762 if (hash_field_ == 0) Hash();
13769 return string_->IsSeqOneByteString()
13776 const uint16_t* SubStringKey<uint16_t>::GetChars() {
13777 return string_->IsSeqTwoByteString()
13785 if (hash_field_ == 0) Hash();
13794 if (hash_field_ == 0) Hash();
13822 : string_(string) { }
13828 uint32_t
Hash() {
return string_->Hash(); }
13837 string_ = string_->TryFlattenGetString();
13842 ASSERT(string_->IsInternalizedString());
13847 string_, string_->length(), string_->hash_field());
13858 template<
typename Shape,
typename Key>
13864 template<
typename Shape,
typename Key>
13867 kElementsStartOffset,
13872 template<
typename Shape,
typename Key>
13874 int at_least_space_for,
13879 ? at_least_space_for
13880 : ComputeCapacity(at_least_space_for);
13886 { MaybeObject* maybe_obj =
13887 heap-> AllocateHashTable(EntryToIndex(capacity), pretenure);
13888 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
13899 if (!key->IsUniqueName()) {
13913 uint32_t capacity = Capacity();
13914 uint32_t entry = FirstProbe(key->
Hash(), capacity);
13915 uint32_t count = 1;
13918 int index = EntryToIndex(entry);
13919 Object* element =
get(index);
13920 if (element->IsUndefined())
break;
13921 if (key == element)
return entry;
13922 if (!element->IsUniqueName() &&
13923 !element->IsTheHole() &&
13931 entry = NextProbe(entry, count++, capacity);
13937 template<
typename Shape,
typename Key>
13945 for (
int i = kPrefixStartIndex;
13946 i < kPrefixStartIndex + Shape::kPrefixSize;
13948 new_table->
set(i,
get(i), mode);
13952 int capacity = Capacity();
13953 for (
int i = 0; i < capacity; i++) {
13954 uint32_t from_index = EntryToIndex(i);
13955 Object* k =
get(from_index);
13958 uint32_t insertion_index =
13960 for (
int j = 0; j < Shape::kEntrySize; j++) {
13961 new_table->
set(insertion_index + j,
get(from_index + j), mode);
13971 template<
typename Shape,
typename Key>
13975 uint32_t expected) {
13977 uint32_t capacity = Capacity();
13978 uint32_t entry = FirstProbe(hash, capacity);
13979 for (
int i = 1; i < probe; i++) {
13980 if (entry == expected)
return expected;
13981 entry = NextProbe(entry, i, capacity);
13987 template<
typename Shape,
typename Key>
13991 int index1 = EntryToIndex(entry1);
13992 int index2 = EntryToIndex(entry2);
13993 Object* temp[Shape::kEntrySize];
13994 for (
int j = 0; j < Shape::kEntrySize; j++) {
13995 temp[j] =
get(index1 + j);
13997 for (
int j = 0; j < Shape::kEntrySize; j++) {
13998 set(index1 + j,
get(index2 + j), mode);
14000 for (
int j = 0; j < Shape::kEntrySize; j++) {
14001 set(index2 + j, temp[j], mode);
14006 template<
typename Shape,
typename Key>
14010 uint32_t capacity = Capacity();
14012 for (
int probe = 1; !done; probe++) {
14016 for (uint32_t current = 0; current < capacity; current++) {
14017 Object* current_key =
get(EntryToIndex(current));
14018 if (IsKey(current_key)) {
14019 uint32_t target = EntryForProbe(key, current_key, probe, current);
14020 if (current == target)
continue;
14021 Object* target_key =
get(EntryToIndex(target));
14022 if (!IsKey(target_key) ||
14023 EntryForProbe(key, target_key, probe, target) != target) {
14025 Swap(current, target, mode);
14039 template<
typename Shape,
typename Key>
14043 int capacity = Capacity();
14044 int nof = NumberOfElements() + n;
14045 int nod = NumberOfDeletedElements();
14049 if (nod <= (capacity - nof) >> 1) {
14050 int needed_free = nof >> 1;
14051 if (nof + needed_free <= capacity)
return this;
14054 const int kMinCapacityForPretenure = 256;
14055 bool should_pretenure = pretenure ==
TENURED ||
14058 { MaybeObject* maybe_obj =
14063 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
14070 template<
typename Shape,
typename Key>
14072 int capacity = Capacity();
14073 int nof = NumberOfElements();
14077 if (nof > (capacity >> 2))
return this;
14082 int at_least_room_for = nof;
14083 if (at_least_room_for < 16)
return this;
14085 const int kMinCapacityForPretenure = 256;
14087 (at_least_room_for > kMinCapacityForPretenure) &&
14090 { MaybeObject* maybe_obj =
14095 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
14102 template<
typename Shape,
typename Key>
14104 uint32_t capacity = Capacity();
14105 uint32_t entry = FirstProbe(hash, capacity);
14106 uint32_t count = 1;
14109 Object* element = KeyAt(entry);
14110 if (element->IsUndefined() || element->IsTheHole())
break;
14111 entry = NextProbe(entry, count++, capacity);
14191 template MaybeObject*
14199 uint32_t,
Object*, PropertyDetails);
14202 uint32_t,
Object*, PropertyDetails);
14235 object->PrepareSlowElementsForSort(limit),
14243 ASSERT(HasDictionaryElements());
14253 if (!maybe_new_double->ToObject(&new_double))
return maybe_new_double;
14259 { MaybeObject* maybe_obj =
14261 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
14268 uint32_t undefs = 0;
14270 for (
int i = 0; i < capacity; i++) {
14272 if (dict->
IsKey(k)) {
14278 PropertyDetails details = dict->
DetailsAt(i);
14279 if (details.type() ==
CALLBACKS || details.IsReadOnly()) {
14289 if (value->IsUndefined()) {
14297 new_dict->
AddNumberEntry(pos, value, details)->ToObjectUnchecked();
14306 new_dict->
AddNumberEntry(key, value, details)->ToObjectUnchecked();
14311 uint32_t result = pos;
14312 PropertyDetails no_details = PropertyDetails(
NONE,
NORMAL, 0);
14314 while (undefs > 0) {
14320 new_dict->
AddNumberEntry(pos, heap->undefined_value(), no_details)->
14321 ToObjectUnchecked();
14326 set_elements(new_dict);
14333 result_double->
set_value(static_cast<double>(result));
14334 return result_double;
14344 Isolate* isolate =
object->GetIsolate();
14345 if (object->HasSloppyArgumentsElements() ||
14346 object->map()->is_observed()) {
14350 if (object->HasDictionaryElements()) {
14354 if (object->IsJSArray() || dict->requires_slow_elements() ||
14355 dict->max_number_key() >= limit) {
14367 dict->CopyValuesTo(*fast_elements);
14368 object->ValidateElements();
14370 object->set_map_and_elements(*new_map, *fast_elements);
14371 }
else if (object->HasExternalArrayElements() ||
14372 object->HasFixedTypedArrayElements()) {
14376 }
else if (!object->HasFastDoubleElements()) {
14377 EnsureWritableFastElements(
object);
14379 ASSERT(object->HasFastSmiOrObjectElements() ||
14380 object->HasFastDoubleElements());
14386 uint32_t elements_length =
static_cast<uint32_t
>(elements_base->length());
14387 if (limit > elements_length) {
14388 limit = elements_length ;
14394 uint32_t result = 0;
14395 if (elements_base->map() == isolate->
heap()->fixed_double_array_map()) {
14398 unsigned int holes = limit;
14401 for (
unsigned int i = 0; i < holes; i++) {
14408 while (holes > i) {
14418 while (holes < limit) {
14429 unsigned int undefs = limit;
14430 unsigned int holes = limit;
14433 for (
unsigned int i = 0; i < undefs; i++) {
14435 if (current->IsTheHole()) {
14438 }
else if (current->IsUndefined()) {
14444 while (undefs > i) {
14445 current = elements->
get(undefs);
14446 if (current->IsTheHole()) {
14449 }
else if (current->IsUndefined()) {
14452 elements->
set(i, current, write_barrier);
14458 while (undefs < holes) {
14462 while (holes < limit) {
14473 switch (elements()->
map()->instance_type()) {
14474 #define INSTANCE_TYPE_TO_ARRAY_TYPE(Type, type, TYPE, ctype, size) \
14475 case EXTERNAL_##TYPE##_ARRAY_TYPE: \
14476 case FIXED_##TYPE##_ARRAY_TYPE: \
14477 return kExternal##Type##Array;
14480 #undef INSTANCE_TYPE_TO_ARRAY_TYPE
14490 switch (elements()->
map()->instance_type()) {
14491 #define INSTANCE_TYPE_TO_ELEMENT_SIZE(Type, type, TYPE, ctype, size) \
14492 case EXTERNAL_##TYPE##_ARRAY_TYPE: \
14496 #undef INSTANCE_TYPE_TO_ELEMENT_SIZE
14506 uint8_t clamped_value = 0;
14507 if (index < static_cast<uint32_t>(
length())) {
14508 if (value->IsSmi()) {
14510 if (int_value < 0) {
14512 }
else if (int_value > 255) {
14513 clamped_value = 255;
14515 clamped_value =
static_cast<uint8_t
>(int_value);
14517 }
else if (value->IsHeapNumber()) {
14519 if (!(double_value > 0)) {
14522 }
else if (double_value > 255) {
14524 clamped_value = 255;
14527 clamped_value =
static_cast<uint8_t
>(lrint(double_value));
14532 ASSERT(value->IsUndefined());
14534 set(index, clamped_value);
14544 return Handle<Object>(array->SetValue(index, *value), array->GetIsolate());
14548 template<
typename ExternalArrayClass,
typename ValueType>
14549 static MaybeObject* ExternalArrayIntSetter(
Heap* heap,
14550 ExternalArrayClass* receiver,
14554 if (index < static_cast<uint32_t>(receiver->length())) {
14555 if (value->IsSmi()) {
14557 cast_value =
static_cast<ValueType>(int_value);
14558 }
else if (value->IsHeapNumber()) {
14564 ASSERT(value->IsUndefined());
14566 receiver->set(index, cast_value);
14576 array->SetValue(index, *value),
14582 return ExternalArrayIntSetter<ExternalInt8Array, int8_t>
14583 (
GetHeap(),
this, index, value);
14592 array->SetValue(index, *value),
14599 return ExternalArrayIntSetter<ExternalUint8Array, uint8_t>
14600 (
GetHeap(),
this, index, value);
14609 array->SetValue(index, *value),
14616 return ExternalArrayIntSetter<ExternalInt16Array, int16_t>
14617 (
GetHeap(),
this, index, value);
14626 array->SetValue(index, *value),
14633 return ExternalArrayIntSetter<ExternalUint16Array, uint16_t>
14634 (
GetHeap(),
this, index, value);
14642 array->SetValue(index, *value),
14648 return ExternalArrayIntSetter<ExternalInt32Array, int32_t>
14649 (
GetHeap(),
this, index, value);
14658 array->SetValue(index, *value),
14664 uint32_t cast_value = 0;
14666 if (index < static_cast<uint32_t>(
length())) {
14667 if (value->IsSmi()) {
14669 cast_value =
static_cast<uint32_t
>(int_value);
14670 }
else if (value->IsHeapNumber()) {
14672 cast_value =
static_cast<uint32_t
>(
DoubleToUint32(double_value));
14676 ASSERT(value->IsUndefined());
14678 set(index, cast_value);
14689 array->SetValue(index, *value),
14697 if (index < static_cast<uint32_t>(
length())) {
14698 if (value->IsSmi()) {
14700 cast_value =
static_cast<float>(int_value);
14701 }
else if (value->IsHeapNumber()) {
14703 cast_value =
static_cast<float>(double_value);
14707 ASSERT(value->IsUndefined());
14709 set(index, cast_value);
14720 array->SetValue(index, *value),
14728 if (index < static_cast<uint32_t>(
length())) {
14729 if (value->IsSmi()) {
14731 double_value =
static_cast<double>(int_value);
14732 }
else if (value->IsHeapNumber()) {
14737 ASSERT(value->IsUndefined());
14739 set(index, double_value);
14746 ASSERT(!HasFastProperties());
14747 Object* value = property_dictionary()->ValueAt(result->GetDictionaryEntry());
14755 ASSERT(!global->HasFastProperties());
14756 int entry = global->property_dictionary()->FindEntry(*name);
14758 Isolate* isolate = global->GetIsolate();
14760 isolate->
factory()->the_hole_value());
14762 details = details.AsDeleted();
14764 handle(global->property_dictionary()), name, cell, details);
14765 global->set_properties(*dictionary);
14768 Object* value = global->property_dictionary()->ValueAt(entry);
14769 ASSERT(value->IsPropertyCell());
14777 return LookupKey(&key, s);
14789 : c1_(c1), c2_(c2) {
14791 uint32_t hash = seed;
14793 hash += hash << 10;
14797 hash += hash << 10;
14801 hash ^= hash >> 11;
14802 hash += hash << 15;
14813 ASSERT_EQ(static_cast<int32_t>(hash), static_cast<int32_t>(check_hash));
14818 if (!o->IsString())
return false;
14820 if (other->
length() != 2)
return false;
14821 if (other->Get(0) != c1_)
return false;
14822 return other->Get(1) == c2_;
14827 if (!key->IsString())
return 0;
14847 int entry = FindEntry(&key);
14848 if (entry == kNotFound) {
14852 ASSERT(StringShape(*result).IsInternalized());
14862 int entry = FindEntry(&key);
14863 if (entry == kNotFound) {
14867 ASSERT(StringShape(*result).IsInternalized());
14874 int entry = FindEntry(key);
14877 if (entry != kNotFound) {
14884 { MaybeObject* maybe_obj = EnsureCapacity(1, key);
14885 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
14891 if (!maybe_string->ToObject(&
string))
return maybe_string;
14901 table->
set(EntryToIndex(entry),
string);
14913 RelocInfo::kNoPosition);
14914 int entry = FindEntry(&key);
14915 if (entry == kNotFound)
return GetHeap()->undefined_value();
14916 return get(EntryToIndex(entry) + 1);
14923 int scope_position) {
14925 context->
closure()->shared(),
14928 int entry = FindEntry(&key);
14929 if (entry == kNotFound)
return GetHeap()->undefined_value();
14930 return get(EntryToIndex(entry) + 1);
14937 int entry = FindEntry(&key);
14938 if (entry == kNotFound)
return GetHeap()->undefined_value();
14939 return get(EntryToIndex(entry) + 1);
14950 RelocInfo::kNoPosition);
14952 MaybeObject* maybe_cache = EnsureCapacity(1, &key);
14953 if (!maybe_cache->To(&cache))
return maybe_cache;
14957 if (!maybe_k->To(&k))
return maybe_k;
14960 cache->
set(EntryToIndex(entry), k);
14961 cache->
set(EntryToIndex(entry) + 1, value);
14970 int scope_position) {
14972 context->
closure()->shared(),
14976 { MaybeObject* maybe_obj = EnsureCapacity(1, &key);
14977 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
14985 { MaybeObject* maybe_k = key.AsObject(
GetHeap());
14986 if (!maybe_k->ToObject(&k))
return maybe_k;
14989 cache->
set(EntryToIndex(entry), k);
14990 cache->
set(EntryToIndex(entry) + 1, value);
15001 { MaybeObject* maybe_obj = EnsureCapacity(1, &key);
15002 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
15010 cache->
set(EntryToIndex(entry), value);
15011 cache->
set(EntryToIndex(entry) + 1, value);
15019 for (
int entry = 0,
size = Capacity(); entry <
size; entry++) {
15020 int entry_index = EntryToIndex(entry);
15021 int value_index = entry_index + 1;
15022 if (
get(value_index) == value) {
15039 int len = strings_->length();
15040 if (o->
length() != len)
return false;
15041 for (
int i = 0; i < len; i++) {
15042 if (o->
get(i) != strings_->get(i))
return false;
15047 uint32_t
Hash() {
return HashForObject(strings_); }
15051 int len = strings->
length();
15053 for (
int i = 0; i < len; i++) {
15068 int entry = FindEntry(&key);
15069 if (entry == kNotFound)
return GetHeap()->undefined_value();
15070 return get(EntryToIndex(entry) + 1);
15077 { MaybeObject* maybe_obj = EnsureCapacity(1, &key);
15078 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
15083 cache->
set(EntryToIndex(entry), array);
15084 cache->
set(EntryToIndex(entry) + 1, value);
15090 template<
typename Shape,
typename Key>
15092 int at_least_space_for,
15095 { MaybeObject* maybe_obj =
15098 at_least_space_for,
15101 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
15105 SetNextEnumerationIndex(PropertyDetails::kInitialIndex);
15113 dictionary->GenerateNewEnumerationIndices());
15116 template<
typename Shape,
typename Key>
15124 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
15127 for (
int i = 0; i <
length; i++) {
15133 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
15140 for (
int i = 0; i < capacity; i++) {
15142 int index = DetailsAt(i).dictionary_index();
15148 iteration_order->
SortPairs(enumeration_order, enumeration_order->
length());
15151 for (
int i = 0; i <
length; i++) {
15152 int index =
Smi::cast(iteration_order->
get(i))->value();
15153 int enum_index = PropertyDetails::kInitialIndex + i;
15160 for (
int i = 0; i < capacity; i++) {
15162 int enum_index =
Smi::cast(enumeration_order->
get(pos++))->value();
15163 PropertyDetails details = DetailsAt(i);
15164 PropertyDetails new_details = PropertyDetails(
15165 details.attributes(), details.type(), enum_index);
15166 DetailsAtPut(i, new_details);
15171 SetNextEnumerationIndex(PropertyDetails::kInitialIndex+length);
15175 template<
typename Shape,
typename Key>
15178 if (Shape::kIsEnumerable &&
15179 !PropertyDetails::IsValidIndex(NextEnumerationIndex() + n)) {
15182 { MaybeObject* maybe_result = GenerateNewEnumerationIndices();
15183 if (!maybe_result->ToObject(&result))
return maybe_result;
15190 template<
typename Shape,
typename Key>
15194 PropertyDetails details = DetailsAt(entry);
15197 return heap->false_value();
15199 SetEntry(entry, heap->the_hole_value(), heap->the_hole_value());
15201 return heap->true_value();
15205 template<
typename Shape,
typename Key>
15211 template<
typename Shape,
typename Key>
15213 int entry = this->FindEntry(key);
15217 ValueAtPut(entry, value);
15223 { MaybeObject* maybe_obj = EnsureCapacity(1, key);
15224 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
15228 { MaybeObject* maybe_k = Shape::AsObject(this->
GetHeap(), key);
15229 if (!maybe_k->ToObject(&k))
return maybe_k;
15231 PropertyDetails details = PropertyDetails(
NONE,
NORMAL, 0);
15238 template<
typename Shape,
typename Key>
15241 PropertyDetails details) {
15246 { MaybeObject* maybe_obj = EnsureCapacity(1, key);
15247 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
15256 template<
typename Shape,
typename Key>
15259 PropertyDetails details,
15263 { MaybeObject* maybe_k = Shape::AsObject(this->
GetHeap(), key);
15264 if (!maybe_k->ToObject(&k))
return maybe_k;
15269 if (!details.IsDeleted() &&
15270 details.dictionary_index() == 0 &&
15271 Shape::kIsEnumerable) {
15274 int index = NextEnumerationIndex();
15275 details = PropertyDetails(details.attributes(), details.type(), index);
15276 SetNextEnumerationIndex(index + 1);
15278 SetEntry(entry, k, value, details);
15289 if (requires_slow_elements())
return;
15292 if (key > kRequiresSlowElementsLimit) {
15293 set_requires_slow_elements();
15297 Object* max_index_object =
get(kMaxNumberKeyIndex);
15298 if (!max_index_object->IsSmi() || max_number_key() < key) {
15308 PropertyDetails details) {
15310 dictionary->AddNumberEntry(key, *value, details),
15316 PropertyDetails details) {
15317 UpdateMaxNumberKey(key);
15319 return Add(key, value, details);
15326 return Add(key, value, PropertyDetails(
NONE,
NORMAL, 0));
15331 UpdateMaxNumberKey(key);
15332 return AtPut(key, value);
15338 return AtPut(key, value);
15346 PropertyDetails details) {
15348 dictionary->Set(index, *value, details),
15358 dictionary->Set(index, *value),
15365 PropertyDetails details) {
15366 int entry = FindEntry(key);
15367 if (entry == kNotFound)
return AddNumberEntry(key, value, details);
15369 details = PropertyDetails(details.attributes(),
15371 DetailsAt(entry).dictionary_index());
15372 MaybeObject* maybe_object_key =
15375 if (!maybe_object_key->ToObject(&object_key))
return maybe_object_key;
15376 SetEntry(entry, object_key, value, details);
15383 int entry = FindEntry(key);
15384 if (entry == kNotFound)
return AddNumberEntry(key, value);
15385 MaybeObject* maybe_object_key =
15388 if (!maybe_object_key->ToObject(&object_key))
return maybe_object_key;
15389 SetEntry(entry, object_key, value);
15395 template<
typename Shape,
typename Key>
15400 for (
int i = 0; i < capacity; i++) {
15403 PropertyDetails details = DetailsAt(i);
15404 if (details.IsDeleted())
continue;
15406 if ((attr & filter) == 0) result++;
15413 template<
typename Shape,
typename Key>
15415 return NumberOfElementsFilterAttributes(
15416 static_cast<PropertyAttributes>(
DONT_ENUM | SYMBOLIC));
15420 template<
typename Shape,
typename Key>
15425 ASSERT(storage->
length() >= NumberOfElementsFilterAttributes(filter));
15428 for (
int i = 0; i < capacity; i++) {
15431 PropertyDetails details = DetailsAt(i);
15432 if (details.IsDeleted())
continue;
15434 if ((attr & filter) == 0) storage->
set(index++, k);
15437 if (sort_mode == Dictionary<Shape, Key>::SORTED) {
15447 PropertyDetails
da(dict->DetailsAt(a->
value()));
15448 PropertyDetails
db(dict->DetailsAt(b->
value()));
15449 return da.dictionary_index() < db.dictionary_index();
15456 int length = storage->
length();
15457 int capacity = Capacity();
15458 int properties = 0;
15459 for (
int i = 0; i < capacity; i++) {
15461 if (IsKey(k) && !k->IsSymbol()) {
15462 PropertyDetails details = DetailsAt(i);
15463 if (details.IsDeleted() || details.IsDontEnum())
continue;
15466 if (properties == length)
break;
15471 std::sort(start, start + length, cmp);
15472 for (
int i = 0; i <
length; i++) {
15474 storage->
set(i, KeyAt(index));
15479 template<
typename Shape,
typename Key>
15485 ASSERT(storage->
length() >= NumberOfElementsFilterAttributes(filter));
15487 for (
int i = 0; i < capacity; i++) {
15490 PropertyDetails details = DetailsAt(i);
15491 if (details.IsDeleted())
continue;
15493 if ((attr & filter) == 0) storage->
set(index++, k);
15496 if (sort_mode == Dictionary<Shape, Key>::SORTED) {
15504 template<
typename Shape,
typename Key>
15507 for (
int i = 0; i < capacity; i++) {
15511 if (e->IsPropertyCell()) {
15514 if (e == value)
return k;
15518 return heap->undefined_value();
15523 JSObject* obj,
int unused_property_fields) {
15526 int number_of_elements = NumberOfElements();
15527 if (number_of_elements > kMaxNumberOfDescriptors)
return obj;
15529 if (number_of_elements != NextEnumerationIndex()) {
15530 MaybeObject* maybe_result = GenerateNewEnumerationIndices();
15531 if (maybe_result->IsFailure())
return maybe_result;
15534 int instance_descriptor_length = 0;
15535 int number_of_fields = 0;
15540 int capacity = Capacity();
15541 for (
int i = 0; i < capacity; i++) {
15544 Object* value = ValueAt(i);
15547 instance_descriptor_length++;
15548 if (type ==
NORMAL && !value->IsJSFunction()) {
15549 number_of_fields += 1;
15559 if (!maybe_new_map->To(&new_map))
return maybe_new_map;
15562 if (instance_descriptor_length == 0) {
15563 ASSERT_LE(unused_property_fields, inobject_props);
15567 obj->set_properties(heap->empty_fixed_array());
15575 MaybeObject* maybe_descriptors =
15577 if (!maybe_descriptors->To(&descriptors)) {
15578 return maybe_descriptors;
15583 int number_of_allocated_fields =
15584 number_of_fields + unused_property_fields - inobject_props;
15585 if (number_of_allocated_fields < 0) {
15587 number_of_allocated_fields = 0;
15588 unused_property_fields = inobject_props - number_of_fields;
15593 MaybeObject* maybe_fields =
15595 if (!maybe_fields->To(&fields))
return maybe_fields;
15598 int current_offset = 0;
15599 for (
int i = 0; i < capacity; i++) {
15602 Object* value = ValueAt(i);
15604 if (k->IsSymbol()) {
15610 if (!maybe_key->To(&key))
return maybe_key;
15613 PropertyDetails details = DetailsAt(i);
15614 int enumeration_index = details.dictionary_index();
15617 if (value->IsJSFunction()) {
15619 descriptors->
Set(enumeration_index - 1, &d, witness);
15620 }
else if (type ==
NORMAL) {
15621 if (current_offset < inobject_props) {
15626 int offset = current_offset - inobject_props;
15627 fields->
set(offset, value);
15631 details.attributes(),
15634 descriptors->
Set(enumeration_index - 1, &d, witness);
15638 details.attributes());
15639 descriptors->
Set(enumeration_index - 1, &d, witness);
15645 ASSERT(current_offset == number_of_fields);
15647 descriptors->
Sort();
15655 obj->set_properties(fields);
15656 ASSERT(obj->IsJSObject());
15672 table_base->EnsureCapacity(n, *key, pretenure),
15681 table_base->Shrink(*key),
15691 if (hash->IsUndefined())
return false;
15693 return (FindEntry(key) != kNotFound);
15699 ASSERT(table->IsKey(*key));
15703 table->GetIsolate());
15705 int entry = table->FindEntry(*key);
15708 if (entry != kNotFound)
return table;
15713 entry = new_table->FindInsertionEntry(
Smi::cast(*object_hash)->
value());
15714 new_table->set(EntryToIndex(entry), *key);
15715 new_table->ElementAdded();
15722 ASSERT(table->IsKey(*key));
15727 int entry = table->FindEntry(*key);
15730 if (entry == kNotFound)
return table;
15733 table->set_the_hole(EntryToIndex(entry));
15734 table->ElementRemoved();
15747 table_base->EnsureCapacity(n, *key, pretenure),
15756 table_base->Shrink(*key),
15766 if (hash->IsUndefined()) {
15767 return GetHeap()->the_hole_value();
15769 int entry = FindEntry(key);
15770 if (entry == kNotFound)
return GetHeap()->the_hole_value();
15771 return get(EntryToIndex(entry) + 1);
15778 ASSERT(table->IsKey(*key));
15780 Isolate* isolate = table->GetIsolate();
15785 int entry = table->FindEntry(*key);
15788 if (value->IsTheHole()) {
15789 if (entry == kNotFound)
return table;
15790 table->RemoveEntry(entry);
15791 return Shrink(table, key);
15795 if (entry != kNotFound) {
15796 table->set(EntryToIndex(entry) + 1, *value);
15801 table = EnsureCapacity(table, 1, key);
15809 void ObjectHashTable::AddEntry(
int entry,
Object* key,
Object* value) {
15810 set(EntryToIndex(entry), key);
15811 set(EntryToIndex(entry) + 1, value);
15816 void ObjectHashTable::RemoveEntry(
int entry) {
15825 int entry = FindEntry(key);
15826 if (entry == kNotFound)
return GetHeap()->the_hole_value();
15827 return get(EntryToValueIndex(entry));
15833 int entry = FindEntry(key);
15835 if (entry != kNotFound) {
15836 set(EntryToValueIndex(entry), value);
15842 { MaybeObject* maybe_obj = EnsureCapacity(1, key,
TENURED);
15843 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
15851 void WeakHashTable::AddEntry(
int entry,
Object* key,
Object* value) {
15852 set(EntryToIndex(entry), key);
15853 set(EntryToValueIndex(entry), value);
15868 ASSERT(offset_ < length_);
15869 uint8_t* ptr = &array_[offset_];
15870 ASSERT(reinterpret_cast<uintptr_t>(ptr) %
sizeof(uintptr_t) == 0);
15873 offset_ +=
sizeof(*data);
15874 ASSERT(offset_ <= length_);
15883 int previous_length =
15884 previous.
is_null() ? 0 : previous->serialized_data()->length();
15885 int length =
sizeof(descriptor) + previous_length;
15890 value->set_serialized_data(*serialized_descriptor);
15894 uint8_t* array = serialized_descriptor->GetDataStartAddress();
15895 if (previous_length != 0) {
15896 uint8_t* previous_array =
15897 previous->serialized_data()->GetDataStartAddress();
15898 OS::MemCopy(array, previous_array, previous_length);
15899 array += previous_length;
15901 ASSERT(reinterpret_cast<uintptr_t>(array) %
sizeof(uintptr_t) == 0);
15904 *data = descriptor;
15910 #ifdef ENABLE_DEBUGGER_SUPPORT
15912 bool DebugInfo::HasBreakPoint(
int code_position) {
15914 Object* break_point_info = GetBreakPointInfo(code_position);
15918 if (break_point_info->IsUndefined())
return false;
15919 return BreakPointInfo::cast(break_point_info)->GetBreakPointCount() > 0;
15924 Object* DebugInfo::GetBreakPointInfo(
int code_position) {
15926 int index = GetBreakPointInfoIndex(code_position);
15929 if (index == kNoBreakPointInfo)
return GetHeap()->undefined_value();
15930 return BreakPointInfo::cast(break_points()->
get(index));
15935 void DebugInfo::ClearBreakPoint(Handle<DebugInfo> debug_info,
15937 Handle<Object> break_point_object) {
15938 Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_position),
15939 debug_info->GetIsolate());
15940 if (break_point_info->IsUndefined())
return;
15941 BreakPointInfo::ClearBreakPoint(
15942 Handle<BreakPointInfo>::cast(break_point_info),
15943 break_point_object);
15947 void DebugInfo::SetBreakPoint(Handle<DebugInfo> debug_info,
15949 int source_position,
15950 int statement_position,
15951 Handle<Object> break_point_object) {
15952 Isolate* isolate = debug_info->GetIsolate();
15953 Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_position),
15955 if (!break_point_info->IsUndefined()) {
15956 BreakPointInfo::SetBreakPoint(
15957 Handle<BreakPointInfo>::cast(break_point_info),
15958 break_point_object);
15964 int index = kNoBreakPointInfo;
15965 for (
int i = 0; i < debug_info->break_points()->length(); i++) {
15966 if (debug_info->break_points()->get(i)->IsUndefined()) {
15971 if (index == kNoBreakPointInfo) {
15973 Handle<FixedArray> old_break_points =
15975 Handle<FixedArray> new_break_points =
15976 isolate->factory()->NewFixedArray(
15977 old_break_points->length() +
15978 Debug::kEstimatedNofBreakPointsInFunction);
15980 debug_info->set_break_points(*new_break_points);
15981 for (
int i = 0; i < old_break_points->length(); i++) {
15982 new_break_points->set(i, old_break_points->get(i));
15984 index = old_break_points->length();
15986 ASSERT(index != kNoBreakPointInfo);
15991 new_break_point_info->set_code_position(
Smi::FromInt(code_position));
15992 new_break_point_info->set_source_position(
Smi::FromInt(source_position));
15993 new_break_point_info->
15994 set_statement_position(
Smi::FromInt(statement_position));
15995 new_break_point_info->set_break_point_objects(
15996 isolate->heap()->undefined_value());
15997 BreakPointInfo::SetBreakPoint(new_break_point_info, break_point_object);
15998 debug_info->break_points()->set(index, *new_break_point_info);
16003 Object* DebugInfo::GetBreakPointObjects(
int code_position) {
16004 Object* break_point_info = GetBreakPointInfo(code_position);
16005 if (break_point_info->IsUndefined()) {
16006 return GetHeap()->undefined_value();
16008 return BreakPointInfo::cast(break_point_info)->break_point_objects();
16013 int DebugInfo::GetBreakPointCount() {
16014 if (break_points()->IsUndefined())
return 0;
16016 for (
int i = 0; i < break_points()->length(); i++) {
16017 if (!break_points()->get(i)->IsUndefined()) {
16018 BreakPointInfo* break_point_info =
16019 BreakPointInfo::cast(break_points()->
get(i));
16020 count += break_point_info->GetBreakPointCount();
16027 Object* DebugInfo::FindBreakPointInfo(Handle<DebugInfo> debug_info,
16028 Handle<Object> break_point_object) {
16029 Heap* heap = debug_info->GetHeap();
16030 if (debug_info->break_points()->IsUndefined())
return heap->undefined_value();
16031 for (
int i = 0; i < debug_info->break_points()->length(); i++) {
16032 if (!debug_info->break_points()->get(i)->IsUndefined()) {
16033 Handle<BreakPointInfo> break_point_info =
16034 Handle<BreakPointInfo>(BreakPointInfo::cast(
16035 debug_info->break_points()->get(i)));
16036 if (BreakPointInfo::HasBreakPointObject(break_point_info,
16037 break_point_object)) {
16038 return *break_point_info;
16042 return heap->undefined_value();
16048 int DebugInfo::GetBreakPointInfoIndex(
int code_position) {
16049 if (break_points()->IsUndefined())
return kNoBreakPointInfo;
16050 for (
int i = 0; i < break_points()->length(); i++) {
16051 if (!break_points()->get(i)->IsUndefined()) {
16052 BreakPointInfo* break_point_info =
16053 BreakPointInfo::cast(break_points()->
get(i));
16054 if (break_point_info->code_position()->value() == code_position) {
16059 return kNoBreakPointInfo;
16064 void BreakPointInfo::ClearBreakPoint(Handle<BreakPointInfo> break_point_info,
16065 Handle<Object> break_point_object) {
16066 Isolate* isolate = break_point_info->GetIsolate();
16068 if (break_point_info->break_point_objects()->IsUndefined())
return;
16070 if (!break_point_info->break_point_objects()->IsFixedArray()) {
16071 if (break_point_info->break_point_objects() == *break_point_object) {
16072 break_point_info->set_break_point_objects(
16073 isolate->heap()->undefined_value());
16078 ASSERT(break_point_info->break_point_objects()->IsFixedArray());
16079 Handle<FixedArray> old_array =
16080 Handle<FixedArray>(
16082 Handle<FixedArray> new_array =
16083 isolate->factory()->NewFixedArray(old_array->length() - 1);
16084 int found_count = 0;
16085 for (
int i = 0; i < old_array->length(); i++) {
16086 if (old_array->get(i) == *break_point_object) {
16087 ASSERT(found_count == 0);
16090 new_array->set(i - found_count, old_array->get(i));
16094 if (found_count > 0) break_point_info->set_break_point_objects(*new_array);
16099 void BreakPointInfo::SetBreakPoint(Handle<BreakPointInfo> break_point_info,
16100 Handle<Object> break_point_object) {
16101 Isolate* isolate = break_point_info->GetIsolate();
16104 if (break_point_info->break_point_objects()->IsUndefined()) {
16105 break_point_info->set_break_point_objects(*break_point_object);
16109 if (break_point_info->break_point_objects() == *break_point_object)
return;
16111 if (!break_point_info->break_point_objects()->IsFixedArray()) {
16112 Handle<FixedArray> array = isolate->factory()->NewFixedArray(2);
16113 array->set(0, break_point_info->break_point_objects());
16114 array->set(1, *break_point_object);
16115 break_point_info->set_break_point_objects(*array);
16119 Handle<FixedArray> old_array =
16120 Handle<FixedArray>(
16122 Handle<FixedArray> new_array =
16123 isolate->factory()->NewFixedArray(old_array->length() + 1);
16124 for (
int i = 0; i < old_array->length(); i++) {
16126 if (old_array->get(i) == *break_point_object)
return;
16127 new_array->set(i, old_array->get(i));
16130 new_array->set(old_array->length(), *break_point_object);
16131 break_point_info->set_break_point_objects(*new_array);
16135 bool BreakPointInfo::HasBreakPointObject(
16136 Handle<BreakPointInfo> break_point_info,
16137 Handle<Object> break_point_object) {
16139 if (break_point_info->break_point_objects()->IsUndefined())
return false;
16141 if (!break_point_info->break_point_objects()->IsFixedArray()) {
16142 return break_point_info->break_point_objects() == *break_point_object;
16145 FixedArray* array =
FixedArray::cast(break_point_info->break_point_objects());
16146 for (
int i = 0; i < array->length(); i++) {
16147 if (array->get(i) == *break_point_object) {
16156 int BreakPointInfo::GetBreakPointCount() {
16158 if (break_point_objects()->IsUndefined())
return 0;
16160 if (!break_point_objects()->IsFixedArray())
return 1;
16164 #endif // ENABLE_DEBUGGER_SUPPORT
16169 static_cast<FieldIndex>(index->
value()));
16173 Object* JSDate::DoGetField(FieldIndex index) {
16179 Object* stamp = cache_stamp();
16180 if (stamp != date_cache->
stamp() && stamp->IsSmi()) {
16182 int64_t local_time_ms =
16183 date_cache->
ToLocal(static_cast<int64_t>(value()->
Number()));
16184 SetLocalFields(local_time_ms, date_cache);
16187 case kYear:
return year();
16188 case kMonth:
return month();
16189 case kDay:
return day();
16191 case kHour:
return hour();
16199 return GetUTCField(index, value()->
Number(), date_cache);
16202 double time = value()->
Number();
16205 int64_t local_time_ms = date_cache->
ToLocal(static_cast<int64_t>(time));
16217 Object* JSDate::GetUTCField(FieldIndex index,
16219 DateCache* date_cache) {
16224 int64_t time_ms =
static_cast<int64_t
>(value);
16227 return Smi::FromInt(date_cache->TimezoneOffset(time_ms));
16235 int year, month, day;
16236 date_cache->YearMonthDayFromDays(days, &year, &month, &day);
16261 if (is_value_nan) {
16277 void JSDate::SetLocalFields(int64_t local_time_ms,
DateCache* date_cache) {
16280 int year, month, day;
16282 int weekday = date_cache->
Weekday(days);
16283 int hour = time_in_day_ms / (60 * 60 * 1000);
16284 int min = (time_in_day_ms / (60 * 1000)) % 60;
16285 int sec = (time_in_day_ms / 1000) % 60;
16286 set_cache_stamp(date_cache->
stamp());
16299 set_backing_store(
NULL);
16318 set_elements(
GetHeap()->EmptyExternalArrayForMap(
map()));
16323 switch (elements_kind) {
16324 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
16325 case TYPE##_ELEMENTS: return EXTERNAL_##TYPE##_ELEMENTS;
16328 #undef TYPED_ARRAY_CASE
16337 Handle<JSArrayBuffer> JSTypedArray::MaterializeArrayBuffer(
16338 Handle<JSTypedArray> typed_array) {
16340 Handle<Map>
map(typed_array->map());
16341 Isolate* isolate = typed_array->
GetIsolate();
16345 Handle<JSArrayBuffer> buffer = isolate->factory()->NewJSArrayBuffer();
16346 Handle<FixedTypedArrayBase> fixed_typed_array(
16349 fixed_typed_array->DataSize(),
false);
16350 memcpy(buffer->backing_store(),
16351 fixed_typed_array->DataPtr(),
16352 fixed_typed_array->DataSize());
16353 Handle<ExternalArray> new_elements =
16354 isolate->factory()->NewExternalArray(
16355 fixed_typed_array->length(), typed_array->type(),
16356 static_cast<uint8_t*
>(buffer->backing_store()));
16359 FixedToExternalElementsKind(map->elements_kind()));
16361 buffer->set_weak_first_view(*typed_array);
16362 ASSERT(typed_array->weak_next() == isolate->heap()->undefined_value());
16363 typed_array->set_buffer(*buffer);
16364 typed_array->set_map_and_elements(*new_map, *new_elements);
16377 return MaterializeArrayBuffer(
self);
16382 return static_cast<HeapType*
>(type_raw());
16387 ASSERT(IsPropertyCell());
16388 set_type_raw(type, ignored);
16394 Isolate* isolate = cell->GetIsolate();
16401 if (new_type->Is(old_type)) {
16405 cell->dependent_code()->DeoptimizeDependentCodeGroup(
16412 return HeapType::Any(isolate);
16418 cell->set_value(*value);
16419 if (!HeapType::Any()->
Is(cell->type())) {
16421 cell->set_type(*new_type);
16439 #define ERROR_MESSAGES_TEXTS(C, T) T,
16440 static const char* error_messages_[] = {
16443 #undef ERROR_MESSAGES_TEXTS
16444 return error_messages_[reason];
MUST_USE_RESULT MaybeObject * CopyInsertDescriptor(Descriptor *descriptor, TransitionFlag flag)
static const double kPretenureRatio
void VisitTwoByteString(const uint16_t *chars, unsigned length)
static const int kInitialSize
void LookupRealNamedPropertyInPrototypes(Name *name, LookupResult *result)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter NULL
Object * type_feedback_info()
static DeclaredAccessorInfo * cast(Object *obj)
void SetEnumCache(FixedArray *bridge_storage, FixedArray *new_cache, Object *new_index_cache)
static Handle< Object > SetElement(Handle< JSObject > object, uint32_t index, Handle< Object > value, PropertyAttributes attributes, StrictMode strict_mode, bool check_prototype=true, SetPropertyMode set_mode=SET_PROPERTY)
static Handle< Object > GetElementWithReceiver(Isolate *isolate, Handle< Object > object, Handle< Object > receiver, uint32_t index)
bool Contains(DependencyGroup group, Code *code)
Object * Lookup(MapHandleList *maps, int code_kind)
int IndexInCodeCache(Object *name, Code *code)
bool prohibits_overwriting()
static void SetValueInferType(Handle< PropertyCell > cell, Handle< Object > value)
void set_elements_kind(ElementsKind elements_kind)
#define CHECK_NOT_EMPTY_HANDLE(isolate, call)
int CalculateInstanceSize()
static uint32_t NameFlagsHashHelper(Name *name, Code::Flags flags)
void SetBackPointer(Object *value, WriteBarrierMode mode=UPDATE_WRITE_BARRIER)
StringKey(String *string)
Object * KeyAt(int entry)
static bool OnSamePage(Address address1, Address address2)
Failure * StackOverflow()
Handle< JSObject > NewFunctionPrototype(Handle< JSFunction > function)
static void EnsureCanContainElements(Handle< JSObject > object, Object **elements, uint32_t count, EnsureElementsMode mode)
Code * builtin(Name name)
void FlattenString(Handle< String > string)
static MUST_USE_RESULT MaybeObject * Allocate(Isolate *isolate, int number_of_deopt_points, PretenureFlag pretenure)
static const int kGenerousAllocationCount
void PrintGeneralization(FILE *file, const char *reason, int modify_index, int split, int descriptors, bool constant_to_field, Representation old_representation, Representation new_representation)
void set_deopt_count(int value)
Object * get(AccessorComponent component)
#define SLOW_ASSERT(condition)
static DeoptimizationOutputData * cast(Object *obj)
uint32_t HashForObject(Object *other)
void CopyValuesTo(FixedArray *elements)
static Handle< ObjectHashTable > EnsureCapacity(Handle< ObjectHashTable > table, int n, Handle< Object > key, PretenureFlag pretenure=NOT_TENURED)
void AddCharacters(const Char *chars, int len)
static const int kNotFound
#define CHECK_EQ(expected, value)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in only print modified registers Don t break for ASM_UNIMPLEMENTED_BREAK macros print stack trace when an illegal exception is thrown 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
bool IsExternalArrayElementsKind(ElementsKind kind)
bool IsHoleyElementsKind(ElementsKind kind)
static const int kCodeEntryOffset
static DependentCode * ForObject(Handle< HeapObject > object, DependencyGroup group)
Code * FindFirstHandler()
bool HasElementsTransition()
static void Insert(Name *key, AccessorInfo *entry, int valid_descriptors, Handle< DescriptorArray > array)
static void EnsureHasInitialMap(Handle< JSFunction > function)
static const int kEntries
static Handle< Object > SetValue(Handle< ExternalFloat32Array > array, uint32_t index, Handle< Object > value)
Object * Lookup(Name *name, Code::Flags flags)
static PropertyAttributes GetPropertyAttributeWithInterceptor(Handle< JSObject > object, Handle< JSObject > receiver, Handle< Name > name, bool continue_search)
int CalculateInObjectProperties()
MUST_USE_RESULT MaybeObject * AllocateOneByteInternalizedString(Vector< const uint8_t > str, uint32_t hash_field)
void InvalidateRelocation()
static int EntryToIndex(int entry)
uint32_t HashForObject(Object *obj)
int inobject_properties()
void set_has_deoptimization_support(bool value)
#define PROFILE(IsolateGetter, Call)
virtual uint32_t Hash()=0
void RemoveFromCodeCache(Name *name, Code *code, int index)
static Handle< Map > CurrentMapForDeprecated(Handle< Map > map)
static Handle< Object > SetPropertyWithCallback(Handle< JSObject > object, Handle< Object > structure, Handle< Name > name, Handle< Object > value, Handle< JSObject > holder, StrictMode strict_mode)
Object * LookupRegExp(String *source, JSRegExp::Flags flags)
void ResetPretenureDecision()
void ClearOptimizedCodeMap()
MUST_USE_RESULT MaybeObject * CopyDropDescriptors()
static bool compare(const Chars1 *a, const Chars2 *b, int len)
#define RETURN_IF_SCHEDULED_EXCEPTION(isolate)
void set(int index, Object *value)
bool is_hidden_prototype()
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths true
static bool compare(const uint8_t *a, const uint8_t *b, int len)
static Handle< FixedArray > SetFastElementsCapacityAndLength(Handle< JSObject > object, int capacity, int length, SetFastElementsCapacitySmiMode smi_mode)
PropertyCell * GetPropertyCell(LookupResult *result)
Handle< String > InternalizeString(Handle< String > str)
void PrintF(const char *format,...)
bool IsOneByteEqualTo(Vector< const uint8_t > str)
static void DecodeMinorKey(int minor_key, CompareIC::State *left_state, CompareIC::State *right_state, CompareIC::State *handler_state, Token::Value *op)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf map
virtual MaybeObject * AsObject(Heap *heap)
bool InNewSpace(Object *object)
Handle< PropertyCell > NewPropertyCell(Handle< Object > value)
static ExecutableAccessorInfo * cast(Object *obj)
bool EquivalentToForNormalization(Map *other, PropertyNormalizationMode mode)
static TypeFeedbackInfo * cast(Object *obj)
static int Decode(Isolate *isolate, FILE *f, byte *begin, byte *end)
static Handle< Object > ToNumber(Isolate *isolate, Handle< Object > obj, bool *exc)
static String * cast(Object *obj)
MUST_USE_RESULT MaybeObject * Add(Key key, Object *value, PropertyDetails details)
bool HeapNumberBooleanValue()
void SetValue(Object *value, bool is_value_nan)
void DetailsAtPut(int entry, PropertyDetails value)
void copy(int from, int to)
static int AppendUnique(Handle< Object > descriptors, Handle< FixedArray > array, int valid_descriptors)
static void SetPrototype(Handle< JSFunction > function, Handle< Object > value)
MaybeObject * TryFlatten(PretenureFlag pretenure=NOT_TENURED)
const uint32_t kTwoByteStringTag
static void DeleteHiddenProperty(Handle< JSObject > object, Handle< Name > key)
uint32_t NumberToUint32(Object *number)
BailoutId AstId(int index)
void ClearTypeFeedbackInfo(Heap *heap)
static void SetObserved(Handle< JSObject > object)
bool function_with_prototype()
void set_opt_count(int opt_count)
Handle< DescriptorArray > NewDescriptorArray(int number_of_descriptors, int slack=0)
static Failure * InternalError()
BailoutId ast_id(uint32_t index)
virtual MaybeObject * AsObject(Heap *heap)
int NumberOfLocalElements(PropertyAttributes filter)
uint32_t HashForObject(Object *other)
bool IsMatch(Object *other)
bool ToUint32(uint32_t *value)
String * constructor_name()
static Handle< ObjectHashTable > Shrink(Handle< ObjectHashTable > table, Handle< Object > key)
static Handle< Map > CopyInstallDescriptors(Handle< Map > map, int new_descriptor, Handle< DescriptorArray > descriptors)
void ReportFailedAccessCheckWrapper(Handle< JSObject > receiver, v8::AccessType type)
int unused_property_fields()
void SourceCodePrint(StringStream *accumulator, int max_length)
AllocationSite * FindFirstAllocationSite()
static Handle< Object > SetPropertyViaPrototypesWithHandler(Handle< JSProxy > proxy, Handle< JSReceiver > receiver, Handle< Name > name, Handle< Object > value, PropertyAttributes attributes, StrictMode strict_mode, bool *done)
MUST_USE_RESULT MaybeObject * Put(MapHandleList *maps, int code_kind, Code *code)
static const char * Name(Value tok)
static Smi * FromInt(int value)
uint32_t HashForObject(Object *obj)
static uint32_t StringHash(Object *obj)
bool IsFastObjectElementsKind(ElementsKind kind)
MUST_USE_RESULT MaybeObject * GetLocalPropertyPostInterceptor(Object *receiver, Name *name, PropertyAttributes *attributes)
void IteratePointer(ObjectVisitor *v, int offset)
void set_number_of_entries(DependencyGroup group, int value)
StaticResource< ConsStringIteratorOp > * objects_string_iterator()
#define LOG(isolate, Call)
RegExpKey(String *string, JSRegExp::Flags flags)
Object * GetNormalizedProperty(const LookupResult *result)
AccessorDescriptor * FindAccessor(Name *name)
Map * elements_transition_map()
void CopyKeysTo(FixedArray *storage, PropertyAttributes filter, SortMode sort_mode)
static const int kContextOffset
static Object * GetObjectFromEntryAddress(Address location_of_address)
static const int kEnumCacheBridgeIndicesCacheIndex
MUST_USE_RESULT MaybeObject * CopyJSObject(JSObject *source, AllocationSite *site=NULL)
MUST_USE_RESULT MaybeObject * GetElementWithHandler(Object *receiver, uint32_t index)
static Handle< Map > GeneralizeRepresentation(Handle< Map > map, int modify_index, Representation new_representation, StoreMode store_mode)
uint64_t double_to_uint64(double d)
void set_top(Address top)
static void SetIdentityHash(Handle< JSObject > object, Handle< Smi > hash)
int NumberOfOwnDescriptors()
static const int kDependentCodeOffset
bool SameValue(Handle< Value > that) const
void CopyTo(int pos, FixedArray *dest, int dest_pos, int len)
MUST_USE_RESULT MaybeObject * GetPropertyWithDefinedGetter(Object *receiver, JSReceiver *getter)
virtual MUST_USE_RESULT Handle< Object > Get(Handle< Object > receiver, Handle< JSObject > holder, uint32_t key, Handle< FixedArrayBase > backing_store=Handle< FixedArrayBase >::null())=0
static const int kArrayIndexHashMask
static void SetInstancePrototype(Handle< JSFunction > function, Handle< Object > value)
static HeapObject * cast(Object *obj)
static bool HasLocalElement(Handle< JSReceiver > object, uint32_t index)
MaybeObject * AllocateNewStorageFor(Heap *heap, Representation representation)
#define TYPED_ARRAY_SHORT_PRINT(Type, type, TYPE, ctype, size)
static Handle< T > cast(Handle< S > that)
bool IsMatch(Object *strings)
bool MayNamedAccess(JSObject *receiver, Object *key, v8::AccessType type)
static const int kMaxHashCalcLength
MUST_USE_RESULT MaybeObject * AllocateCodeCache()
void set_pre_allocated_property_fields(int value)
static CodeCacheHashTable * cast(Object *obj)
static const int kProtoTransitionElementsPerEntry
Object * AsObject(Heap *heap)
static AccessorPair * cast(Object *obj)
MUST_USE_RESULT MaybeObject * AddKeysFromJSArray(JSArray *array)
static void IterateBody(HeapObject *obj, int object_size, ObjectVisitor *v)
void ZapPrototypeTransitions()
PropertyAttributes property_attributes()
static uint32_t StringSharedHashHelper(String *source, SharedFunctionInfo *shared, StrictMode strict_mode, int scope_position)
HeapObject * UncheckedPrototypeTransitions()
static ExternalTwoByteString * cast(Object *obj)
bool IsMatch(Object *obj)
TraversableMap * GetAndResetParent()
int GetEnumElementKeys(FixedArray *storage)
static bool HasRealElementProperty(Handle< JSObject > object, uint32_t index)
SeededNumberDictionary * element_dictionary()
static const int kEnumCacheBridgeLength
static Map * cast(Object *obj)
CodeFlusher * code_flusher()
static uint16_t TrailSurrogate(uint32_t char_code)
void FindAllTypes(TypeHandleList *types)
EnumIndexComparator(NameDictionary *dict)
void CompleteInobjectSlackTracking()
Object * object_at(int i)
MUST_USE_RESULT MaybeObject * Put(String *src, Context *context, Object *value)
Handle< DeclaredAccessorDescriptor > NewDeclaredAccessorDescriptor()
kSerializedDataOffset Object
bool prohibits_overwriting()
static Handle< Object > SetPrototype(Handle< JSObject > object, Handle< Object > value, bool skip_hidden_prototypes=false)
bool ToInt32(int32_t *value)
static ByteArray * cast(Object *obj)
void set_type(HeapType *value, WriteBarrierMode mode=UPDATE_WRITE_BARRIER)
static bool HasRealNamedProperty(Handle< JSObject > object, Handle< Name > key)
int NumberOfEnumElements()
Vector< T > SubVector(int from, int to)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in only print modified registers Don t break for ASM_UNIMPLEMENTED_BREAK macros print stack trace when an illegal exception is thrown randomize hashes to avoid predictable hash Fixed seed to use to hash property Print the time it takes to deserialize the snapshot testing_bool_flag testing_int_flag string flag tmp file in which to serialize heap Print the time it takes to lazily compile hydrogen code stubs concurrent_recompilation concurrent_sweeping Print usage including on console Map counters to a file Enable debugger compile events enable GDBJIT enable GDBJIT interface for all code objects dump only objects containing this substring stress the GC compactor to flush out pretty print source code print source AST function name where to insert a breakpoint print scopes for builtins trace contexts operations print stuff during garbage collection report code statistics after GC report handles after GC trace cache state transitions print interface inference details prints when objects are turned into dictionaries report heap spill statistics along with trace isolate state changes trace regexp bytecode execution Minimal Log all events to the log file Log API events to the log file Log heap samples on garbage collection for the hp2ps tool log positions Log suspect operations Used with turns on browser compatible mode for profiling v8 Specify the name of the log file Enable low level linux profiler Enable perf linux profiler(experimental annotate support).") DEFINE_string(gc_fake_mmap
bool LookupStringIfExists(String *str, String **result)
static AllocationSite * cast(Object *obj)
static Object * RawUninitializedSentinel(Heap *heap)
void MarkForOptimization()
static FreeSpace * cast(Object *obj)
static const unsigned int kContainsCachedArrayIndexMask
#define INSTANCE_TYPE_TO_ARRAY_TYPE(Type, type, TYPE, ctype, size)
void ClearInstanceofCache()
static bool HasRealNamedCallbackProperty(Handle< JSObject > object, Handle< Name > key)
Bootstrapper * bootstrapper()
void Set(int descriptor_number, Descriptor *desc, const WhitenessWitness &)
bool VerifyBailoutId(BailoutId id)
MUST_USE_RESULT MaybeObject * Uint32ToString(uint32_t value, bool check_number_string_cache=true)
bool SameValue(Object *other)
void Relocate(intptr_t delta)
static SeqOneByteString * cast(Object *obj)
MUST_USE_RESULT MaybeObject * ToObject(Isolate *isolate)
void set_object_at(int i, Object *object)
WriteBarrierMode GetWriteBarrierMode(const DisallowHeapAllocation &promise)
static Failure * Exception()
MUST_USE_RESULT MaybeObject * PutRegExp(String *src, JSRegExp::Flags flags, FixedArray *value)
bool MayIndexedAccessWrapper(Handle< JSObject > receiver, uint32_t index, v8::AccessType type)
Object * FindInCodeCache(Name *name, Code::Flags flags)
static void Clear(Isolate *isolate, Address address, ConstantPoolArray *constant_pool)
MUST_USE_RESULT MaybeObject * GetElementsTransitionMapSlow(ElementsKind elements_kind)
bool marked_for_deoptimization()
bool MakeExternal(v8::String::ExternalStringResource *resource)
int GetLocalElementKeys(FixedArray *storage, PropertyAttributes filter)
static Handle< Object > GetElementNoExceptionThrown(Isolate *isolate, Handle< Object > object, uint32_t index)
#define INSTANCE_TYPE_TO_ELEMENT_SIZE(Type, type, TYPE, ctype, size)
void DeoptimizeDependentCodeGroup(Isolate *isolate, DependentCode::DependencyGroup group)
int SourceStatementPosition(Address pc)
Map * LookupElementsTransitionMap(ElementsKind elements_kind)
static PropertyAttributes GetPropertyAttributeWithFailedAccessCheck(Handle< JSObject > object, LookupResult *result, Handle< Name > name, bool continue_search)
uint32_t HashForObject(Object *obj)
bool IsTwoByteEqualTo(Vector< const uc16 > str)
void CheckArrayAbuse(JSObject *obj, const char *op, uint32_t key, bool allow_appending)
uint16_t SlicedStringGet(int index)
static Handle< Object > GetPropertyWithCallback(Handle< JSObject > object, Handle< Object > receiver, Handle< Object > structure, Handle< Name > name)
bool Contains(Object *key)
Object * SetValue(uint32_t index, Object *value)
RandomNumberGenerator * random_number_generator()
void SetEnumLength(int length)
Handle< Object > Lookup(MapHandleList *maps, Code::Flags flags)
static Handle< Object > PrepareSlowElementsForSort(Handle< JSObject > object, uint32_t limit)
static Handle< Object > SetHiddenProperty(Handle< JSObject > object, Handle< Name > key, Handle< Object > value)
bool IsCacheable(Isolate *isolate)
#define CALL_AND_RETRY_OR_DIE(ISOLATE, FUNCTION_CALL, RETURN_VALUE, RETURN_EMPTY)
static const int kDescriptorLengthIndex
List< Handle< Map > > MapHandleList
void(* IndexedPropertyDeleterCallback)(uint32_t index, const PropertyCallbackInfo< Boolean > &info)
#define ASSERT(condition)
void EvictOptimizedCodeMap(SharedFunctionInfo *code_map_holder)
bool CanTransitionToMoreGeneralFastElementsKind(ElementsKind elements_kind, bool allow_only_packed)
static void AppendCallbackDescriptors(Handle< Map > map, Handle< Object > descriptors)
bool MarkCodeForDeoptimization(Isolate *isolate, DependentCode::DependencyGroup group)
static Handle< Object > SetLocalPropertyIgnoreAttributes(Handle< JSObject > object, Handle< Name > key, Handle< Object > value, PropertyAttributes attributes, ValueType value_type=OPTIMAL_REPRESENTATION, StoreMode mode=ALLOW_AS_CONSTANT, ExtensibilityCheck extensibility_check=PERFORM_EXTENSIBILITY_CHECK)
MUST_USE_RESULT MaybeObject * UnionOfKeys(FixedArray *other)
static Handle< JSObject > DeepCopy(Handle< JSObject > object, AllocationSiteUsageContext *site_context, DeepCopyHints hints=kNoHints)
void LocalLookup(Name *name, LookupResult *result, bool search_hidden_prototypes=false)
static Handle< Object > GetPropertyWithReceiver(Handle< Object > object, Handle< Object > receiver, Handle< Name > name, PropertyAttributes *attributes)
static Script * cast(Object *obj)
MUST_USE_RESULT MaybeObject * PutEval(String *src, Context *context, SharedFunctionInfo *value, int scope_position)
void(* AccessorSetterCallback)(Local< String > property, Local< Value > value, const PropertyCallbackInfo< void > &info)
static Handle< Map > RawCopy(Handle< Map > map, int instance_size)
int SourcePosition(Address pc)
#define VISITOR_SYNCHRONIZATION_TAGS_LIST(V)
static Dictionary< Shape, Key > * cast(Object *obj)
#define CALL_HEAP_FUNCTION_VOID(ISOLATE, FUNCTION_CALL)
MUST_USE_RESULT MaybeObject * EnsureCapacity(int n, Key key)
static Context * cast(Object *context)
Object * SlowReverseLookup(Object *value)
const uc16 * GetTwoByteData(unsigned start)
static const int kSourceIndex
static SharedFunctionInfo * cast(Object *obj)
static Handle< Object > SetAccessor(Handle< JSObject > object, Handle< AccessorInfo > info)
const uint32_t kStringRepresentationMask
int SizeFromMap(Map *map)
TwoCharHashTableKey(uint16_t c1, uint16_t c2, uint32_t seed)
MUST_USE_RESULT MaybeObject * AllocateTwoByteInternalizedString(Vector< const uc16 > str, uint32_t hash_field)
#define ERROR_MESSAGES_LIST(V)
static MUST_USE_RESULT MaybeObject * Allocate(Isolate *isolate, int number_of_descriptors, int slack=0)
static bool HasHiddenProperties(Handle< JSObject > object)
static Handle< Map > CopyForObserved(Handle< Map > map)
static void MarkCodeAsExecuted(byte *sequence, Isolate *isolate)
static const int kShortSize
Name * GetSortedKey(int descriptor_number)
Name * GetKey(int transition_number)
static PropertyAttributes GetPropertyAttributeWithHandler(Handle< JSProxy > proxy, Handle< JSReceiver > receiver, Handle< Name > name)
MUST_USE_RESULT MaybeObject * GetPropertyWithHandler(Object *receiver, Name *name)
void(* IndexedPropertySetterCallback)(uint32_t index, Local< Value > value, const PropertyCallbackInfo< Value > &info)
static Handle< Map > CopyDropDescriptors(Handle< Map > map)
Handle< Object > GetProperty(Handle< JSReceiver > obj, const char *name)
static const int kEntrySize
const bool FLAG_enable_slow_asserts
SmartArrayPointer< uc16 > ToWideCString(RobustnessFlag robustness_flag=FAST_STRING_TRAVERSAL)
int number_of_entries(DependencyGroup group)
const int kFastElementsKindCount
#define RETURN_IF_EMPTY_HANDLE(isolate, call)
void LookupCallbackProperty(Name *name, LookupResult *result)
static FixedTypedArrayBase * cast(Object *obj)
MUST_USE_RESULT MaybeObject * Copy()
MUST_USE_RESULT MaybeObject * AddToOptimizedCodeMap(Context *native_context, Code *code, FixedArray *literals, BailoutId osr_ast_id)
Map * FindLastMatchMap(int verbatim, int length, DescriptorArray *descriptors)
bool ReferencesObject(Object *obj)
bool IsFastElementsKind(ElementsKind kind)
static ExternalAsciiString * cast(Object *obj)
void Lookup(Name *name, LookupResult *result)
void InvalidateEmbeddedObjects()
MUST_USE_RESULT MaybeObject * EnsureWritableFastElements()
void set_the_hole(int index)
static Handle< Object > Freeze(Handle< JSObject > object)
void MarkInOptimizationQueue()
MUST_USE_RESULT MaybeObject * Put(Name *name, Code *code)
static const int kInvalidStamp
Object * AsObject(Heap *heap)
#define CALL_HEAP_FUNCTION_PASS_EXCEPTION(ISOLATE, FUNCTION_CALL)
void ConstantPoolIterateBody(ObjectVisitor *v)
static Code * cast(Object *obj)
bool IsMatch(Object *string)
static const unsigned kMaxEncodedSize
virtual const uint16_t * data() const =0
void AddDependentCode(DependentCode::DependencyGroup group, Handle< Code > code)
void AdjustLiveBytes(Address address, int by, InvocationMode mode)
int GetSequenceIndexFromFastElementsKind(ElementsKind elements_kind)
static Symbol * cast(Object *obj)
#define HANDLE_CODE_AGE(AGE)
Handle< JSObject > VisitElementOrProperty(Handle< JSObject > object, Handle< JSObject > value)
static MUST_USE_RESULT Handle< String > Truncate(Handle< SeqString > string, int new_length)
Object * GetValue(int descriptor_number)
static Handle< Object > GetPropertyPostInterceptor(Handle< JSObject > object, Handle< Object > receiver, Handle< Name > name, PropertyAttributes *attributes)
void PrintDeoptLocation(FILE *out, int bailout_id)
AccessorPair * GetLocalElementAccessorPair(uint32_t index)
static Object ** RawField(HeapObject *obj, int offset)
TransitionArray * unchecked_transition_array()
#define RETURN_IF_EMPTY_HANDLE_VALUE(isolate, call, value)
bool MayNamedAccessWrapper(Handle< JSObject > receiver, Handle< Object > key, v8::AccessType type)
static Smi * cast(Object *object)
static const char * AllocationIndexToString(int index)
void AddDependentCompilationInfo(CompilationInfo *info)
static void IterateBody(HeapObject *obj, ObjectVisitor *v)
void FindAllMaps(MapHandleList *maps)
void ClearCodeCache(Heap *heap)
static const int kOsrAstIdOffset
static Handle< Object > SetValue(Handle< ExternalFloat64Array > array, uint32_t index, Handle< Object > value)
static const int kZeroHash
bool Equals(String *other)
static const int kHeaderSize
static Handle< Map > CopyGeneralizeAllRepresentations(Handle< Map > map, int modify_index, StoreMode store_mode, PropertyAttributes attributes, const char *reason)
static Handle< Map > CopyReplaceDescriptors(Handle< Map > map, Handle< DescriptorArray > descriptors, TransitionFlag flag, Handle< Name > name)
Handle< Object > CallTrap(const char *name, Handle< Object > derived_trap, int argc, Handle< Object > args[])
Map * GetMarkerMap(Isolate *isolate)
kInstanceClassNameOffset flag
static Handle< ObjectHashSet > Add(Handle< ObjectHashSet > table, Handle< Object > key)
bool IsMatch(Object *string)
Object * GetInternalField(int index)
MUST_USE_RESULT MaybeObject * AddNumberEntry(uint32_t key, Object *value)
void set_dictionary_map(bool value)
void Add(Vector< const char > format, Vector< FmtElm > elms)
static void TransitionElementsKind(Handle< JSObject > object, ElementsKind to_kind)
void IterateBody(InstanceType type, int object_size, ObjectVisitor *v)
#define ASSERT_OBJECT_ALIGNED(address)
bool has_instance_call_handler()
static Handle< Object > TryMigrateInstance(Handle< JSObject > instance)
Code * GetCodeFromOptimizedCodeMap(int index)
void DeprecateTransitionTree()
static bool IsOneByte(const uc16 *chars, int length)
SmartArrayPointer< char > ToCString(AllowNullsFlag allow_nulls, RobustnessFlag robustness_flag, int offset, int length, int *length_output=0)
void AbortDueToDependencyChange()
uint32_t TranslateAstIdToPcOffset(BailoutId ast_id)
Object * ValueAt(int entry)
Object * InObjectPropertyAtPut(int index, Object *value, WriteBarrierMode mode=UPDATE_WRITE_BARRIER)
static void MakeCodeAgeSequenceYoung(byte *sequence, Isolate *isolate)
bool IsInobjectSlackTrackingInProgress()
static void GeneralizeFieldRepresentation(Handle< JSObject > object, int modify_index, Representation new_representation, StoreMode store_mode)
MUST_USE_RESULT MaybeObject * AllocateHeapNumber(double value, PretenureFlag pretenure=NOT_TENURED)
void(* AccessorGetterCallback)(Local< String > property, const PropertyCallbackInfo< Value > &info)
const uint16_t * SeqTwoByteStringGetData(unsigned start)
void CopyFrom(int dst_index, DescriptorArray *src, int src_index, const WhitenessWitness &)
static const int kMaxCachedPrototypeTransitions
void(* IndexedPropertyGetterCallback)(uint32_t index, const PropertyCallbackInfo< Value > &info)
static Handle< DependentCode > Insert(Handle< DependentCode > entries, DependencyGroup group, Handle< Object > object)
static PropertyAttributes GetLocalElementAttribute(Handle< JSReceiver > object, uint32_t index)
UnicodeCache * unicode_cache()
void RemoveByIndex(Object *name, Code *code, int index)
static void DefineAccessor(Handle< JSObject > object, Handle< Name > name, Handle< Object > getter, Handle< Object > setter, PropertyAttributes attributes, v8::AccessControl access_control=v8::DEFAULT)
static JSFunctionProxy * cast(Object *obj)
static uchar Length(uchar chr, int previous)
V8_INLINE bool IsNull() const
void Remove(Object *value)
static void NoWriteBarrierSet(FixedArray *array, int index, Object *value)
bool IsMatch(Object *other)
bool IsMatch(Object *other)
static const int kTransitionSize
int GetIndex(Name *name, Code::Flags flags)
void set_the_hole(int index)
void CopyEnumCacheFrom(DescriptorArray *array)
static bool compare(const uint16_t *a, const uint16_t *b, int len)
static Handle< DeclaredAccessorDescriptor > Create(Isolate *isolate, const DeclaredAccessorDescriptorData &data, Handle< DeclaredAccessorDescriptor > previous)
static void DeoptimizeGlobalObject(JSObject *object)
static const int kLiteralNativeContextIndex
virtual size_t length() const =0
void FailurePrint(FILE *out=stdout)
void Iterate(ObjectVisitor *v)
Object * Lookup(Name *name, Code::Flags flags)
void RemoveCompilationInfo(DependentCode::DependencyGroup group, CompilationInfo *info)
bool CanDeoptAt(Address pc)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long mode(MIPS only)") DEFINE_string(expose_natives_as
Handle< JSArrayBuffer > GetBuffer()
virtual MUST_USE_RESULT MaybeObject * AddElementsToFixedArray(Object *receiver, JSObject *holder, FixedArray *to, FixedArrayBase *from=NULL)=0
static void Update(Handle< PolymorphicCodeCache > cache, MapHandleList *maps, Code::Flags flags, Handle< Code > code)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object size
void(* NamedPropertyQueryCallback)(Local< String > property, const PropertyCallbackInfo< Integer > &info)
PolymorphicCodeCacheHashTableKey(MapHandleList *maps, int code_flags)
static uint32_t ComputeUtf8Hash(Vector< const char > chars, uint32_t seed, int *utf16_length_out)
v8::internal::Object * get(int index)
bool WouldConvertToSlowElements(Handle< Object > key)
bool IsUtf8EqualTo(Vector< const char > str, bool allow_prefix_match=false)
static SeededNumberDictionary * cast(Object *obj)
void Append(Descriptor *desc, const WhitenessWitness &)
void(* NamedPropertySetterCallback)(Local< String > property, Local< Value > value, const PropertyCallbackInfo< Value > &info)
virtual const char * NameOfCPURegister(int reg) const
bool MarkAsUndetectable()
int NumberOfElementsFilterAttributes(PropertyAttributes filter)
bool ComputeArrayIndex(uint32_t *index)
IntrusiveMapTransitionIterator(TransitionArray *transition_array)
const char * Mnemonic() const
bool IsTransitionElementsKind(ElementsKind kind)
STATIC_ASSERT(sizeof(CPURegister)==sizeof(Register))
static void PrintElementsTransition(FILE *file, Handle< JSObject > object, ElementsKind from_kind, Handle< FixedArrayBase > from_elements, ElementsKind to_kind, Handle< FixedArrayBase > to_elements)
static Cell * cast(Object *obj)
Handle< String > NewSubString(Handle< String > str, int begin, int end)
static Handle< Map > PutPrototypeTransition(Handle< Map > map, Handle< Object > prototype, Handle< Map > target_map)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in only print modified registers Don t break for ASM_UNIMPLEMENTED_BREAK macros print stack trace when an illegal exception is thrown randomize hashes to avoid predictable hash Fixed seed to use to hash property Print the time it takes to deserialize the snapshot testing_bool_flag testing_int_flag string flag tmp file in which to serialize heap Print the time it takes to lazily compile hydrogen code stubs concurrent_recompilation concurrent_sweeping Print usage including flags
bool IsFastPackedElementsKind(ElementsKind kind)
friend class RelocIterator
void ReplaceCode(Code *code)
void Recompute(DependentCode *entries)
MUST_USE_RESULT MaybeObject * Put(FixedArray *key, Map *value)
static MUST_USE_RESULT MaybeObject * GetPropertyOrFail(Handle< Object > object, Handle< Object > receiver, LookupResult *result, Handle< Name > key, PropertyAttributes *attributes)
bool PassesFilter(const char *raw_filter)
void set_undefined(int index)
static SlicedString * cast(Object *obj)
static void MemCopy(void *dest, const void *src, size_t size)
static const int kProtoTransitionMapOffset
int pre_allocated_property_fields()
void set_expected_nof_properties(int value)
void SetNumberOfElements(int nof)
static uint32_t update(uint32_tprevious, boolvalue)
MUST_USE_RESULT MaybeObject * AsElementsKind(ElementsKind kind)
Context * native_context()
Local< Value > GetPrototype()
static uint32_t MapsHashHelper(MapHandleList *maps, int code_flags)
void IteratePointers(ObjectVisitor *v, int start, int end)
Object * GetConstant(int descriptor_number)
void MarkForConcurrentOptimization()
MUST_USE_RESULT MaybeObject * AddEntry(Key key, Object *value, PropertyDetails details, uint32_t hash)
static bool IsValidElementsTransition(ElementsKind from_kind, ElementsKind to_kind)
static const uchar kMaxNonSurrogateCharCode
MUST_USE_RESULT MaybeObject * LookupKey(HashTableKey *key, Object **s)
static const int kNotFound
static Failure * cast(MaybeObject *object)
void ClearAllICsByKind(Code::Kind kind)
#define CALL_HEAP_FUNCTION(ISOLATE, FUNCTION_CALL, TYPE)
void FindAndReplace(const FindAndReplacePattern &pattern)
void ResetForNewContext(int new_ic_age)
static Handle< Object > SetValue(Handle< ExternalInt8Array > array, uint32_t index, Handle< Object > value)
#define ERROR_MESSAGES_TEXTS(C, T)
bool ToArrayIndex(uint32_t *index)
ElementsKind GetFastElementsKindFromSequenceIndex(int sequence_number)
ElementsKind GetElementsKind()
Smi * PcAndState(int index)
byte * instruction_start()
static Handle< Map > GetElementsTransitionMap(Handle< JSObject > object, ElementsKind to_kind)
static void PrintTop(Isolate *isolate, FILE *file, bool print_args, bool print_line_number)
MUST_USE_RESULT MaybeObject * AllocateFixedArrayWithHoles(int length, PretenureFlag pretenure=NOT_TENURED)
#define MAKE_STRUCT_CASE(NAME, Name, name)
const uint8_t * GetChars()
void check(i::Vector< const uint8_t > string)
static const int kMaxCachedArrayIndexLength
MUST_USE_RESULT MaybeObject * ShareDescriptor(DescriptorArray *descriptors, Descriptor *descriptor)
static PropertyAttributes GetPropertyAttributePostInterceptor(Handle< JSObject > object, Handle< JSObject > receiver, Handle< Name > name, bool continue_search)
static const char *const kTags[kNumberOfSyncTags]
MUST_USE_RESULT MaybeObject * CopyUpTo(int enumeration_index)
Handle< Object > NewTypeError(const char *message, Vector< Handle< Object > > args)
Object * LookupEval(String *src, Context *context, StrictMode strict_mode, int scope_position)
uint32_t HashForObject(Key key, Object *object)
static Oddball * cast(Object *obj)
static PolymorphicCodeCacheHashTable * cast(Object *obj)
static Address & Address_at(Address addr)
static uint16_t LeadSurrogate(uint32_t char_code)
unsigned int FastD2UI(double x)
Handle< Object > ToBoolean(bool value)
static Handle< ObjectHashSet > EnsureCapacity(Handle< ObjectHashSet > table, int n, Handle< Object > key, PretenureFlag pretenure=NOT_TENURED)
FlatStringReader(Isolate *isolate, Handle< String > str)
static const int kMaxInstanceSize
static Handle< Object > GetPropertyWithInterceptor(Handle< JSObject > object, Handle< Object > receiver, Handle< Name > name, PropertyAttributes *attributes)
Object ** RawFieldOfElementAt(int index)
int GetFieldIndex(int descriptor_number)
MUST_USE_RESULT MaybeObject * AsObject(Heap *heap)
static Handle< JSObject > Copy(Handle< JSObject > object)
bool Equals(const Representation &other) const
Object * GetPrototype(Isolate *isolate)
static void UpdateMapCodeCache(Handle< HeapObject > object, Handle< Name > name, Handle< Code > code)
static PropertyAttributes GetElementAttributeWithHandler(Handle< JSProxy > proxy, Handle< JSReceiver > receiver, uint32_t index)
MUST_USE_RESULT MaybeObject * GenerateNewEnumerationIndices()
#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName)
void set_inobject_properties(int value)
Object * RawFastPropertyAt(int index)
Handle< Object > GetSourceCode()
bool HasPrototypeTransitions()
static Handle< ObjectHashSet > Remove(Handle< ObjectHashSet > table, Handle< Object > key)
static int GetDeoptimizationId(Isolate *isolate, Address addr, BailoutType type)
int32_t Int32Value() const
static bool Contains(Name *key, AccessorInfo *entry, int valid_descriptors, Handle< DescriptorArray > array)
MUST_USE_RESULT MaybeObject * CopyAddDescriptor(Descriptor *descriptor, TransitionFlag flag)
bool IsMoreGeneralElementsKindTransition(ElementsKind from_kind, ElementsKind to_kind)
int first_code_ptr_index()
BailoutId TranslatePcOffsetToAstId(uint32_t pc_offset)
static const int kProtoTransitionNumberOfEntriesOffset
static void TransformToFastProperties(Handle< JSObject > object, int unused_property_fields)
STATIC_ASSERT(NUMBER_OF_KINDS<=16)
Handle< HeapNumber > NewHeapNumber(double value, PretenureFlag pretenure=NOT_TENURED)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra code(assertions) for debugging") DEFINE_bool(code_comments
static int TimeInDay(int64_t time_ms, int days)
static MUST_USE_RESULT MaybeObject * Allocate(Heap *heap, int at_least_space_for, PretenureFlag pretenure=NOT_TENURED)
MUST_USE_RESULT MaybeObject * InternalizeString(String *str)
uint32_t EntryForProbe(Key key, Object *k, int probe, uint32_t expected)
static Handle< Object > GetOrCreateIdentityHash(Handle< JSReceiver > object)
static const char * Kind2String(Kind kind)
void SetCapacity(int capacity)
static Handle< PropertyCell > EnsurePropertyCell(Handle< JSGlobalObject > global, Handle< Name > name)
bool ShouldConvertToFastDoubleElements(bool *has_smi_only_elements)
Handle< ByteArray > NewByteArray(int length, PretenureFlag pretenure=NOT_TENURED)
static FunctionTemplateInfo * cast(Object *obj)
static const int kIsNotArrayIndexMask
Vector< const uc16 > ToUC16Vector()
uint32_t FindInsertionEntry(uint32_t hash)
Handle< FixedArray > NewFixedArray(int size, PretenureFlag pretenure=NOT_TENURED)
virtual bool IsMatch(Object *string)
bool IsFixedTypedArrayElementsKind(ElementsKind kind)
static Handle< Map > Get(Handle< NormalizedMapCache > cache, Handle< JSObject > object, PropertyNormalizationMode mode)
bool IsOneByteRepresentationUnderneath()
bool DictionaryElementsInPrototypeChainOnly()
SetFastElementsCapacitySmiMode
static const int kDescriptorSize
SafepointEntry GetSafepointEntry(Address pc)
OldSpace * old_pointer_space()
static const int kPropertiesOffset
static void EnsureDescriptorSlack(Handle< Map > map, int slack)
Handle< Foreign > object_wrapper()
Map * InternalizedStringMapForString(String *str)
static bool Equals(State *state_1, State *state_2, unsigned to_check)
#define ASSERT_LE(v1, v2)
void RecordWrites(HeapObject *obj)
Object * Lookup(Object *key)
static FixedDoubleArray * cast(Object *obj)
PretenureFlag GetPretenureMode()
static const char * State2String(State state)
static PropertyAttributes GetPropertyAttributeWithReceiver(Handle< JSReceiver > object, Handle< JSReceiver > receiver, Handle< Name > name)
int GetIndex(Object *name, Code *code)
bool IsTwoByteRepresentation()
static Code * GetCodeFromTargetAddress(Address address)
int number_of_transitions()
bool is_inline_cache_stub()
static Handle< Object > SetOwnElement(Handle< JSObject > object, uint32_t index, Handle< Object > value, StrictMode strict_mode)
bool IsFastSmiElementsKind(ElementsKind kind)
StringsKey(FixedArray *strings)
bool has_pending_exception()
void set_length(int value)
void VisitOneByteString(const uint8_t *chars, unsigned length)
bool IsMoreGeneralThan(int verbatim, int valid, int new_size, DescriptorArray *other)
static Handle< DescriptorArray > CopyUpToAddAttributes(Handle< DescriptorArray > desc, int enumeration_index, PropertyAttributes attributes)
Object * GetIdentityHash()
static void DigestTransitionFeedback(Handle< AllocationSite > site, ElementsKind to_kind)
FixedArray * GetEnumIndicesCache()
static ElementsAccessor * ForArray(FixedArrayBase *array)
static void UpdateCodeCache(Handle< Map > map, Handle< Name > name, Handle< Code > code)
static const int kHeaderSize
static int GetOutputInfo(DeoptimizationOutputData *data, BailoutId node_id, SharedFunctionInfo *shared)
void NotifyLeafMapLayoutChange()
double FastUI2D(unsigned x)
static const int kCachedCodeOffset
void CopyFrom(const CodeDesc &desc)
bool BooleanValue() const
InterceptorInfo * GetNamedInterceptor()
void SortPairs(FixedArray *numbers, uint32_t len)
static void FatalProcessOutOfMemory(const char *location, bool take_snapshot=false)
MUST_USE_RESULT MaybeObject * Shrink(Key key)
int CompareChars(const lchar *lhs, const rchar *rhs, int chars)
PropertyDetails GetDetails(int descriptor_number)
static PropertyCell * cast(Object *obj)
int TenToThe(int exponent)
Object ** GetFirstElementAddress()
TraversableMap * ChildIteratorNext()
static unsigned Encode(char *out, uchar c, int previous, bool replace_invalid=false)
void SetNumberOfDeletedElements(int nod)
unsigned back_edge_table_offset()
Failure * Throw(Object *exception, MessageLocation *location=NULL)
MaybeObject *(* getter)(Isolate *isolate, Object *object, void *data)
DeclaredAccessorDescriptorIterator(DeclaredAccessorDescriptor *descriptor)
InlineCacheState ic_state()
byte * relocation_start()
static const int kArrayIndexValueBits
#define STATIC_ASCII_VECTOR(x)
void Reset(String *string, unsigned offset=0)
V8_INLINE bool IsUndefined() const
void set_construction_count(int value)
uint32_t pc_offset(uint32_t index)
double get_scalar(int index)
static AllocationMemento * cast(Object *obj)
static v8::internal::Handle< To > OpenHandle(v8::Local< From > handle)
Object * Lookup(Object *key)
static void Fix(Handle< JSProxy > proxy)
static uint32_t MakeArrayIndexHash(uint32_t value, int length)
V8_INLINE Handle< Primitive > Undefined(Isolate *isolate)
Handle< Map > FindTransitionedMap(MapHandleList *candidates)
uint16_t ConsStringGet(int index)
static Handle< Object > GetOrCreateHash(Handle< Object > object, Isolate *isolate)
void set_map_no_write_barrier(Map *value)
bool LookupTwoCharsStringIfExists(uint16_t c1, uint16_t c2, String **result)
static void DoGenerateNewEnumerationIndices(Handle< NameDictionary > dictionary)
Vector< const char > CStrVector(const char *data)
void(* IndexedPropertyQueryCallback)(uint32_t index, const PropertyCallbackInfo< Integer > &info)
void PostGarbageCollection()
MUST_USE_RESULT MaybeObject * GetProperty(Name *key)
static Local< Context > ToLocal(v8::internal::Handle< v8::internal::Context > obj)
bool EquivalentToForTransition(Map *other)
Object * SlowReverseLookup(Object *value)
#define DECLARE_TAG(ignore1, name, ignore2)
static JSArray * cast(Object *obj)
void HeapSortPairs(FixedArray *content, FixedArray *numbers, int len)
#define T(name, string, precedence)
static int SizeFor(int length)
static Object * GetField(Object *date, Smi *index)
bool HasEnumIndicesCache()
bool IsTerminalElementsKind(ElementsKind kind)
MUST_USE_RESULT MaybeObject * EnsureCapacity(int n, HashTableKey *key, PretenureFlag pretenure=NOT_TENURED)
static Handle< Object > SetElement(Handle< JSReceiver > object, uint32_t index, Handle< Object > value, PropertyAttributes attributes, StrictMode strict_mode)
Map * FindUpdatedMap(int verbatim, int length, DescriptorArray *descriptors)
static const int kProtoTransitionHeaderSize
StringSharedKey(String *source, SharedFunctionInfo *shared, StrictMode strict_mode, int scope_position)
#define ASSERT_LT(v1, v2)
static uchar ValueOf(const byte *str, unsigned length, unsigned *cursor)
bool IsFastSmiOrObjectElementsKind(ElementsKind kind)
static JSDate * cast(Object *obj)
bool Equals(unsigned length, String *string_1, String *string_2)
void SetNextEnumerationIndex(int index)
V8_INLINE bool IsString() const
static ElementsAccessor * ForKind(ElementsKind elements_kind)
static Handle< Object > SetFastElement(Handle< JSObject > object, uint32_t index, Handle< Object > value, StrictMode strict_mode, bool check_prototype)
static SeqTwoByteString * cast(Object *obj)
void RemoveByIndex(int index)
Representation generalize(Representation other)
void GetLocalPropertyNames(FixedArray *storage, int index, PropertyAttributes filter=NONE)
#define RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, T)
void LookupRealNamedProperty(Name *name, LookupResult *result)
bool HasTransitionArray()
const int kElementsKindCount
bool IsTransitionableFastElementsKind(ElementsKind from_kind)
static const int kHeaderSize
PropertyNormalizationMode
void Lookup(Name *name, LookupResult *result)
FlatContent GetFlatContent()
void set(int index, double value)
static const int kMaxShortPrintLength
Handle< JSObject > StructureWalk(Handle< JSObject > object)
static int SNPrintF(Vector< char > str, const char *format,...)
Handle< NameDictionary > NameDictionaryShrink(Handle< NameDictionary > dict, Handle< Name > name)
MUST_USE_RESULT MaybeObject * NumberFromDouble(double value, PretenureFlag pretenure=NOT_TENURED)
static const int kInitialLength
void PrintElementsKind(FILE *out, ElementsKind kind)
static void OptimizeAsPrototype(Handle< JSObject > object)
GroupStartIndexes(DependentCode *entries)
static const int kArrayIndexHashLengthShift
uint32_t DoubleToUint32(double x)
static void Initialize(Handle< JSArray > array, int capacity, int length=0)
bool AsArrayIndex(uint32_t *index)
static void MigrateInstance(Handle< JSObject > instance)
static const int kMapOffset
void PrintName(FILE *out=stdout)
bool ShouldConvertToSlowElements(int new_capacity)
int NumberOfDescribedProperties(DescriptorFlag which=OWN_DESCRIPTORS, PropertyAttributes filter=NONE)
static Handle< Object > SetValue(Handle< ExternalUint16Array > array, uint32_t index, Handle< Object > value)
bool HasPrototypeTransitions()
static Handle< Object > SetPropertyWithDefinedSetter(Handle< JSReceiver > object, Handle< JSReceiver > setter, Handle< Object > value)
bool FindHandlers(CodeHandleList *code_list, int length=-1)
int32_t DoubleToInt32(double x)
bool is_the_hole(int index)
void IteratePrefix(ObjectVisitor *visitor)
static const int kEntriesStart
static HeapNumber * cast(Object *obj)
bool CanHaveMoreTransitions()
static PropertyAttributes GetElementAttributeWithReceiver(Handle< JSObject > object, Handle< JSReceiver > receiver, uint32_t index, bool continue_search)
static void EnqueueChangeRecord(Handle< JSObject > object, const char *type, Handle< Name > name, Handle< Object > old_value)
void AttachInitialMap(Map *map)
static void WriteToFlat(String *source, sinkchar *sink, int from, int to)
static MUST_USE_RESULT MaybeObject * Allocate(Heap *heap, int at_least_space_for, MinimumCapacity capacity_option=USE_DEFAULT_MINIMUM_CAPACITY, PretenureFlag pretenure=NOT_TENURED)
NameDictionary * property_dictionary()
static Handle< Object > SetElementsLength(Handle< JSArray > array, Handle< Object > length)
static uint32_t HashSequentialString(const schar *chars, int length, uint32_t seed)
void InitializeRepresentations(Representation representation)
void set_value(double value)
bool IsSimpleTransition()
const char * GetBailoutReason(BailoutReason reason)
static void MigrateToMap(Handle< JSObject > object, Handle< Map > new_map)
virtual size_t length() const =0
Handle< String > InternalizeOneByteString(Vector< const uint8_t > str)
static double nan_value()
bool has_deoptimization_support()
virtual void SetCapacityAndLength(Handle< JSArray > array, int capacity, int length)=0
MUST_USE_RESULT MaybeObject * CopySize(int new_length, PretenureFlag pretenure=NOT_TENURED)
static Handle< Object > GetElementWithInterceptor(Handle< JSObject > object, Handle< Object > receiver, uint32_t index)
bool is_compare_ic_stub()
const char * ElementsKindToString(ElementsKind kind)
static ObjectHashTable * cast(Object *obj)
static Handle< Object > Call(Isolate *isolate, Handle< Object > callable, Handle< Object > receiver, int argc, Handle< Object > argv[], bool *pending_exception, bool convert_receiver=false)
void TrimOptimizedCodeMap(int shrink_by)
MUST_USE_RESULT MaybeObject * AllocateInternalizedStringImpl(T t, int chars, uint32_t hash_field)
static Handle< Object > SetProperty(Handle< JSReceiver > object, Handle< Name > key, Handle< Object > value, PropertyAttributes attributes, StrictMode strict_mode, StoreFromKeyed store_mode=MAY_BE_STORE_FROM_KEYED)
void set_code_no_write_barrier(Code *code)
Handle< T > handle(T *t, Isolate *isolate)
void set_bailout_reason(BailoutReason reason)
bool is_the_hole(int index)
V8_INLINE bool IsEmpty() const
static void SetNormalizedProperty(Handle< JSObject > object, const LookupResult *result, Handle< Object > value)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function info
AccessorDescriptor * GetCallbacks(int descriptor_number)
void set_bit_field3(uint32_t bits)
InterceptorInfo * GetIndexedInterceptor()
#define CODE_KIND_LIST(V)
bool IsMapInArrayPrototypeChain()
MUST_USE_RESULT MaybeObject * CopyWithPreallocatedFieldDescriptors()
#define IS_POWER_OF_TWO(x)
Map * GetTarget(int transition_number)
void PrintName(Object *o)
PropertyType GetType(int descriptor_number)
void YearMonthDayFromDays(int days, int *year, int *month, int *day)
static Object * cast(Object *value)
MUST_USE_RESULT MaybeObject * NumberFromUint32(uint32_t value, PretenureFlag pretenure=NOT_TENURED)
IncrementalMarking * incremental_marking()
bool Contains(Address addr)
MUST_USE_RESULT MaybeObject * Put(Object *key, Object *value)
static void AllocateStorageForMap(Handle< JSObject > object, Handle< Map > map)
ElementsKind GetInitialFastElementsKind()
void BecomeJSObject(Handle< JSReceiver > object)
MUST_USE_RESULT MaybeObject * AllocateUninitializedFixedArray(int length)
static const int kEnumCacheIndex
void SetNumberOfDescriptors(int number_of_descriptors)
Object * GetBackPointer()
virtual MaybeObject * AsObject(Heap *heap)
void HeapObjectShortPrint(StringStream *accumulator)
void HeapNumberPrint(FILE *out=stdout)
PropertyDetails DetailsAt(int entry)
Object * DeleteProperty(int entry, JSObject::DeleteMode mode)
uint32_t ComputeLongHash(uint64_t key)
FixedArray * GetLiteralsFromOptimizedCodeMap(int index)
void set_bit_field(byte value)
static const int kPrologueOffsetNotSet
void CopyEnumKeysTo(FixedArray *storage)
static int SizeFor(int length)
void(* NamedPropertyGetterCallback)(Local< String > property, const PropertyCallbackInfo< Value > &info)
static Handle< DescriptorArray > Merge(Handle< DescriptorArray > desc, int verbatim, int valid, int new_size, int modify_index, StoreMode store_mode, Handle< DescriptorArray > other)
Handle< String > InternalizeUtf8String(Vector< const char > str)
virtual const char * data() const =0
static JSReceiver * cast(Object *obj)
void LocalLookupRealNamedProperty(Name *name, LookupResult *result)
void PrintInstanceMigration(FILE *file, Map *original_map, Map *new_map)
static Handle< Object > SetValue(Handle< ExternalUint8Array > array, uint32_t index, Handle< Object > value)
ElementsKind GetNextMoreGeneralFastElementsKind(ElementsKind elements_kind, bool allow_only_packed)
static JSValue * cast(Object *obj)
void CopyBytes(uint8_t *target, uint8_t *source)
bool fits_into(const Representation &other) const
static Handle< HeapType > UpdatedType(Handle< PropertyCell > cell, Handle< Object > value)
bool ShouldConvertToFastElements()
void ChildIteratorStart()
static const int kFieldsAdded
void ShortPrint(FILE *out=stdout)
static void JSArrayUpdateLengthFromIndex(Handle< JSArray > array, uint32_t index, Handle< Object > value)
static Handle< Object > SetValue(Handle< ExternalInt32Array > array, uint32_t index, Handle< Object > value)
static void Visit(String *string, unsigned offset, Visitor &visitor, ConsOp &cons_op, int32_t type, unsigned length)
static Handle< SeededNumberDictionary > NormalizeElements(Handle< JSObject > object)
int number_of_descriptors()
static Handle< Object > SetValue(Handle< ExternalInt16Array > array, uint32_t index, Handle< Object > value)
uint32_t HashForObject(Object *obj)
static Handle< T > null()
CodeCacheHashTableKey(Name *name, Code *code)
void MemsetPointer(T **dest, U *value, int counter)
MUST_USE_RESULT MaybeObject * CopyAsElementsKind(ElementsKind kind, TransitionFlag flag)
static const int kProtoTransitionPrototypeOffset
StringComparator(ConsStringIteratorOp *op_1, ConsStringIteratorOp *op_2)
static Handle< Map > GetPrototypeTransition(Handle< Map > map, Handle< Object > prototype)
static bool Contains(Name *key, AccessorInfo *entry, int valid_descriptors, Handle< FixedArray > array)
static const int kInitialSize
static void Expand(Handle< JSArray > array, int minimum_size_of_backing_fixed_array)
#define ASSERT_EQ(v1, v2)
void SetInstanceClassName(String *name)
void set_owns_descriptors(bool is_shared)
bool HasFastObjectElements()
static PropertyAttributes GetLocalPropertyAttribute(Handle< JSReceiver > object, Handle< Name > name)
InstanceType instance_type()
static JSProxy * cast(Object *obj)
void SetParent(TraversableMap *parent)
Handle< String > Uint32ToString(uint32_t value)
static bool ShouldZapGarbage()
static HeapObject * FromAddress(Address address)
Object * AsObject(Heap *heap)
Object * Lookup(String *src, Context *context)
static Handle< Object > SetPropertyForResult(Handle< JSObject > object, LookupResult *result, Handle< Name > name, Handle< Object > value, PropertyAttributes attributes, StrictMode strict_mode, StoreFromKeyed store_mode=MAY_BE_STORE_FROM_KEYED)
bool HasNamedInterceptor()
bool requires_slow_elements()
static Handle< ObjectHashSet > Shrink(Handle< ObjectHashSet > table, Handle< Object > key)
const uint32_t kOneByteStringTag
void Swap(uint32_t entry1, uint32_t entry2, WriteBarrierMode mode)
MUST_USE_RESULT MaybeObject * AllocateFixedArray(int length, PretenureFlag pretenure=NOT_TENURED)
void SmiPrint(FILE *out=stdout)
static Handle< Object > SetValue(Handle< ExternalUint32Array > array, uint32_t index, Handle< Object > value)
InternalizedStringKey(String *string)
void EnableDeoptimizationSupport(Code *recompiled)
#define ASSERT_NE(v1, v2)
JSObjectWalkVisitor(ContextObject *site_context, bool copying, JSObject::DeepCopyHints hints)
bool IsTemplateFor(Object *object)
ZoneList< Handle< HeapObject > > * dependencies(DependentCode::DependencyGroup group)
PerThreadAssertScopeDebugOnly< HEAP_ALLOCATION_ASSERT, false > DisallowHeapAllocation
static AccessorInfo * cast(Object *obj)
static FixedArray * cast(Object *obj)
static const unsigned kMaxOneByteChar
MUST_USE_RESULT MaybeObject * InternalizeUtf8String(const char *str)
static void SetFastDoubleElementsCapacityAndLength(Handle< JSObject > object, int capacity, int length)
static const int kHeaderSize
static bool SetupArrayBufferAllocatingData(Isolate *isolate, Handle< JSArrayBuffer > array_buffer, size_t allocated_length, bool initialize=true)
static uint32_t Hash(String *string, uint32_t seed)
static const int kEnumCacheBridgeCacheIndex
void Print(const v8::FunctionCallbackInfo< v8::Value > &args)
bool IsCompatibleReceiver(Object *receiver)
kSerializedDataOffset kPrototypeTemplateOffset kIndexedPropertyHandlerOffset kInstanceCallHandlerOffset kInternalFieldCountOffset dependent_code
Object * AsObject(Heap *heap)
int NumberOfSlackDescriptors()
static Handle< TransitionArray > AddTransition(Handle< Map > map, Handle< Name > key, Handle< Map > target, SimpleTransitionFlag flag)
static Handle< Map > CopyNormalized(Handle< Map > map, PropertyNormalizationMode mode, NormalizedMapSharingMode sharing)
static HashTable * cast(Object *obj)
ElementsKind elements_kind()
MUST_USE_RESULT MaybeObject * AtNumberPut(uint32_t key, Object *value)
void set_is_shared(bool value)
static const int kEntryLength
static Handle< Object > PreventExtensions(Handle< JSObject > object)
void Add(const T &element, AllocationPolicy allocator=AllocationPolicy())
static TypeHandle Constant(i::Handle< i::Object > value, Region *region)
FixedArray * GetEnumCache()
static Handle< ObjectHashTable > Put(Handle< ObjectHashTable > table, Handle< Object > key, Handle< Object > value)
int first_heap_ptr_index()
bool IsOneByteRepresentation()
static Handle< Object > DeleteElement(Handle< JSReceiver > object, uint32_t index, DeleteMode mode=NORMAL_DELETION)
static void NormalizeProperties(Handle< JSObject > object, PropertyNormalizationMode mode, int expected_additional_properties)
const uint32_t kMaxUInt32
MUST_USE_RESULT MaybeObject * NumberFromInt32(int32_t value, PretenureFlag pretenure=NOT_TENURED)
void SetEntry(int entry, Object *key, Object *value)
static const int kFlagsIndex
Object * GetCallbacksObject(int descriptor_number)
static const uint32_t kHashBitMask
static const int kNextMapIndex
static VisitorId GetVisitorId(int instance_type, int instance_size)
bool IsFastHoleyElementsKind(ElementsKind kind)
static Handle< AccessorPair > Copy(Handle< AccessorPair > pair)
Address GetDataStartAddress()
static MUST_USE_RESULT Handle< SeededNumberDictionary > Set(Handle< SeededNumberDictionary > dictionary, uint32_t index, Handle< Object > value, PropertyDetails details)
static Handle< Object > GetElement(Isolate *isolate, Handle< Object > object, uint32_t index)
void IterateElements(ObjectVisitor *visitor)
ContextObject * site_context()
bool HasDictionaryElements()
CodeCacheHashTableKey(Name *name, Code::Flags flags)
ElementsAccessor * GetElementsAccessor()
void OutputToFile(FILE *out)
static const int kAttachedToSharedFunctionInfo
void DeprecateTarget(Name *key, DescriptorArray *new_descriptors)
String * TryFlattenGetString(PretenureFlag pretenure=NOT_TENURED)
bool HasFastArgumentsElements()
int count_of_code_ptr_entries()
static WeakHashTable * cast(Object *obj)
void set_bit_field2(byte value)
void MakeOlder(MarkingParity)
void CreateFillerObjectAt(Address addr, int size)
void SwapPairs(FixedArray *numbers, int i, int j)
void set_marked_for_deoptimization(bool flag)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric literals(0o77, 0b11)") DEFINE_bool(harmony_strings
static const int kHashShift
#define RUNTIME_ENTRY(name, nargs, ressize)
static Name * cast(Object *obj)
bool has_debug_break_slots()
static unsigned decode(uint32_tvalue)
static int LengthOfFixedArray(int deopt_points)
bool InstancesNeedRewriting(Map *target, int target_number_of_fields, int target_inobject, int target_unused)
static const int kMaxCapacity
int SearchOptimizedCodeMap(Context *native_context, BailoutId osr_ast_id)
Local< Boolean > ToBoolean() const
bool HasIndexedInterceptor()
static uint32_t RegExpHash(String *string, Smi *flags)
static Representation None()
int NumberOfLocalProperties(PropertyAttributes filter=NONE)
int GetSortedKeyIndex(int descriptor_number)
static int LengthFor(int number_of_descriptors)
MUST_USE_RESULT MaybeObject * AtPut(Key key, Object *value)
Handle< Object > NewError(const char *maker, const char *message, Handle< JSArray > args)
static Handle< Map > CurrentMapForDeprecatedInternal(Handle< Map > map)
Vector< Handle< Object > > HandleVector(v8::internal::Handle< T > *elms, int length)
const int kMaxKeyedPolymorphism
static Flags RemoveTypeFromFlags(Flags flags)
static Representation Tagged()
static int DaysFromTime(int64_t time_ms)
AccessorPair * GetLocalPropertyAccessorPair(Name *name)
void JSFunctionIterateBody(int object_size, ObjectVisitor *v)
int NumberOfEnumElements()
int NextEnumerationIndex()
Object ** GetKeySlot(int transition_number)
void CopyChars(sinkchar *dest, const sourcechar *src, int chars)
MUST_USE_RESULT MaybeObject * set_elements_transition_map(Map *transitioned_map)
static Handle< Object > DeleteProperty(Handle< JSReceiver > object, Handle< Name > name, DeleteMode mode=NORMAL_DELETION)
static void DeoptimizeMarkedCode(Isolate *isolate)
void UpdateToFinishedCode(DependencyGroup group, CompilationInfo *info, Code *code)
static const int kConstructStubOffset
Smi * GenerateIdentityHash()
kInstanceClassNameOffset kNeedsAccessCheckBit kRemovePrototypeBit kIsExpressionBit allows_lazy_compilation
static int SizeFor(int length)
Vector< const uint8_t > ToOneByteVector()
static Handle< Map > GeneralizeAllFieldRepresentations(Handle< Map > map, Representation new_representation)
void SetKey(int transition_number, Name *value)
MUST_USE_RESULT MaybeObject * AsObject(Heap *heap)
Object * GetHiddenProperty(Name *key)
MUST_USE_RESULT MaybeObject * Shrink(Key key)
static const char * GetStateName(State state)
static ConsString * cast(Object *obj)
Handle< FixedArray > CopySizeFixedArray(Handle< FixedArray > array, int new_length, PretenureFlag pretenure=NOT_TENURED)
uint32_t HashForObject(Object *obj)
bool HasDictionaryArgumentsElements()
void JSObjectShortPrint(StringStream *accumulator)
static CodeCache * cast(Object *obj)
int count_of_heap_ptr_entries()
MUST_USE_RESULT MaybeObject * LookupString(String *key, Object **s)
static FixedArrayBase * cast(Object *object)
void DisableOptimization(BailoutReason reason)
static Context * NativeContextFromLiterals(FixedArray *literals)
Object * FindNthObject(int n, Map *match_map)
Handle< Map > NewMap(InstanceType type, int instance_size, ElementsKind elements_kind=TERMINAL_FAST_ELEMENTS_KIND)
void StringShortPrint(StringStream *accumulator)
MaybeObject * AsObject(Heap *heap)
MaybeObject *(* setter)(Isolate *isolate, JSObject *object, Object *value, void *data)
void ClearNonLiveTransitions(Heap *heap)
Object * GetComponent(AccessorComponent component)
uint32_t HashForObject(Object *key)
static Handle< Object > GetAccessor(Handle< JSObject > object, Handle< Name > name, AccessorComponent component)
static const int kMaxValue
bool IsMarkedForConcurrentOptimization()
int NextFreePropertyIndex()
static const int kCodeCacheOffset
static Handle< Object > PrepareElementsForSort(Handle< JSObject > object, uint32_t limit)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in name
static const int kNotFound
int expected_nof_properties()
struct v8::internal::IeeeDoubleBigEndianArchType::@42 bits
void SetTarget(int transition_number, Map *target)
String * Operate(String *string, unsigned *offset_out, int32_t *type_out, unsigned *length_out)
MUST_USE_RESULT MaybeObject * Initialize(Heap *heap, const char *to_string, Object *to_number, byte kind)
MUST_USE_RESULT MaybeObject * CopyReplaceDescriptor(DescriptorArray *descriptors, Descriptor *descriptor, int index, TransitionFlag flag)
Handle< Object > NewNumberFromUint(uint32_t value, PretenureFlag pretenure=NOT_TENURED)
MUST_USE_RESULT MaybeObject * AllocateMap(InstanceType instance_type, int instance_size, ElementsKind elements_kind=TERMINAL_FAST_ELEMENTS_KIND)
void EvictFromOptimizedCodeMap(Code *optimized_code, const char *reason)
ElementsKind GetHoleyElementsKind(ElementsKind packed_kind)
void(* NamedPropertyDeleterCallback)(Local< String > property, const PropertyCallbackInfo< Boolean > &info)
void TraverseTransitionTree(TraverseCallback callback, void *data)
MUST_USE_RESULT MaybeObject * TransformPropertiesToFastFor(JSObject *obj, int unused_property_fields)
static void Insert(Name *key, AccessorInfo *entry, int valid_descriptors, Handle< FixedArray > array)
void UpdateMaxNumberKey(uint32_t key)
static MUST_USE_RESULT MaybeObject * AsObject(Heap *heap, uint32_t key)
void SetSortedKey(int pointer, int descriptor_number)
void InitializeDescriptors(DescriptorArray *descriptors)
static Handle< Object > SetPropertyWithInterceptor(Handle< JSObject > object, Handle< Name > name, Handle< Object > value, PropertyAttributes attributes, StrictMode strict_mode)
Object * allocation_sites_list()
#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size)
void set_hash_field(uint32_t value)
FixedArray * GetPrototypeTransitions()
ExtraICState extra_ic_state()
static JSObject * cast(Object *obj)
static const int kMaxArrayIndexSize
ElementsKind GetNextTransitionElementsKind(ElementsKind kind)
void AddDependentCompilationInfo(DependentCode::DependencyGroup group, CompilationInfo *info)
Handle< JSArray > NewJSArray(ElementsKind elements_kind, int length, int capacity, ArrayStorageAllocationMode mode=INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE, PretenureFlag pretenure=NOT_TENURED)
static const char *const kTagNames[kNumberOfSyncTags]
MarkCompactCollector * mark_compact_collector()
bool IsDictionaryElementsKind(ElementsKind kind)
static MUST_USE_RESULT Handle< SeededNumberDictionary > AddNumberEntry(Handle< SeededNumberDictionary > dictionary, uint32_t key, Handle< Object > value, PropertyDetails details)
const DeclaredAccessorDescriptorData * Next()
static const int kLiteralsOffset
static const int kNoPreviousCharacter
Local< Uint32 > ToArrayIndex() const
void BecomeJSFunction(Handle< JSReceiver > object)
Handle< T > CloseAndEscape(Handle< T > handle_value)
CompilationInfo * compilation_info_at(int i)
static InterceptorInfo * cast(Object *obj)
uint32_t max_number_key()
bool IsFastDoubleElementsKind(ElementsKind kind)
void set_unused_property_fields(int value)
const uint32_t kStringEncodingMask
Name * GetKey(int descriptor_number)
void LookupDescriptor(JSObject *holder, Name *name, LookupResult *result)
Object * Lookup(FixedArray *key)
MUST_USE_RESULT MaybeObject * AtNumberPut(uint32_t key, Object *value)
const uint16_t * GetChars()
static MUST_USE_RESULT Handle< UnseededNumberDictionary > Set(Handle< UnseededNumberDictionary > dictionary, uint32_t index, Handle< Object > value)
static Handle< JSObject > DeepWalk(Handle< JSObject > object, AllocationSiteCreationContext *site_context)
void SetComponents(Object *getter, Object *setter)
Handle< SeededNumberDictionary > NewSeededNumberDictionary(int at_least_space_for)
static int ComputeCapacity(int at_least_space_for)
static void AddDependentCompilationInfo(Handle< AllocationSite > site, Reason reason, CompilationInfo *info)
int64_t ToLocal(int64_t time_ms)
IntrusivePrototypeTransitionIterator(HeapObject *proto_trans)
String * constructor_name()
virtual MUST_USE_RESULT MaybeObject * AsObject(Heap *heap)=0
MUST_USE_RESULT MaybeObject * AsObject(Heap *heap)
MUST_USE_RESULT MaybeObject * Update(Name *name, Code *code)
void set_requires_slow_elements()
static bool HasLocalProperty(Handle< JSReceiver >, Handle< Name > name)
static JSGlobalObject * cast(Object *obj)
void StartInobjectSlackTracking(Map *map)
static JSFunction * cast(Object *obj)