51 #ifdef ENABLE_DISASSEMBLER
60 MUST_USE_RESULT static MaybeObject* CreateJSValue(JSFunction* constructor,
63 { MaybeObject* maybe_result =
64 constructor->GetHeap()->AllocateJSObject(constructor);
65 if (!maybe_result->ToObject(&result))
return maybe_result;
74 return CreateJSValue(native_context->number_function(),
this);
75 }
else if (IsBoolean()) {
76 return CreateJSValue(native_context->boolean_function(),
this);
77 }
else if (IsString()) {
78 return CreateJSValue(native_context->string_function(),
this);
88 }
else if (IsNumber()) {
89 Isolate* isolate = Isolate::Current();
91 return CreateJSValue(native_context->number_function(),
this);
92 }
else if (IsBoolean()) {
95 return CreateJSValue(native_context->boolean_function(),
this);
96 }
else if (IsString()) {
99 return CreateJSValue(native_context->string_function(),
this);
108 if (IsTrue())
return this;
109 if (IsFalse())
return this;
114 if (heap_object->IsUndefined() || heap_object->IsNull()) {
115 return heap_object->
GetHeap()->false_value();
118 if (heap_object->IsUndetectableObject()) {
119 return heap_object->
GetHeap()->false_value();
121 if (heap_object->IsString()) {
125 if (heap_object->IsHeapNumber()) {
128 return heap_object->
GetHeap()->true_value();
134 if (IsJSReceiver()) {
139 holder = native_context->number_function()->instance_prototype();
140 }
else if (IsString()) {
141 holder = native_context->string_function()->instance_prototype();
142 }
else if (IsBoolean()) {
143 holder = native_context->boolean_function()->instance_prototype();
145 Isolate::Current()->PushStackTraceAndDie(
159 MaybeObject* value =
GetProperty(receiver, &result, name, attributes);
172 if (structure->IsForeign()) {
176 MaybeObject* value = (callback->
getter)(receiver, callback->
data);
182 if (structure->IsAccessorInfo()) {
192 return isolate->
Throw(*error);
194 Object* fun_obj = data->getter();
196 if (call_fun ==
NULL)
return isolate->
heap()->undefined_value();
200 LOG(isolate, ApiNamedPropertyAccess(
"load",
self, name));
206 VMState state(isolate, EXTERNAL);
210 if (result.IsEmpty()) {
211 return isolate->
heap()->undefined_value();
213 Object* return_value = *v8::Utils::OpenHandle(*result);
219 if (structure->IsAccessorPair()) {
221 if (getter->IsSpecFunction()) {
226 return isolate->
heap()->undefined_value();
243 "get", isolate->derived_get_trap(),
ARRAY_SIZE(args), args);
251 Isolate* isolate =
object->IsHeapObject()
253 : Isolate::Current();
262 if (!maybe->To<
String>(&name))
return maybe;
273 if (!maybe->To<
String>(&name))
return maybe;
281 if (!maybe->To<
String>(&name))
return maybe;
291 #ifdef ENABLE_DEBUGGER_SUPPORT
292 Debug* debug = fun->GetHeap()->isolate()->debug();
295 if (debug->StepInActive() && fun->IsJSFunction()) {
301 bool has_pending_exception;
313 LookupResult* result,
316 if (result->IsProperty()) {
317 switch (result->type()) {
320 Object* obj = result->GetCallbackObject();
321 if (obj->IsAccessorInfo()) {
324 *attributes = result->GetAttributes();
325 return result->holder()->GetPropertyWithCallback(
326 receiver, result->GetCallbackObject(), name);
336 result->holder()->LookupRealNamedPropertyInPrototypes(name, &r);
337 if (r.IsProperty()) {
349 result->holder()->LookupRealNamedProperty(name, &r);
350 if (r.IsProperty()) {
367 return heap->undefined_value();
373 LookupResult* result,
375 bool continue_search) {
376 if (result->IsProperty()) {
377 switch (result->type()) {
380 Object* obj = result->GetCallbackObject();
381 if (obj->IsAccessorInfo()) {
384 return result->GetAttributes();
393 if (!continue_search)
break;
396 result->holder()->LookupRealNamedPropertyInPrototypes(name, &r);
397 if (r.IsProperty()) {
410 if (continue_search) {
411 result->holder()->LookupRealNamedProperty(name, &r);
413 result->holder()->LocalLookupRealNamedProperty(name, &r);
415 if (!r.IsFound())
break;
437 if (IsGlobalObject()) {
440 ASSERT(!value->IsJSGlobalPropertyCell());
447 if (IsGlobalObject()) {
451 cell->set_value(value);
462 PropertyDetails details) {
464 object->SetNormalizedProperty(*key, *value, details),
471 PropertyDetails details) {
475 Object* store_value = value;
476 if (IsGlobalObject()) {
478 MaybeObject* maybe_store_value =
480 if (!maybe_store_value->ToObject(&store_value))
return maybe_store_value;
483 { MaybeObject* maybe_dict =
485 if (!maybe_dict->ToObject(&dict))
return maybe_dict;
492 int enumeration_index;
494 if (original_details.IsDeleted()) {
498 enumeration_index = original_details.dictionary_index();
499 ASSERT(enumeration_index > 0);
502 details = PropertyDetails(
503 details.attributes(), details.type(), enumeration_index);
505 if (IsGlobalObject()) {
508 cell->set_value(value);
524 if (IsGlobalObject()) {
525 PropertyDetails details = dictionary->
DetailsAt(entry);
526 if (details.IsDontDelete()) {
534 if (!maybe_new_map->To(&new_map))
return maybe_new_map;
541 cell->set_value(cell->
GetHeap()->the_hole_value());
545 if (deleted ==
GetHeap()->true_value()) {
547 MaybeObject* maybe_properties = dictionary->
Shrink(name);
548 if (!maybe_properties->To(&new_properties)) {
549 return maybe_properties;
551 set_properties(new_properties);
556 return GetHeap()->true_value();
562 if (!cons_obj->IsJSFunction())
565 if (!fun->shared()->IsApiFunction())
577 LookupResult* result,
580 Isolate* isolate =
object->IsHeapObject()
582 : Isolate::Current();
585 object->GetProperty(*receiver, result, *key, attributes),
591 LookupResult* result,
596 AssertNoContextChange ncc;
606 if (!result->IsHandler()) {
607 Object* last = result->IsProperty()
612 if (current->IsAccessCheckNeeded()) {
628 if (current == last)
break;
632 if (!result->IsProperty()) {
634 return heap->undefined_value();
636 *attributes = result->GetAttributes();
638 switch (result->type()) {
640 value = result->holder()->GetNormalizedProperty(result);
641 ASSERT(!value->IsTheHole() || result->IsReadOnly());
642 return value->IsTheHole() ? heap->undefined_value() : value;
644 value = result->holder()->FastPropertyAt(result->GetFieldIndex());
645 ASSERT(!value->IsTheHole() || result->IsReadOnly());
646 return value->IsTheHole() ? heap->undefined_value() : value;
648 return result->GetConstantFunction();
650 return result->holder()->GetPropertyWithCallback(
651 receiver, result->GetCallbackObject(), name);
653 return result->proxy()->GetPropertyWithHandler(receiver, name);
655 return result->holder()->GetPropertyWithInterceptor(
656 receiver, name, attributes);
669 ? Isolate::Current()->heap()
676 holder != heap->null_value();
678 if (!holder->IsJSObject()) {
681 if (holder->IsNumber()) {
682 holder = native_context->number_function()->instance_prototype();
683 }
else if (holder->IsString()) {
684 holder = native_context->string_function()->instance_prototype();
685 }
else if (holder->IsBoolean()) {
686 holder = native_context->boolean_function()->instance_prototype();
687 }
else if (holder->IsJSProxy()) {
691 ASSERT(holder->IsUndefined() || holder->IsNull());
692 return heap->undefined_value();
702 if (js_object->IsAccessCheckNeeded()) {
706 return heap->undefined_value();
714 if (js_object->elements() != heap->empty_fixed_array()) {
716 receiver, js_object, index);
717 if (result != heap->the_hole_value())
return result;
721 return heap->undefined_value();
727 Heap* heap = Isolate::Current()->heap();
729 return context->number_function()->instance_prototype();
736 if (heap_object->IsJSReceiver()) {
737 return heap_object->
map()->prototype();
742 if (heap_object->IsHeapNumber()) {
743 return context->number_function()->instance_prototype();
745 if (heap_object->IsString()) {
746 return context->string_function()->instance_prototype();
748 if (heap_object->IsBoolean()) {
749 return context->boolean_function()->instance_prototype();
751 return heap->null_value();
771 if (IsJSReceiver()) {
781 if (other ==
this)
return true;
785 if (IsNumber() && other->IsNumber()) {
786 double this_value =
Number();
787 double other_value = other->
Number();
788 return (this_value == other_value) ||
791 if (IsString() && other->IsString()) {
809 }
else if (IsFailure()) {
828 accumulator->
Add(
"Failure(%p)", reinterpret_cast<void*>(value()));
833 PrintF(out,
"Failure(%p)", reinterpret_cast<void*>(value()));
842 static bool AnWord(
String* str) {
843 if (str->
length() == 0)
return false;
844 int c0 = str->Get(0);
845 int c1 = str->
length() > 1 ? str->Get(1) : 0;
850 }
else if (c0 ==
'A' || c0 ==
'E' || c0 ==
'I' || c0 ==
'O') {
852 }
else if ((c1 == 0 || (c1 >=
'A' && c1 <=
'Z')) &&
853 (c0 ==
'F' || c0 ==
'H' || c0 ==
'M' || c0 ==
'N' || c0 ==
'R' ||
854 c0 ==
'S' || c0 ==
'X')) {
861 MaybeObject* String::SlowTryFlatten(
PretenureFlag pretenure) {
867 if (!
HEAP->IsAllocationAllowed())
return this;
871 switch (StringShape(
this).representation_tag()) {
874 if (cs->second()->length() == 0) {
885 { MaybeObject* maybe_object = heap->AllocateRawAsciiString(len, tenure);
886 if (!maybe_object->ToObject(&
object))
return maybe_object;
889 String* first = cs->first();
890 int first_length = first->length();
893 String* second = cs->second();
899 { MaybeObject* maybe_object =
900 heap->AllocateRawTwoByteString(len, tenure);
901 if (!maybe_object->ToObject(&
object))
return maybe_object;
905 String* first = cs->first();
906 int first_length = first->length();
908 String* second = cs->second();
914 cs->set_first(result);
927 ASSERT(!this->IsExternalString());
934 ASSERT(memcmp(smart_chars.start(),
936 resource->
length() *
sizeof(smart_chars[0])) == 0);
940 int size = this->
Size();
945 bool is_symbol = this->IsSymbol();
952 ? (is_ascii ? heap->external_symbol_with_ascii_data_map()
953 : heap->external_symbol_map())
954 : (is_ascii ? heap->external_string_with_ascii_data_map()
955 : heap->external_string_map()));
959 ? (is_ascii ? heap->short_external_symbol_with_ascii_data_map()
960 : heap->short_external_symbol_map())
961 : (is_ascii ? heap->short_external_string_with_ascii_data_map()
962 : heap->short_external_string_map()));
965 self->set_resource(resource);
966 if (is_symbol)
self->Hash();
969 int new_size = this->
Size();
986 ASSERT(memcmp(smart_chars.start(),
988 resource->
length() *
sizeof(smart_chars[0])) == 0);
992 int size = this->
Size();
996 bool is_symbol = this->IsSymbol();
1002 is_symbol ? heap->external_ascii_symbol_map()
1003 : heap->external_ascii_string_map());
1006 is_symbol ? heap->short_external_ascii_symbol_map()
1007 : heap->short_external_ascii_string_map());
1010 self->set_resource(resource);
1011 if (is_symbol)
self->Hash();
1014 int new_size = this->
Size();
1027 accumulator->
Add(
"<Very long string[%u]>", len);
1032 accumulator->
Add(
"<Invalid String>");
1038 bool truncated =
false;
1044 for (
int i = 0; i < len; i++) {
1047 if (c < 32 || c >= 127) {
1053 accumulator->
Add(
"<String[%u]: ",
length());
1054 for (
int i = 0; i < len; i++) {
1057 accumulator->
Put(
'>');
1061 accumulator->
Add(
"<String[%u]\\: ",
length());
1062 for (
int i = 0; i < len; i++) {
1065 accumulator->
Add(
"\\n");
1066 }
else if (c ==
'\r') {
1067 accumulator->
Add(
"\\r");
1068 }
else if (c ==
'\\') {
1069 accumulator->
Add(
"\\\\");
1070 }
else if (c < 32 || c > 126) {
1071 accumulator->
Add(
"\\x%02x", c);
1073 accumulator->
Put(c);
1077 accumulator->
Put(
'.');
1078 accumulator->
Put(
'.');
1079 accumulator->
Put(
'.');
1081 accumulator->
Put(
'>');
1088 switch (
map()->instance_type()) {
1090 double length =
JSArray::cast(
this)->length()->IsUndefined()
1093 accumulator->
Add(
"<JS Array[%u]>", static_cast<uint32_t>(length));
1097 accumulator->
Add(
"<JS WeakMap>");
1101 accumulator->
Add(
"<JS RegExp>");
1106 bool printed =
false;
1107 if (fun_name->IsString()) {
1110 accumulator->
Add(
"<JS Function ");
1111 accumulator->
Put(str);
1112 accumulator->
Put(
'>');
1117 accumulator->
Add(
"<JS Function>");
1124 Map* map_of_this =
map();
1126 Object* constructor = map_of_this->constructor();
1127 bool printed =
false;
1128 if (constructor->IsHeapObject() &&
1130 accumulator->
Add(
"!!!INVALID CONSTRUCTOR!!!");
1132 bool global_object = IsJSGlobalProxy();
1133 if (constructor->IsJSFunction()) {
1135 accumulator->
Add(
"!!!INVALID SHARED ON CONSTRUCTOR!!!");
1139 if (constructor_name->IsString()) {
1142 bool vowel = AnWord(str);
1143 accumulator->
Add(
"<%sa%s ",
1144 global_object ?
"Global Object: " :
"",
1146 accumulator->
Put(str);
1153 accumulator->
Add(
"<JS %sObject", global_object ?
"Global " :
"");
1157 accumulator->
Add(
" value = ");
1160 accumulator->
Put(
'>');
1170 if (from_kind != to_kind) {
1171 PrintF(file,
"elements transition [");
1191 accumulator->
Add(
"!!!INVALID POINTER!!!");
1195 accumulator->
Add(
"!!!INVALID MAP!!!");
1199 accumulator->
Add(
"%p ",
this);
1209 switch (
map()->instance_type()) {
1211 accumulator->
Add(
"<Map(elements=%u)>",
Map::cast(
this)->elements_kind());
1217 accumulator->
Add(
"<FixedDoubleArray[%u]>",
1227 accumulator->
Add(
"<ExternalPixelArray[%u]>",
1231 accumulator->
Add(
"<ExternalByteArray[%u]>",
1235 accumulator->
Add(
"<ExternalUnsignedByteArray[%u]>",
1239 accumulator->
Add(
"<ExternalShortArray[%u]>",
1243 accumulator->
Add(
"<ExternalUnsignedShortArray[%u]>",
1247 accumulator->
Add(
"<ExternalIntArray[%u]>",
1251 accumulator->
Add(
"<ExternalUnsignedIntArray[%u]>",
1255 accumulator->
Add(
"<ExternalFloatArray[%u]>",
1259 accumulator->
Add(
"<ExternalDoubleArray[%u]>",
1263 accumulator->
Add(
"<SharedFunctionInfo>");
1266 accumulator->
Add(
"<JSMessageObject>");
1268 #define MAKE_STRUCT_CASE(NAME, Name, name) \
1270 accumulator->Put('<'); \
1271 accumulator->Add(#Name); \
1272 accumulator->Put('>'); \
1275 #undef MAKE_STRUCT_CASE
1277 accumulator->
Add(
"<Code>");
1281 accumulator->
Add(
"<undefined>");
1282 else if (IsTheHole())
1283 accumulator->
Add(
"<the hole>");
1285 accumulator->
Add(
"<null>");
1287 accumulator->
Add(
"<true>");
1289 accumulator->
Add(
"<false>");
1291 accumulator->
Add(
"<Odd Oddball>");
1295 accumulator->
Add(
"<Number: ");
1297 accumulator->
Put(
'>');
1300 accumulator->
Add(
"<JSProxy>");
1303 accumulator->
Add(
"<JSFunctionProxy>");
1306 accumulator->
Add(
"<Foreign>");
1309 accumulator->
Add(
"Cell for ");
1313 accumulator->
Add(
"<Other heap object (%d)>",
map()->instance_type());
1345 ExternalAsciiStringIterateBody(v);
1348 ExternalTwoByteStringIterateBody(v);
1379 ->JSFunctionIterateBody(object_size, v);
1391 reinterpret_cast<Foreign*
>(
this)->ForeignIterateBody(v);
1397 reinterpret_cast<Code*
>(
this)->CodeIterateBody(v);
1421 #define MAKE_STRUCT_CASE(NAME, Name, name) \
1424 #undef MAKE_STRUCT_CASE
1428 PrintF(
"Unknown type: %d\n", type);
1436 #if __BYTE_ORDER == __LITTLE_ENDIAN
1438 #elif __BYTE_ORDER == __BIG_ENDIAN
1445 return GetHeap()->false_value();
1450 return GetHeap()->false_value();
1452 return GetHeap()->true_value();
1470 accumulator->
Add(
"%s", buffer.
start());
1475 if (IsJSFunction() && IsJSFunctionProxy()) {
1476 return GetHeap()->function_class_symbol();
1478 if (
map()->constructor()->IsJSFunction()) {
1480 return String::cast(constructor->shared()->instance_class_name());
1483 return GetHeap()->Object_symbol();
1488 if (
map()->constructor()->IsJSFunction()) {
1491 if (name->
length() > 0)
return name;
1492 String* inferred_name = constructor->shared()->inferred_name();
1493 if (inferred_name->
length() > 0)
return inferred_name;
1499 return GetHeap()->Object_symbol();
1507 if (
map()->unused_property_fields() == 0) {
1510 { MaybeObject* maybe_values =
1511 properties()->
CopySize(properties()->length() + new_unused + 1);
1512 if (!maybe_values->To(&values))
return maybe_values;
1514 set_properties(values);
1524 if (!buffer->
has_more())
return false;
1541 ASSERT(!IsJSGlobalProxy());
1544 name,
map()->NumberOfOwnDescriptors()));
1556 MaybeObject* maybe_obj =
1558 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
1569 ASSERT(index <
map()->inobject_properties() ||
1570 (index -
map()->inobject_properties()) < properties()->length() ||
1571 map()->unused_property_fields() == 0);
1575 if (
map()->unused_property_fields() == 0) {
1577 MaybeObject* maybe_values =
1578 properties()->CopySize(properties()->length() +
kFieldsAdded);
1579 if (!maybe_values->To(&values))
return maybe_values;
1589 if (!maybe_new_map->To(&new_map))
return maybe_new_map;
1593 set_properties(values);
1626 if (!maybe_new_map->To(&new_map))
return maybe_new_map;
1639 Object* store_value = value;
1640 if (IsGlobalObject()) {
1644 store_value = dict->
ValueAt(entry);
1649 PropertyDetails details = PropertyDetails(attributes,
NORMAL, index);
1651 dict->
SetEntry(entry, name, store_value, details);
1655 { MaybeObject* maybe_store_value =
1657 if (!maybe_store_value->ToObject(&store_value))
return maybe_store_value;
1661 PropertyDetails details = PropertyDetails(attributes,
NORMAL);
1663 { MaybeObject* maybe_result = dict->
Add(name, store_value, details);
1664 if (!maybe_result->ToObject(&result))
return maybe_result;
1677 ASSERT(!IsJSGlobalProxy());
1678 Map* map_of_this =
map();
1687 *
FACTORY->NewTypeError(
"object_not_extensible",
1695 if (value->IsJSFunction()) {
1706 { MaybeObject* maybe_obj =
1708 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
1726 if (result.IsFound()) {
1729 return SetProperty(&result, name, value, attributes, strict_mode);
1732 MaybeObject* result_object;
1734 SetPropertyViaPrototypes(name, value, attributes, strict_mode, &done);
1735 if (done)
return result_object;
1737 return AddProperty(name, value, attributes, strict_mode,
1746 int old_index = dictionary->
FindEntry(name);
1747 int new_enumeration_index = 0;
1748 if (old_index != -1) {
1750 new_enumeration_index = dictionary->
DetailsAt(old_index).dictionary_index();
1753 PropertyDetails new_details(attributes,
NORMAL, new_enumeration_index);
1759 int transition_index,
1767 MaybeObject* maybe_result =
1769 if (!maybe_result->To(&result))
return maybe_result;
1783 if (owned_descriptors ||
1784 old_target->instance_descriptors() == old_map->instance_descriptors()) {
1791 for (
Object* current = old_map;
1792 !current->IsUndefined();
1795 if (map->instance_descriptors() != old_descriptors)
break;
1797 map->set_instance_descriptors(new_descriptors);
1811 if (
map()->unused_property_fields() == 0 &&
1815 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
1826 if (!maybe_new_map->To(&new_map))
return maybe_new_map;
1831 if (
map()->unused_property_fields() == 0) {
1833 MaybeObject* maybe_new_properties =
1834 properties()->CopySize(properties()->length() +
kFieldsAdded);
1835 if (!maybe_new_properties->To(&new_properties))
return maybe_new_properties;
1842 if (new_properties !=
NULL) {
1843 set_properties(new_properties);
1861 if (!interceptor->setter()->IsUndefined()) {
1862 LOG(isolate, ApiNamedPropertyAccess(
"interceptor-named-set",
this, name));
1866 v8::ToCData<v8::NamedPropertySetter>(interceptor->setter());
1870 VMState state(isolate, EXTERNAL);
1872 isolate->
heap()->undefined_value() :
1880 if (!result.IsEmpty())
return *value_handle;
1882 MaybeObject* raw_result =
1883 this_handle->SetPropertyPostInterceptor(*name_handle,
1899 object->SetProperty(*key, *value, attributes, strict_mode),
1911 if (!result.IsFound()) {
1914 return SetProperty(&result, name, value, attributes, strict_mode, store_mode);
1928 ASSERT(!value->IsTheHole());
1934 if (structure->IsForeign()) {
1938 MaybeObject* obj = (callback->
setter)(
this, value, callback->
data);
1940 if (obj->IsFailure())
return obj;
1941 return *value_handle;
1944 if (structure->IsAccessorInfo()) {
1955 return isolate->
Throw(*error);
1957 Object* call_obj = data->setter();
1959 if (call_fun ==
NULL)
return value;
1961 LOG(isolate, ApiNamedPropertyAccess(
"store",
this, name));
1966 VMState state(isolate, EXTERNAL);
1972 return *value_handle;
1975 if (structure->IsAccessorPair()) {
1977 if (setter->IsSpecFunction()) {
1987 return isolate->
Throw(
2004 #ifdef ENABLE_DEBUGGER_SUPPORT
2005 Debug* debug = isolate->debug();
2008 if (debug->StepInActive() && fun->IsJSFunction()) {
2009 debug->HandleStepIn(
2013 bool has_pending_exception;
2018 return *value_handle;
2029 pt != heap->null_value();
2030 pt = pt->GetPrototype()) {
2031 if (pt->IsJSProxy()) {
2034 if (!maybe->To<
String>(&name)) {
2039 this, name, value,
NONE, strict_mode, found);
2046 int entry = dictionary->
FindEntry(index);
2048 PropertyDetails details = dictionary->
DetailsAt(entry);
2051 return SetElementWithCallback(dictionary->
ValueAt(entry),
2060 return heap->the_hole_value();
2063 MaybeObject* JSObject::SetPropertyViaPrototypes(
2076 LookupResult result(isolate);
2078 if (result.IsFound()) {
2079 switch (result.type()) {
2083 *done = result.IsReadOnly();
2087 result.holder()->GetPropertyAttributeWithInterceptor(
2093 if (!FLAG_es5_readonly && result.IsReadOnly())
break;
2096 name, value, result.holder(), strict_mode);
2099 return result.proxy()->SetPropertyViaPrototypesWithHandler(
2100 this, name, value, attributes, strict_mode, done);
2110 if (!FLAG_es5_readonly) *done =
false;
2113 Handle<Object> args[] = { Handle<Object>(name), Handle<Object>(
this)};
2117 return heap->the_hole_value();
2124 static void ZapEndOfFixedArray(
Address new_end,
int to_trim) {
2128 for (
int i = 1; i < to_trim; i++) {
2134 template<RightTrimMode trim_mode>
2135 static void RightTrimFixedArray(Heap* heap, FixedArray* elms,
int to_trim) {
2136 ASSERT(elms->map() !=
HEAP->fixed_cow_array_map());
2140 const int len = elms->length();
2147 ZapEndOfFixedArray(new_end, to_trim);
2155 heap->CreateFillerObjectAt(new_end, size_delta);
2157 elms->set_length(len - to_trim);
2172 if (slack <= descriptors->NumberOfSlackDescriptors())
return;
2173 int number_of_descriptors = descriptors->number_of_descriptors();
2174 Isolate* isolate = map->GetIsolate();
2179 for (
int i = 0; i < number_of_descriptors; ++i) {
2180 new_descriptors->CopyFrom(i, *descriptors, i, witness);
2183 map->set_instance_descriptors(*new_descriptors);
2189 Isolate* isolate = map->GetIsolate();
2192 int nof_callbacks = callbacks.length();
2194 ASSERT(array->NumberOfSlackDescriptors() >= nof_callbacks);
2199 for (
int i = 0; i < nof_callbacks; ++i) {
2204 entry->set_name(*key);
2207 int nof = map->NumberOfOwnDescriptors();
2212 for (
int i = nof_callbacks - 1; i >= 0; i--) {
2218 array->Append(&desc);
2223 map->SetNumberOfOwnDescriptors(nof);
2229 for (
int i = 0; i < maps->length(); ++i) {
2230 if (!maps->
at(i).is_null() && maps->
at(i).is_identical_to(map))
return true;
2237 static Handle<T> MaybeNull(
T* p) {
2239 return Handle<T>(p);
2252 MaybeNull(current_map->LookupElementsTransitionMap(kind));
2253 if (maybe_transitioned_map.
is_null())
break;
2254 if (ContainsMap(candidates, maybe_transitioned_map) &&
2256 transitioned_map = maybe_transitioned_map;
2259 current_map = maybe_transitioned_map;
2262 return transitioned_map;
2273 ASSERT(index <= to_index);
2275 for (; index < to_index; ++index) {
2281 if (next_map->elements_kind() == to_kind)
return next_map;
2291 Map* to_map = FindClosestElementsTransition(
this, to_kind);
2297 static MaybeObject* AddMissingElementsTransitions(
Map* map,
2305 ASSERT(index <= to_index);
2309 for (; index < to_index; ++index) {
2311 MaybeObject* maybe_next_map =
2313 if (!maybe_next_map->To(¤t_map))
return maybe_next_map;
2319 MaybeObject* maybe_next_map =
2321 if (!maybe_next_map->To(¤t_map))
return maybe_next_map;
2331 Isolate* isolate =
object->GetIsolate();
2333 object->GetElementsTransitionMap(isolate, to_kind),
2342 if (from_kind == to_kind) {
2346 bool allow_store_transition =
2351 !start_map->IsUndefined() && !start_map->
is_shared() &&
2356 allow_store_transition &=
2361 if (!allow_store_transition) {
2365 Map* closest_map = FindClosestElementsTransition(start_map, to_kind);
2371 return AddMissingElementsTransitions(closest_map, to_kind);
2376 LookupResult* result) {
2377 if (IsJSGlobalProxy()) {
2379 if (proto->IsNull())
return result->NotFound();
2380 ASSERT(proto->IsJSGlobalObject());
2390 ASSERT(!result->IsFound() ||
2391 (result->holder() ==
this && result->IsFastPropertyType()));
2394 if (result->IsField() &&
2395 result->IsReadOnly() &&
2397 result->DisallowCaching();
2405 if (IsGlobalObject()) {
2407 if (d.IsDeleted()) {
2415 if (value->IsTheHole()) result->DisallowCaching();
2416 result->DictionaryResult(
this, entry);
2426 if (result->IsFound())
return;
2433 LookupResult* result) {
2436 pt != heap->null_value();
2437 pt = pt->GetPrototype()) {
2438 if (pt->IsJSProxy()) {
2443 if (result->IsFound())
return;
2451 LookupResult* result,
2454 bool check_prototype,
2456 if (check_prototype && !result->IsProperty()) {
2460 if (result->IsProperty()) {
2461 if (!result->IsReadOnly()) {
2462 switch (result->type()) {
2464 Object* obj = result->GetCallbackObject();
2465 if (obj->IsAccessorInfo()) {
2482 if (r.IsProperty()) {
2502 return *value_handle;
2512 if (result->IsHandler()) {
2513 return result->proxy()->SetPropertyWithHandler(
2514 this, key, value, attributes, strict_mode);
2517 result, key, value, attributes, strict_mode, store_mode);
2530 "has", isolate->derived_has_trap(),
ARRAY_SIZE(args), args);
2533 return result->ToBoolean()->IsTrue();
2550 CallTrap(
"set", isolate->derived_set_trap(),
ARRAY_SIZE(args), args);
2577 if (result->IsUndefined()) {
2579 return GetHeap()->the_hole_value();
2583 bool has_pending_exception;
2587 ARRAY_SIZE(argv), argv, &has_pending_exception);
2596 ASSERT(configurable->IsTrue() || configurable->IsFalse());
2597 if (configurable->IsFalse()) {
2603 return isolate->
Throw(*error);
2605 ASSERT(configurable->IsTrue());
2612 ASSERT(hasWritable->IsTrue() || hasWritable->IsFalse());
2613 if (hasWritable->IsTrue()) {
2618 ASSERT(writable->IsTrue() || writable->IsFalse());
2619 *done = writable->IsFalse();
2620 if (!*done)
return GetHeap()->the_hole_value();
2625 return isolate->
Throw(*error);
2632 if (!setter->IsUndefined()) {
2634 return receiver->SetPropertyWithDefinedSetter(
2642 return isolate->
Throw(*error);
2658 Object* bool_result = result->ToBoolean();
2665 isolate->
Throw(*error);
2697 if (result->IsUndefined())
return ABSENT;
2699 bool has_pending_exception;
2703 ARRAY_SIZE(argv), argv, &has_pending_exception);
2704 if (has_pending_exception)
return NONE;
2717 if (configurable->IsFalse()) {
2723 isolate->
Throw(*error);
2727 int attributes =
NONE;
2728 if (enumerable->ToBoolean()->IsFalse()) attributes |=
DONT_ENUM;
2729 if (configurable->ToBoolean()->IsFalse()) attributes |=
DONT_DELETE;
2730 if (writable->ToBoolean()->IsFalse()) attributes |=
READ_ONLY;
2741 return GetPropertyAttributeWithHandler(receiver, *name);
2753 if (IsJSFunctionProxy()) {
2759 ASSERT(self->IsJSObject());
2763 if (maybe_hash->To<
Object>(&hash) && hash->IsSmi()) {
2781 if (trap->IsUndefined()) {
2786 isolate->
Throw(*error);
2800 object->GetIsolate(),
2801 object->AddFastPropertyUsingMap(*map));
2814 AssertNoContextChange ncc;
2819 if (!name_raw->IsSymbol() && name_raw->
length() <= 2) {
2821 { MaybeObject* maybe_symbol_version = heap->
LookupSymbol(name_raw);
2822 if (maybe_symbol_version->ToObject(&symbol_version)) {
2829 if (IsAccessCheckNeeded()) {
2832 result, name_raw, value_raw,
true, strict_mode);
2836 if (IsJSGlobalProxy()) {
2838 if (proto->IsNull())
return value_raw;
2839 ASSERT(proto->IsJSGlobalObject());
2841 result, name_raw, value_raw, attributes, strict_mode, store_mode);
2851 if (!result->IsProperty() && !
self->IsJSContextExtensionObject()) {
2853 MaybeObject* result_object =
self->SetPropertyViaPrototypes(
2854 *name, *value, attributes, strict_mode, &done);
2855 if (done)
return result_object;
2858 if (!result->IsFound()) {
2860 return self->AddProperty(
2861 *name, *value, attributes, strict_mode, store_mode);
2863 if (result->IsProperty() && result->IsReadOnly()) {
2875 switch (result->type()) {
2877 return self->SetNormalizedProperty(result, *value);
2879 return self->FastPropertyAtPut(result->GetFieldIndex(), *value);
2882 if (*value == result->GetConstantFunction())
return *value;
2884 attributes = result->GetAttributes();
2885 return self->ConvertDescriptorToField(*name, *value, attributes);
2887 Object* callback_object = result->GetCallbackObject();
2888 return self->SetPropertyWithCallback(callback_object,
2895 return self->SetPropertyWithInterceptor(*name,
2900 Map* transition_map = result->GetTransitionTarget();
2901 int descriptor = transition_map->
LastAdded();
2903 DescriptorArray* descriptors = transition_map->instance_descriptors();
2904 PropertyDetails details = descriptors->
GetDetails(descriptor);
2906 if (details.type() ==
FIELD) {
2907 if (attributes == details.attributes()) {
2909 return self->AddFastPropertyUsingMap(transition_map,
2914 return self->ConvertDescriptorToField(*name, *value, attributes);
2915 }
else if (details.type() ==
CALLBACKS) {
2924 if (constant_function == *value) {
2925 self->set_map(transition_map);
2926 return constant_function;
2931 result->GetTransitionIndex(), *name, *value, attributes);
2958 object->GetIsolate(),
2959 object->SetLocalPropertyIgnoreAttributes(*key, *value, attributes),
2970 AssertNoContextChange ncc;
2972 LookupResult result(isolate);
2976 if (IsAccessCheckNeeded()) {
2986 if (IsJSGlobalProxy()) {
2988 if (proto->IsNull())
return value;
2989 ASSERT(proto->IsJSGlobalObject());
2997 if (!result.IsFound()) {
3003 switch (result.type()) {
3005 PropertyDetails details = PropertyDetails(attributes,
NORMAL);
3012 if (value == result.GetConstantFunction())
return value;
3014 attributes = result.GetAttributes();
3021 Map* transition_map = result.GetTransitionTarget();
3022 int descriptor = transition_map->
LastAdded();
3024 DescriptorArray* descriptors = transition_map->instance_descriptors();
3025 PropertyDetails details = descriptors->
GetDetails(descriptor);
3027 if (details.type() ==
FIELD) {
3028 if (attributes == details.attributes()) {
3036 }
else if (details.type() ==
CALLBACKS) {
3045 result.GetTransitionIndex(), name, value, attributes);
3059 bool continue_search) {
3063 if (result.IsFound())
return result.GetAttributes();
3065 if (continue_search) {
3068 if (!pt->IsNull()) {
3080 bool continue_search) {
3085 AssertNoContextChange ncc;
3094 if (!interceptor->query()->IsUndefined()) {
3096 v8::ToCData<v8::NamedPropertyQuery>(interceptor->query());
3098 ApiNamedPropertyAccess(
"interceptor-named-has", *holder_handle, name));
3102 VMState state(isolate, EXTERNAL);
3109 }
else if (!interceptor->getter()->IsUndefined()) {
3111 v8::ToCData<v8::NamedPropertyGetter>(interceptor->getter());
3113 ApiNamedPropertyAccess(
"interceptor-named-get-has",
this, name));
3117 VMState state(isolate, EXTERNAL);
3122 return holder_handle->GetPropertyAttributePostInterceptor(*receiver_handle,
3144 LookupResult* result,
3146 bool continue_search) {
3148 if (IsAccessCheckNeeded()) {
3153 receiver, result, name, continue_search);
3156 if (result->IsFound()) {
3157 switch (result->type()) {
3162 return result->GetAttributes();
3164 return JSProxy::cast(result->proxy())->GetPropertyAttributeWithHandler(
3168 return result->holder()->GetPropertyAttributeWithInterceptor(
3197 int index = fast->
Hash() % kEntries;
3198 Object* result =
get(index);
3199 if (result->IsMap() &&
3202 if (FLAG_verify_heap) {
3212 MaybeObject* maybe_fresh =
3214 if (maybe_fresh->ToObject(&fresh)) {
3228 { MaybeObject* maybe_result =
3230 if (!maybe_result->ToObject(&result))
return maybe_result;
3234 isolate->
counters()->normalized_maps()->Increment();
3241 int entries = length();
3242 for (
int i = 0; i != entries; i++) {
3251 Isolate* isolate =
object->GetIsolate();
3253 object->UpdateMapCodeCache(*name, *code));
3258 if (
map()->is_shared()) {
3265 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
3277 int expected_additional_properties) {
3279 object->NormalizeProperties(
3280 mode, expected_additional_properties));
3285 int expected_additional_properties) {
3289 ASSERT(!IsGlobalObject());
3291 ASSERT(!IsJSGlobalProxy());
3293 Map* map_of_this =
map();
3297 int property_count = real_size;
3298 if (expected_additional_properties > 0) {
3299 property_count += expected_additional_properties;
3301 property_count += 2;
3305 if (!maybe_dictionary->To(&dictionary))
return maybe_dictionary;
3308 for (
int i = 0; i < real_size; i++) {
3309 PropertyDetails details = descs->
GetDetails(i);
3310 switch (details.type()) {
3312 PropertyDetails d = PropertyDetails(details.attributes(),
3314 details.descriptor_index());
3316 MaybeObject* maybe_dictionary =
3317 dictionary->
Add(descs->
GetKey(i), value, d);
3318 if (!maybe_dictionary->To(&dictionary))
return maybe_dictionary;
3322 PropertyDetails d = PropertyDetails(details.attributes(),
3324 details.descriptor_index());
3326 MaybeObject* maybe_dictionary =
3327 dictionary->
Add(descs->
GetKey(i), value, d);
3328 if (!maybe_dictionary->To(&dictionary))
return maybe_dictionary;
3333 details = details.set_pointer(0);
3334 MaybeObject* maybe_dictionary =
3335 dictionary->
Add(descs->
GetKey(i), value, details);
3336 if (!maybe_dictionary->To(&dictionary))
return maybe_dictionary;
3356 MaybeObject* maybe_map =
3358 normalized_map_cache()->Get(
this, mode);
3359 if (!maybe_map->To(&new_map))
return maybe_map;
3367 int instance_size_delta = map_of_this->
instance_size() - new_instance_size;
3368 ASSERT(instance_size_delta >= 0);
3370 instance_size_delta);
3373 -instance_size_delta);
3378 set_properties(dictionary);
3380 current_heap->
isolate()->
counters()->props_to_dictionary()->Increment();
3383 if (FLAG_trace_normalization) {
3384 PrintF(
"Object properties have been normalized:\n");
3393 int unused_property_fields) {
3395 object->GetIsolate(),
3396 object->TransformToFastProperties(unused_property_fields));
3402 ASSERT(!IsGlobalObject());
3404 TransformPropertiesToFastFor(
this, unused_property_fields);
3411 object->NormalizeElements(),
3421 Map* old_map = array->
map();
3423 (old_map == old_map->
GetHeap()->non_strict_arguments_elements_map());
3427 if (array->IsDictionary())
return array;
3433 int length = IsJSArray()
3436 int old_capacity = 0;
3437 int used_elements = 0;
3438 GetElementsCapacityAndUsage(&old_capacity, &used_elements);
3442 if (!maybe->ToObject(&
object))
return maybe;
3447 bool has_double_elements = array->IsFixedDoubleArray();
3448 for (
int i = 0; i < length; i++) {
3450 if (has_double_elements) {
3459 MaybeObject* maybe_value_object =
3461 if (!maybe_value_object->ToObject(&value))
return maybe_value_object;
3467 PropertyDetails details = PropertyDetails(
NONE,
NORMAL);
3468 if (!value->IsTheHole()) {
3470 MaybeObject* maybe_result =
3472 if (!maybe_result->ToObject(&result))
return maybe_result;
3486 if (!maybe->ToObject(&new_map))
return maybe;
3488 set_elements(dictionary);
3495 if (FLAG_trace_normalization) {
3496 PrintF(
"Object elements have been normalized:\n");
3516 }
while (hash_value == 0 && attempts < 30);
3517 hash_value = hash_value != 0 ? hash_value : 1;
3526 if (maybe->IsFailure())
return maybe;
3541 if (stored_value->IsSmi())
return stored_value;
3549 if (result->IsFailure())
return result;
3550 if (result->ToObjectUnchecked()->IsUndefined()) {
3559 Object* hash = this->hash();
3570 if (IsJSGlobalProxy()) {
3574 if (proxy_parent->IsNull())
return GetHeap()->undefined_value();
3575 ASSERT(proxy_parent->IsJSGlobalObject());
3578 ASSERT(!IsJSGlobalProxy());
3579 MaybeObject* hidden_lookup =
3580 GetHiddenPropertiesHashTable(ONLY_RETURN_INLINE_VALUE);
3581 Object* inline_value = hidden_lookup->ToObjectUnchecked();
3583 if (inline_value->IsSmi()) {
3585 if (key ==
GetHeap()->identity_hash_symbol()) {
3586 return inline_value;
3588 return GetHeap()->undefined_value();
3592 if (inline_value->IsUndefined())
return GetHeap()->undefined_value();
3596 if (entry->IsTheHole())
return GetHeap()->undefined_value();
3605 obj->SetHiddenProperty(*key, *value),
3612 if (IsJSGlobalProxy()) {
3616 if (proxy_parent->IsNull())
return GetHeap()->undefined_value();
3617 ASSERT(proxy_parent->IsJSGlobalObject());
3620 ASSERT(!IsJSGlobalProxy());
3621 MaybeObject* hidden_lookup =
3622 GetHiddenPropertiesHashTable(ONLY_RETURN_INLINE_VALUE);
3623 Object* inline_value = hidden_lookup->ToObjectUnchecked();
3626 if (value->IsSmi() &&
3627 key ==
GetHeap()->identity_hash_symbol() &&
3628 (inline_value->IsUndefined() || inline_value->IsSmi())) {
3629 return SetHiddenPropertiesHashTable(value);
3632 hidden_lookup = GetHiddenPropertiesHashTable(CREATE_NEW_IF_ABSENT);
3634 if (!hidden_lookup->To(&hashtable))
return hidden_lookup;
3637 MaybeObject* insert_result = hashtable->
Put(key, value);
3639 if (!insert_result->To(&new_table))
return insert_result;
3640 if (new_table != hashtable) {
3643 MaybeObject* store_result = SetHiddenPropertiesHashTable(new_table);
3644 if (store_result->IsFailure())
return store_result;
3653 if (IsJSGlobalProxy()) {
3657 if (proxy_parent->IsNull())
return;
3658 ASSERT(proxy_parent->IsJSGlobalObject());
3662 ASSERT(!IsJSGlobalProxy());
3663 MaybeObject* hidden_lookup =
3664 GetHiddenPropertiesHashTable(ONLY_RETURN_INLINE_VALUE);
3665 Object* inline_value = hidden_lookup->ToObjectUnchecked();
3669 if (inline_value->IsUndefined() || inline_value->IsSmi())
return;
3672 MaybeObject* delete_result = hashtable->
Put(key,
GetHeap()->the_hole_value());
3674 ASSERT(!delete_result->IsFailure());
3685 MaybeObject* JSObject::GetHiddenPropertiesHashTable(
3686 InitializeHiddenProperties init_option) {
3687 ASSERT(!IsJSGlobalProxy());
3703 inline_value =
GetHeap()->undefined_value();
3706 inline_value =
GetHeap()->undefined_value();
3716 &attributes)->ToObjectUnchecked();
3719 if (init_option == ONLY_RETURN_INLINE_VALUE ||
3720 inline_value->IsHashTable()) {
3721 return inline_value;
3724 ObjectHashTable* hashtable;
3725 static const int kInitialCapacity = 4;
3726 MaybeObject* maybe_obj =
3729 if (!maybe_obj->To<ObjectHashTable>(&hashtable))
return maybe_obj;
3731 if (inline_value->IsSmi()) {
3734 MaybeObject* insert_result =
3735 hashtable->Put(
GetHeap()->identity_hash_symbol(), inline_value);
3736 ObjectHashTable* new_table;
3737 if (!insert_result->To(&new_table))
return insert_result;
3742 MaybeObject* store_result =
3748 if (store_result->IsFailure())
return store_result;
3753 MaybeObject* JSObject::SetHiddenPropertiesHashTable(
Object* value) {
3754 ASSERT(!IsJSGlobalProxy());
3763 DescriptorArray* descriptors = this->
map()->instance_descriptors();
3764 if (descriptors->number_of_descriptors() > 0) {
3765 int sorted_index = descriptors->GetSortedKeyIndex(0);
3768 ASSERT(descriptors->GetType(sorted_index) ==
FIELD);
3775 MaybeObject* store_result =
3781 if (store_result->IsFailure())
return store_result;
3786 MaybeObject* JSObject::DeletePropertyPostInterceptor(String* name,
3791 if (!result.IsFound())
return GetHeap()->true_value();
3796 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
3803 MaybeObject* JSObject::DeletePropertyWithInterceptor(String* name) {
3805 HandleScope scope(isolate);
3807 Handle<String> name_handle(name);
3808 Handle<JSObject> this_handle(
this);
3809 if (!interceptor->deleter()->IsUndefined()) {
3811 v8::ToCData<v8::NamedPropertyDeleter>(interceptor->deleter());
3813 ApiNamedPropertyAccess(
"interceptor-named-delete", *this_handle, name));
3814 CustomArguments args(isolate, interceptor->data(),
this,
this);
3819 VMState state(isolate, EXTERNAL);
3823 if (!result.IsEmpty()) {
3824 ASSERT(result->IsBoolean());
3825 Handle<Object> result_internal = v8::Utils::OpenHandle(*result);
3826 result_internal->VerifyApiCallResultType();
3827 return *result_internal;
3830 MaybeObject* raw_result =
3831 this_handle->DeletePropertyPostInterceptor(*name_handle,
NORMAL_DELETION);
3837 MaybeObject* JSObject::DeleteElementWithInterceptor(uint32_t index) {
3839 Heap* heap = isolate->heap();
3842 AssertNoContextChange ncc;
3843 HandleScope scope(isolate);
3845 if (interceptor->deleter()->IsUndefined())
return heap->false_value();
3847 v8::ToCData<v8::IndexedPropertyDeleter>(interceptor->deleter());
3848 Handle<JSObject> this_handle(
this);
3850 ApiIndexedPropertyAccess(
"interceptor-indexed-delete",
this, index));
3851 CustomArguments args(isolate, interceptor->data(),
this,
this);
3856 VMState state(isolate, EXTERNAL);
3857 result = deleter(index, info);
3860 if (!result.IsEmpty()) {
3861 ASSERT(result->IsBoolean());
3862 Handle<Object> result_internal = v8::Utils::OpenHandle(*result);
3863 result_internal->VerifyApiCallResultType();
3864 return *result_internal;
3866 MaybeObject* raw_result = this_handle->GetElementsAccessor()->Delete(
3886 if (IsAccessCheckNeeded() &&
3889 return isolate->
heap()->false_value();
3902 return isolate->
Throw(*error);
3904 return isolate->
heap()->false_value();
3907 if (IsJSGlobalProxy()) {
3909 if (proto->IsNull())
return isolate->
heap()->false_value();
3910 ASSERT(proto->IsJSGlobalObject());
3917 return DeleteElementWithInterceptor(index);
3937 ASSERT(name->IsString());
3940 if (IsAccessCheckNeeded() &&
3943 return isolate->
heap()->false_value();
3946 if (IsJSGlobalProxy()) {
3948 if (proto->IsNull())
return isolate->
heap()->false_value();
3949 ASSERT(proto->IsJSGlobalObject());
3957 LookupResult result(isolate);
3959 if (!result.IsFound())
return isolate->
heap()->true_value();
3969 return isolate->
heap()->false_value();
3972 if (result.IsInterceptor()) {
3975 return DeletePropertyPostInterceptor(name, mode);
3977 return DeletePropertyWithInterceptor(name);
3981 { MaybeObject* maybe_obj =
3983 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
4007 bool JSObject::ReferencesObjectFromElements(
FixedArray* elements,
4013 int length = IsJSArray()
4016 for (
int i = 0; i < length; ++i) {
4018 if (!element->IsTheHole() && element == object)
return true;
4023 if (!key->IsUndefined())
return true;
4031 Map* map_of_this =
map();
4036 if (map_of_this->constructor() == obj) {
4041 if (map_of_this->prototype() == obj) {
4047 if (!key->IsUndefined()) {
4075 if (ReferencesObjectFromElements(elements, kind, obj))
return true;
4081 int length = parameter_map->
length();
4082 for (
int i = 2; i < length; ++i) {
4084 if (!value->IsTheHole() && value == obj)
return true;
4090 if (ReferencesObjectFromElements(arguments, kind, obj))
return true;
4096 if (IsJSFunction()) {
4100 arguments_boilerplate();
4106 Context* context = f->context();
4107 if (context->IsNativeContext()) {
4114 if (context->
get(i)->IsJSObject()) {
4117 if (ctxobj->
map()->constructor() == arguments_function) {
4121 }
else if (ctxobj == obj) {
4145 if (IsAccessCheckNeeded() &&
4147 isolate->
heap()->undefined_value(),
4150 return isolate->
heap()->false_value();
4153 if (IsJSGlobalProxy()) {
4155 if (proto->IsNull())
return this;
4156 ASSERT(proto->IsJSGlobalObject());
4166 "cant_prevent_ext_external_array_elements",
4168 return isolate->
Throw(*error);
4183 MaybeObject* maybe =
map()->
Copy();
4184 if (!maybe->To(&new_map))
return maybe;
4201 o != heap->null_value();
4203 if (!o->IsJSObject())
return false;
4209 ASSERT(!curr->IsAccessCheckNeeded());
4211 if (curr !=
this && enum_length != 0)
return false;
4223 : NumberOfOwnDescriptors();
4224 for (
int i = 0; i < limit; i++) {
4225 if ((descs->
GetDetails(i).attributes() & filter) == 0) result++;
4233 int limit = NumberOfOwnDescriptors();
4234 for (
int i = 0; i < limit; i++) {
4243 int number_of_own_descriptors = NumberOfOwnDescriptors();
4245 for (
int i = 0; i < number_of_own_descriptors; i++) {
4248 if (current_index > max_index) max_index = current_index;
4251 return max_index + 1;
4257 int number_of_own_descriptors = NumberOfOwnDescriptors();
4258 for (
int i = 0; i < number_of_own_descriptors; i++) {
4268 ASSERT(name->IsString());
4272 if (IsJSGlobalProxy()) {
4274 if (proto->IsNull())
return result->NotFound();
4275 ASSERT(proto->IsJSGlobalObject());
4286 if (IsAccessCheckNeeded()) {
4287 result->DisallowCaching();
4293 if (name->
Equals(heap->Proto_symbol()) && !IsJSContextExtensionObject()) {
4294 result->ConstantResult(js_object);
4300 !heap->isolate()->bootstrapper()->IsActive()) {
4301 result->InterceptorResult(js_object);
4312 for (
Object* current =
this;
4313 current != heap->null_value();
4316 if (result->IsFound())
return;
4325 for (
Object* current =
this;
4326 current != heap->null_value() && current->IsJSObject();
4329 if (result->IsPropertyCallbacks())
return;
4337 static bool UpdateGetterSetterInDictionary(
4343 int entry = dictionary->
FindEntry(index);
4346 PropertyDetails details = dictionary->
DetailsAt(entry);
4347 if (details.type() ==
CALLBACKS && result->IsAccessorPair()) {
4348 ASSERT(!details.IsDontDelete());
4349 if (details.attributes() != attributes) {
4351 PropertyDetails(attributes,
CALLBACKS, index));
4361 MaybeObject* JSObject::DefineElementAccessor(uint32_t index,
4383 return GetHeap()->undefined_value();
4390 return GetHeap()->undefined_value();
4398 uint32_t length = parameter_map->length();
4400 index < (length - 2) ? parameter_map->get(index + 2) :
NULL;
4401 if (probe ==
NULL || probe->IsTheHole()) {
4403 if (arguments->IsDictionary()) {
4404 SeededNumberDictionary* dictionary =
4406 if (UpdateGetterSetterInDictionary(dictionary,
4411 return GetHeap()->undefined_value();
4419 AccessorPair* accessors;
4421 if (!maybe_accessors->To(&accessors))
return maybe_accessors;
4423 accessors->SetComponents(getter, setter);
4425 return SetElementCallback(index, accessors, attributes);
4429 MaybeObject* JSObject::CreateAccessorPairFor(String* name) {
4430 LookupResult result(
GetHeap()->isolate());
4432 if (result.IsPropertyCallbacks()) {
4439 Object* obj = result.GetCallbackObject();
4440 if (obj->IsAccessorPair()) {
4448 MaybeObject* JSObject::DefinePropertyAccessor(String* name,
4455 bool only_attribute_changes = getter->IsNull() && setter->IsNull();
4457 MaybeObject* getterOk = heap->undefined_value();
4458 if (!getter->IsNull()) {
4460 if (getterOk->IsFailure())
return getterOk;
4463 MaybeObject* setterOk = heap->undefined_value();
4464 if (getterOk != heap->null_value() && !setter->IsNull()) {
4466 if (setterOk->IsFailure())
return setterOk;
4469 if (getterOk != heap->null_value() && setterOk != heap->null_value()) {
4470 return heap->undefined_value();
4474 AccessorPair* accessors;
4475 MaybeObject* maybe_accessors = CreateAccessorPairFor(name);
4476 if (!maybe_accessors->To(&accessors))
return maybe_accessors;
4478 accessors->SetComponents(getter, setter);
4479 return SetPropertyCallback(name, accessors, attributes);
4483 bool JSObject::CanSetCallback(String* name) {
4484 ASSERT(!IsAccessCheckNeeded() ||
4495 if (callback_result.IsFound()) {
4496 Object* obj = callback_result.GetCallbackObject();
4497 if (obj->IsAccessorInfo() &&
4507 MaybeObject* JSObject::SetElementCallback(uint32_t index,
4510 PropertyDetails details = PropertyDetails(attributes,
CALLBACKS);
4513 SeededNumberDictionary* dictionary;
4515 if (!maybe_dictionary->To(&dictionary))
return maybe_dictionary;
4520 { MaybeObject* maybe_dictionary = dictionary->Set(index, structure, details);
4521 if (!maybe_dictionary->To(&dictionary))
return maybe_dictionary;
4524 dictionary->set_requires_slow_elements();
4526 if (elements()->
map() ==
GetHeap()->non_strict_arguments_elements_map()) {
4533 if (index < static_cast<uint32_t>(parameter_map->length()) - 2) {
4534 parameter_map->set(index + 2,
GetHeap()->the_hole_value());
4536 parameter_map->set(1, dictionary);
4538 set_elements(dictionary);
4541 return GetHeap()->undefined_value();
4545 MaybeObject* JSObject::SetPropertyCallback(String* name,
4550 if (maybe_ok->IsFailure())
return maybe_ok;
4554 if (IsGlobalObject()) {
4557 if (!maybe_new_map->To(&new_map))
return maybe_new_map;
4558 ASSERT(new_map->is_dictionary_map());
4568 PropertyDetails details = PropertyDetails(attributes,
CALLBACKS);
4570 if (maybe_ok->IsFailure())
return maybe_ok;
4572 return GetHeap()->undefined_value();
4582 object->GetIsolate(),
4583 object->DefineAccessor(*name, *getter, *setter, attributes));
4592 if (IsAccessCheckNeeded() &&
4595 return isolate->
heap()->undefined_value();
4598 if (IsJSGlobalProxy()) {
4600 if (proto->IsNull())
return this;
4601 ASSERT(proto->IsJSGlobalObject());
4603 name, getter, setter, attributes);
4608 AssertNoContextChange ncc;
4613 if (!CanSetCallback(name))
return isolate->
heap()->undefined_value();
4617 DefineElementAccessor(index, getter, setter, attributes) :
4618 DefinePropertyAccessor(name, getter, setter, attributes);
4622 static MaybeObject* TryAccessorTransition(
JSObject*
self,
4623 Map* transitioned_map,
4624 int target_descriptor,
4629 PropertyDetails details = descs->
GetDetails(target_descriptor);
4632 if (details.type() !=
CALLBACKS)
return self->GetHeap()->null_value();
4634 if (!descriptor->IsAccessorPair())
return self->GetHeap()->null_value();
4640 if (target_accessor == accessor && target_attributes == attributes) {
4641 self->set_map(transitioned_map);
4647 return self->GetHeap()->null_value();
4655 ASSERT(accessor->IsSpecFunction() || accessor->IsUndefined());
4659 if (result.IsFound()
4660 && !result.IsPropertyCallbacks()
4661 && !result.IsTransition())
return GetHeap()->null_value();
4665 if (result.IsPropertyCallbacks()) {
4666 Object* callback_value = result.GetCallbackObject();
4667 if (callback_value->IsAccessorPair()) {
4669 Object* entry = source_accessors->
get(component);
4670 if (entry == accessor && result.GetAttributes() == attributes) {
4674 return GetHeap()->null_value();
4677 int descriptor_number = result.GetDescriptorIndex();
4681 if (result.IsFound()) {
4682 Map* target = result.GetTransitionTarget();
4686 ASSERT(
map()->instance_descriptors()->GetKey(descriptor_number) == name);
4687 return TryAccessorTransition(
4688 this, target, descriptor_number, component, accessor, attributes);
4695 if (result.IsFound()) {
4696 Map* target = result.GetTransitionTarget();
4697 int descriptor_number = target->
LastAdded();
4698 ASSERT(target->instance_descriptors()->GetKey(descriptor_number) == name);
4699 return TryAccessorTransition(
4700 this, target, descriptor_number, component, accessor, attributes);
4707 MaybeObject* maybe_accessors;
4711 if (source_accessors !=
NULL) {
4712 maybe_accessors = source_accessors->
Copy();
4716 if (!maybe_accessors->To(&accessors))
return maybe_accessors;
4717 accessors->
set(component, accessor);
4722 MaybeObject* maybe_new_map =
4724 if (!maybe_new_map->To(&new_map))
return maybe_new_map;
4735 if (IsAccessCheckNeeded() &&
4738 return isolate->
heap()->undefined_value();
4741 if (IsJSGlobalProxy()) {
4743 if (proto->IsNull())
return this;
4744 ASSERT(proto->IsJSGlobalObject());
4750 AssertNoContextChange ncc;
4755 if (!CanSetCallback(name))
return isolate->
heap()->undefined_value();
4761 if (IsJSArray())
return isolate->
heap()->undefined_value();
4783 return isolate->
heap()->undefined_value();
4791 MaybeObject* maybe_ok =
4793 if (maybe_ok->IsFailure())
return maybe_ok;
4796 LookupResult result(isolate);
4800 if (result.IsFound() && (result.IsReadOnly() || result.IsDontDelete())) {
4801 return isolate->
heap()->undefined_value();
4804 MaybeObject* maybe_ok =
4806 if (maybe_ok->IsFailure())
return maybe_ok;
4818 AssertNoContextChange ncc;
4821 if (IsAccessCheckNeeded() &&
4824 return heap->undefined_value();
4831 obj != heap->null_value();
4836 int entry = dictionary->
FindEntry(index);
4840 element->IsAccessorPair()) {
4848 obj != heap->null_value();
4850 LookupResult result(heap->
isolate());
4852 if (result.IsFound()) {
4853 if (result.IsReadOnly())
return heap->undefined_value();
4854 if (result.IsPropertyCallbacks()) {
4855 Object* obj = result.GetCallbackObject();
4856 if (obj->IsAccessorPair()) {
4863 return heap->undefined_value();
4871 for (
int i = 0; i < number_of_own_descriptors; i++) {
4882 return GetHeap()->undefined_value();
4891 MaybeObject* maybe_result =
4893 if (!maybe_result->To(&result))
return maybe_result;
4895 result->set_prototype(prototype());
4896 result->set_constructor(constructor());
4900 int new_bit_field3 = bit_field3();
4901 new_bit_field3 = OwnsDescriptors::update(new_bit_field3,
true);
4902 new_bit_field3 = NumberOfOwnDescriptorsBits::update(new_bit_field3, 0);
4903 new_bit_field3 = EnumLengthBits::update(new_bit_field3, kInvalidEnumCache);
4911 int new_instance_size = instance_size();
4913 new_instance_size -= inobject_properties() *
kPointerSize;
4917 MaybeObject* maybe_result = RawCopy(new_instance_size);
4918 if (!maybe_result->To(&result))
return maybe_result;
4924 result->set_code_cache(code_cache());
4929 if (FLAG_verify_heap && result->
is_shared()) {
4930 result->SharedMapVerify();
4940 MaybeObject* maybe_result = RawCopy(instance_size());
4941 if (!maybe_result->To(&result))
return maybe_result;
4955 Descriptor* descriptor) {
4959 ASSERT(NumberOfOwnDescriptors() ==
4960 instance_descriptors()->number_of_descriptors());
4962 MaybeObject* maybe_result = CopyDropDescriptors();
4963 if (!maybe_result->To(&result))
return maybe_result;
4965 String* name = descriptor->GetKey();
4968 MaybeObject* maybe_transitions =
4970 if (!maybe_transitions->To(&transitions))
return maybe_transitions;
4977 new_descriptors = descriptors;
4978 new_descriptors->
Append(descriptor);
4982 old_size, old_size < 4 ? 1 : old_size / 2);
4983 if (!maybe_descriptors->To(&new_descriptors))
return maybe_descriptors;
4988 for (
int i = 0; i < old_size; ++i) {
4989 new_descriptors->
CopyFrom(i, descriptors, i, witness);
4992 new_descriptors->
Append(descriptor, witness);
5006 for (
Object* current = GetBackPointer();
5007 !current->IsUndefined();
5010 if (map->instance_descriptors() != descriptors)
break;
5011 map->set_instance_descriptors(new_descriptors);
5014 set_instance_descriptors(new_descriptors);
5022 set_transitions(transitions);
5023 set_owns_descriptors(
false);
5032 int descriptor_index) {
5033 ASSERT(descriptors->IsSortedNoDuplicates());
5036 MaybeObject* maybe_result = CopyDropDescriptors();
5037 if (!maybe_result->To(&result))
return maybe_result;
5039 result->InitializeDescriptors(descriptors);
5047 MaybeObject* maybe_transitions = AddTransition(name, result, simple_flag);
5048 if (!maybe_transitions->To(&transitions))
return maybe_transitions;
5050 set_transitions(transitions);
5051 result->SetBackPointer(
this);
5060 ASSERT(!HasElementsTransition() ||
5063 elements_transition_map()->elements_kind())) &&
5068 ASSERT(kind != elements_kind());
5071 bool insert_transition =
5074 if (insert_transition && owns_descriptors()) {
5078 MaybeObject* maybe_new_map = CopyDropDescriptors();
5079 if (!maybe_new_map->To(&new_map))
return maybe_new_map;
5081 MaybeObject* added_elements = set_elements_transition_map(new_map);
5082 if (added_elements->IsFailure())
return added_elements;
5087 set_owns_descriptors(
false);
5095 MaybeObject* maybe_new_map =
Copy();
5096 if (!maybe_new_map->To(&new_map))
return maybe_new_map;
5100 if (insert_transition) {
5101 MaybeObject* added_elements = set_elements_transition_map(new_map);
5102 if (added_elements->IsFailure())
return added_elements;
5111 if (pre_allocated_property_fields() == 0)
return CopyDropDescriptors();
5115 ASSERT(constructor()->IsJSFunction());
5122 MaybeObject* maybe_descriptors =
5123 descriptors->
CopyUpTo(number_of_own_descriptors);
5124 if (!maybe_descriptors->To(&new_descriptors))
return maybe_descriptors;
5133 int number_of_own_descriptors = NumberOfOwnDescriptors();
5134 MaybeObject* maybe_descriptors =
5135 descriptors->
CopyUpTo(number_of_own_descriptors);
5136 if (!maybe_descriptors->To(&new_descriptors))
return maybe_descriptors;
5147 MaybeObject* maybe_failure = descriptor->KeyToSymbol();
5148 if (maybe_failure->IsFailure())
return maybe_failure;
5150 int old_size = NumberOfOwnDescriptors();
5151 int new_size = old_size + 1;
5152 descriptor->SetEnumerationIndex(new_size);
5155 owns_descriptors() &&
5156 CanHaveMoreTransitions()) {
5157 return ShareDescriptor(descriptors, descriptor);
5162 if (!maybe_descriptors->To(&new_descriptors))
return maybe_descriptors;
5167 for (
int i = 0; i < old_size; ++i) {
5168 new_descriptors->
CopyFrom(i, descriptors, i, witness);
5173 new_descriptors->
Set(old_size, descriptor, witness);
5174 new_descriptors->
Sort();
5176 new_descriptors->
Append(descriptor, witness);
5179 String* key = descriptor->GetKey();
5182 return CopyReplaceDescriptors(new_descriptors, key, flag, insertion_index);
5191 MaybeObject* maybe_result = descriptor->KeyToSymbol();
5192 if (maybe_result->IsFailure())
return maybe_result;
5195 int index = old_descriptors->SearchWithCache(descriptor->GetKey(),
this);
5197 return CopyReplaceDescriptor(old_descriptors, descriptor, index, flag);
5199 return CopyAddDescriptor(descriptor, flag);
5204 if (enumeration_index == 0)
return GetHeap()->empty_descriptor_array();
5206 int size = enumeration_index;
5209 MaybeObject* maybe_descriptors = Allocate(size);
5210 if (!maybe_descriptors->To(&descriptors))
return maybe_descriptors;
5213 for (
int i = 0; i < size; ++i) {
5214 descriptors->
CopyFrom(i,
this, i, witness);
5217 if (number_of_descriptors() != enumeration_index) descriptors->
Sort();
5224 Descriptor* descriptor,
5225 int insertion_index,
5228 MaybeObject* maybe_failure = descriptor->KeyToSymbol();
5229 if (maybe_failure->IsFailure())
return maybe_failure;
5231 String* key = descriptor->GetKey();
5234 int new_size = NumberOfOwnDescriptors();
5235 ASSERT(0 <= insertion_index && insertion_index < new_size);
5237 PropertyDetails details = descriptors->
GetDetails(insertion_index);
5238 ASSERT_LE(details.descriptor_index(), new_size);
5239 descriptor->SetEnumerationIndex(details.descriptor_index());
5243 if (!maybe_descriptors->To(&new_descriptors))
return maybe_descriptors;
5246 for (
int i = 0; i < new_size; ++i) {
5247 if (i == insertion_index) {
5248 new_descriptors->
Set(i, descriptor, witness);
5250 new_descriptors->
CopyFrom(i, descriptors, i, witness);
5255 if (new_size != descriptors->
length()) new_descriptors->
Sort();
5257 return CopyReplaceDescriptors(new_descriptors, key, flag, insertion_index);
5264 Isolate* isolate = map->GetIsolate();
5266 map->UpdateCodeCache(*name, *code));
5274 if (code_cache()->IsFixedArray()) {
5277 if (!maybe_result->ToObject(&result))
return maybe_result;
5279 set_code_cache(result);
5289 if (!code_cache()->IsFixedArray()) {
5292 return GetHeap()->undefined_value();
5299 if (!code_cache()->IsFixedArray()) {
5309 ASSERT(!code_cache()->IsFixedArray());
5319 : transition_array_(transition_array) { }
5327 return (*TransitionArrayHeader())->IsSmi();
5333 int number_of_transitions = transition_array_->number_of_transitions();
5334 while (index < number_of_transitions) {
5336 return transition_array_->GetTarget(index);
5339 if (index == number_of_transitions &&
5340 transition_array_->HasElementsTransition()) {
5341 Map* elements_transition = transition_array_->elements_transition();
5343 return elements_transition;
5345 *TransitionArrayHeader() = transition_array_->
GetHeap()->fixed_array_map();
5350 Object** TransitionArrayHeader() {
5354 TransitionArray* transition_array_;
5363 : proto_trans_(proto_trans) { }
5371 return (*Header())->IsSmi();
5377 if (transitionNumber < NumberOfTransitions()) {
5379 return GetTransition(transitionNumber);
5381 *Header() = proto_trans_->GetHeap()->fixed_array_map();
5390 int NumberOfTransitions() {
5391 FixedArray* proto_trans =
reinterpret_cast<FixedArray*
>(proto_trans_);
5396 Map* GetTransition(
int transitionNumber) {
5397 FixedArray* proto_trans =
reinterpret_cast<FixedArray*
>(proto_trans_);
5398 return Map::cast(proto_trans->get(IndexFor(transitionNumber)));
5401 int IndexFor(
int transitionNumber) {
5407 HeapObject* proto_trans_;
5449 if (HasTransitionArray()) {
5450 if (HasPrototypeTransitions()) {
5462 if (!transition_array->
map()->IsSmi() &&
5463 !transition_array->IsTransitionArray()) {
5472 Map* next = proto_iterator.
Next();
5479 Map* next = transition_iterator.
Next();
5495 if (child !=
NULL) {
5501 callback(current, data);
5502 if (current ==
this)
break;
5515 if (normal_type_cache()->IsUndefined()) {
5517 { MaybeObject* maybe_result =
5519 if (!maybe_result->ToObject(&result))
return maybe_result;
5521 set_normal_type_cache(result);
5523 return UpdateNormalTypeCache(name, code);
5525 ASSERT(default_cache()->IsFixedArray());
5526 return UpdateDefaultCache(name, code);
5531 MaybeObject* CodeCache::UpdateDefaultCache(
String* name,
Code*
code) {
5540 int length = cache->length();
5541 int deleted_index = -1;
5542 for (
int i = 0; i < length; i += kCodeCacheEntrySize) {
5543 Object* key = cache->get(i);
5544 if (key->IsNull()) {
5545 if (deleted_index < 0) deleted_index = i;
5548 if (key->IsUndefined()) {
5549 if (deleted_index >= 0) i = deleted_index;
5550 cache->set(i + kCodeCacheEntryNameOffset, name);
5551 cache->set(i + kCodeCacheEntryCodeOffset, code);
5558 cache->set(i + kCodeCacheEntryCodeOffset, code);
5566 if (deleted_index >= 0) {
5567 cache->set(deleted_index + kCodeCacheEntryNameOffset, name);
5568 cache->set(deleted_index + kCodeCacheEntryCodeOffset, code);
5574 int new_length = length + ((length >> 1)) + kCodeCacheEntrySize;
5575 new_length = new_length - new_length % kCodeCacheEntrySize;
5576 ASSERT((new_length % kCodeCacheEntrySize) == 0);
5578 { MaybeObject* maybe_result = cache->CopySize(new_length);
5579 if (!maybe_result->ToObject(&result))
return maybe_result;
5584 cache->set(length + kCodeCacheEntryNameOffset, name);
5585 cache->set(length + kCodeCacheEntryCodeOffset, code);
5586 set_default_cache(cache);
5591 MaybeObject* CodeCache::UpdateNormalTypeCache(String* name, Code* code) {
5595 { MaybeObject* maybe_new_cache = cache->Put(name, code);
5596 if (!maybe_new_cache->ToObject(&new_cache))
return maybe_new_cache;
5598 set_normal_type_cache(new_cache);
5605 return LookupNormalTypeCache(name, flags);
5607 return LookupDefaultCache(name, flags);
5614 int length = cache->
length();
5615 for (
int i = 0; i < length; i += kCodeCacheEntrySize) {
5616 Object* key = cache->
get(i + kCodeCacheEntryNameOffset);
5618 if (key->IsNull())
continue;
5619 if (key->IsUndefined())
return key;
5627 return GetHeap()->undefined_value();
5632 if (!normal_type_cache()->IsUndefined()) {
5634 return cache->Lookup(name, flags);
5636 return GetHeap()->undefined_value();
5643 if (normal_type_cache()->IsUndefined())
return -1;
5649 int len = array->
length();
5650 for (
int i = 0; i < len; i += kCodeCacheEntrySize) {
5651 if (array->
get(i + kCodeCacheEntryCodeOffset) ==
code)
return i + 1;
5659 ASSERT(!normal_type_cache()->IsUndefined());
5669 ASSERT_EQ(1, kCodeCacheEntryCodeOffset - kCodeCacheEntryNameOffset);
5683 : name_(name), flags_(flags), code_(
NULL) { }
5687 flags_(code->flags()),
5692 if (!other->IsFixedArray())
return false;
5696 if (flags != flags_) {
5699 return name_->Equals(name);
5706 uint32_t
Hash() {
return NameFlagsHashHelper(name_, flags_); }
5712 return NameFlagsHashHelper(name, code->flags());
5718 { MaybeObject* maybe_obj = code_->GetHeap()->AllocateFixedArray(2);
5719 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
5722 pair->
set(0, name_);
5723 pair->
set(1, code_);
5737 int entry = FindEntry(&key);
5738 if (entry == kNotFound)
return GetHeap()->undefined_value();
5739 return get(EntryToIndex(entry) + 1);
5746 { MaybeObject* maybe_obj = EnsureCapacity(1, &key);
5747 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
5755 { MaybeObject* maybe_k = key.
AsObject();
5756 if (!maybe_k->ToObject(&k))
return maybe_k;
5759 cache->
set(EntryToIndex(entry), k);
5760 cache->
set(EntryToIndex(entry) + 1, code);
5768 int entry = FindEntry(&key);
5769 return (entry == kNotFound) ? -1 : entry;
5776 set(EntryToIndex(index), heap->the_hole_value());
5777 set(EntryToIndex(index) + 1, heap->the_hole_value());
5786 Isolate* isolate = cache->GetIsolate();
5795 if (cache()->IsUndefined()) {
5797 { MaybeObject* maybe_result =
5800 if (!maybe_result->ToObject(&result))
return maybe_result;
5806 ->
Lookup(maps, flags)->IsUndefined());
5811 { MaybeObject* maybe_new_cache = hash_table->
Put(maps, flags, code);
5812 if (!maybe_new_cache->ToObject(&new_cache))
return maybe_new_cache;
5814 set_cache(new_cache);
5821 if (!cache()->IsUndefined()) {
5839 code_flags_(code_flags) {}
5844 FromObject(other, &other_flags, &other_maps);
5845 if (code_flags_ != other_flags)
return false;
5846 if (maps_->length() != other_maps.length())
return false;
5848 int this_hash = MapsHashHelper(maps_, code_flags_);
5849 int other_hash = MapsHashHelper(&other_maps, other_flags);
5850 if (this_hash != other_hash)
return false;
5855 for (
int i = 0; i < maps_->length(); ++i) {
5856 bool match_found =
false;
5857 for (
int j = 0; j < other_maps.length(); ++j) {
5858 if (*(maps_->at(i)) == *(other_maps.
at(j))) {
5863 if (!match_found)
return false;
5869 uint32_t hash = code_flags;
5870 for (
int i = 0; i < maps->length(); ++i) {
5871 hash ^= maps->
at(i)->Hash();
5877 return MapsHashHelper(maps_, code_flags_);
5883 FromObject(obj, &other_flags, &other_maps);
5884 return MapsHashHelper(&other_maps, other_flags);
5892 { MaybeObject* maybe_obj =
5893 HEAP->AllocateUninitializedFixedArray(maps_->length() + 1);
5894 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
5898 for (
int i = 0; i < maps_->length(); ++i) {
5899 list->
set(i + 1, *maps_->at(i));
5911 for (
int i = 1; i < list->
length(); ++i) {
5926 int entry = FindEntry(&key);
5927 if (entry == kNotFound)
return GetHeap()->undefined_value();
5928 return get(EntryToIndex(entry) + 1);
5937 { MaybeObject* maybe_obj = EnsureCapacity(1, &key);
5938 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
5943 { MaybeObject* maybe_obj = key.
AsObject();
5944 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
5946 cache->
set(EntryToIndex(entry), obj);
5947 cache->
set(EntryToIndex(entry) + 1, code);
5955 MaybeObject* maybe_result =
5958 if (!maybe_result->To<
FixedArray>(&result))
return maybe_result;
5961 for (
int i = 0; i < result->
length(); i++) {
5963 ASSERT(current->IsNumber() || current->IsString());
5973 MaybeObject* maybe_result =
5976 if (!maybe_result->To(&result))
return maybe_result;
5979 for (
int i = 0; i < result->
length(); i++) {
5981 ASSERT(current->IsNumber() || current->IsString());
5991 if (new_length == 0)
return heap->empty_fixed_array();
5994 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
6000 if (new_length < len) len = new_length;
6005 for (
int i = 0; i < len; i++) {
6006 result->
set(i,
get(i), mode);
6015 for (
int index = 0; index < len; index++) {
6016 dest->
set(dest_pos+index,
get(pos+index), mode);
6022 bool FixedArray::IsEqualTo(
FixedArray* other) {
6023 if (length() != other->
length())
return false;
6024 for (
int i = 0 ; i < length(); ++i) {
6025 if (
get(i) != other->
get(i))
return false;
6033 Heap* heap = Isolate::Current()->heap();
6035 int size = number_of_descriptors + slack;
6036 if (size == 0)
return heap->empty_descriptor_array();
6040 if (!maybe_array->To(&result))
return maybe_array;
6042 result->
set(kDescriptorLengthIndex,
Smi::FromInt(number_of_descriptors));
6055 Object* new_index_cache) {
6056 ASSERT(bridge_storage->
length() >= kEnumCacheBridgeLength);
6057 ASSERT(new_index_cache->IsSmi() || new_index_cache->IsFixedArray());
6059 ASSERT(!HasEnumCache() || new_cache->
length() > GetEnumCache()->length());
6061 set(kEnumCacheBridgeCacheIndex, new_cache);
6063 set(kEnumCacheBridgeIndicesCacheIndex, new_index_cache);
6064 set(kEnumCacheIndex, bridge_storage);
6073 PropertyDetails details = src->
GetDetails(src_index);
6074 Descriptor desc(src->
GetKey(src_index), value, details);
6075 Set(dst_index, &desc, witness);
6085 int len = number_of_descriptors();
6087 for (
int i = 0; i < len; ++i) SetSortedKey(i, i);
6090 const int max_parent_index = (len / 2) - 1;
6091 for (
int i = max_parent_index; i >= 0; --i) {
6092 int parent_index = i;
6093 const uint32_t parent_hash = GetSortedKey(i)->Hash();
6094 while (parent_index <= max_parent_index) {
6095 int child_index = 2 * parent_index + 1;
6096 uint32_t child_hash = GetSortedKey(child_index)->Hash();
6097 if (child_index + 1 < len) {
6098 uint32_t right_child_hash = GetSortedKey(child_index + 1)->Hash();
6099 if (right_child_hash > child_hash) {
6101 child_hash = right_child_hash;
6104 if (child_hash <= parent_hash)
break;
6105 SwapSortedKeys(parent_index, child_index);
6107 parent_index = child_index;
6112 for (
int i = len - 1; i > 0; --i) {
6114 SwapSortedKeys(0, i);
6116 int parent_index = 0;
6117 const uint32_t parent_hash = GetSortedKey(parent_index)->Hash();
6118 const int max_parent_index = (i / 2) - 1;
6119 while (parent_index <= max_parent_index) {
6120 int child_index = parent_index * 2 + 1;
6121 uint32_t child_hash = GetSortedKey(child_index)->Hash();
6122 if (child_index + 1 < i) {
6123 uint32_t right_child_hash = GetSortedKey(child_index + 1)->Hash();
6124 if (right_child_hash > child_hash) {
6126 child_hash = right_child_hash;
6129 if (child_hash <= parent_hash)
break;
6130 SwapSortedKeys(parent_index, child_index);
6131 parent_index = child_index;
6134 ASSERT(IsSortedNoDuplicates());
6142 if (!maybe_copy->To(©))
return maybe_copy;
6144 copy->set_getter(getter());
6145 copy->set_setter(setter());
6151 Object* accessor =
get(component);
6152 return accessor->IsTheHole() ?
GetHeap()->undefined_value() : accessor;
6158 ASSERT(deopt_entry_count > 0);
6159 return HEAP->AllocateFixedArray(LengthFor(deopt_entry_count),
6166 if (number_of_deopt_points == 0)
return HEAP->empty_fixed_array();
6167 return HEAP->AllocateFixedArray(LengthOfFixedArray(number_of_deopt_points),
6174 if (IsEmpty())
return other->
IsEmpty();
6175 if (other->
IsEmpty())
return false;
6176 if (length() != other->
length())
return false;
6177 for (
int i = 0; i < length(); ++i) {
6178 if (
get(i) != other->
get(i))
return false;
6186 if (!Isolate::Current()->heap()->Contains(
this))
return false;
6192 int length = this->length();
6193 StringShape shape(
this);
6201 string = cons->
first();
6202 shape = StringShape(
string);
6206 offset = slice->
offset();
6207 string = slice->
parent();
6208 shape = StringShape(
string);
6237 int* length_return) {
6244 if (length < 0) length =
kMaxInt - offset;
6249 buffer->Reset(offset,
this);
6250 int character_position = offset;
6253 while (buffer->
has_more() && character_position++ < offset + length) {
6259 if (length_return) {
6260 *length_return = utf8_bytes;
6263 char* result = NewArray<char>(utf8_bytes + 1);
6267 buffer->
Seek(offset);
6268 character_position = offset;
6269 int utf8_byte_position = 0;
6271 while (buffer->
has_more() && character_position++ < offset + length) {
6276 utf8_byte_position +=
6280 result[utf8_byte_position] = 0;
6287 int* length_return) {
6288 return ToCString(allow_nulls, robust_flag, 0, -1, length_return);
6293 return GetTwoByteData(0);
6298 ASSERT(!IsAsciiRepresentationUnderneath());
6299 switch (StringShape(
this).representation_tag()) {
6304 ExternalTwoByteStringGetData(start);
6326 buffer->Reset(
this);
6328 uc16* result = NewArray<uc16>(length() + 1);
6333 result[i++] = character;
6341 return reinterpret_cast<uc16*
>(
6347 unsigned* offset_ptr,
6348 unsigned max_chars) {
6349 unsigned chars_read = 0;
6350 unsigned offset = *offset_ptr;
6351 while (chars_read < max_chars) {
6353 reinterpret_cast<char*
>(
this) -
6374 *offset_ptr = offset;
6380 unsigned* remaining,
6381 unsigned* offset_ptr,
6382 unsigned max_chars) {
6385 *remaining = max_chars;
6386 *offset_ptr += max_chars;
6399 unsigned* offset_ptr,
6400 unsigned max_chars) {
6402 unsigned offset = *offset_ptr;
6403 int offset_correction = 0;
6407 unsigned left_length = (unsigned)left->
length();
6408 if (left_length > offset &&
6409 (max_chars <= left_length - offset ||
6410 (rbb->
capacity <= left_length - offset &&
6411 (max_chars = left_length - offset,
true)))) {
6419 if (StringShape(left).IsCons()) {
6425 *offset_ptr = offset + offset_correction;
6428 }
else if (left_length <= offset) {
6432 offset -= left_length;
6433 offset_correction += left_length;
6434 if (StringShape(right).IsCons()) {
6440 *offset_ptr = offset + offset_correction;
6456 *offset_ptr = offset + offset_correction;
6464 unsigned* remaining,
6465 unsigned* offset_ptr,
6466 unsigned max_chars) {
6469 reinterpret_cast<const unibrow::byte*
>(GetChars()) + *offset_ptr;
6470 *remaining = max_chars;
6471 *offset_ptr += max_chars;
6478 unsigned* offset_ptr,
6479 unsigned max_chars) {
6480 unsigned chars_read = 0;
6481 unsigned offset = *offset_ptr;
6483 while (chars_read < max_chars) {
6502 *offset_ptr = offset;
6508 unsigned* offset_ptr,
6509 unsigned max_chars) {
6511 if (max_chars > capacity) max_chars = capacity;
6517 *offset_ptr += max_chars;
6518 rbb->
cursor += max_chars;
6524 unsigned* offset_ptr,
6525 unsigned max_chars) {
6527 if (max_chars > capacity) max_chars = capacity;
6530 *offset_ptr += max_chars;
6531 rbb->
cursor += max_chars;
6541 unsigned* offset_ptr,
6542 unsigned max_chars) {
6543 ASSERT(*offset_ptr <= static_cast<unsigned>(input->
length()));
6544 if (max_chars == 0) {
6548 switch (StringShape(input).representation_tag()) {
6574 ExternalTwoByteStringReadBlockIntoBuffer(rbb,
6592 void Relocatable::PostGarbageCollectionProcessing() {
6593 Isolate* isolate = Isolate::Current();
6594 Relocatable* current = isolate->relocatable_top();
6595 while (current !=
NULL) {
6596 current->PostGarbageCollection();
6597 current = current->prev_;
6603 int Relocatable::ArchiveSpacePerThread() {
6604 return sizeof(Isolate::Current()->relocatable_top());
6609 char* Relocatable::ArchiveState(Isolate* isolate,
char* to) {
6610 *
reinterpret_cast<Relocatable**
>(to) = isolate->relocatable_top();
6611 isolate->set_relocatable_top(
NULL);
6612 return to + ArchiveSpacePerThread();
6617 char* Relocatable::RestoreState(Isolate* isolate,
char* from) {
6618 isolate->set_relocatable_top(*reinterpret_cast<Relocatable**>(from));
6619 return from + ArchiveSpacePerThread();
6623 char* Relocatable::Iterate(ObjectVisitor* v,
char* thread_storage) {
6624 Relocatable* top = *
reinterpret_cast<Relocatable**
>(thread_storage);
6626 return thread_storage + ArchiveSpacePerThread();
6630 void Relocatable::Iterate(ObjectVisitor* v) {
6631 Isolate* isolate = Isolate::Current();
6632 Iterate(v, isolate->relocatable_top());
6636 void Relocatable::Iterate(ObjectVisitor* v, Relocatable* top) {
6637 Relocatable* current = top;
6638 while (current !=
NULL) {
6639 current->IterateInstance(v);
6640 current = current->prev_;
6646 : Relocatable(isolate),
6647 str_(str.location()),
6648 length_(str->length()) {
6654 : Relocatable(isolate),
6657 length_(input.length()),
6658 start_(input.start()) { }
6662 if (str_ ==
NULL)
return;
6666 ASSERT(content.IsFlat());
6667 is_ascii_ = content.IsAscii();
6669 start_ = content.ToAsciiVector().start();
6671 start_ = content.ToUC16Vector().start();
6692 unsigned* offset_ptr,
6693 unsigned max_chars) {
6695 if (max_chars == 0)
return;
6697 switch (StringShape(input).representation_tag()) {
6718 ExternalAsciiStringReadBlockIntoBuffer(rbb, offset_ptr, max_chars);
6721 ExternalTwoByteStringReadBlockIntoBuffer(rbb,
6743 unsigned* remaining,
6744 unsigned* offset_ptr) {
6746 unsigned chars = input->
length() - *offset_ptr;
6758 unsigned* remaining,
6759 unsigned* offset_ptr) {
6761 ASSERT(*offset_ptr <= (
unsigned)input->length());
6762 unsigned chars = input->length() - *offset_ptr;
6763 if (chars > capacity) chars = capacity;
6778 unsigned* offset_ptr,
6779 unsigned max_chars) {
6781 unsigned offset = *offset_ptr;
6782 int offset_correction = 0;
6786 unsigned left_length = (unsigned)left->
length();
6787 if (left_length > offset &&
6788 max_chars <= left_length - offset) {
6791 if (StringShape(left).IsCons()) {
6796 *offset_ptr = offset + offset_correction;
6799 }
else if (left_length <= offset) {
6802 offset -= left_length;
6803 offset_correction += left_length;
6805 if (StringShape(right).IsCons()) {
6810 *offset_ptr = offset + offset_correction;
6816 max_chars -= left_length - offset;
6820 if (offset == left_length) {
6823 offset -= left_length;
6824 offset_correction += left_length;
6827 *offset_ptr = offset + offset_correction;
6840 return left->Get(index);
6846 if (StringShape(
string).IsCons()) {
6849 if (left->
length() > index) {
6853 string = cons_string->
second();
6856 return string->Get(index);
6875 buffer, offset_ptr, chars);
6886 buffer, offset_ptr, chars);
6890 template <
typename sink
char>
6899 ASSERT(0 <= from && from <= to && to <= source->
length());
6900 switch (StringShape(source).full_representation_tag()) {
6931 int boundary = first->
length();
6932 if (to - boundary >= boundary - from) {
6934 if (from < boundary) {
6936 sink += boundary - from;
6942 source = cons_string->
second();
6945 if (to > boundary) {
6950 if (to - boundary == 1) {
6951 sink[boundary - from] =
static_cast<sinkchar
>(second->Get(0));
6952 }
else if (second->IsSeqAsciiString()) {
6958 sink + boundary - from,
6971 unsigned offset = slice->
offset();
6980 template <
typename IteratorA,
typename IteratorB>
6981 static inline bool CompareStringContents(IteratorA*
ia, IteratorB*
ib) {
6984 while (ia->has_more()) {
6985 uint32_t ca = ia->GetNext();
6986 uint32_t cb = ib->GetNext();
6998 template <
typename Char>
6999 static inline bool CompareRawStringContents(Vector<Char> a, Vector<Char> b) {
7000 int length = a.length();
7002 const Char* pa = a.start();
7003 const Char* pb = b.start();
7005 #ifndef V8_HOST_CAN_READ_UNALIGNED
7009 const int kAlignmentMask =
sizeof(uint32_t) - 1;
7010 uint32_t pa_addr =
reinterpret_cast<uint32_t
>(pa);
7011 uint32_t pb_addr =
reinterpret_cast<uint32_t
>(pb);
7012 if (((pa_addr & kAlignmentMask) | (pb_addr & kAlignmentMask)) == 0) {
7014 const int kStepSize =
sizeof(int) /
sizeof(Char);
7015 int endpoint = length - kStepSize;
7017 for (; i <= endpoint; i += kStepSize) {
7018 uint32_t wa = *
reinterpret_cast<const uint32_t*
>(pa + i);
7019 uint32_t wb = *
reinterpret_cast<const uint32_t*
>(pb + i);
7024 #ifndef V8_HOST_CAN_READ_UNALIGNED
7028 for (; i < length; i++) {
7037 template <
typename IteratorA>
7038 static inline bool CompareStringContentsPartial(Isolate* isolate,
7041 String::FlatContent content = b->GetFlatContent();
7042 if (content.IsFlat()) {
7043 if (content.IsAscii()) {
7044 VectorIterator<char>
ib(content.ToAsciiVector());
7045 return CompareStringContents(ia, &ib);
7047 VectorIterator<uc16>
ib(content.ToUC16Vector());
7048 return CompareStringContents(ia, &ib);
7051 isolate->objects_string_compare_buffer_b()->Reset(0, b);
7052 return CompareStringContents(ia,
7053 isolate->objects_string_compare_buffer_b());
7058 bool String::SlowEquals(String* other) {
7061 if (len != other->length())
return false;
7062 if (len == 0)
return true;
7069 if (
Hash() != other->Hash()) {
7070 bool found_difference =
false;
7071 for (
int i = 0; i < len; i++) {
7072 if (Get(i) != other->Get(i)) {
7073 found_difference =
true;
7077 ASSERT(found_difference);
7081 if (
Hash() != other->Hash())
return false;
7086 if (this->Get(0) != other->Get(0))
return false;
7089 String* rhs = other->TryFlattenGetString();
7091 if (StringShape(lhs).IsSequentialAscii() &&
7092 StringShape(rhs).IsSequentialAscii()) {
7095 return CompareRawStringContents(Vector<const char>(str1, len),
7096 Vector<const char>(str2, len));
7100 String::FlatContent lhs_content = lhs->GetFlatContent();
7101 String::FlatContent rhs_content = rhs->GetFlatContent();
7102 if (lhs_content.IsFlat()) {
7103 if (lhs_content.IsAscii()) {
7104 Vector<const char> vec1 = lhs_content.ToAsciiVector();
7105 if (rhs_content.IsFlat()) {
7106 if (rhs_content.IsAscii()) {
7107 Vector<const char> vec2 = rhs_content.ToAsciiVector();
7108 return CompareRawStringContents(vec1, vec2);
7110 VectorIterator<char> buf1(vec1);
7111 VectorIterator<uc16>
ib(rhs_content.ToUC16Vector());
7112 return CompareStringContents(&buf1, &ib);
7115 VectorIterator<char> buf1(vec1);
7116 isolate->objects_string_compare_buffer_b()->Reset(0, rhs);
7117 return CompareStringContents(&buf1,
7118 isolate->objects_string_compare_buffer_b());
7121 Vector<const uc16> vec1 = lhs_content.ToUC16Vector();
7122 if (rhs_content.IsFlat()) {
7123 if (rhs_content.IsAscii()) {
7124 VectorIterator<uc16> buf1(vec1);
7125 VectorIterator<char>
ib(rhs_content.ToAsciiVector());
7126 return CompareStringContents(&buf1, &ib);
7128 Vector<const uc16> vec2(rhs_content.ToUC16Vector());
7129 return CompareRawStringContents(vec1, vec2);
7132 VectorIterator<uc16> buf1(vec1);
7133 isolate->objects_string_compare_buffer_b()->Reset(0, rhs);
7134 return CompareStringContents(&buf1,
7135 isolate->objects_string_compare_buffer_b());
7139 isolate->objects_string_compare_buffer_a()->Reset(0, lhs);
7140 return CompareStringContentsPartial(isolate,
7141 isolate->objects_string_compare_buffer_a(), rhs);
7147 if (StringShape(
this).IsSymbol())
return false;
7151 if (map == heap->string_map()) {
7152 this->
set_map(heap->undetectable_string_map());
7154 }
else if (map == heap->ascii_string_map()) {
7155 this->
set_map(heap->undetectable_ascii_string_map());
7170 for (i = 0; i < slen && decoder->has_more(); i++) {
7171 uint32_t r = decoder->GetNext();
7173 if (i > slen - 1)
return false;
7177 if (Get(i) != r)
return false;
7180 return i == slen && !decoder->has_more();
7186 if (str.
length() != slen)
return false;
7190 str.
start(), slen) == 0;
7192 for (
int i = 0; i < slen; i++) {
7193 if (Get(i) !=
static_cast<uint16_t>(str[i]))
return false;
7201 if (str.
length() != slen)
return false;
7206 for (
int i = 0; i < slen; i++) {
7207 if (Get(i) != str[i])
return false;
7213 uint32_t String::ComputeAndSetHash() {
7217 const int len =
length();
7221 if (StringShape(
this).IsSequentialAscii()) {
7225 }
else if (StringShape(
this).IsSequentialTwoByte()) {
7230 StringInputBuffer buffer(
this);
7260 if (d < 0 || d > 9)
return false;
7261 uint32_t result = d;
7264 if (d < 0 || d > 9)
return false;
7266 if (result > 429496729
U - ((d > 5) ? 1 : 0))
return false;
7267 result = (result * 10) + d;
7275 bool String::SlowAsArrayIndex(uint32_t* index) {
7284 StringInputBuffer buffer(
this);
7365 if (start == 0 && end ==
length())
return this;
7372 int length = this->
length();
7373 for (
int i = 0; i <
length; i++) {
7374 fprintf(file,
"%c", Get(i));
7388 int to_trim = enum_cache->
length() - live_enum;
7389 if (to_trim <= 0)
return;
7390 RightTrimFixedArray<FROM_GC>(heap, descriptors->
GetEnumCache(), to_trim);
7394 RightTrimFixedArray<FROM_GC>(heap, enum_indices_cache, to_trim);
7398 static void TrimDescriptorArray(Heap* heap,
7400 DescriptorArray* descriptors,
7401 int number_of_own_descriptors) {
7402 int number_of_descriptors = descriptors->number_of_descriptors();
7403 int to_trim = number_of_descriptors - number_of_own_descriptors;
7404 if (to_trim <= 0)
return;
7406 RightTrimFixedArray<FROM_GC>(heap, descriptors, to_trim);
7407 descriptors->SetNumberOfDescriptors(number_of_own_descriptors);
7409 if (descriptors->HasEnumCache()) TrimEnumCache(heap, map, descriptors);
7410 descriptors->Sort();
7416 static bool ClearBackPointer(Heap* heap, Map* target) {
7435 int transition_index = 0;
7438 bool descriptors_owner_died =
false;
7443 if (ClearBackPointer(heap, target)) {
7444 if (target->instance_descriptors() == descriptors) {
7445 descriptors_owner_died =
true;
7446 descriptors_owner_died =
true;
7449 if (i != transition_index) {
7451 t->
SetKey(transition_index, key);
7453 collector->RecordSlot(key_slot, key_slot, key);
7464 descriptors_owner_died =
true;
7476 if (descriptors_owner_died) {
7477 if (number_of_own_descriptors > 0) {
7478 TrimDescriptorArray(heap,
this, descriptors, number_of_own_descriptors);
7498 int hash = (
static_cast<uint32_t
>(
7499 reinterpret_cast<uintptr_t
>(constructor())) >> 2);
7504 hash ^= (
static_cast<uint32_t
>(
7505 reinterpret_cast<uintptr_t
>(prototype())) << 2);
7514 constructor() == other->constructor() &&
7515 prototype() == other->prototype() &&
7538 code()->optimizable());
7553 shared()->code()->set_profiler_ticks(0);
7562 ASSERT(result != Isolate::Current()->has_pending_exception());
7572 ASSERT(shared->allows_lazy_compilation_without_context());
7574 return CompileLazyHelper(&info, flag);
7588 ASSERT(code->kind() == Code::OPTIMIZED_FUNCTION);
7589 ASSERT(native_context->IsNativeContext());
7591 Object* value = shared->optimized_code_map();
7593 if (value->IsSmi()) {
7598 new_code_map->set(0, *native_context);
7599 new_code_map->set(1, *code);
7600 new_code_map->set(2, *literals);
7604 ASSERT_EQ(-1, shared->SearchOptimizedCodeMap(*native_context));
7605 int old_length = old_code_map->length();
7607 new_code_map =
FACTORY->NewFixedArray(new_length);
7608 old_code_map->CopyTo(0, *new_code_map, 0, old_length);
7609 new_code_map->set(old_length, *native_context);
7610 new_code_map->set(old_length + 1, *code);
7611 new_code_map->set(old_length + 2, *literals);
7614 for (
int i = 0; i < new_code_map->length(); i +=
kEntryLength) {
7615 ASSERT(new_code_map->get(i)->IsNativeContext());
7616 ASSERT(new_code_map->get(i + 1)->IsCode());
7618 Code::OPTIMIZED_FUNCTION);
7619 ASSERT(new_code_map->get(i + 2)->IsFixedArray());
7622 shared->set_optimized_code_map(*new_code_map);
7629 ASSERT(optimized_code_map()->IsFixedArray());
7634 function->set_literals(cached_literals);
7638 ASSERT(function->context()->native_context() == code_map->
get(index - 1));
7639 function->ReplaceCode(code);
7646 if (function->shared()->is_compiled()) {
7647 function->ReplaceCode(function->shared()->code());
7648 function->shared()->set_code_age(0);
7650 ASSERT(function->shared()->allows_lazy_compilation());
7652 result = CompileLazyHelper(&info, flag);
7653 ASSERT(!result || function->is_compiled());
7664 return CompileLazyHelper(&info, flag);
7670 return function->is_compiled() ||
CompileLazy(
function, flag);
7678 if (!shared_info->script()->IsScript())
return false;
7679 if (shared_info->optimization_disabled())
return false;
7680 Code* code = shared_info->code();
7681 if (code->
kind() == Code::OPTIMIZED_FUNCTION)
return true;
7683 if (code->
kind() != Code::FUNCTION)
return true;
7689 if (IsGlobalObject())
return this;
7695 if (new_proto->IsFailure())
return new_proto;
7696 ASSERT(new_proto ==
this);
7703 ASSERT(value->IsJSReceiver());
7708 if (value->IsJSObject()) {
7710 if (ok->IsFailure())
return ok;
7720 if (!maybe_new_map->To(&new_map))
return maybe_new_map;
7721 new_map->set_prototype(value);
7723 if (maybe_object->IsFailure())
return maybe_object;
7728 set_prototype_or_initial_map(value);
7730 heap->ClearInstanceofCache();
7737 Object* construct_prototype = value;
7743 if (!value->IsJSReceiver()) {
7748 MaybeObject* maybe_new_map =
map()->
Copy();
7749 if (!maybe_new_map->To(&new_map))
return maybe_new_map;
7753 new_map->set_constructor(value);
7755 construct_prototype =
7757 initial_object_prototype();
7768 Map* no_prototype_map = shared()->is_classic_mode()
7769 ? native_context->function_without_prototype_map()
7770 : native_context->strict_mode_function_without_prototype_map();
7772 if (
map() == no_prototype_map)
return;
7774 ASSERT(
map() == (shared()->is_classic_mode()
7775 ? native_context->function_map()
7776 : native_context->strict_mode_function_map()));
7779 set_prototype_or_initial_map(no_prototype_map->
GetHeap()->the_hole_value());
7784 shared()->set_instance_class_name(name);
7790 PrintF(out,
"%s", *name);
7803 { MaybeObject* maybe_symbol =
7804 Isolate::Current()->heap()->LookupAsciiSymbol(to_string);
7805 if (!maybe_symbol->To(&symbol))
return maybe_symbol;
7807 set_to_string(symbol);
7808 set_to_number(to_number);
7822 return !script()->IsUndefined() &&
7823 !
reinterpret_cast<Script*
>(script())->source()->IsUndefined();
7846 return instance_size;
7857 if (!FLAG_inline_new
7867 for (
Object* obj = prototype;
7868 obj != heap->null_value();
7872 LookupResult result(heap->
isolate());
7875 if (result.IsFound()) {
7876 switch (result.type()) {
7906 bool only_simple_this_property_assignments,
7910 only_simple_this_property_assignments));
7911 set_this_property_assignments(assignments);
7921 set_this_property_assignments(heap->undefined_value());
7927 Object* obj = this_property_assignments();
7928 ASSERT(obj->IsFixedArray());
7937 Object* obj = this_property_assignments();
7938 ASSERT(obj->IsFixedArray());
7967 accumulator->
Add(
"<No Source>");
7978 accumulator->
Add(
"<Invalid Source>");
7983 accumulator->
Add(
"function ");
7984 Object* name = this->name();
7991 if (len <= max_length || max_length < 0) {
7994 accumulator->
Put(script_source,
7997 accumulator->
Add(
"...\n");
8002 static bool IsCodeEquivalent(
Code* code,
Code* recompiled) {
8004 ByteArray* code_relocation = code->relocation_info();
8005 ByteArray* recompiled_relocation = recompiled->relocation_info();
8006 int length = code_relocation->
length();
8007 if (length != recompiled_relocation->
length())
return false;
8011 return compare == 0;
8019 if (IsCodeEquivalent(code, recompiled)) {
8021 code->set_deoptimization_data(recompiled->deoptimization_data());
8028 set_code(recompiled);
8042 set_optimization_disabled(
true);
8046 if (
code()->kind() == Code::FUNCTION) {
8047 code()->set_optimizable(
false);
8049 if (FLAG_trace_opt) {
8050 PrintF(
"[disabled optimization for %s, reason: %s]\n",
8070 if (!FLAG_clever_optimizations)
return;
8073 if (live_objects_may_exist())
return;
8074 set_live_objects_may_exist(
true);
8086 set_initial_map(map);
8090 set_construct_stub(builtins->
builtin(Builtins::kJSConstructStubCountdown));
8096 Map* map =
reinterpret_cast<Map*
>(initial_map());
8108 set_initial_map(heap->raw_unchecked_undefined_value());
8110 ASSERT_EQ(builtins->builtin(Builtins::kJSConstructStubCountdown),
8112 set_construct_stub(builtins->builtin(Builtins::kJSConstructStubGeneric));
8114 set_live_objects_may_exist(
false);
8124 set_initial_map(map);
8128 set_construct_stub(builtins->
builtin(Builtins::kJSConstructStubCountdown));
8130 set_live_objects_may_exist(
true);
8135 code()->ClearInlineCaches();
8137 if (
code()->kind() == Code::FUNCTION) {
8138 code()->set_profiler_ticks(0);
8139 if (optimization_disabled() &&
8142 set_optimization_disabled(
false);
8143 code()->set_optimizable(
true);
8151 static void GetMinInobjectSlack(
Map* map,
void* data) {
8153 if (*reinterpret_cast<int*>(data) > slack) {
8154 *
reinterpret_cast<int*
>(data) = slack;
8159 static void ShrinkInstanceSize(Map* map,
void* data) {
8160 int slack = *
reinterpret_cast<int*
>(data);
8161 map->set_inobject_properties(map->inobject_properties() - slack);
8162 map->set_unused_property_fields(map->unused_property_fields() - slack);
8163 map->set_instance_size(map->instance_size() - slack *
kPointerSize);
8175 set_initial_map(heap->undefined_value());
8177 ASSERT_EQ(builtins->builtin(Builtins::kJSConstructStubCountdown),
8179 set_construct_stub(builtins->builtin(Builtins::kJSConstructStubGeneric));
8195 ASSERT(native_context->IsNativeContext());
8196 if (!FLAG_cache_optimized_code)
return -1;
8197 Object* value = optimized_code_map();
8198 if (!value->IsSmi()) {
8200 int length = optimized_code_map->
length();
8201 for (
int i = 0; i <
length; i += 3) {
8202 if (optimized_code_map->
get(i) == native_context) {
8211 #define DECLARE_TAG(ignore1, name, ignore2) name,
8219 #define DECLARE_TAG(ignore1, ignore2, name) name,
8227 void ObjectVisitor::VisitCodeTarget(RelocInfo* rinfo) {
8228 ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode()));
8230 Object* old_target = target;
8231 VisitPointer(&target);
8236 void ObjectVisitor::VisitCodeEntry(
Address entry_address) {
8239 VisitPointer(&code);
8240 if (code != old_code) {
8246 void ObjectVisitor::VisitGlobalPropertyCell(RelocInfo* rinfo) {
8247 ASSERT(rinfo->rmode() == RelocInfo::GLOBAL_PROPERTY_CELL);
8248 Object* cell = rinfo->target_cell();
8250 VisitPointer(&cell);
8251 if (cell != old_cell) {
8252 rinfo->set_target_cell(reinterpret_cast<JSGlobalPropertyCell*>(cell));
8257 void ObjectVisitor::VisitDebugTarget(RelocInfo* rinfo) {
8258 ASSERT((RelocInfo::IsJSReturn(rinfo->rmode()) &&
8259 rinfo->IsPatchedReturnSequence()) ||
8260 (RelocInfo::IsDebugBreakSlot(rinfo->rmode()) &&
8261 rinfo->IsPatchedDebugBreakSlotSequence()));
8263 Object* old_target = target;
8264 VisitPointer(&target);
8268 void ObjectVisitor::VisitEmbeddedPointer(RelocInfo* rinfo) {
8269 ASSERT(rinfo->rmode() == RelocInfo::EMBEDDED_OBJECT);
8270 VisitPointer(rinfo->target_object_address());
8273 void ObjectVisitor::VisitExternalReference(RelocInfo* rinfo) {
8274 Address* p = rinfo->target_reference_address();
8275 VisitExternalReferences(p, p + 1);
8279 set_relocation_info(
GetHeap()->empty_byte_array());
8285 it.rinfo()->apply(delta);
8292 ASSERT(Marking::Color(
this) == Marking::WHITE_OBJECT);
8304 int mode_mask = RelocInfo::kCodeTargetMask |
8305 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) |
8306 RelocInfo::ModeMask(RelocInfo::GLOBAL_PROPERTY_CELL) |
8307 RelocInfo::kApplyMask;
8310 RelocInfo::Mode mode = it.rinfo()->rmode();
8311 if (mode == RelocInfo::EMBEDDED_OBJECT) {
8314 }
else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) {
8317 }
else if (RelocInfo::IsCodeTarget(mode)) {
8325 it.rinfo()->apply(delta);
8338 int position = RelocInfo::kNoPosition;
8344 while (!it.
done()) {
8349 int dist =
static_cast<int>(pc - it.
rinfo()->pc());
8350 int pos =
static_cast<int>(it.
rinfo()->data());
8354 if ((dist < distance) ||
8355 (dist == distance && pos > position)) {
8373 int statement_position = 0;
8375 while (!it.
done()) {
8376 if (RelocInfo::IsStatementPosition(it.
rinfo()->rmode())) {
8377 int p =
static_cast<int>(it.
rinfo()->data());
8378 if (statement_position < p && p <= position) {
8379 statement_position = p;
8384 return statement_position;
8389 SafepointTable table(
this);
8390 return table.FindEntry(pc);
8404 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
8406 RelocInfo* info = it.rinfo();
8407 Object*
object = info->target_object();
8408 if (object->IsMap())
return Map::cast(
object);
8415 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET) |
8416 RelocInfo::ModeMask(RelocInfo::CONSTRUCT_CALL) |
8417 RelocInfo::ModeMask(RelocInfo::CODE_TARGET_WITH_ID) |
8418 RelocInfo::ModeMask(RelocInfo::CODE_TARGET_CONTEXT);
8420 RelocInfo* info = it.rinfo();
8430 Object* raw_info = type_feedback_info();
8431 if (raw_info->IsTypeFeedbackInfo()) {
8434 for (
int i = 0; i < type_feedback_cells->
CellCount(); i++) {
8448 #ifdef ENABLE_DISASSEMBLER
8450 void DeoptimizationInputData::DeoptimizationInputDataPrint(FILE* out) {
8453 PrintF(out,
"Deoptimization Input Data (deopt points = %d)\n", deopt_count);
8454 if (0 == deopt_count)
return;
8456 PrintF(out,
"%6s %6s %6s %6s %12s\n",
"index",
"ast id",
"argc",
"pc",
8457 FLAG_print_code_verbose ?
"commands" :
"");
8458 for (
int i = 0; i < deopt_count; i++) {
8459 PrintF(out,
"%6d %6d %6d %6d",
8462 ArgumentsStackHeight(i)->value(),
8465 if (!FLAG_print_code_verbose) {
8470 int translation_index = TranslationIndex(i)->value();
8471 TranslationIterator iterator(TranslationByteArray(), translation_index);
8474 ASSERT(Translation::BEGIN == opcode);
8475 int frame_count = iterator.Next();
8476 int jsframe_count = iterator.Next();
8477 PrintF(out,
" %s {frame count=%d, js frame count=%d}\n",
8478 Translation::StringFor(opcode),
8482 while (iterator.HasNext() &&
8483 Translation::BEGIN !=
8485 PrintF(out,
"%24s %s ",
"", Translation::StringFor(opcode));
8488 case Translation::BEGIN:
8492 case Translation::JS_FRAME: {
8493 int ast_id = iterator.Next();
8494 int function_id = iterator.Next();
8495 unsigned height = iterator.Next();
8496 PrintF(out,
"{ast_id=%d, function=", ast_id);
8497 if (function_id != Translation::kSelfLiteralId) {
8498 Object*
function = LiteralArray()->get(function_id);
8503 PrintF(out,
", height=%u}", height);
8507 case Translation::ARGUMENTS_ADAPTOR_FRAME:
8508 case Translation::CONSTRUCT_STUB_FRAME: {
8509 int function_id = iterator.Next();
8510 JSFunction*
function =
8512 unsigned height = iterator.Next();
8513 PrintF(out,
"{function=");
8514 function->PrintName(out);
8515 PrintF(out,
", height=%u}", height);
8519 case Translation::GETTER_STUB_FRAME:
8520 case Translation::SETTER_STUB_FRAME: {
8521 int function_id = iterator.Next();
8522 JSFunction*
function =
8524 PrintF(out,
"{function=");
8525 function->PrintName(out);
8530 case Translation::DUPLICATE:
8534 int reg_code = iterator.Next();
8539 case Translation::INT32_REGISTER: {
8540 int reg_code = iterator.Next();
8545 case Translation::UINT32_REGISTER: {
8546 int reg_code = iterator.Next();
8548 "{input=%s (unsigned)}",
8553 case Translation::DOUBLE_REGISTER: {
8554 int reg_code = iterator.Next();
8555 PrintF(out,
"{input=%s}",
8560 case Translation::STACK_SLOT: {
8561 int input_slot_index = iterator.Next();
8562 PrintF(out,
"{input=%d}", input_slot_index);
8566 case Translation::INT32_STACK_SLOT: {
8567 int input_slot_index = iterator.Next();
8568 PrintF(out,
"{input=%d}", input_slot_index);
8572 case Translation::UINT32_STACK_SLOT: {
8573 int input_slot_index = iterator.Next();
8574 PrintF(out,
"{input=%d (unsigned)}", input_slot_index);
8578 case Translation::DOUBLE_STACK_SLOT: {
8579 int input_slot_index = iterator.Next();
8580 PrintF(out,
"{input=%d}", input_slot_index);
8584 case Translation::LITERAL: {
8585 unsigned literal_index = iterator.Next();
8586 PrintF(out,
"{literal_id=%u}", literal_index);
8590 case Translation::ARGUMENTS_OBJECT:
8599 void DeoptimizationOutputData::DeoptimizationOutputDataPrint(FILE* out) {
8600 PrintF(out,
"Deoptimization Output Data (deopt points = %d)\n",
8604 PrintF(
"%6s %8s %s\n",
"ast id",
"pc",
"state");
8608 this->
AstId(i).ToInt(),
8617 const char* Code::Kind2String(Kind kind) {
8619 case FUNCTION:
return "FUNCTION";
8620 case OPTIMIZED_FUNCTION:
return "OPTIMIZED_FUNCTION";
8621 case STUB:
return "STUB";
8622 case BUILTIN:
return "BUILTIN";
8623 case LOAD_IC:
return "LOAD_IC";
8624 case KEYED_LOAD_IC:
return "KEYED_LOAD_IC";
8625 case STORE_IC:
return "STORE_IC";
8626 case KEYED_STORE_IC:
return "KEYED_STORE_IC";
8627 case CALL_IC:
return "CALL_IC";
8628 case KEYED_CALL_IC:
return "KEYED_CALL_IC";
8629 case UNARY_OP_IC:
return "UNARY_OP_IC";
8630 case BINARY_OP_IC:
return "BINARY_OP_IC";
8631 case COMPARE_IC:
return "COMPARE_IC";
8632 case TO_BOOLEAN_IC:
return "TO_BOOLEAN_IC";
8654 const char* Code::StubType2String(StubType type) {
8656 case NORMAL:
return "NORMAL";
8657 case FIELD:
return "FIELD";
8669 void Code::PrintExtraICState(FILE* out, Kind kind, ExtraICState extra) {
8670 const char* name =
NULL;
8674 name =
"STRING_INDEX_OUT_OF_BOUNDS";
8678 case KEYED_STORE_IC:
8687 PrintF(out,
"extra_ic_state = %s\n", name);
8689 PrintF(out,
"extra_ic_state = %d\n", extra);
8694 void Code::Disassemble(
const char* name, FILE* out) {
8695 PrintF(out,
"kind = %s\n", Kind2String(
kind()));
8700 PrintF(out,
"type = %s\n", StubType2String(
type()));
8714 if ((name !=
NULL) && (name[0] !=
'\0')) {
8715 PrintF(out,
"name = %s\n", name);
8717 if (
kind() == OPTIMIZED_FUNCTION) {
8725 if (
kind() == FUNCTION) {
8726 DeoptimizationOutputData* data =
8728 data->DeoptimizationOutputDataPrint(out);
8729 }
else if (
kind() == OPTIMIZED_FUNCTION) {
8730 DeoptimizationInputData* data =
8732 data->DeoptimizationInputDataPrint(out);
8736 if (
kind() == OPTIMIZED_FUNCTION) {
8737 SafepointTable table(
this);
8738 PrintF(out,
"Safepoints (size = %u)\n", table.size());
8739 for (
unsigned i = 0; i < table.length(); i++) {
8740 unsigned pc_offset = table.GetPcOffset(i);
8742 table.PrintEntry(i);
8743 PrintF(out,
" (sp -> fp)");
8744 SafepointEntry entry = table.GetEntry(i);
8745 if (entry.deoptimization_index() != Safepoint::kNoDeoptimizationIndex) {
8746 PrintF(out,
" %6d", entry.deoptimization_index());
8750 if (entry.argument_count() > 0) {
8751 PrintF(out,
" argc: %d", entry.argument_count());
8757 ASSERT(type_feedback_info()->IsUndefined());
8758 }
else if (
kind() == FUNCTION) {
8765 unsigned length = address[0];
8766 PrintF(out,
"Stack checks (size = %u)\n", length);
8767 PrintF(out,
"ast_id pc_offset\n");
8768 for (
unsigned i = 0; i < length; ++i) {
8769 unsigned index = (2 * i) + 1;
8770 PrintF(out,
"%6u %9u\n", address[index], address[index + 1]);
8775 if (!type_feedback_info()->IsUndefined()) {
8783 for (RelocIterator it(
this); !it.done(); it.next()) it.rinfo()->Print(out);
8786 #endif // ENABLE_DISASSEMBLER
8800 if (!maybe->To(&new_elements))
return maybe;
8807 bool has_fast_smi_elements =
8810 if (has_fast_smi_elements) {
8825 { MaybeObject* maybe_obj =
8826 accessor->
CopyElements(
this, new_elements, new_elements_kind);
8827 if (maybe_obj->IsFailure())
return maybe_obj;
8831 if (new_elements_kind != elements_kind) {
8832 MaybeObject* maybe =
8834 if (!maybe->To(&new_map))
return maybe;
8840 parameter_map->
set(1, new_elements);
8843 if (FLAG_trace_elements_transitions) {
8851 return new_elements;
8863 { MaybeObject* maybe_obj =
8865 if (!maybe_obj->To(&elems))
return maybe_obj;
8877 { MaybeObject* maybe_obj =
8879 if (!maybe_obj->To(&new_map))
return maybe_obj;
8884 { MaybeObject* maybe_obj =
8886 if (maybe_obj->IsFailure())
return maybe_obj;
8893 parameter_map->
set(1, elems);
8896 if (FLAG_trace_elements_transitions) {
8914 if (capacity == 0) {
8915 new_elements = heap->empty_fixed_array();
8918 if (!maybe_obj->To(&new_elements))
return maybe_obj;
8920 set_elements(new_elements);
8925 void JSArray::Expand(
int required_size) {
8941 const int proto_offset =
8945 for (
int i = 0; i < number_of_transitions; i++) {
8946 if (cache->
get(proto_offset + i * step) == prototype) {
8947 Object* map = cache->
get(map_offset + i * step);
8959 if (
is_shared() || !FLAG_cache_prototype_transitions)
return this;
8966 int capacity = (cache->
length() - header) / step;
8970 if (transitions > capacity) {
8975 { MaybeObject* maybe_cache =
8977 if (!maybe_cache->To(&new_cache))
return maybe_cache;
8980 for (
int i = 0; i < capacity * step; i++) {
8981 new_cache->
set(i + header, cache->
get(i + header));
8985 if (set_result->IsFailure())
return set_result;
8988 int last = transitions - 1;
9002 transition_array->
length());
9010 proto_transitions->
length());
9015 bool skip_hidden_prototypes) {
9023 if (!value->IsJSReceiver() && !value->IsNull())
return value;
9037 *
FACTORY->NewTypeError(
"non_extensible_proto",
9038 HandleVector<Object>(&handle, 1)));
9045 for (
Object* pt = value; pt != heap->null_value(); pt = pt->GetPrototype()) {
9050 *
FACTORY->NewError(
"cyclic_proto", HandleVector<Object>(
NULL, 0)));
9056 if (skip_hidden_prototypes) {
9060 while (current_proto->IsJSObject() &&
9068 Map* map = real_receiver->
map();
9071 if (map->prototype() == value)
return value;
9073 if (value->IsJSObject()) {
9075 if (ok->IsFailure())
return ok;
9079 if (new_map ==
NULL) {
9080 MaybeObject* maybe_new_map = map->
Copy();
9081 if (!maybe_new_map->To(&new_map))
return maybe_new_map;
9083 MaybeObject* maybe_new_cache =
9085 if (maybe_new_cache->IsFailure())
return maybe_new_cache;
9087 new_map->set_prototype(value);
9089 ASSERT(new_map->prototype() == value);
9090 real_receiver->
set_map(new_map);
9106 args->arguments() - first_arg - (arg_count - 1),
9115 AssertNoContextChange ncc;
9122 if (!interceptor->query()->IsUndefined()) {
9124 v8::ToCData<v8::IndexedPropertyQuery>(interceptor->query());
9126 ApiIndexedPropertyAccess(
"interceptor-indexed-has",
this, index));
9130 VMState state(isolate, EXTERNAL);
9131 result = query(index, info);
9137 }
else if (!interceptor->getter()->IsUndefined()) {
9139 v8::ToCData<v8::IndexedPropertyGetter>(interceptor->getter());
9141 ApiIndexedPropertyAccess(
"interceptor-indexed-has-get",
this, index));
9145 VMState state(isolate, EXTERNAL);
9146 result = getter(index, info);
9148 if (!result.
IsEmpty())
return true;
9151 if (holder_handle->GetElementsAccessor()->HasElement(
9152 *receiver_handle, *holder_handle, index)) {
9156 if (holder_handle->IsStringObjectWithCharacterAt(index))
return true;
9157 Object* pt = holder_handle->GetPrototype();
9158 if (pt->IsJSProxy()) {
9161 receiver, index) !=
ABSENT;
9163 if (pt->IsNull())
return false;
9170 if (IsAccessCheckNeeded()) {
9178 if (IsJSGlobalProxy()) {
9181 ASSERT(proto->IsJSGlobalObject());
9201 uint32_t length = IsJSArray() ?
9202 static_cast<uint32_t
>
9205 if ((index < length) &&
9213 uint32_t length = IsJSArray() ?
9214 static_cast<uint32_t
>
9217 if ((index < length) &&
9252 uint32_t length = parameter_map->
length();
9254 index < (length - 2) ? parameter_map->
get(index + 2) :
NULL;
9258 if (arguments->IsDictionary()) {
9265 length = arguments->
length();
9266 probe = (index < length) ? arguments->
get(index) :
NULL;
9279 if (IsAccessCheckNeeded()) {
9293 if (accessor->
HasElement(receiver,
this, index)) {
9301 if (pt->IsNull())
return false;
9302 if (pt->IsJSProxy()) {
9305 receiver, index) !=
ABSENT;
9311 MaybeObject* JSObject::SetElementWithInterceptor(uint32_t index,
9315 bool check_prototype,
9320 AssertNoContextChange ncc;
9325 if (!interceptor->setter()->IsUndefined()) {
9327 v8::ToCData<v8::IndexedPropertySetter>(interceptor->setter());
9329 ApiIndexedPropertyAccess(
"interceptor-indexed-set",
this, index));
9335 VMState state(isolate, EXTERNAL);
9339 if (!result.IsEmpty())
return *value_handle;
9341 MaybeObject* raw_result =
9342 this_handle->SetElementWithoutInterceptor(index,
9353 MaybeObject* JSObject::GetElementWithCallback(
Object* receiver,
9358 ASSERT(!structure->IsForeign());
9361 if (structure->IsAccessorInfo()) {
9363 Object* fun_obj = data->getter();
9365 if (call_fun ==
NULL)
return isolate->heap()->undefined_value();
9366 HandleScope scope(isolate);
9369 Handle<Object> number = isolate->factory()->NewNumberFromUint(index);
9370 Handle<String> key = isolate->factory()->NumberToString(number);
9371 LOG(isolate, ApiNamedPropertyAccess(
"load", *
self, *key));
9372 CustomArguments args(isolate, data->data(), *
self, *holder_handle);
9377 VMState state(isolate, EXTERNAL);
9381 if (result.IsEmpty())
return isolate->heap()->undefined_value();
9382 Handle<Object> result_internal = v8::Utils::OpenHandle(*result);
9383 result_internal->VerifyApiCallResultType();
9384 return *result_internal;
9388 if (structure->IsAccessorPair()) {
9390 if (getter->IsSpecFunction()) {
9395 return isolate->heap()->undefined_value();
9403 MaybeObject* JSObject::SetElementWithCallback(
Object* structure,
9409 HandleScope scope(isolate);
9413 ASSERT(!value->IsTheHole());
9414 Handle<Object> value_handle(value, isolate);
9419 ASSERT(!structure->IsForeign());
9421 if (structure->IsAccessorInfo()) {
9423 Handle<JSObject>
self(
this);
9426 Object* call_obj = data->setter();
9428 if (call_fun ==
NULL)
return value;
9429 Handle<Object> number = isolate->factory()->NewNumberFromUint(index);
9430 Handle<String> key(isolate->factory()->NumberToString(number));
9431 LOG(isolate, ApiNamedPropertyAccess(
"store", *
self, *key));
9432 CustomArguments args(isolate, data->data(), *
self, *holder_handle);
9436 VMState state(isolate, EXTERNAL);
9442 return *value_handle;
9445 if (structure->IsAccessorPair()) {
9447 if (setter->IsSpecFunction()) {
9454 Handle<Object> holder_handle(holder, isolate);
9455 Handle<Object> key(isolate->factory()->NewNumberFromUint(index));
9456 Handle<Object> args[2] = { key, holder_handle };
9457 return isolate->Throw(
9458 *isolate->factory()->NewTypeError(
"no_setter_in_callback",
9470 if (!elements()->IsFixedArray())
return false;
9472 if (elements->
map() != heap->non_strict_arguments_elements_map()) {
9476 return !arguments->IsDictionary();
9482 if (!elements()->IsFixedArray())
return false;
9484 if (elements->
map() != heap->non_strict_arguments_elements_map()) {
9488 return arguments->IsDictionary();
9498 bool check_prototype) {
9503 if (backing_store->
map() ==
GetHeap()->non_strict_arguments_elements_map()) {
9507 if (!maybe->To(&backing_store))
return maybe;
9509 uint32_t capacity =
static_cast<uint32_t
>(backing_store->
length());
9511 if (check_prototype &&
9512 (index >= capacity || backing_store->
get(index)->IsTheHole())) {
9518 if (found)
return result;
9521 uint32_t new_capacity = capacity;
9523 uint32_t array_length = 0;
9524 bool must_update_array_length =
false;
9525 bool introduces_holes =
true;
9528 introduces_holes = index > array_length;
9529 if (index >= array_length) {
9530 must_update_array_length =
true;
9531 array_length = index + 1;
9534 introduces_holes = index >= capacity;
9540 if (introduces_holes &&
9545 if (maybe->IsFailure())
return maybe;
9550 if (index >= capacity) {
9551 bool convert_to_slow =
true;
9552 if ((index - capacity) <
kMaxGap) {
9554 ASSERT(new_capacity > index);
9556 convert_to_slow =
false;
9559 if (convert_to_slow) {
9561 if (result->IsFailure())
return result;
9568 MaybeObject* maybe =
9570 if (maybe->IsFailure())
return maybe;
9583 if (!maybe_new_map->To(&new_map))
return maybe_new_map;
9588 if (new_capacity != capacity) {
9594 { MaybeObject* maybe =
9598 if (!maybe->To(&new_elements))
return maybe;
9600 new_elements->
set(index, value);
9606 ASSERT(elements()->IsFixedArray());
9607 backing_store->
set(index, value);
9608 if (must_update_array_length) {
9619 bool check_prototype,
9628 (elements->
map() == heap->non_strict_arguments_elements_map());
9636 int entry = dictionary->
FindEntry(index);
9639 PropertyDetails details = dictionary->
DetailsAt(entry);
9641 return SetElementWithCallback(element, index, value,
this, strict_mode);
9648 details = PropertyDetails(
9649 attributes,
NORMAL, details.dictionary_index());
9651 }
else if (details.IsReadOnly() && !element->IsTheHole()) {
9653 return isolate->
heap()->undefined_value();
9661 return isolate->
Throw(*error);
9665 if (is_arguments && element->IsAliasedArgumentsEntry()) {
9669 ASSERT(!context->
get(context_index)->IsTheHole());
9670 context->
set(context_index, value);
9672 if (!details.IsReadOnly()) value = element;
9678 if (check_prototype) {
9680 MaybeObject* result =
9682 index, value, &found, strict_mode);
9683 if (found)
return result;
9687 if (!
map()->is_extensible()) {
9689 return isolate->
heap()->undefined_value();
9697 return isolate->
Throw(*error);
9701 PropertyDetails details = PropertyDetails(attributes,
NORMAL);
9702 MaybeObject* maybe = dictionary->
AddNumberEntry(index, value, details);
9703 if (!maybe->To(&new_dictionary))
return maybe;
9706 elements->
set(1, new_dictionary);
9708 set_elements(new_dictionary);
9716 MaybeObject* result =
9718 if (result->IsFailure())
return result;
9723 uint32_t new_length = 0;
9732 bool has_smi_only_elements =
false;
9733 bool should_convert_to_fast_double_elements =
9735 if (has_smi_only_elements) {
9738 MaybeObject* result = should_convert_to_fast_double_elements
9744 if (result->IsFailure())
return result;
9746 if (FLAG_trace_normalization) {
9747 PrintF(
"Object elements are fast case again:\n");
9760 bool check_prototype) {
9764 uint32_t elms_length =
static_cast<uint32_t
>(base_elms->
length());
9768 if (check_prototype &&
9769 (index >= elms_length ||
9776 if (found)
return result;
9781 bool value_is_smi = value->IsSmi();
9782 bool introduces_holes =
true;
9783 uint32_t length = elms_length;
9786 introduces_holes = index > length;
9788 introduces_holes = index >= elms_length;
9791 if (!value->IsNumber()) {
9796 if (maybe_obj->IsFailure())
return maybe_obj;
9797 maybe_obj =
SetFastElement(index, value, strict_mode, check_prototype);
9798 if (maybe_obj->IsFailure())
return maybe_obj;
9803 double double_value = value_is_smi
9813 if (maybe->IsFailure())
return maybe;
9817 if (index < elms_length) {
9819 elms->
set(index, double_value);
9822 uint32_t array_length = 0;
9824 if (index >= array_length) {
9832 if ((index - elms_length) <
kMaxGap) {
9836 ASSERT(static_cast<uint32_t>(new_capacity) > index);
9837 MaybeObject* maybe_obj =
9839 if (maybe_obj->IsFailure())
return maybe_obj;
9848 ASSERT(
map()->has_fast_double_elements());
9849 ASSERT(elements()->IsFixedDoubleArray());
9852 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
9855 return SetElement(index, value,
NONE, strict_mode, check_prototype);
9866 this, index, value, strict_mode);
9869 index, value, attributes, strict_mode, check_proto);
9878 ASSERT(!object->HasExternalArrayElements());
9880 object->GetIsolate(),
9881 object->SetElement(index, *value,
NONE, strict_mode,
false),
9892 if (object->HasExternalArrayElements()) {
9893 if (!value->IsSmi() && !value->IsHeapNumber() && !value->IsUndefined()) {
9901 object->GetIsolate(),
9902 object->SetElement(index, *value, attr, strict_mode,
true, set_mode),
9911 bool check_prototype,
9914 if (IsAccessCheckNeeded()) {
9920 return *value_handle;
9924 if (IsJSGlobalProxy()) {
9926 if (proto->IsNull())
return value;
9927 ASSERT(proto->IsJSGlobalObject());
9944 return isolate->
Throw(*error);
9951 if (!maybe_object->To(&dictionary))
return maybe_object;
9958 return SetElementWithInterceptor(index,
9966 return SetElementWithoutInterceptor(index,
9975 MaybeObject* JSObject::SetElementWithoutInterceptor(uint32_t index,
9979 bool check_prototype,
9990 return SetFastElement(index, value, strict_mode, check_prototype);
9996 return pixels->
SetValue(index, value);
10000 return array->SetValue(index, value);
10003 ExternalUnsignedByteArray* array =
10005 return array->SetValue(index, value);
10009 return array->SetValue(index, value);
10012 ExternalUnsignedShortArray* array =
10014 return array->SetValue(index, value);
10018 return array->SetValue(index, value);
10021 ExternalUnsignedIntArray* array =
10023 return array->SetValue(index, value);
10027 return array->SetValue(index, value);
10031 return array->SetValue(index, value);
10035 check_prototype, set_mode);
10038 uint32_t length = parameter_map->length();
10040 (index < length - 2) ? parameter_map->get(index + 2) :
NULL;
10041 if (probe !=
NULL && !probe->IsTheHole()) {
10044 ASSERT(!context->get(context_index)->IsTheHole());
10045 context->set(context_index, value);
10048 parameter_map->set_the_hole(index + 2);
10051 MaybeObject* maybe_entry =
10053 if (!maybe_entry->ToObject(&value))
return maybe_entry;
10057 if (arguments->IsDictionary()) {
10059 check_prototype, set_mode);
10061 return SetFastElement(index, value, strict_mode, check_prototype);
10068 return isolate->
heap()->null_value();
10075 object->TransitionElementsKind(to_kind),
10088 if (elements() == isolate->
heap()->empty_fixed_array() ||
10098 if (!maybe_new_map->To(&new_map))
return maybe_new_map;
10100 if (FLAG_trace_elements_transitions) {
10108 uint32_t capacity =
static_cast<uint32_t
>(elms->
length());
10109 uint32_t length = capacity;
10113 if (raw_length->IsUndefined()) {
10124 MaybeObject* maybe_result =
10126 if (maybe_result->IsFailure())
return maybe_result;
10135 if (maybe_result->IsFailure())
return maybe_result;
10163 uint32_t old_len = 0;
10167 if (index >= old_len && index != 0xffffffff) {
10169 { MaybeObject* maybe_len =
10171 if (!maybe_len->ToObject(&len))
return maybe_len;
10184 AssertNoContextChange ncc;
10189 if (!interceptor->getter()->IsUndefined()) {
10191 v8::ToCData<v8::IndexedPropertyGetter>(interceptor->getter());
10193 ApiIndexedPropertyAccess(
"interceptor-indexed-get",
this, index));
10199 VMState state(isolate, EXTERNAL);
10200 result = getter(index, info);
10203 if (!result.IsEmpty()) {
10204 Handle<Object> result_internal = v8::Utils::OpenHandle(*result);
10205 result_internal->VerifyApiCallResultType();
10206 return *result_internal;
10210 Heap* heap = holder_handle->GetHeap();
10212 MaybeObject* raw_result = handler->
Get(*this_handle,
10215 if (raw_result != heap->the_hole_value())
return raw_result;
10219 Object* pt = holder_handle->GetPrototype();
10220 if (pt == heap->null_value())
return heap->undefined_value();
10225 bool JSObject::HasDenseElements() {
10228 GetElementsCapacityAndUsage(&capacity, &used);
10229 return (capacity == 0) || (used > (capacity / 2));
10233 void JSObject::GetElementsCapacityAndUsage(
int* capacity,
int* used) {
10238 FixedArray* backing_store =
NULL;
10241 backing_store_base =
10244 if (backing_store->IsDictionary()) {
10245 SeededNumberDictionary* dictionary =
10247 *capacity = dictionary->Capacity();
10248 *used = dictionary->NumberOfElements();
10255 *capacity = backing_store_base->length();
10263 *capacity = backing_store->length();
10264 for (
int i = 0; i < *capacity; ++i) {
10265 if (!backing_store->get(i)->IsTheHole()) ++(*used);
10269 SeededNumberDictionary* dictionary =
10271 *capacity = dictionary->Capacity();
10272 *used = dictionary->NumberOfElements();
10277 *capacity = backing_store_base->length();
10284 *capacity = elms->length();
10285 for (
int i = 0; i < *capacity; i++) {
10286 if (!elms->is_the_hole(i)) ++(*used);
10301 *capacity = external_array->length();
10302 *used = external_array->length();
10313 GetHeap()->InNewSpace(
this))) {
10319 int old_capacity = 0;
10320 int used_elements = 0;
10321 GetElementsCapacityAndUsage(&old_capacity, &used_elements);
10324 return 3 * dictionary_size <= new_capacity;
10331 if (!HasDenseElements())
return false;
10334 if (IsAccessCheckNeeded())
return false;
10338 if (elements->
map() ==
GetHeap()->non_strict_arguments_elements_map()) {
10349 uint32_t array_size = 0;
10355 uint32_t dictionary_size =
static_cast<uint32_t
>(dictionary->
Capacity()) *
10357 return 2 * dictionary_size >= array_size;
10362 bool* has_smi_only_elements) {
10363 *has_smi_only_elements =
false;
10364 if (FLAG_unbox_double_arrays) {
10368 bool found_double =
false;
10369 for (
int i = 0; i < dictionary->
Capacity(); i++) {
10371 if (key->IsNumber()) {
10373 if (!value->IsNumber())
return false;
10374 if (!value->IsSmi()) {
10375 found_double =
true;
10379 *has_smi_only_elements = !found_double;
10380 return found_double;
10392 #ifdef OBJECT_PRINT
10393 template<
typename Shape,
typename Key>
10396 for (
int i = 0; i < capacity; i++) {
10400 if (k->IsString()) {
10406 ValueAt(i)->ShortPrint(out);
10414 template<
typename Shape,
typename Key>
10420 for (
int i = 0; i < capacity; i++) {
10423 elements->
set(pos++, ValueAt(i), mode);
10431 ASSERT(
map()->has_named_interceptor());
10433 ASSERT(constructor->shared()->IsApiFunction());
10435 constructor->shared()->get_api_func_data()->named_property_handler();
10441 ASSERT(
map()->has_indexed_interceptor());
10443 ASSERT(constructor->shared()->IsApiFunction());
10445 constructor->shared()->get_api_func_data()->indexed_property_handler();
10457 if (result.IsFound()) {
10458 return GetProperty(receiver, &result, name, attributes);
10463 if (pt->IsNull())
return GetHeap()->undefined_value();
10475 if (result.IsFound()) {
10476 return GetProperty(receiver, &result, name, attributes);
10478 return GetHeap()->undefined_value();
10493 if (!interceptor->getter()->IsUndefined()) {
10495 v8::ToCData<v8::NamedPropertyGetter>(interceptor->getter());
10497 ApiNamedPropertyAccess(
"interceptor-named-get", *holder_handle, name));
10503 VMState state(isolate, EXTERNAL);
10507 if (!result.IsEmpty()) {
10508 *attributes =
NONE;
10509 Handle<Object> result_internal = v8::Utils::OpenHandle(*result);
10510 result_internal->VerifyApiCallResultType();
10511 return *result_internal;
10515 MaybeObject* result = holder_handle->GetPropertyPostInterceptor(
10527 if (IsAccessCheckNeeded()) {
10534 LookupResult result(isolate);
10536 return result.IsFound() && !result.IsInterceptor();
10542 if (IsAccessCheckNeeded()) {
10558 uint32_t length = IsJSArray() ?
10559 static_cast<uint32_t
>(
10562 return (index < length) &&
10567 uint32_t length = IsJSArray() ?
10568 static_cast<uint32_t
>(
10571 return (index < length) &&
10577 return index < static_cast<uint32_t>(pixels->
length());
10588 return index < static_cast<uint32_t>(array->
length());
10600 return GetHeap()->null_value();
10607 if (IsAccessCheckNeeded()) {
10614 LookupResult result(isolate);
10616 return result.IsPropertyCallbacks();
10638 if (
this != numbers) {
10639 temp = numbers->
get(i);
10646 static void InsertionSortPairs(
FixedArray* content,
10649 for (
int i = 1; i < len; i++) {
10666 for (
int i = 1; i < len; ++i) {
10667 int child_index = i;
10668 while (child_index > 0) {
10669 int parent_index = ((child_index + 1) >> 1) - 1;
10672 if (parent_value < child_value) {
10673 content->
SwapPairs(numbers, parent_index, child_index);
10677 child_index = parent_index;
10682 for (
int i = len - 1; i > 0; --i) {
10686 int parent_index = 0;
10688 int child_index = ((parent_index + 1) << 1) - 1;
10689 if (child_index >= i)
break;
10693 if (child_index + 1 >= i || child1_value > child2_value) {
10694 if (parent_value > child1_value)
break;
10695 content->
SwapPairs(numbers, parent_index, child_index);
10696 parent_index = child_index;
10698 if (parent_value > child2_value)
break;
10699 content->
SwapPairs(numbers, parent_index, child_index + 1);
10700 parent_index = child_index + 1;
10712 InsertionSortPairs(
this, numbers, len);
10717 uint32_t max_index = min_index;
10719 for (i = 1; i < len; i++) {
10726 if (max_index - min_index + 1 == len) {
10730 for (i = 0; i < len; i++) {
10756 for (
int i = 0; i < real_size; i++) {
10757 storage->
set(index + i, descs->
GetKey(i));
10775 uint32_t length = IsJSArray() ?
10776 static_cast<uint32_t
>(
10779 if (length == 0)
return 0;
10794 int length = IsJSArray() ?
10797 for (
int i = 0; i < length; i++) {
10799 if (storage !=
NULL) {
10810 int length = IsJSArray() ?
10813 for (
int i = 0; i < length; i++) {
10815 if (storage !=
NULL) {
10826 while (counter < length) {
10827 if (storage !=
NULL) {
10844 while (counter < length) {
10845 if (storage !=
NULL) {
10854 if (storage !=
NULL) {
10864 int mapped_length = parameter_map->
length() - 2;
10866 if (arguments->IsDictionary()) {
10871 if (storage !=
NULL) {
10876 for (
int i = 0; i < mapped_length; ++i) {
10877 if (!parameter_map->
get(i + 2)->IsTheHole()) {
10885 int backing_length = arguments->
length();
10887 for (; i < mapped_length; ++i) {
10888 if (!parameter_map->
get(i + 2)->IsTheHole()) {
10891 }
else if (i < backing_length && !arguments->
get(i)->IsTheHole()) {
10896 for (; i < backing_length; ++i) {
10905 if (this->IsJSValue()) {
10907 if (val->IsString()) {
10910 for (
int i = 0; i < str->
length(); i++) {
10914 counter += str->
length();
10924 static_cast<PropertyAttributes>(
DONT_ENUM));
10961 int scope_position)
10964 language_mode_(language_mode),
10965 scope_position_(scope_position) { }
10968 if (!other->IsFixedArray())
return false;
10971 if (shared != shared_)
return false;
10972 int language_unchecked =
Smi::cast(other_array->
get(2))->value();
10977 if (language_mode != language_mode_)
return false;
10978 int scope_position =
Smi::cast(other_array->
get(3))->value();
10979 if (scope_position != scope_position_)
return false;
10981 return source->
Equals(source_);
10987 int scope_position) {
10988 uint32_t hash = source->
Hash();
10997 if (language_mode ==
STRICT_MODE) hash ^= 0x8000;
10999 hash += scope_position;
11006 source_, shared_, language_mode_, scope_position_);
11013 int language_unchecked =
Smi::cast(other_array->
get(2))->value();
11018 int scope_position =
Smi::cast(other_array->
get(3))->value();
11020 source, shared, language_mode, scope_position);
11026 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
11029 other_array->
set(0, shared_);
11030 other_array->
set(1, source_);
11033 return other_array;
11040 int scope_position_;
11049 flags_(
Smi::FromInt(flags.value())) { }
11077 return string->Hash() + flags->
value();
11111 return Isolate::Current()->heap()->AllocateSymbol(
11122 template <
typename Char>
11133 if (hasher.has_trivial_hash()) {
11140 hasher.AddCharacter(static_cast<uc32>(
string_[i]));
11147 hasher.AddCharacterNoIndex(static_cast<uc32>(
string_[i]));
11192 : string_(string), from_(from), length_(length), seed_(seed) { }
11196 ASSERT(from_ + length_ <= string_->length());
11197 StringHasher hasher(length_, string_->GetHeap()->HashSeed());
11201 if (hasher.has_trivial_hash()) {
11202 hash_field_ = hasher.GetHashField();
11207 while (i < length_ && hasher.is_array_index()) {
11208 hasher.AddCharacter(static_cast<uc32>(
11209 string_->SeqAsciiStringGet(i + from_)));
11215 while (i < length_) {
11216 hasher.AddCharacterNoIndex(static_cast<uc32>(
11217 string_->SeqAsciiStringGet(i + from_)));
11220 hash_field_ = hasher.GetHashField();
11239 if (hash_field_ == 0)
Hash();
11241 return HEAP->AllocateAsciiSymbol(chars, hash_field_);
11248 uint32_t hash_field_;
11312 template<
typename Shape,
typename Key>
11314 IteratePointers(v, 0, kElementsStartOffset);
11318 template<
typename Shape,
typename Key>
11321 kElementsStartOffset,
11322 kHeaderSize + length() * kPointerSize);
11326 template<
typename Shape,
typename Key>
11331 int capacity = (capacity_option == USE_CUSTOM_MINIMUM_CAPACITY)
11332 ? at_least_space_for
11333 : ComputeCapacity(at_least_space_for);
11339 { MaybeObject* maybe_obj = Isolate::Current()->heap()->
11340 AllocateHashTable(EntryToIndex(capacity), pretenure);
11341 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
11352 if (!key->IsSymbol()) {
11368 uint32_t count = 1;
11372 Object* element =
get(index);
11373 if (element->IsUndefined())
break;
11374 if (key == element)
return entry;
11375 if (!element->IsSymbol() &&
11376 !element->IsTheHole() &&
11384 entry =
NextProbe(entry, count++, capacity);
11390 template<
typename Shape,
typename Key>
11398 for (
int i = kPrefixStartIndex;
11399 i < kPrefixStartIndex + Shape::kPrefixSize;
11401 new_table->
set(i,
get(i), mode);
11405 int capacity = Capacity();
11406 for (
int i = 0; i < capacity; i++) {
11407 uint32_t from_index = EntryToIndex(i);
11408 Object* k =
get(from_index);
11411 uint32_t insertion_index =
11413 for (
int j = 0; j < Shape::kEntrySize; j++) {
11414 new_table->
set(insertion_index + j,
get(from_index + j), mode);
11424 template<
typename Shape,
typename Key>
11426 int capacity = Capacity();
11427 int nof = NumberOfElements() + n;
11428 int nod = NumberOfDeletedElements();
11432 if (nod <= (capacity - nof) >> 1) {
11433 int needed_free = nof >> 1;
11434 if (nof + needed_free <= capacity)
return this;
11437 const int kMinCapacityForPretenure = 256;
11439 (capacity > kMinCapacityForPretenure) && !GetHeap()->InNewSpace(
this);
11441 { MaybeObject* maybe_obj =
11443 USE_DEFAULT_MINIMUM_CAPACITY,
11445 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
11452 template<
typename Shape,
typename Key>
11454 int capacity = Capacity();
11455 int nof = NumberOfElements();
11459 if (nof > (capacity >> 2))
return this;
11464 int at_least_room_for = nof;
11465 if (at_least_room_for < 16)
return this;
11467 const int kMinCapacityForPretenure = 256;
11469 (at_least_room_for > kMinCapacityForPretenure) &&
11470 !GetHeap()->InNewSpace(
this);
11472 { MaybeObject* maybe_obj =
11473 Allocate(at_least_room_for,
11474 USE_DEFAULT_MINIMUM_CAPACITY,
11476 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
11483 template<
typename Shape,
typename Key>
11485 uint32_t capacity = Capacity();
11486 uint32_t entry = FirstProbe(hash, capacity);
11487 uint32_t count = 1;
11490 Object* element = KeyAt(entry);
11491 if (element->IsUndefined() || element->IsTheHole())
break;
11492 entry = NextProbe(entry, count++, capacity);
11526 uint32_t, Object*);
11529 AtPut(uint32_t, Object*);
11567 String*, Object*, PropertyDetails);
11569 template MaybeObject*
11577 uint32_t, Object*, PropertyDetails);
11580 uint32_t, Object*, PropertyDetails);
11592 AddEntry(uint32_t, Object*, PropertyDetails, uint32_t);
11595 AddEntry(uint32_t, Object*, PropertyDetails, uint32_t);
11598 String*, Object*, PropertyDetails, uint32_t);
11621 Object* new_double;
11623 if (!maybe_new_double->ToObject(&new_double))
return maybe_new_double;
11629 { MaybeObject* maybe_obj =
11631 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
11638 uint32_t undefs = 0;
11640 for (
int i = 0; i < capacity; i++) {
11641 Object* k = dict->
KeyAt(i);
11642 if (dict->
IsKey(k)) {
11647 Object* value = dict->
ValueAt(i);
11648 PropertyDetails details = dict->
DetailsAt(i);
11658 if (value->IsUndefined()) {
11666 new_dict->
AddNumberEntry(pos, value, details)->ToObjectUnchecked();
11675 new_dict->
AddNumberEntry(key, value, details)->ToObjectUnchecked();
11680 uint32_t result = pos;
11681 PropertyDetails no_details = PropertyDetails(
NONE,
NORMAL);
11683 while (undefs > 0) {
11689 new_dict->
AddNumberEntry(pos, heap->undefined_value(), no_details)->
11690 ToObjectUnchecked();
11695 set_elements(new_dict);
11702 result_double->
set_value(static_cast<double>(result));
11703 return result_double;
11727 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
11732 { MaybeObject* maybe_new_array =
11734 if (!maybe_new_array->ToObject(&new_array))
return maybe_new_array;
11747 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
11756 uint32_t elements_length =
static_cast<uint32_t
>(elements_base->
length());
11757 if (limit > elements_length) {
11758 limit = elements_length ;
11768 Object* new_double;
11770 if (!maybe_new_double->ToObject(&new_double))
return maybe_new_double;
11775 uint32_t result = 0;
11776 if (elements_base->
map() == heap->fixed_double_array_map()) {
11779 unsigned int holes = limit;
11782 for (
unsigned int i = 0; i < holes; i++) {
11789 while (holes > i) {
11799 while (holes < limit) {
11810 unsigned int undefs = limit;
11811 unsigned int holes = limit;
11814 for (
unsigned int i = 0; i < undefs; i++) {
11815 Object* current = elements->
get(i);
11816 if (current->IsTheHole()) {
11819 }
else if (current->IsUndefined()) {
11825 while (undefs > i) {
11826 current = elements->
get(undefs);
11827 if (current->IsTheHole()) {
11830 }
else if (current->IsUndefined()) {
11833 elements->
set(i, current, write_barrier);
11839 while (undefs < holes) {
11843 while (holes < limit) {
11853 result_double->
set_value(static_cast<double>(result));
11854 return result_double;
11859 uint8_t clamped_value = 0;
11860 if (index < static_cast<uint32_t>(
length())) {
11861 if (value->IsSmi()) {
11863 if (int_value < 0) {
11865 }
else if (int_value > 255) {
11866 clamped_value = 255;
11868 clamped_value =
static_cast<uint8_t
>(int_value);
11870 }
else if (value->IsHeapNumber()) {
11872 if (!(double_value > 0)) {
11875 }
else if (double_value > 255) {
11877 clamped_value = 255;
11880 clamped_value =
static_cast<uint8_t
>(lrint(double_value));
11885 ASSERT(value->IsUndefined());
11887 set(index, clamped_value);
11893 template<
typename ExternalArrayClass,
typename ValueType>
11894 static MaybeObject* ExternalArrayIntSetter(
Heap* heap,
11895 ExternalArrayClass* receiver,
11898 ValueType cast_value = 0;
11899 if (index < static_cast<uint32_t>(receiver->length())) {
11900 if (value->IsSmi()) {
11902 cast_value =
static_cast<ValueType
>(int_value);
11903 }
else if (value->IsHeapNumber()) {
11905 cast_value =
static_cast<ValueType
>(
DoubleToInt32(double_value));
11909 ASSERT(value->IsUndefined());
11911 receiver->set(index, cast_value);
11918 return ExternalArrayIntSetter<ExternalByteArray, int8_t>
11919 (
GetHeap(),
this, index, value);
11925 return ExternalArrayIntSetter<ExternalUnsignedByteArray, uint8_t>
11926 (
GetHeap(),
this, index, value);
11932 return ExternalArrayIntSetter<ExternalShortArray, int16_t>
11933 (
GetHeap(),
this, index, value);
11939 return ExternalArrayIntSetter<ExternalUnsignedShortArray, uint16_t>
11940 (
GetHeap(),
this, index, value);
11945 return ExternalArrayIntSetter<ExternalIntArray, int32_t>
11946 (
GetHeap(),
this, index, value);
11951 uint32_t cast_value = 0;
11953 if (index < static_cast<uint32_t>(
length())) {
11954 if (value->IsSmi()) {
11956 cast_value =
static_cast<uint32_t
>(int_value);
11957 }
else if (value->IsHeapNumber()) {
11959 cast_value =
static_cast<uint32_t
>(
DoubleToUint32(double_value));
11963 ASSERT(value->IsUndefined());
11965 set(index, cast_value);
11974 if (index < static_cast<uint32_t>(
length())) {
11975 if (value->IsSmi()) {
11977 cast_value =
static_cast<float>(int_value);
11978 }
else if (value->IsHeapNumber()) {
11980 cast_value =
static_cast<float>(double_value);
11984 ASSERT(value->IsUndefined());
11986 set(index, cast_value);
11995 if (index < static_cast<uint32_t>(
length())) {
11996 if (value->IsSmi()) {
11998 double_value =
static_cast<double>(int_value);
11999 }
else if (value->IsHeapNumber()) {
12004 ASSERT(value->IsUndefined());
12006 set(index, double_value);
12022 Isolate* isolate = global->GetIsolate();
12024 global->EnsurePropertyCell(*name),
12035 { MaybeObject* maybe_cell =
12037 if (!maybe_cell->ToObject(&cell))
return maybe_cell;
12040 details = details.AsDeleted();
12041 Object* dictionary;
12042 { MaybeObject* maybe_dictionary =
12044 if (!maybe_dictionary->ToObject(&dictionary))
return maybe_dictionary;
12050 ASSERT(value->IsJSGlobalPropertyCell());
12058 return LookupKey(&key, s);
12070 : c1_(c1), c2_(c2) {
12072 uint32_t hash =
seed;
12074 hash += hash << 10;
12078 hash += hash << 10;
12082 hash ^= hash >> 11;
12083 hash += hash << 15;
12093 ASSERT_EQ(static_cast<int>(hasher.GetHash()), static_cast<int>(hash));
12099 if (!o->IsString())
return false;
12101 if (other->
length() != 2)
return false;
12102 if (other->Get(0) != c1_)
return false;
12103 return other->Get(1) == c2_;
12108 if (!key->IsString())
return 0;
12133 ASSERT(StringShape(result).IsSymbol());
12149 ASSERT(StringShape(result).IsSymbol());
12159 return LookupKey(&key, s);
12166 return LookupKey(&key, s);
12175 return LookupKey(&key, s);
12182 return LookupKey(&key, s);
12185 MaybeObject* SymbolTable::LookupKey(
HashTableKey* key, Object** s) {
12197 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
12202 { MaybeObject* maybe_symbol = key->
AsObject();
12203 if (!maybe_symbol->ToObject(&symbol))
return maybe_symbol;
12209 SymbolTable* table =
reinterpret_cast<SymbolTable*
>(obj);
12212 entry = table->FindInsertionEntry(key->
Hash());
12214 table->ElementAdded();
12225 return FLAG_use_strict
12235 CurrentGlobalLanguageMode(),
12236 RelocInfo::kNoPosition);
12246 int scope_position) {
12248 context->
closure()->shared(),
12272 CurrentGlobalLanguageMode(),
12273 RelocInfo::kNoPosition);
12276 if (!maybe_cache->To(&cache))
return maybe_cache;
12279 MaybeObject* maybe_k = key.
AsObject();
12280 if (!maybe_k->To(&k))
return maybe_k;
12293 int scope_position) {
12295 context->
closure()->shared(),
12300 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
12308 { MaybeObject* maybe_k = key.
AsObject();
12309 if (!maybe_k->ToObject(&k))
return maybe_k;
12325 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
12341 Object* the_hole_value =
GetHeap()->the_hole_value();
12342 for (
int entry = 0, size =
Capacity(); entry < size; entry++) {
12344 int value_index = entry_index + 1;
12345 if (
get(value_index) == value) {
12362 int len = symbols_->
length();
12363 if (o->
length() != len)
return false;
12364 for (
int i = 0; i < len; i++) {
12365 if (o->
get(i) != symbols_->
get(i))
return false;
12374 int len = symbols->
length();
12376 for (
int i = 0; i < len; i++) {
12401 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
12413 template<
typename Shape,
typename Key>
12416 { MaybeObject* maybe_obj =
12418 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
12422 SetNextEnumerationIndex(PropertyDetails::kInitialIndex);
12430 dictionary->GenerateNewEnumerationIndices());
12433 template<
typename Shape,
typename Key>
12441 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
12444 for (
int i = 0; i < length; i++) {
12450 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
12457 for (
int i = 0; i < capacity; i++) {
12459 int index = DetailsAt(i).dictionary_index();
12465 iteration_order->
SortPairs(enumeration_order, enumeration_order->
length());
12468 for (
int i = 0; i < length; i++) {
12469 int index =
Smi::cast(iteration_order->
get(i))->value();
12470 int enum_index = PropertyDetails::kInitialIndex + i;
12477 for (
int i = 0; i < capacity; i++) {
12479 int enum_index =
Smi::cast(enumeration_order->
get(pos++))->value();
12480 PropertyDetails details = DetailsAt(i);
12481 PropertyDetails new_details =
12482 PropertyDetails(details.attributes(), details.type(), enum_index);
12483 DetailsAtPut(i, new_details);
12488 SetNextEnumerationIndex(PropertyDetails::kInitialIndex+length);
12492 template<
typename Shape,
typename Key>
12495 if (Shape::kIsEnumerable &&
12496 !PropertyDetails::IsValidIndex(NextEnumerationIndex() + n)) {
12499 { MaybeObject* maybe_result = GenerateNewEnumerationIndices();
12500 if (!maybe_result->ToObject(&result))
return maybe_result;
12507 template<
typename Shape,
typename Key>
12511 PropertyDetails details = DetailsAt(entry);
12514 return heap->false_value();
12516 SetEntry(entry, heap->the_hole_value(), heap->the_hole_value());
12518 return heap->true_value();
12522 template<
typename Shape,
typename Key>
12528 template<
typename Shape,
typename Key>
12530 int entry = this->FindEntry(key);
12534 ValueAtPut(entry, value);
12540 { MaybeObject* maybe_obj = EnsureCapacity(1, key);
12541 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
12545 { MaybeObject* maybe_k = Shape::AsObject(key);
12546 if (!maybe_k->ToObject(&k))
return maybe_k;
12548 PropertyDetails details = PropertyDetails(
NONE,
NORMAL);
12555 template<
typename Shape,
typename Key>
12558 PropertyDetails details) {
12559 ASSERT(details.dictionary_index() == details.descriptor_index());
12565 { MaybeObject* maybe_obj = EnsureCapacity(1, key);
12566 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
12575 template<
typename Shape,
typename Key>
12578 PropertyDetails details,
12582 { MaybeObject* maybe_k = Shape::AsObject(key);
12583 if (!maybe_k->ToObject(&k))
return maybe_k;
12588 if (!details.IsDeleted() &&
12589 details.dictionary_index() == 0 &&
12590 Shape::kIsEnumerable) {
12593 int index = NextEnumerationIndex();
12594 details = PropertyDetails(details.attributes(), details.type(), index);
12595 SetNextEnumerationIndex(index + 1);
12597 SetEntry(entry, k, value, details);
12626 PropertyDetails details) {
12629 return Add(key, value, details);
12642 return AtPut(key, value);
12648 return AtPut(key, value);
12656 PropertyDetails details) {
12658 dictionary->Set(index, *value, details),
12668 dictionary->Set(index, *value),
12675 PropertyDetails details) {
12679 details = PropertyDetails(details.attributes(),
12683 Object* object_key;
12684 if (!maybe_object_key->ToObject(&object_key))
return maybe_object_key;
12685 SetEntry(entry, object_key, value, details);
12695 Object* object_key;
12696 if (!maybe_object_key->ToObject(&object_key))
return maybe_object_key;
12697 SetEntry(entry, object_key, value);
12703 template<
typename Shape,
typename Key>
12708 for (
int i = 0; i < capacity; i++) {
12711 PropertyDetails details = DetailsAt(i);
12712 if (details.IsDeleted())
continue;
12714 if ((attr & filter) == 0) result++;
12721 template<
typename Shape,
typename Key>
12723 return NumberOfElementsFilterAttributes(
12724 static_cast<PropertyAttributes>(
DONT_ENUM));
12728 template<
typename Shape,
typename Key>
12736 for (
int i = 0; i < capacity; i++) {
12739 PropertyDetails details = DetailsAt(i);
12740 if (details.IsDeleted())
continue;
12742 if ((attr & filter) == 0) storage->
set(index++, k);
12745 if (sort_mode == Dictionary<Shape, Key>::SORTED) {
12753 int length = storage->
length();
12756 Object* undefined_value = heap->undefined_value();
12758 int properties = 0;
12763 for (
int i = 0; i < capacity; i++) {
12764 Object* k =
KeyAt(i);
12766 PropertyDetails details =
DetailsAt(i);
12767 if (details.IsDeleted() || details.IsDontEnum())
continue;
12769 storage->
set(details.dictionary_index() - 1, k);
12770 if (properties == length)
break;
12778 if (properties < length) {
12779 if (properties == 0)
return heap->empty_fixed_array();
12781 for (
int i = 0; i <
length; ++i) {
12782 Object* value = storage->
get(i);
12783 if (value != undefined_value) {
12784 storage->
set(properties, value);
12788 RightTrimFixedArray<FROM_MUTATOR>(heap, storage, length - properties);
12794 template<
typename Shape,
typename Key>
12799 ASSERT(storage->
length() >= NumberOfElementsFilterAttributes(
12800 static_cast<PropertyAttributes>(
NONE)));
12802 for (
int i = 0; i < capacity; i++) {
12805 PropertyDetails details = DetailsAt(i);
12806 if (details.IsDeleted())
continue;
12807 storage->
set(index++, k);
12810 if (sort_mode == Dictionary<Shape, Key>::SORTED) {
12818 template<
typename Shape,
typename Key>
12821 for (
int i = 0; i < capacity; i++) {
12824 Object* e = ValueAt(i);
12825 if (e->IsJSGlobalPropertyCell()) {
12828 if (e == value)
return k;
12832 return heap->undefined_value();
12837 JSObject* obj,
int unused_property_fields) {
12845 if (maybe_result->IsFailure())
return maybe_result;
12848 int instance_descriptor_length = 0;
12849 int number_of_fields = 0;
12855 for (
int i = 0; i < capacity; i++) {
12856 Object* k =
KeyAt(i);
12861 instance_descriptor_length++;
12863 (!value->IsJSFunction() || heap->
InNewSpace(value))) {
12864 number_of_fields += 1;
12874 if (!maybe_new_map->To(&new_map))
return maybe_new_map;
12877 if (instance_descriptor_length == 0) {
12878 ASSERT_LE(unused_property_fields, inobject_props);
12882 obj->set_properties(heap->empty_fixed_array());
12890 MaybeObject* maybe_descriptors =
12892 if (!maybe_descriptors->To(&descriptors)) {
12893 return maybe_descriptors;
12898 int number_of_allocated_fields =
12899 number_of_fields + unused_property_fields - inobject_props;
12900 if (number_of_allocated_fields < 0) {
12902 number_of_allocated_fields = 0;
12903 unused_property_fields = inobject_props - number_of_fields;
12908 MaybeObject* maybe_fields =
12910 if (!maybe_fields->To(&fields))
return maybe_fields;
12913 int current_offset = 0;
12914 for (
int i = 0; i < capacity; i++) {
12915 Object* k =
KeyAt(i);
12921 if (!maybe_key->To(&key))
return maybe_key;
12923 PropertyDetails details =
DetailsAt(i);
12924 ASSERT(details.descriptor_index() == details.dictionary_index());
12925 int enumeration_index = details.descriptor_index();
12928 if (value->IsJSFunction() && !heap->
InNewSpace(value)) {
12931 details.attributes(),
12932 enumeration_index);
12933 descriptors->
Set(enumeration_index - 1, &d, witness);
12934 }
else if (type ==
NORMAL) {
12935 if (current_offset < inobject_props) {
12940 int offset = current_offset - inobject_props;
12941 fields->
set(offset, value);
12945 details.attributes(),
12946 enumeration_index);
12947 descriptors->
Set(enumeration_index - 1, &d, witness);
12951 details.attributes(),
12952 enumeration_index);
12953 descriptors->
Set(enumeration_index - 1, &d, witness);
12959 ASSERT(current_offset == number_of_fields);
12961 descriptors->
Sort();
12969 obj->set_properties(fields);
12970 ASSERT(obj->IsJSObject());
12984 if (maybe_hash->ToObjectUnchecked()->IsUndefined())
return false;
12996 if (maybe_hash->IsFailure())
return maybe_hash;
12997 hash =
Smi::cast(maybe_hash->ToObjectUnchecked())->value();
13007 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
13022 if (maybe_hash->ToObjectUnchecked()->IsUndefined())
return this;
13041 if (maybe_hash->ToObjectUnchecked()->IsUndefined()) {
13042 return GetHeap()->the_hole_value();
13057 if (maybe_hash->IsFailure())
return maybe_hash;
13058 hash =
Smi::cast(maybe_hash->ToObjectUnchecked())->value();
13063 if (value->IsTheHole()) {
13065 RemoveEntry(entry);
13078 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
13086 void ObjectHashTable::AddEntry(
int entry, Object* key, Object* value) {
13093 void ObjectHashTable::RemoveEntry(
int entry) {
13100 #ifdef ENABLE_DEBUGGER_SUPPORT
13102 bool DebugInfo::HasBreakPoint(
int code_position) {
13104 Object* break_point_info = GetBreakPointInfo(code_position);
13108 if (break_point_info->IsUndefined())
return false;
13109 return BreakPointInfo::cast(break_point_info)->GetBreakPointCount() > 0;
13114 Object* DebugInfo::GetBreakPointInfo(
int code_position) {
13116 int index = GetBreakPointInfoIndex(code_position);
13119 if (index == kNoBreakPointInfo)
return GetHeap()->undefined_value();
13120 return BreakPointInfo::cast(break_points()->
get(index));
13125 void DebugInfo::ClearBreakPoint(Handle<DebugInfo> debug_info,
13127 Handle<Object> break_point_object) {
13128 Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_position));
13129 if (break_point_info->IsUndefined())
return;
13130 BreakPointInfo::ClearBreakPoint(
13131 Handle<BreakPointInfo>::cast(break_point_info),
13132 break_point_object);
13136 void DebugInfo::SetBreakPoint(Handle<DebugInfo> debug_info,
13138 int source_position,
13139 int statement_position,
13140 Handle<Object> break_point_object) {
13141 Isolate* isolate = Isolate::Current();
13142 Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_position));
13143 if (!break_point_info->IsUndefined()) {
13144 BreakPointInfo::SetBreakPoint(
13145 Handle<BreakPointInfo>::cast(break_point_info),
13146 break_point_object);
13152 int index = kNoBreakPointInfo;
13153 for (
int i = 0; i < debug_info->break_points()->length(); i++) {
13154 if (debug_info->break_points()->get(i)->IsUndefined()) {
13159 if (index == kNoBreakPointInfo) {
13161 Handle<FixedArray> old_break_points =
13163 Handle<FixedArray> new_break_points =
13164 isolate->factory()->NewFixedArray(
13165 old_break_points->length() +
13166 Debug::kEstimatedNofBreakPointsInFunction);
13168 debug_info->set_break_points(*new_break_points);
13169 for (
int i = 0; i < old_break_points->length(); i++) {
13170 new_break_points->set(i, old_break_points->get(i));
13172 index = old_break_points->length();
13174 ASSERT(index != kNoBreakPointInfo);
13179 new_break_point_info->set_code_position(
Smi::FromInt(code_position));
13180 new_break_point_info->set_source_position(
Smi::FromInt(source_position));
13181 new_break_point_info->
13182 set_statement_position(
Smi::FromInt(statement_position));
13183 new_break_point_info->set_break_point_objects(
13184 isolate->heap()->undefined_value());
13185 BreakPointInfo::SetBreakPoint(new_break_point_info, break_point_object);
13186 debug_info->break_points()->set(index, *new_break_point_info);
13191 Object* DebugInfo::GetBreakPointObjects(
int code_position) {
13192 Object* break_point_info = GetBreakPointInfo(code_position);
13193 if (break_point_info->IsUndefined()) {
13194 return GetHeap()->undefined_value();
13196 return BreakPointInfo::cast(break_point_info)->break_point_objects();
13201 int DebugInfo::GetBreakPointCount() {
13202 if (break_points()->IsUndefined())
return 0;
13204 for (
int i = 0; i < break_points()->length(); i++) {
13205 if (!break_points()->get(i)->IsUndefined()) {
13206 BreakPointInfo* break_point_info =
13207 BreakPointInfo::cast(break_points()->
get(i));
13208 count += break_point_info->GetBreakPointCount();
13215 Object* DebugInfo::FindBreakPointInfo(Handle<DebugInfo> debug_info,
13216 Handle<Object> break_point_object) {
13217 Heap* heap = debug_info->GetHeap();
13218 if (debug_info->break_points()->IsUndefined())
return heap->undefined_value();
13219 for (
int i = 0; i < debug_info->break_points()->length(); i++) {
13220 if (!debug_info->break_points()->get(i)->IsUndefined()) {
13221 Handle<BreakPointInfo> break_point_info =
13222 Handle<BreakPointInfo>(BreakPointInfo::cast(
13223 debug_info->break_points()->get(i)));
13224 if (BreakPointInfo::HasBreakPointObject(break_point_info,
13225 break_point_object)) {
13226 return *break_point_info;
13230 return heap->undefined_value();
13236 int DebugInfo::GetBreakPointInfoIndex(
int code_position) {
13237 if (break_points()->IsUndefined())
return kNoBreakPointInfo;
13238 for (
int i = 0; i < break_points()->length(); i++) {
13239 if (!break_points()->get(i)->IsUndefined()) {
13240 BreakPointInfo* break_point_info =
13241 BreakPointInfo::cast(break_points()->
get(i));
13242 if (break_point_info->code_position()->value() == code_position) {
13247 return kNoBreakPointInfo;
13252 void BreakPointInfo::ClearBreakPoint(Handle<BreakPointInfo> break_point_info,
13253 Handle<Object> break_point_object) {
13254 Isolate* isolate = Isolate::Current();
13256 if (break_point_info->break_point_objects()->IsUndefined())
return;
13258 if (!break_point_info->break_point_objects()->IsFixedArray()) {
13259 if (break_point_info->break_point_objects() == *break_point_object) {
13260 break_point_info->set_break_point_objects(
13261 isolate->heap()->undefined_value());
13266 ASSERT(break_point_info->break_point_objects()->IsFixedArray());
13267 Handle<FixedArray> old_array =
13268 Handle<FixedArray>(
13270 Handle<FixedArray> new_array =
13271 isolate->factory()->NewFixedArray(old_array->length() - 1);
13272 int found_count = 0;
13273 for (
int i = 0; i < old_array->length(); i++) {
13274 if (old_array->get(i) == *break_point_object) {
13275 ASSERT(found_count == 0);
13278 new_array->set(i - found_count, old_array->get(i));
13282 if (found_count > 0) break_point_info->set_break_point_objects(*new_array);
13287 void BreakPointInfo::SetBreakPoint(Handle<BreakPointInfo> break_point_info,
13288 Handle<Object> break_point_object) {
13290 if (break_point_info->break_point_objects()->IsUndefined()) {
13291 break_point_info->set_break_point_objects(*break_point_object);
13295 if (break_point_info->break_point_objects() == *break_point_object)
return;
13297 if (!break_point_info->break_point_objects()->IsFixedArray()) {
13298 Handle<FixedArray> array =
FACTORY->NewFixedArray(2);
13299 array->set(0, break_point_info->break_point_objects());
13300 array->set(1, *break_point_object);
13301 break_point_info->set_break_point_objects(*array);
13305 Handle<FixedArray> old_array =
13306 Handle<FixedArray>(
13308 Handle<FixedArray> new_array =
13309 FACTORY->NewFixedArray(old_array->length() + 1);
13310 for (
int i = 0; i < old_array->length(); i++) {
13312 if (old_array->get(i) == *break_point_object)
return;
13313 new_array->set(i, old_array->get(i));
13316 new_array->set(old_array->length(), *break_point_object);
13317 break_point_info->set_break_point_objects(*new_array);
13321 bool BreakPointInfo::HasBreakPointObject(
13322 Handle<BreakPointInfo> break_point_info,
13323 Handle<Object> break_point_object) {
13325 if (break_point_info->break_point_objects()->IsUndefined())
return false;
13327 if (!break_point_info->break_point_objects()->IsFixedArray()) {
13328 return break_point_info->break_point_objects() == *break_point_object;
13331 FixedArray* array =
FixedArray::cast(break_point_info->break_point_objects());
13332 for (
int i = 0; i < array->length(); i++) {
13333 if (array->get(i) == *break_point_object) {
13342 int BreakPointInfo::GetBreakPointCount() {
13344 if (break_point_objects()->IsUndefined())
return 0;
13346 if (!break_point_objects()->IsFixedArray())
return 1;
13350 #endif // ENABLE_DEBUGGER_SUPPORT
13355 static_cast<FieldIndex>(index->
value()));
13359 Object* JSDate::DoGetField(FieldIndex index) {
13365 Object* stamp = cache_stamp();
13366 if (stamp != date_cache->
stamp() && stamp->IsSmi()) {
13368 int64_t local_time_ms =
13369 date_cache->
ToLocal(static_cast<int64_t>(value()->
Number()));
13370 SetLocalFields(local_time_ms, date_cache);
13373 case kYear:
return year();
13374 case kMonth:
return month();
13375 case kDay:
return day();
13377 case kHour:
return hour();
13385 return GetUTCField(index, value()->
Number(), date_cache);
13388 double time = value()->
Number();
13391 int64_t local_time_ms = date_cache->
ToLocal(static_cast<int64_t>(time));
13403 Object* JSDate::GetUTCField(FieldIndex index,
13405 DateCache* date_cache) {
13410 int64_t time_ms =
static_cast<int64_t
>(value);
13413 return Smi::FromInt(date_cache->TimezoneOffset(time_ms));
13421 int year, month, day;
13422 date_cache->YearMonthDayFromDays(days, &year, &month, &day);
13447 if (is_value_nan) {
13463 void JSDate::SetLocalFields(int64_t local_time_ms,
DateCache* date_cache) {
13466 int year, month, day;
13468 int weekday = date_cache->
Weekday(days);
13469 int hour = time_in_day_ms / (60 * 60 * 1000);
13470 int min = (time_in_day_ms / (60 * 1000)) % 60;
13471 int sec = (time_in_day_ms / 1000) % 60;
13472 set_cache_stamp(date_cache->
stamp());
static bool IsBlack(MarkBit mark_bit)
MUST_USE_RESULT MaybeObject * CopyInsertDescriptor(Descriptor *descriptor, TransitionFlag flag)
MUST_USE_RESULT MaybeObject * GetElementWithReceiver(Object *receiver, uint32_t index)
bool FLAG_enable_slow_asserts
MUST_USE_RESULT MaybeObject * GetElementWithInterceptor(Object *receiver, uint32_t index)
static const int kInitialSize
void SetEnumCache(FixedArray *bridge_storage, FixedArray *new_cache, Object *new_index_cache)
MUST_USE_RESULT MaybeObject * LookupAsciiSymbol(Vector< const char > str, Object **s)
void ClearTypeFeedbackCells(Heap *heap)
Object * Lookup(MapHandleList *maps, int code_kind)
int IndexInCodeCache(Object *name, Code *code)
bool IsMatch(Object *string)
bool prohibits_overwriting()
void MarkForParallelRecompilation()
static const int kRequiresSlowElementsTagSize
void set_elements_kind(ElementsKind elements_kind)
bool IsIdentifierPart(unibrow::uchar c)
int CalculateInstanceSize()
void SetBackPointer(Object *value, WriteBarrierMode mode=UPDATE_WRITE_BARRIER)
StringKey(String *string)
static Handle< Object > DeleteElement(Handle< JSObject > obj, uint32_t index)
Object * KeyAt(int entry)
static uchar TrailSurrogate(int char_code)
static Handle< Object > SetProperty(Handle< JSReceiver > object, Handle< String > key, Handle< Object > value, PropertyAttributes attributes, StrictModeFlag strict_mode)
Code * builtin(Name name)
Map * elements_transition()
PropertyAttributes GetPropertyAttribute(String *name)
static const int kGenerousAllocationCount
void set_deopt_count(int value)
JSGlobalPropertyCell * Cell(int index)
Object * get(AccessorComponent component)
#define SLOW_ASSERT(condition)
static bool CompileLazy(Handle< JSFunction > function, ClearExceptionFlag flag)
static DeoptimizationOutputData * cast(Object *obj)
uint32_t HashForObject(Object *other)
void CopyValuesTo(FixedArray *elements)
MUST_USE_RESULT MaybeObject * SetIdentityHash(Smi *hash, CreationFlag flag)
Object * Lookup(String *name, Code::Flags flags)
static const int kNotFound
#define CHECK_EQ(expected, value)
static uchar LeadSurrogate(int char_code)
bool IsExternalArrayElementsKind(ElementsKind kind)
bool IsHoleyElementsKind(ElementsKind kind)
static const int kCodeEntryOffset
Object * LookupAccessor(String *name, AccessorComponent component)
MUST_USE_RESULT MaybeObject * AllocateFixedArray(int length, PretenureFlag pretenure)
static const int kArrayIndexHashMask
bool HasElementsTransition()
void SeqAsciiStringReadBlockIntoBuffer(ReadBlockBuffer *buffer, unsigned *offset, unsigned chars)
int CalculateInObjectProperties()
static int EntryToIndex(int entry)
void InvalidateRelocation()
uint32_t HashForObject(Object *obj)
void AddCharacter(uint32_t c)
const char * ToCString(const v8::String::Utf8Value &value)
int inobject_properties()
void set_has_deoptimization_support(bool value)
virtual uint32_t Hash()=0
Object * LookupRegExp(String *source, JSRegExp::Flags flags)
Handle< String > SymbolFromString(Handle< String > value)
Handle< Value >(* NamedPropertySetter)(Local< String > property, Local< Value > value, const AccessorInfo &info)
uint32_t HashForObject(Object *obj)
void ClearOptimizedCodeMap()
MUST_USE_RESULT MaybeObject * CopyDropDescriptors()
#define RETURN_IF_SCHEDULED_EXCEPTION(isolate)
bool is_hidden_prototype()
void set(int index, Object *value)
MUST_USE_RESULT MaybeObject * TransformPropertiesToFastFor(JSObject *obj, int unused_property_fields)
int SearchOptimizedCodeMap(Context *native_context)
void AddSurrogatePair(uc32 c)
void PrintF(const char *format,...)
static void DoGenerateNewEnumerationIndices(Handle< StringDictionary > dictionary)
bool IsMatch(Object *string)
MUST_USE_RESULT MaybeObject * GetPropertyWithCallback(Object *receiver, Object *structure, String *name)
virtual MUST_USE_RESULT MaybeObject * Delete(JSObject *holder, uint32_t key, JSReceiver::DeleteMode mode)=0
bool InNewSpace(Object *object)
bool EquivalentToForNormalization(Map *other, PropertyNormalizationMode mode)
static TypeFeedbackInfo * cast(Object *obj)
static String * cast(Object *obj)
MUST_USE_RESULT MaybeObject * Add(Key key, Object *value, PropertyDetails details)
StringSharedKey(String *source, SharedFunctionInfo *shared, LanguageMode language_mode, int scope_position)
void SetValue(Object *value, bool is_value_nan)
void DetailsAtPut(int entry, PropertyDetails value)
MUST_USE_RESULT MaybeObject * SetPropertyWithDefinedSetter(JSReceiver *setter, Object *value)
MUST_USE_RESULT MaybeObject * AllocateSubString(String *buffer, int start, int end, PretenureFlag pretenure=NOT_TENURED)
void SetThisPropertyAssignmentsInfo(bool has_only_simple_this_property_assignments, FixedArray *this_property_assignments)
MaybeObject * TryFlatten(PretenureFlag pretenure=NOT_TENURED)
MUST_USE_RESULT PropertyAttributes GetElementAttributeWithHandler(JSReceiver *receiver, uint32_t index)
MUST_USE_RESULT MaybeObject * PrepareSlowElementsForSort(uint32_t limit)
const uint32_t kTwoByteStringTag
uint32_t NumberToUint32(Object *number)
bool HasRealElementProperty(uint32_t index)
BailoutId AstId(int index)
bool function_with_prototype()
void set_opt_count(int opt_count)
Handle< DescriptorArray > NewDescriptorArray(int number_of_descriptors, int slack=0)
uint32_t HashForObject(Object *other)
static Failure * InternalError()
void SeqTwoByteStringReadBlockIntoBuffer(ReadBlockBuffer *buffer, unsigned *offset_ptr, unsigned chars)
int NumberOfLocalElements(PropertyAttributes filter)
bool IsMatch(Object *other)
Object * ToBoolean(bool condition)
void DeleteHiddenProperty(String *key)
int unused_property_fields()
void set_length(Smi *length)
void SourceCodePrint(StringStream *accumulator, int max_length)
PropertyAttributes GetPropertyAttributeWithInterceptor(JSObject *receiver, String *name, bool continue_search)
MUST_USE_RESULT MaybeObject * Put(MapHandleList *maps, int code_kind, Code *code)
MUST_USE_RESULT MaybeObject * ConvertTransitionToMapTransition(int transition_index, String *name, Object *new_value, PropertyAttributes attributes)
static const char * Name(Value tok)
static Smi * FromInt(int value)
bool HasFastSmiElements()
bool IsFastObjectElementsKind(ElementsKind kind)
bool allowed_in_shared_map_code_cache()
void IteratePointer(ObjectVisitor *v, int offset)
#define LOG(isolate, Call)
RegExpKey(String *string, JSRegExp::Flags flags)
unsigned stack_check_table_offset()
Map * elements_transition_map()
void LookupTransition(JSObject *holder, String *name, LookupResult *result)
void CopyKeysTo(FixedArray *storage, PropertyAttributes filter, SortMode sort_mode)
static Object * GetObjectFromEntryAddress(Address location_of_address)
void ReportFailedAccessCheck(JSObject *receiver, v8::AccessType type)
MUST_USE_RESULT MaybeObject * GetElementWithHandler(Object *receiver, uint32_t index)
uint64_t double_to_uint64(double d)
void AddSurrogatePairNoIndex(uc32 c)
bool IsMatch(Object *string)
kPropertyAccessorsOffset kNamedPropertyHandlerOffset kInstanceTemplateOffset kAccessCheckInfoOffset kEvalFrominstructionsOffsetOffset kInstanceClassNameOffset kHiddenPrototypeBit kReadOnlyPrototypeBit kIsTopLevelBit allows_lazy_compilation
bool HasRealNamedProperty(String *key)
int NumberOfOwnDescriptors()
SequentialSymbolKey(Vector< const Char > string, uint32_t seed)
MUST_USE_RESULT MaybeObject * Update(String *name, Code *code)
void CopyTo(int pos, FixedArray *dest, int dest_pos, int len)
MUST_USE_RESULT MaybeObject * GetPropertyWithDefinedGetter(Object *receiver, JSReceiver *getter)
MUST_USE_RESULT MaybeObject * SetPropertyWithFailedAccessCheck(LookupResult *result, String *name, Object *value, bool check_prototype, StrictModeFlag strict_mode)
void VerifyApiCallResultType()
static HeapObject * cast(Object *obj)
MUST_USE_RESULT MaybeObject * Rehash(HashTable *new_table, Key key)
MUST_USE_RESULT MaybeObject * SetInstancePrototype(Object *value)
static Handle< T > cast(Handle< S > that)
MUST_USE_RESULT MaybeObject * SetPrototype(Object *value)
static bool EncodeNonAsciiCharacter(uchar c, byte *buffer, unsigned capacity, unsigned &offset)
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)
const unibrow::byte * ExternalAsciiStringReadBlock(unsigned *remaining, unsigned *offset, unsigned chars)
static CodeCacheHashTable * cast(Object *obj)
static const int kProtoTransitionElementsPerEntry
static AccessorPair * cast(Object *obj)
MUST_USE_RESULT MaybeObject * AddKeysFromJSArray(JSArray *array)
static void IterateBody(HeapObject *obj, int object_size, ObjectVisitor *v)
static Failure * OutOfMemoryException()
JSFunction * GetConstantFunction(int descriptor_number)
void ZapPrototypeTransitions()
PropertyAttributes property_attributes()
bool IsAsciiRepresentation()
TwoCharHashTableKey(uint32_t c1, uint32_t c2, uint32_t seed)
HeapObject * UncheckedPrototypeTransitions()
static ExternalTwoByteString * cast(Object *obj)
bool IsMatch(Object *obj)
void ExternalTwoByteStringReadBlockIntoBuffer(ReadBlockBuffer *buffer, unsigned *offset_ptr, unsigned chars)
TraversableMap * GetAndResetParent()
int GetEnumElementKeys(FixedArray *storage)
MUST_USE_RESULT MaybeObject * GetPropertyWithFailedAccessCheck(Object *receiver, LookupResult *result, String *name, PropertyAttributes *attributes)
SeededNumberDictionary * element_dictionary()
static uint32_t StringHash(Object *obj)
Vector< const char > ToAsciiVector()
static Map * cast(Object *obj)
void CompleteInobjectSlackTracking()
MUST_USE_RESULT MaybeObject * AddNumberEntry(uint32_t key, Object *value, PropertyDetails details)
MUST_USE_RESULT MaybeObject * Put(String *src, Context *context, Object *value)
static StubType ExtractTypeFromFlags(Flags flags)
MUST_USE_RESULT MaybeObject * ConvertDescriptorToField(String *name, Object *new_value, PropertyAttributes attributes)
MUST_USE_RESULT MaybeObject * GetPropertyWithReceiver(Object *receiver, String *key, PropertyAttributes *attributes)
static ByteArray * cast(Object *obj)
static uint32_t ComputeHashField(unibrow::CharacterStream *buffer, int length, uint32_t seed)
MUST_USE_RESULT MaybeObject * SetElementWithCallbackSetterInPrototypes(uint32_t index, Object *value, bool *found, StrictModeFlag strict_mode)
int NumberOfEnumElements()
MUST_USE_RESULT MaybeObject * AsObject()
void ConsStringReadBlockIntoBuffer(ReadBlockBuffer *buffer, unsigned *offset_ptr, unsigned chars)
static FreeSpace * cast(Object *obj)
virtual MUST_USE_RESULT MaybeObject * CopyElements(JSObject *source_holder, uint32_t source_start, FixedArrayBase *destination, ElementsKind destination_kind, uint32_t destination_start, int copy_size, FixedArrayBase *source=NULL)=0
void ClearInstanceofCache()
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)
kPropertyAccessorsOffset kNamedPropertyHandlerOffset kInstanceTemplateOffset kAccessCheckInfoOffset kEvalFrominstructionsOffsetOffset kInstanceClassNameOffset kHiddenPrototypeBit kReadOnlyPrototypeBit is_toplevel
static Failure * Exception()
MUST_USE_RESULT MaybeObject * PutRegExp(String *src, JSRegExp::Flags flags, FixedArray *value)
MUST_USE_RESULT MaybeObject * CopyReplaceDescriptors(DescriptorArray *descriptors, String *name, TransitionFlag flag, int descriptor_index)
void MarkForLazyRecompilation()
void SetKey(int transition_number, String *value)
static Foreign * cast(Object *obj)
MUST_USE_RESULT MaybeObject * GetElementsTransitionMapSlow(ElementsKind elements_kind)
MUST_USE_RESULT MaybeObject * ToObject()
MUST_USE_RESULT MaybeObject * PrepareElementsForSort(uint32_t limit)
Map * SymbolMapForString(String *str)
bool MakeExternal(v8::String::ExternalStringResource *resource)
int GetLocalElementKeys(FixedArray *storage, PropertyAttributes filter)
struct v8::internal::IeeeDoubleBigEndianArchType::@33 bits
int SourceStatementPosition(Address pc)
Map * LookupElementsTransitionMap(ElementsKind elements_kind)
void PrintElementsTransition(FILE *file, ElementsKind from_kind, FixedArrayBase *from_elements, ElementsKind to_kind, FixedArrayBase *to_elements)
uint32_t HashForObject(Object *obj)
static AliasedArgumentsEntry * cast(Object *obj)
bool IsTwoByteEqualTo(Vector< const uc16 > str)
uint16_t SlicedStringGet(int index)
bool Contains(Object *key)
static Handle< Object > TransitionElementsKind(Handle< JSObject > object, ElementsKind to_kind)
void SetEnumLength(int length)
Handle< Object > Lookup(MapHandleList *maps, Code::Flags flags)
Object * HeapNumberToBoolean()
static bool CompileOptimized(Handle< JSFunction > function, BailoutId osr_ast_id, ClearExceptionFlag flag)
List< Handle< Map > > MapHandleList
#define ASSERT(condition)
bool CanTransitionToMoreGeneralFastElementsKind(ElementsKind elements_kind, bool allow_only_packed)
v8::Handle< v8::Value > Print(const v8::Arguments &args)
static void IncrementLiveBytesFromGC(Address address, int by)
MUST_USE_RESULT MaybeObject * SetElement(uint32_t index, Object *value, PropertyAttributes attributes, StrictModeFlag strict_mode, bool check_prototype)
static Handle< Object > SetOwnElement(Handle< JSObject > object, uint32_t index, Handle< Object > value, StrictModeFlag strict_mode)
MUST_USE_RESULT MaybeObject * PreventExtensions()
Map * GetPrototypeTransition(Object *prototype)
static void AppendCallbackDescriptors(Handle< Map > map, Handle< Object > descriptors)
static ExternalUnsignedShortArray * cast(Object *obj)
MUST_USE_RESULT MaybeObject * UnionOfKeys(FixedArray *other)
unibrow::byte * util_buffer
static Script * cast(Object *obj)
MUST_USE_RESULT MaybeObject * PutEval(String *src, Context *context, SharedFunctionInfo *value, int scope_position)
int SourcePosition(Address pc)
MUST_USE_RESULT MaybeObject * EnsureCapacity(int n, Key key)
#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)
MUST_USE_RESULT MaybeObject * SetValue(uint32_t index, Object *value)
void clear_pending_exception()
static Context * cast(Object *context)
Object * SlowReverseLookup(Object *value)
MUST_USE_RESULT MaybeObject * LookupSymbol(Vector< const char > str)
static const int kSourceIndex
PropertyAttributes GetPropertyAttributePostInterceptor(JSObject *receiver, String *name, bool continue_search)
static SharedFunctionInfo * cast(Object *obj)
const uint32_t kStringRepresentationMask
int SizeFromMap(Map *map)
void set(int index, float value)
bool HasElementWithInterceptor(JSReceiver *receiver, uint32_t index)
void ClearElementsTransition()
void RemoveFromCodeCache(String *name, Code *code, int index)
static const int kShortSize
Handle< Value >(* IndexedPropertySetter)(uint32_t index, Local< Value > value, const AccessorInfo &info)
bool IsOptimizing() const
Handle< Object > GetProperty(Handle< JSReceiver > obj, const char *name)
static const int kEntrySize
SmartArrayPointer< uc16 > ToWideCString(RobustnessFlag robustness_flag=FAST_STRING_TRAVERSAL)
Handle< String > NumberToString(Handle< Object > number)
MUST_USE_RESULT MaybeObject * Copy()
bool ReferencesObject(Object *obj)
void ReplaceCode(Code *code)
const uc16 * GetTwoByteData()
void set_map_and_elements(Map *map, FixedArrayBase *value, WriteBarrierMode mode=UPDATE_WRITE_BARRIER)
bool IsFastElementsKind(ElementsKind kind)
static ExternalAsciiString * cast(Object *obj)
MUST_USE_RESULT MaybeObject * EnsureWritableFastElements()
void set_the_hole(int index)
static const int kInvalidStamp
MUST_USE_RESULT MaybeObject * GetPropertyWithInterceptor(Object *receiver, String *name, PropertyAttributes *attributes)
void ClearThisPropertyAssignmentsInfo()
MUST_USE_RESULT MaybeObject * DeletePropertyWithHandler(String *name, DeleteMode mode)
static Code * cast(Object *obj)
Handle< String > LookupAsciiSymbol(Vector< const char > str)
bool IsMatch(Object *string)
virtual const uint16_t * data() const =0
static Handle< Object > SetHiddenProperty(Handle< JSObject > obj, Handle< String > key, Handle< Object > value)
MUST_USE_RESULT MaybeObject * AllocateInternalSymbol(unibrow::CharacterStream *buffer, int chars, uint32_t hash_field)
static uint32_t StringSharedHashHelper(String *source, SharedFunctionInfo *shared, LanguageMode language_mode, int scope_position)
void set(int index, uint32_t value)
MUST_USE_RESULT MaybeObject * LookupSubStringAsciiSymbol(Handle< SeqAsciiString > str, int from, int length, Object **s)
bool HasElementWithReceiver(JSReceiver *receiver, uint32_t index)
int GetSequenceIndexFromFastElementsKind(ElementsKind elements_kind)
bool AsArrayIndex(uint32_t *index)
Object * GetValue(int descriptor_number)
static Object ** RawField(HeapObject *obj, int offset)
Object * GetNormalizedProperty(LookupResult *result)
MUST_USE_RESULT MaybeObject * AllocateHeapNumber(double value, PretenureFlag pretenure)
static Smi * cast(Object *object)
static const char * AllocationIndexToString(int index)
static void IterateBody(HeapObject *obj, ObjectVisitor *v)
static const int kInvalidEnumCache
void ClearCodeCache(Heap *heap)
static const int kZeroHash
bool Equals(String *other)
Handle< String > SubString(Handle< String > str, int start, int end, PretenureFlag pretenure)
MUST_USE_RESULT MaybeObject * Get(JSObject *object, PropertyNormalizationMode mode)
void Lookup(String *name, LookupResult *result)
Vector< const char > string_
MaybeObject *(* setter)(JSObject *object, Object *value, void *data)
Handle< Object > CallTrap(const char *name, Handle< Object > derived_trap, int argc, Handle< Object > args[])
static ExternalShortArray * cast(Object *obj)
MaybeObject *(* getter)(Object *object, void *data)
void LookupCallbackProperty(String *name, LookupResult *result)
JSGlobalPropertyCell * GetPropertyCell(LookupResult *result)
static MarkBit MarkBitFrom(Address addr)
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)
void LookupDescriptor(JSObject *holder, String *name, LookupResult *result)
Handle< Value >(* IndexedPropertyGetter)(uint32_t index, const AccessorInfo &info)
void IterateBody(InstanceType type, int object_size, ObjectVisitor *v)
int this_property_assignments_count()
virtual MUST_USE_RESULT MaybeObject * AsObject()=0
SmartArrayPointer< char > ToCString(AllowNullsFlag allow_nulls, RobustnessFlag robustness_flag, int offset, int length, int *length_output=0)
MUST_USE_RESULT MaybeObject * SetPropertyWithCallback(Object *structure, String *name, Object *value, JSObject *holder, StrictModeFlag strict_mode)
Object * ValueAt(int entry)
Object * InObjectPropertyAtPut(int index, Object *value, WriteBarrierMode mode=UPDATE_WRITE_BARRIER)
MUST_USE_RESULT MaybeObject * SetValue(uint32_t index, Object *value)
Map * GetTransition(int transition_index)
bool IsMatch(Object *symbols)
bool IsInobjectSlackTrackingInProgress()
static const int kMaxNumberKeyIndex
bool LookupSymbolIfExists(String *str, String **symbol)
const uint16_t * SeqTwoByteStringGetData(unsigned start)
void CopyFrom(int dst_index, DescriptorArray *src, int src_index, const WhitenessWitness &)
static const int kMaxCachedPrototypeTransitions
MUST_USE_RESULT MaybeObject * LookupTwoByteSymbol(Vector< const uc16 > str, Object **s)
UnicodeCache * unicode_cache()
bool HasFastSmiOrObjectElements()
MUST_USE_RESULT MaybeObject * GetIdentityHash(CreationFlag flag)
void RemoveByIndex(Object *name, Code *code, int index)
static uchar Length(uchar chr, int previous)
void Remove(Object *value)
static void NoWriteBarrierSet(FixedArray *array, int index, Object *value)
static const uint32_t kMaxGap
bool HasNamedInterceptor()
String * GetKey(int descriptor_number)
bool IsMatch(Object *other)
TwoByteSymbolKey(Vector< const uc16 > str, uint32_t seed)
MUST_USE_RESULT MaybeObject * GetIdentityHash(CreationFlag flag)
bool IsMatch(Object *other)
static const int kTransitionSize
void set_the_hole(int index)
void CopyEnumCacheFrom(DescriptorArray *array)
static void DeoptimizeGlobalObject(JSObject *object)
static const int kLiteralNativeContextIndex
virtual size_t length() const =0
void Iterate(ObjectVisitor *v)
uint32_t HashForObject(Object *other)
void SetOptimizing(BailoutId osr_ast_id)
Handle< Value >(* NamedPropertyGetter)(Local< String > property, const AccessorInfo &info)
virtual MUST_USE_RESULT MaybeObject * AddElementsToFixedArray(Object *receiver, JSObject *holder, FixedArray *to, FixedArrayBase *from=NULL)=0
MUST_USE_RESULT MaybeObject * GetLocalPropertyPostInterceptor(Object *receiver, String *name, PropertyAttributes *attributes)
MUST_USE_RESULT MaybeObject * SetFastElement(uint32_t index, Object *value, StrictModeFlag strict_mode, bool check_prototype)
static void Update(Handle< PolymorphicCodeCache > cache, MapHandleList *maps, Code::Flags flags, Handle< Code > code)
MUST_USE_RESULT MaybeObject * AllocateUninitializedFixedDoubleArray(int length, PretenureFlag pretenure=NOT_TENURED)
static void PrintTop(FILE *file, bool print_args, bool print_line_number)
PolymorphicCodeCacheHashTableKey(MapHandleList *maps, int code_flags)
STATIC_ASSERT((FixedDoubleArray::kHeaderSize &kDoubleAlignmentMask)==0)
static SeededNumberDictionary * cast(Object *obj)
void Append(Descriptor *desc, const WhitenessWitness &)
virtual const char * NameOfCPURegister(int reg) const
bool MarkAsUndetectable()
void LookupRealNamedPropertyInPrototypes(String *name, LookupResult *result)
int NumberOfElementsFilterAttributes(PropertyAttributes filter)
MUST_USE_RESULT MaybeObject * AddConstantFunctionProperty(String *name, JSFunction *function, PropertyAttributes attributes)
MUST_USE_RESULT MaybeObject * AddFastProperty(String *name, Object *value, PropertyAttributes attributes, StoreFromKeyed store_mode=MAY_BE_STORE_FROM_KEYED)
IntrusiveMapTransitionIterator(TransitionArray *transition_array)
bool IsStringObjectWithCharacterAt(uint32_t index)
void InstallFromOptimizedCodeMap(JSFunction *function, int index)
bool IsFastPackedElementsKind(ElementsKind kind)
MUST_USE_RESULT MaybeObject * Put(FixedArray *key, Map *value)
virtual void Seek(unsigned)
void set_undefined(int index)
static SlicedString * cast(Object *obj)
static ExternalIntArray * cast(Object *obj)
static const int kProtoTransitionMapOffset
SymbolKey(String *string)
MUST_USE_RESULT MaybeObject * SetPrototypeTransitions(FixedArray *prototype_transitions)
static void AddToOptimizedCodeMap(Handle< SharedFunctionInfo > shared, Handle< Context > native_context, Handle< Code > code, Handle< FixedArray > literals)
MUST_USE_RESULT MaybeObject * SetElementsLength(Object *length)
void set_expected_nof_properties(int value)
void SetNumberOfProtoTransitions(int value)
void SetNumberOfElements(int nof)
MUST_USE_RESULT MaybeObject * SetElementWithHandler(JSReceiver *receiver, uint32_t index, Object *value, StrictModeFlag strict_mode)
Handle< Integer >(* NamedPropertyQuery)(Local< String > property, const AccessorInfo &info)
MUST_USE_RESULT MaybeObject * SetFastDoubleElement(uint32_t index, Object *value, StrictModeFlag strict_mode, bool check_prototype=true)
Context * native_context()
static uint32_t MapsHashHelper(MapHandleList *maps, int code_flags)
void IteratePointers(ObjectVisitor *v, int start, int end)
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
void GetLocalPropertyNames(FixedArray *storage, int index)
static Failure * cast(MaybeObject *object)
#define CALL_HEAP_FUNCTION(ISOLATE, FUNCTION_CALL, TYPE)
void ResetForNewContext(int new_ic_age)
MUST_USE_RESULT MaybeObject * SetValue(uint32_t index, Object *value)
bool ToArrayIndex(uint32_t *index)
ElementsKind GetFastElementsKindFromSequenceIndex(int sequence_number)
void SetElementsCapacityAndLength(Handle< JSArray > array, int capacity, int length)
ElementsKind GetElementsKind()
Smi * PcAndState(int index)
byte * instruction_start()
static Object * RawUninitializedSentinel(Heap *heap)
static Handle< Map > GetElementsTransitionMap(Handle< JSObject > object, ElementsKind to_kind)
MUST_USE_RESULT MaybeObject * AllocateFixedArrayWithHoles(int length, PretenureFlag pretenure=NOT_TENURED)
#define MAKE_STRUCT_CASE(NAME, Name, name)
static const int kMaxCachedArrayIndexLength
MUST_USE_RESULT MaybeObject * ShareDescriptor(DescriptorArray *descriptors, Descriptor *descriptor)
Object * SetValue(uint32_t index, Object *value)
MUST_USE_RESULT MaybeObject * DeleteElement(uint32_t index, DeleteMode mode)
static const char *const kTags[kNumberOfSyncTags]
static const int kIsNotArrayIndexMask
void ForbidInlineConstructor()
uint32_t HashForObject(Key key, Object *object)
FixedArray * CopyEnumKeysTo(FixedArray *storage)
static Oddball * cast(Object *obj)
static PolymorphicCodeCacheHashTable * cast(Object *obj)
static Address & Address_at(Address addr)
FlatStringReader(Isolate *isolate, Handle< String > str)
static const int kMaxInstanceSize
int GetFieldIndex(int descriptor_number)
static const uint32_t kRequiresSlowElementsLimit
Handle< Integer >(* IndexedPropertyQuery)(uint32_t index, const AccessorInfo &info)
MUST_USE_RESULT MaybeObject * GenerateNewEnumerationIndices()
MUST_USE_RESULT MaybeObject * PutPrototypeTransition(Object *prototype, Map *map)
void LookupRealNamedProperty(String *name, LookupResult *result)
static SeqAsciiString * cast(Object *obj)
void set_inobject_properties(int value)
Handle< Object > GetSourceCode()
bool HasPrototypeTransitions()
MUST_USE_RESULT MaybeObject * AddProperty(String *name, Object *value, PropertyAttributes attributes, StrictModeFlag strict_mode, StoreFromKeyed store_mode=MAY_BE_STORE_FROM_KEYED, ExtensibilityCheck extensibility_check=PERFORM_EXTENSIBILITY_CHECK)
void set_hash_field(uint32_t value)
MUST_USE_RESULT MaybeObject * SetValue(uint32_t index, Object *value)
V8EXPORT int32_t Int32Value() const
MUST_USE_RESULT MaybeObject * CopyAddDescriptor(Descriptor *descriptor, TransitionFlag flag)
void(* AccessorSetter)(Local< String > property, Local< Value > value, const AccessorInfo &info)
static ExternalUnsignedByteArray * cast(Object *obj)
bool IsMoreGeneralElementsKindTransition(ElementsKind from_kind, ElementsKind to_kind)
static const int kProtoTransitionNumberOfEntriesOffset
static void TransformToFastProperties(Handle< JSObject > object, int unused_property_fields)
static int TimeInDay(int64_t time_ms, int days)
uint32_t HashForObject(Object *other)
static unsigned decode(uint32_t value)
void SetCapacity(int capacity)
MUST_USE_RESULT MaybeObject * set_initial_map_and_cache_transitions(Map *value)
bool ShouldConvertToFastDoubleElements(bool *has_smi_only_elements)
static Handle< Object > SetLocalPropertyIgnoreAttributes(Handle< JSObject > object, Handle< String > key, Handle< Object > value, PropertyAttributes attributes)
Vector< const uc16 > ToUC16Vector()
MUST_USE_RESULT MaybeObject * SetPropertyPostInterceptor(String *name, Object *value, PropertyAttributes attributes, StrictModeFlag strict_mode, ExtensibilityCheck extensibility_check)
uint32_t FindInsertionEntry(uint32_t hash)
SetFastElementsCapacitySmiMode
SafepointEntry GetSafepointEntry(Address pc)
static const int kPropertiesOffset
static void EnsureDescriptorSlack(Handle< Map > map, int slack)
T RoundUp(T x, intptr_t m)
#define CALL_AND_RETRY(ISOLATE, FUNCTION_CALL, RETURN_VALUE, RETURN_EMPTY)
#define ASSERT_LE(v1, v2)
static FixedDoubleArray * cast(Object *obj)
static MUST_USE_RESULT Handle< Object > SetElement(Handle< JSObject > object, uint32_t index, Handle< Object > value, PropertyAttributes attr, StrictModeFlag strict_mode, SetPropertyMode set_mode=SET_PROPERTY)
static const char * State2String(State state)
int GetIndex(Object *name, Code *code)
Object * FastPropertyAt(int index)
static ExternalPixelArray * cast(Object *obj)
static Code * GetCodeFromTargetAddress(Address address)
int number_of_transitions()
bool is_inline_cache_stub()
CodeCacheHashTableKey(String *name, Code::Flags flags)
bool IsFastSmiElementsKind(ElementsKind kind)
MUST_USE_RESULT MaybeObject * CopyNormalized(PropertyNormalizationMode mode, NormalizedMapSharingMode sharing)
bool has_pending_exception()
bool AllowsSetElementsLength()
MUST_USE_RESULT MaybeObject * SetFastElementsCapacityAndLength(int capacity, int length, SetFastElementsCapacitySmiMode smi_mode)
FixedArray * GetEnumIndicesCache()
Object * FastPropertyAtPut(int index, Object *value)
static ElementsAccessor * ForArray(FixedArrayBase *array)
static int GetOutputInfo(DeoptimizationOutputData *data, BailoutId node_id, SharedFunctionInfo *shared)
MUST_USE_RESULT MaybeObject * DeleteElementWithHandler(uint32_t index, DeleteMode mode)
MUST_USE_RESULT MaybeObject * SetPropertyViaPrototypesWithHandler(JSReceiver *receiver, String *name, Object *value, PropertyAttributes attributes, StrictModeFlag strict_mode, bool *done)
static int GetIdentityHash(Handle< JSObject > obj)
static uint32_t NameFlagsHashHelper(String *name, Code::Flags flags)
void CopyFrom(const CodeDesc &desc)
bool HasRealNamedCallbackProperty(String *key)
InterceptorInfo * GetNamedInterceptor()
const unibrow::byte * ConsStringReadBlock(ReadBlockBuffer *buffer, unsigned *offset_ptr, unsigned chars)
void SortPairs(FixedArray *numbers, uint32_t len)
static const int kContainsCachedArrayIndexMask
WriteBarrierMode GetWriteBarrierMode(const AssertNoAllocation &)
MUST_USE_RESULT MaybeObject * Shrink(Key key)
int CompareChars(const lchar *lhs, const rchar *rhs, int chars)
PropertyDetails GetDetails(int descriptor_number)
int TenToThe(int exponent)
virtual MUST_USE_RESULT MaybeObject * Get(Object *receiver, JSObject *holder, uint32_t key, FixedArrayBase *backing_store=NULL)=0
MUST_USE_RESULT MaybeObject * SetValue(uint32_t index, Object *value)
static bool ComputeArrayIndex(unibrow::CharacterStream *buffer, uint32_t *index, int length)
TraversableMap * ChildIteratorNext()
void SetNumberOfDeletedElements(int nod)
Failure * Throw(Object *exception, MessageLocation *location=NULL)
InlineCacheState ic_state()
byte * relocation_start()
void set_construction_count(int value)
double get_scalar(int index)
Object * Lookup(Object *key)
static uint32_t MakeArrayIndexHash(uint32_t value, int length)
static MUST_USE_RESULT MaybeObject * Allocate(int at_least_space_for)
Handle< Map > FindTransitionedMap(MapHandleList *candidates)
uint16_t ConsStringGet(int index)
void Lookup(String *name, LookupResult *result)
void set_map_no_write_barrier(Map *value)
static Handle< Object > Call(Handle< Object > callable, Handle< Object > receiver, int argc, Handle< Object > argv[], bool *pending_exception, bool convert_receiver=false)
bool LookupTwoCharsSymbolIfExists(uint32_t c1, uint32_t c2, String **symbol)
MUST_USE_RESULT MaybeObject * Initialize(int capacity)
void PostGarbageCollection()
virtual bool HasElement(Object *receiver, JSObject *holder, uint32_t key, FixedArrayBase *backing_store=NULL)=0
static unsigned Encode(char *out, uchar c, int previous)
static Local< Context > ToLocal(v8::internal::Handle< v8::internal::Context > obj)
void SetTransition(int transition_index, Map *target)
Object * SlowReverseLookup(Object *value)
#define DECLARE_TAG(ignore1, name, ignore2)
static JSArray * cast(Object *obj)
PropertyAttributes GetPropertyAttributeWithReceiver(JSReceiver *receiver, String *name)
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)
String * GetKey(int transition_number)
bool HasEnumIndicesCache()
static const int kProtoTransitionHeaderSize
bool IsFastSmiOrObjectElementsKind(ElementsKind kind)
bool has_only_simple_this_property_assignments()
static JSDate * cast(Object *obj)
void SetNextEnumerationIndex(int index)
static ElementsAccessor * ForKind(ElementsKind elements_kind)
bool IsThisPropertyAssignmentArgument(int index)
bool IsMatch(Object *string)
static SeqTwoByteString * cast(Object *obj)
void RemoveByIndex(int index)
int PropertyIndexFor(String *name)
const unibrow::byte * SeqAsciiStringReadBlock(unsigned *remaining, unsigned *offset, unsigned chars)
LocalElementType HasLocalElement(uint32_t index)
bool HasTransitionArray()
static ExternalDoubleArray * cast(Object *obj)
bool IsTransitionableFastElementsKind(ElementsKind from_kind)
static void UpdateCodeCache(Handle< Map > map, Handle< String > name, Handle< Code > code)
static const unibrow::byte * ReadBlock(String *input, unibrow::byte *util_buffer, unsigned capacity, unsigned *remaining, unsigned *offset)
PropertyNormalizationMode
static ExternalFloatArray * cast(Object *obj)
bool HasElementWithHandler(uint32_t index)
MUST_USE_RESULT MaybeObject * Put(String *name, Code *code)
FlatContent GetFlatContent()
void set(int index, double value)
static const int kMaxShortPrintLength
static int SNPrintF(Vector< char > str, const char *format,...)
MUST_USE_RESULT MaybeObject * NumberFromDouble(double value, PretenureFlag pretenure=NOT_TENURED)
void PrintElementsKind(FILE *out, ElementsKind kind)
MUST_USE_RESULT MaybeObject * SetFastDoubleElementsCapacityAndLength(int capacity, int length)
uint32_t DoubleToUint32(double x)
uint32_t HashForObject(Object *other)
bool IsMatch(Object *string)
static const int kMapOffset
bool ShouldConvertToSlowElements(int new_capacity)
int NumberOfDescribedProperties(DescriptorFlag which=OWN_DESCRIPTORS, PropertyAttributes filter=NONE)
MUST_USE_RESULT MaybeObject * DeleteNormalizedProperty(String *name, DeleteMode mode)
int32_t DoubleToInt32(double x)
void LocalLookup(String *name, LookupResult *result)
void IteratePrefix(ObjectVisitor *visitor)
static HeapNumber * cast(Object *obj)
void AttachInitialMap(Map *map)
static void WriteToFlat(String *source, sinkchar *sink, int from, int to)
MUST_USE_RESULT MaybeObject * NormalizeElements()
static StringDictionary * cast(Object *obj)
void set_value(double value)
bool IsSimpleTransition()
LanguageMode language_mode()
bool HasElementsTransition()
virtual size_t length() const =0
bool should_have_prototype()
static double nan_value()
bool has_deoptimization_support()
bool is_compare_ic_stub()
void ExternalAsciiStringReadBlockIntoBuffer(ReadBlockBuffer *buffer, unsigned *offset, unsigned chars)
MUST_USE_RESULT MaybeObject * AllocateAccessorPair()
static ObjectHashTable * cast(Object *obj)
bool is_the_hole(int index)
static uint32_t RandomPrivate(Isolate *isolate)
int GetIndex(String *name, Code::Flags flags)
AccessorDescriptor * GetCallbacks(int descriptor_number)
MUST_USE_RESULT MaybeObject * SetPropertyWithHandler(JSReceiver *receiver, String *name, Object *value, PropertyAttributes attributes, StrictModeFlag strict_mode)
InterceptorInfo * GetIndexedInterceptor()
MUST_USE_RESULT MaybeObject * CopyWithPreallocatedFieldDescriptors()
ExtraICState extra_ic_state()
MUST_USE_RESULT PropertyAttributes GetPropertyAttributeWithHandler(JSReceiver *receiver, String *name)
#define IS_POWER_OF_TWO(x)
Map * GetTarget(int transition_number)
bool has_fast_smi_or_object_elements()
bool CanGenerateInlineConstructor(Object *prototype)
void PrintName(Object *o)
PropertyType GetType(int descriptor_number)
static JSGlobalPropertyCell * cast(Object *obj)
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)
bool Contains(Address addr)
StaticResource< StringInputBuffer > * objects_string_input_buffer()
static bool EnsureCompiled(Handle< JSFunction > function, ClearExceptionFlag flag)
static Handle< Object > DeleteProperty(Handle< JSObject > obj, Handle< String > name)
void BecomeJSObject(Handle< JSReceiver > object)
MUST_USE_RESULT MaybeObject * SetPropertyForResult(LookupResult *result, String *key, Object *value, PropertyAttributes attributes, StrictModeFlag strict_mode, StoreFromKeyed store_mode)
static void ReadBlockIntoBuffer(String *input, ReadBlockBuffer *buffer, unsigned *offset_ptr, unsigned max_chars)
static const uint32_t kHashBitMask
bool HasPropertyWithHandler(String *name)
void SetNumberOfDescriptors(int number_of_descriptors)
Object * GetBackPointer()
void AddCharacterNoIndex(uint32_t c)
void SlicedStringReadBlockIntoBuffer(ReadBlockBuffer *buffer, unsigned *offset_ptr, unsigned chars)
void HeapObjectShortPrint(StringStream *accumulator)
PropertyDetails DetailsAt(int entry)
uint32_t ComputeLongHash(uint64_t key)
Object * DeleteProperty(int entry, JSObject::DeleteMode mode)
MUST_USE_RESULT MaybeObject * SetDictionaryElement(uint32_t index, Object *value, PropertyAttributes attributes, StrictModeFlag strict_mode, bool check_prototype, SetPropertyMode set_mode=SET_PROPERTY)
PropertyAttributes GetPropertyAttributeWithFailedAccessCheck(Object *receiver, LookupResult *result, String *name, bool continue_search)
Handle< Object > NewTypeError(const char *type, Vector< Handle< Object > > args)
Handle< SharedFunctionInfo > shared_info() const
MUST_USE_RESULT MaybeObject * SetPropertyWithInterceptor(String *name, Object *value, PropertyAttributes attributes, StrictModeFlag strict_mode)
void set_bit_field(byte value)
static Token::Value ComputeOperation(Code *target)
static const int kMaxNumberOfDescriptors
SymbolsKey(FixedArray *symbols)
virtual const char * data() const =0
static JSReceiver * cast(Object *obj)
MUST_USE_RESULT MaybeObject * Initialize(const char *to_string, Object *to_number, byte kind)
ElementsKind GetNextMoreGeneralFastElementsKind(ElementsKind elements_kind, bool allow_only_packed)
static JSValue * cast(Object *obj)
Vector< const Char > string_
uint32_t HashSequentialString(const schar *chars, int length, uint32_t seed)
bool ShouldConvertToFastElements()
static const int kArrayIndexHashLengthShift
void ChildIteratorStart()
static const int kFieldsAdded
static const int kMaxUncheckedOldFastElementsLength
MUST_USE_RESULT MaybeObject * DefineFastAccessor(String *name, AccessorComponent component, Object *accessor, PropertyAttributes attributes)
void ValueAtPut(int entry, Object *value)
int number_of_descriptors()
void set(int index, double value)
MUST_USE_RESULT MaybeObject * AsObject()
uint32_t HashForObject(Object *obj)
static Handle< T > null()
void MemsetPointer(T **dest, U *value, int counter)
bool is_keyed_store_stub()
Object * LookupEval(String *src, Context *context, LanguageMode language_mode, int scope_position)
MUST_USE_RESULT MaybeObject * CopyAsElementsKind(ElementsKind kind, TransitionFlag flag)
int Search(T *array, String *name, int valid_entries)
static const int kProtoTransitionPrototypeOffset
static MUST_USE_RESULT MaybeObject * Allocate(int number_of_descriptors, int slack=0)
static void IncrementLiveBytesFromMutator(Address address, int by)
MUST_USE_RESULT MaybeObject * GetPropertyWithHandler(Object *receiver, String *name)
Object * Lookup(String *name, Code::Flags flags)
static const int kInitialSize
MUST_USE_RESULT MaybeObject * GetProperty(String *key)
#define ASSERT_EQ(v1, v2)
void SetInstanceClassName(String *name)
SubStringAsciiSymbolKey(Handle< SeqAsciiString > string, int from, int length, uint32_t seed)
void set_owns_descriptors(bool is_shared)
bool HasFastObjectElements()
static bool CompileLazy(Handle< SharedFunctionInfo > shared, ClearExceptionFlag flag)
MUST_USE_RESULT MaybeObject * Add(Object *key)
InstanceType instance_type()
MUST_USE_RESULT MaybeObject * AllocateJSGlobalPropertyCell(Object *value)
static JSProxy * cast(Object *obj)
void SetIdentityHash(Handle< JSObject > object, Smi *hash)
void SetParent(TraversableMap *parent)
Handle< String > Uint32ToString(uint32_t value)
static State ComputeState(Code *target)
static bool ShouldZapGarbage()
bool MayIndexedAccess(JSObject *receiver, uint32_t index, v8::AccessType type)
Object * Lookup(String *src, Context *context)
static Handle< Object > ToNumber(Handle< Object > obj, bool *exc)
bool HasFastHoleyElements()
int NumberOfProtoTransitions()
bool requires_slow_elements()
MUST_USE_RESULT MaybeObject * OptimizeAsPrototype()
static uint32_t NextProbe(uint32_t last, uint32_t number, uint32_t size)
void EnableDeoptimizationSupport(Code *recompiled)
bool TooManyFastProperties(int properties, StoreFromKeyed store_mode)
#define ASSERT_NE(v1, v2)
static AccessorInfo * cast(Object *obj)
static FixedArray * cast(Object *obj)
MUST_USE_RESULT MaybeObject * CopyUpTo(int enumeration_index)
static const int kHeaderSize
static Smi * set(Smi *smi, int bit_position, bool v)
bool IsCompatibleReceiver(Object *receiver)
int NumberOfSlackDescriptors()
Object * SetNormalizedProperty(LookupResult *result, Object *value)
static HashTable * cast(Object *obj)
void set_is_extensible(bool value)
static bool CompileLazy(CompilationInfo *info)
ElementsKind elements_kind()
MUST_USE_RESULT MaybeObject * AtNumberPut(uint32_t key, Object *value)
Object * GetHiddenProperty(String *key)
void set_is_shared(bool value)
static const int kEntryLength
static Handle< Object > GetElement(Handle< Object > object, uint32_t index)
static Handle< Object > PreventExtensions(Handle< JSObject > object)
void Add(const T &element, AllocationPolicy allocator=AllocationPolicy())
FixedArray * GetEnumCache()
static const int kArrayIndexValueBits
MUST_USE_RESULT MaybeObject * RawCopy(int instance_size)
StaticResource< Utf8Decoder > * utf8_decoder()
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)
static Handle< JSGlobalPropertyCell > EnsurePropertyCell(Handle< GlobalObject > global, Handle< String > name)
void SetEntry(int entry, Object *key, Object *value)
static const int kFlagsIndex
MUST_USE_RESULT MaybeObject * AddSlowProperty(String *name, Object *value, PropertyAttributes attributes)
Object * GetCallbacksObject(int descriptor_number)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit 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 SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available 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 MIPS FPU instructions if NULL
int GetThisPropertyAssignmentArgument(int index)
static VisitorId GetVisitorId(int instance_type, int instance_size)
int FindEntry(String *key)
void set_compiler_hints(int value)
bool IsFastHoleyElementsKind(ElementsKind kind)
Address GetDataStartAddress()
static MUST_USE_RESULT Handle< SeededNumberDictionary > Set(Handle< SeededNumberDictionary > dictionary, uint32_t index, Handle< Object > value, PropertyDetails details)
void IterateElements(ObjectVisitor *visitor)
CodeCacheHashTableKey(String *name, Code *code)
bool HasDictionaryElements()
MUST_USE_RESULT MaybeObject * Put(Object *key, Object *value)
ElementsAccessor * GetElementsAccessor()
Utf8SymbolKey(Vector< const char > string, uint32_t seed)
bool HasFastDoubleElements()
MUST_USE_RESULT MaybeObject * JSArrayUpdateLengthFromIndex(uint32_t index, Object *value)
void OutputToFile(FILE *out)
static const int kAttachedToSharedFunctionInfo
MUST_USE_RESULT MaybeObject * SetPrototype(Object *value, bool skip_hidden_prototypes)
String * TryFlattenGetString(PretenureFlag pretenure=NOT_TENURED)
bool HasFastArgumentsElements()
MUST_USE_RESULT MaybeObject * LookupString(String *key, Object **s)
void set_bit_field2(byte value)
static MUST_USE_RESULT MaybeObject * AsObject(uint32_t key)
static void UpdateMapCodeCache(Handle< JSObject > object, Handle< String > name, Handle< Code > code)
void CreateFillerObjectAt(Address addr, int size)
void SwapPairs(FixedArray *numbers, int i, int j)
AsciiSymbolKey(Vector< const char > str, uint32_t seed)
void set(AccessorComponent component, Object *value)
void set(int index, uint8_t value)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra code(assertions) for debugging") DEFINE_bool(code_comments
static const int kMaxCapacity
static int Decode(FILE *f, byte *begin, byte *end)
bool HasIndexedInterceptor()
static uint32_t RegExpHash(String *string, Smi *flags)
int NumberOfLocalProperties(PropertyAttributes filter=NONE)
int GetSortedKeyIndex(int descriptor_number)
static void FlushICache(void *start, size_t size)
bool IsEqualTo(Vector< const char > str)
Address foreign_address()
static ExternalByteArray * cast(Object *obj)
MUST_USE_RESULT MaybeObject * AtPut(Key key, Object *value)
static const int kMaxUncheckedFastElementsLength
Handle< Boolean >(* IndexedPropertyDeleter)(uint32_t index, const AccessorInfo &info)
Vector< Handle< Object > > HandleVector(v8::internal::Handle< T > *elms, int length)
const int kMaxKeyedPolymorphism
static Flags RemoveTypeFromFlags(Flags flags)
void LocalLookupRealNamedProperty(String *name, LookupResult *result)
static int DaysFromTime(int64_t time_ms)
bool is_keyed_call_stub()
V8EXPORT bool IsInt32() const
int aliased_context_slot()
void JSFunctionIterateBody(int object_size, ObjectVisitor *v)
void set_this_property_assignments_count(int value)
bool HasHiddenProperties()
int NumberOfEnumElements()
int NextEnumerationIndex()
const uint32_t kAsciiStringTag
Object ** GetKeySlot(int transition_number)
void CopyChars(sinkchar *dest, const sourcechar *src, int chars)
String * GetThisPropertyAssignmentName(int index)
static const int kConstructStubOffset
Smi * GenerateIdentityHash()
static const int kHashShift
AccessorDescriptor * FindAccessor(String *name)
MUST_USE_RESULT MaybeObject * DeleteProperty(String *name, DeleteMode mode)
static bool EncodeAsciiCharacter(uchar c, byte *buffer, unsigned capacity, unsigned &offset)
MUST_USE_RESULT MaybeObject * Shrink(Key key)
MUST_USE_RESULT MaybeObject * GetHash(CreationFlag flag)
static uint32_t FirstProbe(uint32_t hash, uint32_t size)
static const char * GetStateName(State state)
static ConsString * cast(Object *obj)
uint32_t HashForObject(Object *obj)
bool HasDictionaryArgumentsElements()
void JSObjectShortPrint(StringStream *accumulator)
static CodeCache * cast(Object *obj)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit 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 SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available 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 MIPS FPU instructions if expose natives in global object expose gc extension number of stack frames to capture disable builtin natives files print a stack trace if an assertion failure occurs use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations prepare for turning on always opt minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions automatically set the debug break flag when debugger commands are in the queue always cause a debug break before aborting 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 more details following each garbage collection print amount of external allocated memory after each time it is adjusted flush code that we expect not to use again before full gc do incremental marking steps track object counts and memory usage use caching Perform compaction on every full GC Never perform compaction on full GC testing only Compact code space on full incremental collections Default seed for initializing random allows verbose printing trace parsing and preparsing Check icache flushes in ARM and MIPS simulator Stack alingment in bytes in print stack trace when throwing exceptions randomize hashes to avoid predictable hash Fixed seed to use to hash property activate a timer that switches between V8 threads testing_bool_flag float flag Seed used for threading test randomness A filename with extra code to be included in the Print usage including flags
static int NewElementsCapacity(int old_capacity)
bool IsIdentifierStart(unibrow::uchar c)
static FixedArrayBase * cast(Object *object)
MUST_USE_RESULT MaybeObject * LookupSymbol(Vector< const char > str, Object **s)
static Context * NativeContextFromLiterals(FixedArray *literals)
void StringShortPrint(StringStream *accumulator)
void ClearNonLiveTransitions(Heap *heap)
Object * GetComponent(AccessorComponent component)
uint32_t HashForObject(Object *key)
static const int kMaxValue
int NextFreePropertyIndex()
static const int kCodeCacheOffset
const unibrow::byte * SlicedStringReadBlock(ReadBlockBuffer *buffer, unsigned *offset_ptr, unsigned chars)
MUST_USE_RESULT MaybeObject * SetValue(uint32_t index, Object *value)
static ExternalUnsignedIntArray * cast(Object *obj)
static MUST_USE_RESULT MaybeObject * Allocate(int number_of_deopt_points, PretenureFlag pretenure)
static const int kNotFound
int expected_nof_properties()
static void DefineAccessor(Handle< JSObject > object, Handle< String > name, Handle< Object > getter, Handle< Object > setter, PropertyAttributes attributes)
void set_non_instance_prototype(bool value)
virtual MUST_USE_RESULT MaybeObject * SetLength(JSArray *holder, Object *new_length)=0
const uc32 kMaxAsciiCharCode
MUST_USE_RESULT MaybeObject * Remove(Object *key)
void SetTarget(int transition_number, Map *target)
Handle< Value >(* AccessorGetter)(Local< String > property, const AccessorInfo &info)
MUST_USE_RESULT MaybeObject * CopyReplaceDescriptor(DescriptorArray *descriptors, Descriptor *descriptor, int index, TransitionFlag flag)
MUST_USE_RESULT MaybeObject * AllocateMap(InstanceType instance_type, int instance_size, ElementsKind elements_kind=TERMINAL_FAST_ELEMENTS_KIND)
Handle< Object > NewNumberFromUint(uint32_t value, PretenureFlag pretenure=NOT_TENURED)
MUST_USE_RESULT MaybeObject * Copy()
StringDictionary * property_dictionary()
MUST_USE_RESULT MaybeObject * AsObject()
ElementsKind GetHoleyElementsKind(ElementsKind packed_kind)
MUST_USE_RESULT MaybeObject * CopySize(int new_length)
void TraverseTransitionTree(TraverseCallback callback, void *data)
void SetNoStackCheckTable()
MUST_USE_RESULT MaybeObject * ReplaceSlowProperty(String *name, Object *value, PropertyAttributes attributes)
void UpdateMaxNumberKey(uint32_t key)
static MUST_USE_RESULT MaybeObject * Allocate(int at_least_space_for, MinimumCapacity capacity_option=USE_DEFAULT_MINIMUM_CAPACITY, PretenureFlag pretenure=NOT_TENURED)
MUST_USE_RESULT MaybeObject * SetValue(uint32_t index, Object *value)
void InitializeDescriptors(DescriptorArray *descriptors)
FixedArray * GetPrototypeTransitions()
static void AddFastPropertyUsingMap(Handle< JSObject > object, Handle< Map > map)
static ObjectHashSet * cast(Object *obj)
static JSObject * cast(Object *obj)
static const int kMaxArrayIndexSize
bool HasExternalArrayElements()
static const char *const kTagNames[kNumberOfSyncTags]
static void Clear(Address address)
MarkCompactCollector * mark_compact_collector()
PropertyAttributes GetLocalPropertyAttribute(String *name)
static const int kNoPreviousCharacter
void BecomeJSFunction(Handle< JSReceiver > object)
MUST_USE_RESULT MaybeObject * GetPropertyPostInterceptor(Object *receiver, String *name, PropertyAttributes *attributes)
static InterceptorInfo * cast(Object *obj)
uint32_t max_number_key()
MUST_USE_RESULT MaybeObject * SetValue(uint32_t index, Object *value)
bool IsFastDoubleElementsKind(ElementsKind kind)
MUST_USE_RESULT MaybeObject * EnsureCanContainElements(Object **elements, uint32_t count, EnsureElementsMode mode)
MUST_USE_RESULT MaybeObject * SubString(int from, int to, PretenureFlag pretenure=NOT_TENURED)
void set_unused_property_fields(int value)
bool is_keyed_load_stub()
Object * FindInCodeCache(String *name, Code::Flags flags)
const uint32_t kStringEncodingMask
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)
void SetComponents(Object *getter, Object *setter)
void DisableOptimization(const char *reason)
void set_stack_check_table_offset(unsigned offset)
Handle< Boolean >(* NamedPropertyDeleter)(Local< String > property, const AccessorInfo &info)
void set_bit_field3(int value)
static int ComputeCapacity(int at_least_space_for)
int64_t ToLocal(int64_t time_ms)
Object * GetThisPropertyAssignmentConstant(int index)
MUST_USE_RESULT MaybeObject * AllocateAliasedArgumentsEntry(int slot)
IntrusivePrototypeTransitionIterator(HeapObject *proto_trans)
String * constructor_name()
bool IsAsciiEqualTo(Vector< const char > str)
void set_requires_slow_elements()
Handle< JSObject > Copy(Handle< JSObject > obj)
kPropertyAccessorsOffset kNamedPropertyHandlerOffset kInstanceTemplateOffset kAccessCheckInfoOffset kEvalFrominstructionsOffsetOffset kInstanceClassNameOffset flag
static JSGlobalObject * cast(Object *obj)
void StartInobjectSlackTracking(Map *map)
static JSFunction * cast(Object *obj)