67 #define RUNTIME_ASSERT(value) \
68 if (!(value)) return isolate->ThrowIllegalOperation();
73 #define CONVERT_ARG_CHECKED(Type, name, index) \
74 RUNTIME_ASSERT(args[index]->Is##Type()); \
75 Type* name = Type::cast(args[index]);
77 #define CONVERT_ARG_HANDLE_CHECKED(Type, name, index) \
78 RUNTIME_ASSERT(args[index]->Is##Type()); \
79 Handle<Type> name = args.at<Type>(index);
84 #define CONVERT_BOOLEAN_ARG_CHECKED(name, index) \
85 RUNTIME_ASSERT(args[index]->IsBoolean()); \
86 bool name = args[index]->IsTrue();
91 #define CONVERT_SMI_ARG_CHECKED(name, index) \
92 RUNTIME_ASSERT(args[index]->IsSmi()); \
93 int name = args.smi_at(index);
98 #define CONVERT_DOUBLE_ARG_CHECKED(name, index) \
99 RUNTIME_ASSERT(args[index]->IsNumber()); \
100 double name = args.number_at(index);
105 #define CONVERT_NUMBER_CHECKED(type, name, Type, obj) \
106 RUNTIME_ASSERT(obj->IsNumber()); \
107 type name = NumberTo##Type(obj);
113 #define CONVERT_PROPERTY_DETAILS_CHECKED(name, index) \
114 RUNTIME_ASSERT(args[index]->IsSmi()); \
115 PropertyDetails name = PropertyDetails(Smi::cast(args[index]));
120 #define CONVERT_STRICT_MODE_ARG_CHECKED(name, index) \
121 RUNTIME_ASSERT(args[index]->IsSmi()); \
122 RUNTIME_ASSERT(args.smi_at(index) == kStrictMode || \
123 args.smi_at(index) == kNonStrictMode); \
124 StrictModeFlag name = \
125 static_cast<StrictModeFlag>(args.smi_at(index));
130 #define CONVERT_LANGUAGE_MODE_ARG(name, index) \
131 ASSERT(args[index]->IsSmi()); \
132 ASSERT(args.smi_at(index) == CLASSIC_MODE || \
133 args.smi_at(index) == STRICT_MODE || \
134 args.smi_at(index) == EXTENDED_MODE); \
135 LanguageMode name = \
136 static_cast<LanguageMode>(args.smi_at(index));
139 MUST_USE_RESULT static MaybeObject* DeepCopyBoilerplate(Isolate* isolate,
140 JSObject* boilerplate) {
141 StackLimitCheck
check(isolate);
142 if (check.HasOverflowed())
return isolate->StackOverflow();
144 Heap* heap = isolate->heap();
146 { MaybeObject* maybe_result = heap->CopyJSObject(boilerplate);
147 if (!maybe_result->ToObject(&result))
return maybe_result;
152 if (copy->HasFastProperties()) {
153 FixedArray* properties = copy->properties();
154 for (
int i = 0; i < properties->length(); i++) {
155 Object* value = properties->get(i);
156 if (value->IsJSObject()) {
158 { MaybeObject* maybe_result = DeepCopyBoilerplate(isolate, js_object);
159 if (!maybe_result->ToObject(&result))
return maybe_result;
161 properties->set(i, result);
164 int nof = copy->map()->inobject_properties();
165 for (
int i = 0; i < nof; i++) {
166 Object* value = copy->InObjectPropertyAt(i);
167 if (value->IsJSObject()) {
169 { MaybeObject* maybe_result = DeepCopyBoilerplate(isolate, js_object);
170 if (!maybe_result->ToObject(&result))
return maybe_result;
172 copy->InObjectPropertyAtPut(i, result);
176 { MaybeObject* maybe_result =
177 heap->AllocateFixedArray(copy->NumberOfLocalProperties());
178 if (!maybe_result->ToObject(&result))
return maybe_result;
181 copy->GetLocalPropertyNames(names, 0);
182 for (
int i = 0; i < names->length(); i++) {
183 ASSERT(names->get(i)->IsString());
186 copy->GetLocalPropertyAttribute(key_string);
190 if (attributes !=
NONE)
continue;
192 copy->GetProperty(key_string, &attributes)->ToObjectUnchecked();
193 if (value->IsJSObject()) {
195 { MaybeObject* maybe_result = DeepCopyBoilerplate(isolate, js_object);
196 if (!maybe_result->ToObject(&result))
return maybe_result;
198 { MaybeObject* maybe_result =
201 if (!maybe_result->ToObject(&result))
return maybe_result;
209 ASSERT(!copy->HasExternalArrayElements());
210 switch (copy->GetElementsKind()) {
216 if (elements->map() == heap->fixed_cow_array_map()) {
217 isolate->counters()->cow_arrays_created_runtime()->Increment();
219 for (
int i = 0; i < elements->length(); i++) {
220 ASSERT(!elements->get(i)->IsJSObject());
224 for (
int i = 0; i < elements->length(); i++) {
225 Object* value = elements->get(i);
227 value->IsTheHole() ||
229 if (value->IsJSObject()) {
231 { MaybeObject* maybe_result = DeepCopyBoilerplate(isolate,
233 if (!maybe_result->ToObject(&result))
return maybe_result;
235 elements->set(i, result);
242 SeededNumberDictionary* element_dictionary = copy->element_dictionary();
243 int capacity = element_dictionary->Capacity();
244 for (
int i = 0; i < capacity; i++) {
245 Object* k = element_dictionary->KeyAt(i);
246 if (element_dictionary->IsKey(k)) {
247 Object* value = element_dictionary->ValueAt(i);
248 if (value->IsJSObject()) {
250 { MaybeObject* maybe_result = DeepCopyBoilerplate(isolate,
252 if (!maybe_result->ToObject(&result))
return maybe_result;
254 element_dictionary->ValueAtPut(i, result);
281 static Handle<Map> ComputeObjectLiteralMap(
282 Handle<Context> context,
283 Handle<FixedArray> constant_properties,
284 bool* is_result_from_cache) {
285 Isolate* isolate = context->GetIsolate();
286 int properties_length = constant_properties->length();
287 int number_of_properties = properties_length / 2;
289 int number_of_symbol_keys = 0;
290 for (
int p = 0; p != properties_length; p += 2) {
291 Object* key = constant_properties->get(p);
292 uint32_t element_index = 0;
293 if (key->IsSymbol()) {
294 number_of_symbol_keys++;
295 }
else if (key->ToArrayIndex(&element_index)) {
297 number_of_properties--;
301 ASSERT(number_of_symbol_keys != number_of_properties);
307 const int kMaxKeys = 10;
308 if ((number_of_symbol_keys == number_of_properties) &&
309 (number_of_symbol_keys < kMaxKeys)) {
311 Handle<FixedArray> keys =
312 isolate->factory()->NewFixedArray(number_of_symbol_keys);
313 if (number_of_symbol_keys > 0) {
315 for (
int p = 0; p < properties_length; p += 2) {
316 Object* key = constant_properties->get(p);
317 if (key->IsSymbol()) {
318 keys->set(index++, key);
321 ASSERT(index == number_of_symbol_keys);
323 *is_result_from_cache =
true;
324 return isolate->factory()->ObjectLiteralMapFromCache(context, keys);
326 *is_result_from_cache =
false;
327 return isolate->factory()->CopyMap(
328 Handle<Map>(context->object_function()->initial_map()),
329 number_of_properties);
333 static Handle<Object> CreateLiteralBoilerplate(
335 Handle<FixedArray> literals,
336 Handle<FixedArray> constant_properties);
339 static Handle<Object> CreateObjectLiteralBoilerplate(
341 Handle<FixedArray> literals,
342 Handle<FixedArray> constant_properties,
343 bool should_have_fast_elements,
344 bool has_function_literal) {
351 Handle<Context> context =
358 bool is_result_from_cache =
false;
359 Handle<Map> map = has_function_literal
360 ? Handle<Map>(context->object_function()->initial_map())
361 : ComputeObjectLiteralMap(context,
363 &is_result_from_cache);
365 Handle<JSObject> boilerplate = isolate->factory()->NewJSObjectFromMap(map);
371 int length = constant_properties->length();
372 bool should_transform =
373 !is_result_from_cache && boilerplate->HasFastProperties();
374 if (should_transform || has_function_literal) {
382 for (
int index = 0; index < length; index +=2) {
383 Handle<Object> key(constant_properties->get(index+0), isolate);
384 Handle<Object> value(constant_properties->get(index+1), isolate);
385 if (value->IsFixedArray()) {
389 value = CreateLiteralBoilerplate(isolate, literals, array);
390 if (value.is_null())
return value;
392 Handle<Object> result;
393 uint32_t element_index = 0;
394 if (key->IsSymbol()) {
405 }
else if (key->ToArrayIndex(&element_index)) {
412 double num = key->Number();
416 Handle<String>
name =
417 isolate->factory()->NewStringFromAscii(
CStrVector(str));
419 boilerplate, name, value,
NONE);
425 if (result.is_null())
return result;
432 if (should_transform && !has_function_literal) {
434 boilerplate, boilerplate->map()->unused_property_fields());
458 static const int kSmiLiteralMinimumLength = 1024;
478 Object* maybe_maps_array = global_context->js_array_maps();
479 ASSERT(!maybe_maps_array->IsUndefined());
481 constant_elements_kind);
482 ASSERT(maybe_map->IsMap());
487 ASSERT(FLAG_smi_only_arrays);
493 (constant_elements_values->map() ==
494 isolate->
heap()->fixed_cow_array_map());
496 copied_elements_values = constant_elements_values;
500 for (
int i = 0; i < fixed_array_values->length(); i++) {
501 ASSERT(!fixed_array_values->get(i)->IsFixedArray());
509 copied_elements_values = fixed_array_values_copy;
510 for (
int i = 0; i < fixed_array_values->length(); i++) {
511 Object* current = fixed_array_values->get(i);
512 if (current->IsFixedArray()) {
517 CreateLiteralBoilerplate(isolate, literals, fa);
518 if (result.
is_null())
return result;
519 fixed_array_values_copy->set(i, *result);
524 object->set_elements(*copied_elements_values);
525 object->set_length(
Smi::FromInt(copied_elements_values->length()));
529 if (!FLAG_smi_only_arrays &&
530 constant_elements_values->length() < kSmiLiteralMinimumLength) {
535 isolate)->IsFailure());
542 object->ValidateElements();
552 const bool kHasNoFunctionLiteral =
false;
555 return CreateObjectLiteralBoilerplate(isolate,
559 kHasNoFunctionLiteral);
561 return CreateObjectLiteralBoilerplate(isolate,
565 kHasNoFunctionLiteral);
568 isolate, literals, elements);
578 ASSERT(args.length() == 4);
587 Handle<Object> boilerplate(literals->get(literals_index), isolate);
588 if (*boilerplate == isolate->
heap()->undefined_value()) {
589 boilerplate = CreateObjectLiteralBoilerplate(isolate,
592 should_have_fast_elements,
593 has_function_literal);
596 literals->set(literals_index, *boilerplate);
598 return DeepCopyBoilerplate(isolate,
JSObject::cast(*boilerplate));
604 ASSERT(args.length() == 4);
613 Handle<Object> boilerplate(literals->get(literals_index), isolate);
614 if (*boilerplate == isolate->
heap()->undefined_value()) {
615 boilerplate = CreateObjectLiteralBoilerplate(isolate,
618 should_have_fast_elements,
619 has_function_literal);
622 literals->set(literals_index, *boilerplate);
630 ASSERT(args.length() == 3);
636 Handle<Object> boilerplate(literals->get(literals_index), isolate);
637 if (*boilerplate == isolate->
heap()->undefined_value()) {
642 literals->set(literals_index, *boilerplate);
644 return DeepCopyBoilerplate(isolate,
JSObject::cast(*boilerplate));
650 ASSERT(args.length() == 3);
656 Handle<Object> boilerplate(literals->get(literals_index), isolate);
657 if (*boilerplate == isolate->
heap()->undefined_value()) {
658 ASSERT(*elements != isolate->
heap()->empty_fixed_array());
663 literals->set(literals_index, *boilerplate);
666 isolate->
heap()->fixed_cow_array_map()) {
667 isolate->
counters()->cow_arrays_created_runtime()->Increment();
674 ASSERT(args.length() == 2);
675 Object* handler = args[0];
676 Object* prototype = args[1];
678 prototype->IsJSReceiver() ? prototype : isolate->
heap()->null_value();
684 ASSERT(args.length() == 4);
685 Object* handler = args[0];
686 Object* call_trap = args[1];
687 Object* construct_trap = args[2];
688 Object* prototype = args[3];
690 prototype->IsJSReceiver() ? prototype : isolate->
heap()->null_value();
692 handler, call_trap, construct_trap, used_prototype);
697 ASSERT(args.length() == 1);
704 ASSERT(args.length() == 1);
711 ASSERT(args.length() == 1);
713 return proxy->handler();
718 ASSERT(args.length() == 1);
720 return proxy->call_trap();
725 ASSERT(args.length() == 1);
727 return proxy->construct_trap();
732 ASSERT(args.length() == 1);
735 return isolate->
heap()->undefined_value();
741 ASSERT(args.length() == 1);
744 holder->set_table(*table);
751 ASSERT(args.length() == 2);
756 holder->set_table(*table);
757 return isolate->
heap()->undefined_symbol();
763 ASSERT(args.length() == 2);
773 ASSERT(args.length() == 2);
778 holder->set_table(*table);
779 return isolate->
heap()->undefined_symbol();
785 ASSERT(args.length() == 1);
788 holder->set_table(*table);
795 ASSERT(args.length() == 2);
804 ASSERT(args.length() == 3);
810 holder->set_table(*new_table);
817 ASSERT(args.length() == 1);
819 ASSERT(weakmap->map()->inobject_properties() == 0);
821 weakmap->set_table(*table);
828 NoHandleAllocation ha;
829 ASSERT(args.length() == 2);
838 ASSERT(args.length() == 3);
844 weakmap->set_table(*new_table);
850 NoHandleAllocation ha;
851 ASSERT(args.length() == 1);
853 if (!obj->IsJSObject())
return isolate->
heap()->null_value();
859 NoHandleAllocation ha;
860 ASSERT(args.length() == 1);
864 ASSERT(!obj->IsAccessCheckNeeded() || obj->IsJSObject());
866 if (obj->IsAccessCheckNeeded() &&
868 isolate->
heap()->Proto_symbol(),
871 return isolate->
heap()->undefined_value();
874 }
while (obj->IsJSObject() &&
881 NoHandleAllocation ha;
882 ASSERT(args.length() == 2);
888 if (prototype->IsNull())
return isolate->
heap()->false_value();
889 if (O == prototype)
return isolate->
heap()->true_value();
896 static void GetOwnPropertyImplementation(JSObject* obj,
898 LookupResult* result) {
899 obj->LocalLookupRealNamedProperty(name, result);
901 if (!result->IsProperty()) {
903 if (proto->IsJSObject() &&
911 static bool CheckAccessException(LookupResult* result,
914 Object* callback = result->GetCallbackObject();
915 if (callback->IsAccessorInfo()) {
919 (info->all_can_read() || info->all_can_write())) ||
930 static bool CheckAccess(JSObject* obj,
932 LookupResult* result,
934 ASSERT(result->IsProperty());
936 JSObject* holder = result->holder();
937 JSObject* current = obj;
938 Isolate* isolate = obj->GetIsolate();
940 if (current->IsAccessCheckNeeded() &&
941 !isolate->MayNamedAccess(current, name, access_type)) {
948 if (current == holder) {
956 switch (result->type()) {
958 if (CheckAccessException(result, access_type)) {
966 holder->LookupRealNamedProperty(name, result);
967 if (result->IsProperty()) {
968 if (CheckAccessException(result, access_type)) {
978 isolate->ReportFailedAccessCheck(current, access_type);
984 static bool CheckElementAccess(JSObject* obj,
987 if (obj->IsAccessCheckNeeded() &&
988 !obj->GetIsolate()->MayIndexedAccess(obj, index, access_type)) {
1009 static MaybeObject* GetOwnProperty(
Isolate* isolate,
1012 Heap* heap = isolate->heap();
1014 Handle<JSArray> desc = isolate->factory()->NewJSArrayWithElements(elms);
1015 LookupResult result(isolate);
1021 return heap->undefined_value();
1054 if (obj->IsJSGlobalProxy()) {
1056 if (proto->
IsNull())
return heap->undefined_value();
1057 ASSERT(proto->IsJSGlobalObject());
1061 SeededNumberDictionary* dictionary =
NULL;
1062 if (elements->map() == heap->non_strict_arguments_elements_map()) {
1067 int entry = dictionary->FindEntry(index);
1069 PropertyDetails details = dictionary->DetailsAt(entry);
1070 switch (details.type()) {
1073 AccessorPair* accessors =
1088 ASSERT(!value.is_null());
1105 GetOwnPropertyImplementation(*obj, *name, &result);
1107 if (!result.IsProperty()) {
1108 return heap->undefined_value();
1112 return heap->false_value();
1118 bool is_js_accessor = (result.type() ==
CALLBACKS) &&
1119 (result.GetCallbackObject()->IsAccessorPair());
1121 if (is_js_accessor) {
1139 { MaybeObject* maybe_value = obj->
GetProperty(*obj, &result, *name, &attrs);
1140 if (!maybe_value->ToObject(&value))
return maybe_value;
1157 ASSERT(args.length() == 2);
1161 return GetOwnProperty(isolate, obj, name);
1166 ASSERT(args.length() == 1);
1173 ASSERT(args.length() == 1);
1175 if (obj->IsJSGlobalProxy()) {
1177 if (proto->IsNull())
return isolate->heap()->false_value();
1178 ASSERT(proto->IsJSGlobalObject());
1187 ASSERT(args.length() == 3);
1199 ASSERT(args.length() == 1);
1201 return *isolate->factory()->CreateApiFunction(data);
1206 ASSERT(args.length() == 1);
1208 bool result = arg->IsObjectTemplateInfo() || arg->IsFunctionTemplateInfo();
1209 return isolate->heap()->ToBoolean(result);
1214 ASSERT(args.length() == 2);
1232 ASSERT(args.length() == 1);
1234 Map* old_map =
object->
map();
1236 if (needs_access_checks) {
1239 { MaybeObject* maybe_new_map =
1241 if (!maybe_new_map->ToObject(&new_map))
return maybe_new_map;
1247 return isolate->heap()->ToBoolean(needs_access_checks);
1252 ASSERT(args.length() == 1);
1254 Map* old_map =
object->
map();
1258 { MaybeObject* maybe_new_map =
1260 if (!maybe_new_map->ToObject(&new_map))
return maybe_new_map;
1266 return isolate->heap()->undefined_value();
1270 static Failure* ThrowRedeclarationError(
Isolate* isolate,
1275 isolate->factory()->NewStringFromAscii(
CStrVector(type));
1277 Handle<Object> error =
1278 isolate->factory()->NewTypeError(
"redeclaration",
HandleVector(args, 2));
1279 return isolate->Throw(*error);
1284 ASSERT(args.length() == 3);
1287 isolate->context()->global());
1294 int length = pairs->length();
1295 for (
int i = 0; i < length; i += 2) {
1303 bool is_var = value->IsUndefined();
1304 bool is_const = value->IsTheHole();
1305 bool is_function = value->IsSharedFunctionInfo();
1306 bool is_module = value->IsJSModule();
1307 ASSERT(is_var + is_const + is_function + is_module == 1);
1309 if (is_var || is_const) {
1313 LookupResult lookup(isolate);
1314 if (FLAG_es52_globals)
1315 global->LocalLookup(*name, &lookup);
1317 global->Lookup(*name, &lookup);
1318 if (lookup.IsProperty()) {
1323 if (attributes !=
ABSENT)
continue;
1327 }
else if (is_function) {
1332 isolate->factory()->NewFunctionFromSharedFunctionInfo(
1337 LookupResult lookup(isolate);
1338 global->LocalLookup(*name, &lookup);
1344 if (!is_eval || is_module) {
1348 if (is_const || is_module || (is_native && is_function)) {
1354 if (!lookup.IsProperty() || is_function || is_module) {
1357 if (lookup.IsProperty() && lookup.IsDontDelete()) {
1358 if (lookup.IsReadOnly() || lookup.IsDontEnum() ||
1360 return ThrowRedeclarationError(
1361 isolate, is_function ?
"function" :
"module", name);
1364 attr = lookup.GetAttributes();
1369 global, name, value, static_cast<PropertyAttributes>(attr)));
1374 global, name, value, static_cast<PropertyAttributes>(attr),
1379 ASSERT(!isolate->has_pending_exception());
1380 return isolate->heap()->undefined_value();
1386 ASSERT(args.length() == 4);
1404 context->
Lookup(name, flags, &index, &attributes, &binding_flags);
1406 if (attributes !=
ABSENT) {
1410 if (((attributes &
READ_ONLY) != 0) || (mode == READ_ONLY)) {
1412 ASSERT(mode != READ_ONLY || initial_value->IsTheHole());
1413 const char* type = ((attributes &
READ_ONLY) != 0) ?
"const" :
"var";
1414 return ThrowRedeclarationError(isolate, type, name);
1418 if (*initial_value !=
NULL) {
1421 if (((attributes & READ_ONLY) == 0) ||
1422 context->
get(index)->IsTheHole()) {
1423 context->
set(index, *initial_value);
1446 object = isolate->factory()->NewJSObject(
1447 isolate->context_extension_function());
1455 ASSERT(!object->HasLocalProperty(*name));
1456 Handle<Object> value(isolate->heap()->undefined_value(), isolate);
1457 if (*initial_value !=
NULL) value = initial_value;
1464 if (initial_value->IsTheHole() &&
1465 !
object->IsJSContextExtensionObject()) {
1466 LookupResult lookup(isolate);
1467 object->Lookup(*name, &lookup);
1468 if (lookup.IsFound() && (lookup.type() ==
CALLBACKS)) {
1469 return ThrowRedeclarationError(isolate,
"const", name);
1472 if (object->IsJSGlobalObject()) {
1482 return isolate->heap()->undefined_value();
1487 NoHandleAllocation nha;
1495 bool assign = args.length() == 3;
1516 LookupResult lookup(isolate);
1517 while (object->IsJSObject() &&
1521 if (lookup.IsFound() && lookup.type() ==
INTERCEPTOR) {
1526 raw_holder = *holder;
1531 &lookup, *name, args[2], attributes, strict_mode_flag);
1533 return isolate->heap()->undefined_value();
1541 global = isolate->context()->global();
1543 return global->
SetProperty(*name, args[2], attributes, strict_mode_flag);
1545 return isolate->heap()->undefined_value();
1570 LookupResult lookup(isolate);
1571 global->LocalLookup(*name, &lookup);
1572 if (!lookup.IsProperty()) {
1573 return global->SetLocalPropertyIgnoreAttributes(*name,
1578 if (!lookup.IsReadOnly()) {
1600 if (type ==
FIELD) {
1601 FixedArray* properties = global->properties();
1602 int index = lookup.GetFieldIndex();
1603 if (properties->
get(index)->IsTheHole() || !lookup.IsReadOnly()) {
1604 properties->
set(index, *value);
1606 }
else if (type ==
NORMAL) {
1607 if (global->GetNormalizedProperty(&lookup)->IsTheHole() ||
1608 !lookup.IsReadOnly()) {
1609 global->SetNormalizedProperty(&lookup, *value);
1624 ASSERT(args.length() == 3);
1627 ASSERT(!value->IsTheHole());
1640 context->
Lookup(name, flags, &index, &attributes, &binding_flags);
1643 ASSERT(holder->IsContext());
1647 if ((attributes &
READ_ONLY) == 0 || context->get(index)->IsTheHole()) {
1648 context->set(index, *value);
1655 if (attributes ==
ABSENT) {
1657 isolate->context()->global());
1685 LookupResult lookup(isolate);
1686 object->LocalLookupRealNamedProperty(*name, &lookup);
1687 ASSERT(lookup.IsFound());
1688 ASSERT(lookup.IsReadOnly());
1691 if (type ==
FIELD) {
1692 FixedArray* properties =
object->properties();
1693 int index = lookup.GetFieldIndex();
1694 if (properties->
get(index)->IsTheHole()) {
1695 properties->
set(index, *value);
1697 }
else if (type ==
NORMAL) {
1698 if (object->GetNormalizedProperty(&lookup)->IsTheHole()) {
1699 object->SetNormalizedProperty(&lookup, *value);
1723 Runtime_OptimizeObjectForAddingMultipleProperties) {
1725 ASSERT(args.length() == 2);
1728 if (object->HasFastProperties()) {
1737 ASSERT(args.length() == 4);
1747 isolate->counters()->regexp_entry_runtime()->Increment();
1759 ASSERT(args.length() == 3);
1761 if (elements_count < 0 ||
1764 return isolate->ThrowIllegalOperation();
1767 { MaybeObject* maybe_new_object =
1768 isolate->heap()->AllocateFixedArrayWithHoles(elements_count);
1769 if (!maybe_new_object->ToObject(&new_object))
return maybe_new_object;
1772 { MaybeObject* maybe_new_object = isolate->heap()->AllocateRaw(
1774 if (!maybe_new_object->ToObject(&new_object))
return maybe_new_object;
1780 set_map(isolate->global_context()->regexp_result_map());
1783 array->set_properties(isolate->heap()->empty_fixed_array());
1784 array->set_elements(elements);
1795 ASSERT(args.length() == 5);
1800 if (source->length() == 0) source = isolate->heap()->query_colon_symbol();
1802 Object* global = args[2];
1803 if (!global->IsTrue()) global = isolate->heap()->false_value();
1805 Object* ignoreCase = args[3];
1806 if (!ignoreCase->IsTrue()) ignoreCase = isolate->heap()->false_value();
1808 Object* multiline = args[4];
1809 if (!multiline->IsTrue()) multiline = isolate->heap()->false_value();
1811 Map* map = regexp->
map();
1812 Object* constructor = map->constructor();
1813 if (constructor->IsJSFunction() &&
1819 regexp->InObjectPropertyAtPut(
1821 regexp->InObjectPropertyAtPut(
1823 regexp->InObjectPropertyAtPut(
1836 Heap* heap = isolate->heap();
1837 MaybeObject* result;
1838 result = regexp->SetLocalPropertyIgnoreAttributes(heap->source_symbol(),
1841 ASSERT(!result->IsFailure());
1842 result = regexp->SetLocalPropertyIgnoreAttributes(heap->global_symbol(),
1845 ASSERT(!result->IsFailure());
1847 regexp->SetLocalPropertyIgnoreAttributes(heap->ignore_case_symbol(),
1850 ASSERT(!result->IsFailure());
1851 result = regexp->SetLocalPropertyIgnoreAttributes(heap->multiline_symbol(),
1854 ASSERT(!result->IsFailure());
1856 regexp->SetLocalPropertyIgnoreAttributes(heap->last_index_symbol(),
1859 ASSERT(!result->IsFailure());
1867 ASSERT(args.length() == 1);
1871 prototype->set_elements(isolate->heap()->empty_fixed_array());
1880 Handle<String> key = isolate->factory()->LookupAsciiSymbol(name);
1881 Handle<Code> code(isolate->builtins()->builtin(builtin_name));
1883 isolate->factory()->NewFunction(key,
1888 optimized->shared()->DontAdaptArguments();
1896 ASSERT(args.length() == 1);
1899 InstallBuiltin(isolate, holder,
"pop", Builtins::kArrayPop);
1900 InstallBuiltin(isolate, holder,
"push", Builtins::kArrayPush);
1901 InstallBuiltin(isolate, holder,
"shift", Builtins::kArrayShift);
1902 InstallBuiltin(isolate, holder,
"unshift", Builtins::kArrayUnshift);
1903 InstallBuiltin(isolate, holder,
"slice", Builtins::kArraySlice);
1904 InstallBuiltin(isolate, holder,
"splice", Builtins::kArraySplice);
1905 InstallBuiltin(isolate, holder,
"concat", Builtins::kArrayConcat);
1912 ASSERT(args.length() == 1);
1915 if (!callable->IsJSFunction()) {
1927 return isolate->heap()->undefined_value();
1933 function->context()->
global()->global_context();
1934 return global_context->
global()->global_receiver();
1940 ASSERT(args.length() == 4);
1942 int index = args.smi_at(1);
1955 bool has_pending_exception;
1958 &has_pending_exception);
1959 if (has_pending_exception) {
1960 ASSERT(isolate->has_pending_exception());
1963 literals->set(index, *regexp);
1969 NoHandleAllocation ha;
1970 ASSERT(args.length() == 1);
1973 return f->shared()->name();
1978 NoHandleAllocation ha;
1979 ASSERT(args.length() == 2);
1983 f->shared()->set_name(name);
1984 return isolate->heap()->undefined_value();
1989 NoHandleAllocation ha;
1990 ASSERT(args.length() == 1);
1992 return isolate->heap()->ToBoolean(
1993 f->shared()->name_should_print_as_anonymous());
1998 NoHandleAllocation ha;
1999 ASSERT(args.length() == 1);
2001 f->shared()->set_name_should_print_as_anonymous(
true);
2002 return isolate->heap()->undefined_value();
2007 NoHandleAllocation ha;
2008 ASSERT(args.length() == 1);
2011 Object* obj = f->RemovePrototype();
2012 if (obj->IsFailure())
return obj;
2014 return isolate->heap()->undefined_value();
2020 ASSERT(args.length() == 1);
2024 if (!script->IsScript())
return isolate->heap()->undefined_value();
2032 ASSERT(args.length() == 1);
2036 return *shared->GetSourceCode();
2041 NoHandleAllocation ha;
2042 ASSERT(args.length() == 1);
2045 int pos = fun->shared()->start_position();
2051 ASSERT(args.length() == 2);
2064 NoHandleAllocation ha;
2065 ASSERT(args.length() == 2);
2069 fun->SetInstanceClassName(name);
2070 return isolate->heap()->undefined_value();
2075 NoHandleAllocation ha;
2076 ASSERT(args.length() == 2);
2080 fun->shared()->set_length(length);
2081 return isolate->heap()->undefined_value();
2086 NoHandleAllocation ha;
2087 ASSERT(args.length() == 2);
2090 ASSERT(fun->should_have_prototype());
2092 { MaybeObject* maybe_obj =
2094 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
2101 NoHandleAllocation ha;
2105 MaybeObject* maybe_name =
2106 isolate->heap()->AllocateStringFromAscii(
CStrVector(
"prototype"));
2108 if (!maybe_name->To(&name))
return maybe_name;
2110 if (function->HasFastProperties()) {
2113 int index = instance_desc->Search(name);
2115 PropertyDetails details = instance_desc->
GetDetails(index);
2121 Object* descriptors_unchecked;
2122 { MaybeObject* maybe_descriptors_unchecked =
2124 if (!maybe_descriptors_unchecked->ToObject(&descriptors_unchecked)) {
2125 return maybe_descriptors_unchecked;
2132 { MaybeObject* maybe_map_unchecked =
function->map()->CopyDropDescriptors();
2133 if (!maybe_map_unchecked->ToObject(&map_unchecked)) {
2134 return maybe_map_unchecked;
2138 new_map->set_instance_descriptors(new_descriptors);
2142 int entry =
function->property_dictionary()->FindEntry(name);
2144 PropertyDetails details =
function->property_dictionary()->DetailsAt(entry);
2145 PropertyDetails new_details(
2146 static_cast<PropertyAttributes>(details.attributes() |
READ_ONLY),
2149 function->property_dictionary()->DetailsAtPut(entry, new_details);
2156 NoHandleAllocation ha;
2157 ASSERT(args.length() == 1);
2160 return isolate->heap()->ToBoolean(f->shared()->IsApiFunction());
2165 NoHandleAllocation ha;
2166 ASSERT(args.length() == 1);
2169 return isolate->heap()->ToBoolean(f->IsBuiltin());
2175 ASSERT(args.length() == 2);
2180 if (code->IsNull())
return *target;
2186 if (!source->is_compiled() &&
2196 target_shared->set_code(source_shared->code());
2197 target_shared->set_scope_info(source_shared->scope_info());
2198 target_shared->set_length(source_shared->length());
2199 target_shared->set_formal_parameter_count(
2200 source_shared->formal_parameter_count());
2201 target_shared->set_script(isolate->heap()->undefined_value());
2204 target_shared->code()->set_optimizable(
false);
2208 target_shared->ClearThisPropertyAssignmentsInfo();
2211 target->ReplaceCode(source_shared->code());
2216 int number_of_literals = source->NumberOfLiterals();
2218 isolate->factory()->NewFixedArray(number_of_literals,
TENURED);
2219 if (number_of_literals > 0) {
2221 context->global_context());
2223 target->set_context(*context);
2224 target->set_literals(*literals);
2225 target->set_next_function_link(isolate->heap()->undefined_value());
2227 if (isolate->logger()->is_logging() || CpuProfiler::is_profiling(isolate)) {
2228 isolate->logger()->LogExistingFunction(
2238 ASSERT(args.length() == 2);
2243 return isolate->heap()->undefined_value();
2251 if (code <= 0xffff) {
2252 return isolate->heap()->LookupSingleCharacterStringFromCode(code);
2255 return isolate->heap()->empty_string();
2260 NoHandleAllocation ha;
2261 ASSERT(args.length() == 2);
2268 if (index->IsSmi()) {
2270 if (value < 0)
return isolate->heap()->nan_value();
2273 ASSERT(index->IsHeapNumber());
2282 { MaybeObject* maybe_flat = subject->TryFlatten();
2283 if (!maybe_flat->ToObject(&flat))
return maybe_flat;
2287 if (i >= static_cast<uint32_t>(subject->length())) {
2288 return isolate->heap()->nan_value();
2296 NoHandleAllocation ha;
2297 ASSERT(args.length() == 1);
2298 return CharFromCode(isolate, args[0]);
2305 : array_(isolate->factory()->NewFixedArrayWithHoles(initial_capacity)),
2307 has_non_smi_elements_(
false) {
2310 ASSERT(initial_capacity > 0);
2314 : array_(backing_store),
2316 has_non_smi_elements_(
false) {
2319 ASSERT(backing_store->length() > 0);
2323 int length = array_->length();
2324 int required_length = length_ + elements;
2325 return (length >= required_length);
2329 int length = array_->length();
2330 int required_length = length_ + elements;
2331 if (length < required_length) {
2335 }
while (new_length < required_length);
2337 array_->GetIsolate()->factory()->NewFixedArrayWithHoles(new_length);
2338 array_->CopyTo(0, *extended_array, 0, length_);
2339 array_ = extended_array;
2346 array_->set(length_, value);
2348 has_non_smi_elements_ =
true;
2354 array_->set(length_, value);
2367 return array_->length();
2373 return result_array;
2377 FACTORY->SetContent(target_array, array_);
2379 return target_array;
2385 bool has_non_smi_elements_;
2393 template <
typename s
char>
2394 static inline void StringBuilderConcatHelper(
String*,
2411 int estimated_part_count)
2413 array_builder_(heap->isolate(), estimated_part_count),
2415 character_count_(0),
2416 is_ascii_(subject->IsAsciiRepresentation()) {
2419 ASSERT(estimated_part_count > 0);
2426 int length = to - from;
2453 int length =
string->length();
2455 AddElement(*
string);
2456 if (!string->IsAsciiRepresentation()) {
2464 if (array_builder_.
length() == 0) {
2472 char* char_buffer = seq->GetChars();
2473 StringBuilderConcatHelper(*subject_,
2475 *array_builder_.
array(),
2476 array_builder_.
length());
2482 uc16* char_buffer = seq->GetChars();
2483 StringBuilderConcatHelper(*subject_,
2485 *array_builder_.
array(),
2486 array_builder_.
length());
2489 return joined_string;
2497 character_count_ += by;
2515 void AddElement(
Object* element) {
2516 ASSERT(element->IsSmi() || element->IsString());
2518 array_builder_.
Add(element);
2522 FixedArrayBuilder array_builder_;
2523 Handle<String> subject_;
2524 int character_count_;
2532 : parts_(1, zone), replacement_substrings_(0, zone),
2533 simple_hint_(
false),
2538 int subject_length);
2547 return parts_.length();
2551 return simple_hint_;
2561 REPLACEMENT_SUBSTRING,
2564 NUMBER_OF_PART_TYPES
2567 struct ReplacementPart {
2568 static inline ReplacementPart SubjectMatch() {
2569 return ReplacementPart(SUBJECT_CAPTURE, 0);
2571 static inline ReplacementPart SubjectCapture(
int capture_index) {
2572 return ReplacementPart(SUBJECT_CAPTURE, capture_index);
2574 static inline ReplacementPart SubjectPrefix() {
2575 return ReplacementPart(SUBJECT_PREFIX, 0);
2577 static inline ReplacementPart SubjectSuffix(
int subject_length) {
2578 return ReplacementPart(SUBJECT_SUFFIX, subject_length);
2580 static inline ReplacementPart ReplacementString() {
2581 return ReplacementPart(REPLACEMENT_STRING, 0);
2583 static inline ReplacementPart ReplacementSubString(
int from,
int to) {
2586 return ReplacementPart(-from, to);
2591 ReplacementPart(
int tag,
int data)
2592 : tag(tag), data(data) {
2594 ASSERT(tag < NUMBER_OF_PART_TYPES);
2613 template<
typename Char>
2614 static bool ParseReplacementPattern(ZoneList<ReplacementPart>*
parts,
2615 Vector<Char> characters,
2619 int length = characters.length();
2621 for (
int i = 0; i < length; i++) {
2622 Char c = characters[i];
2624 int next_index = i + 1;
2625 if (next_index == length) {
2628 Char c2 = characters[next_index];
2633 parts->Add(ReplacementPart::ReplacementSubString(last, next_index),
2635 last = next_index + 1;
2644 parts->Add(ReplacementPart::ReplacementSubString(last, i), zone);
2646 parts->Add(ReplacementPart::SubjectPrefix(), zone);
2652 parts->Add(ReplacementPart::ReplacementSubString(last, i), zone);
2654 parts->Add(ReplacementPart::SubjectSuffix(subject_length), zone);
2660 parts->Add(ReplacementPart::ReplacementSubString(last, i), zone);
2662 parts->Add(ReplacementPart::SubjectMatch(), zone);
2676 int capture_ref = c2 -
'0';
2677 if (capture_ref > capture_count) {
2681 int second_digit_index = next_index + 1;
2682 if (second_digit_index < length) {
2684 Char c3 = characters[second_digit_index];
2685 if (
'0' <= c3 && c3 <=
'9') {
2686 int double_digit_ref = capture_ref * 10 + c3 -
'0';
2687 if (double_digit_ref <= capture_count) {
2688 next_index = second_digit_index;
2689 capture_ref = double_digit_ref;
2693 if (capture_ref > 0) {
2695 parts->Add(ReplacementPart::ReplacementSubString(last, i), zone);
2697 ASSERT(capture_ref <= capture_count);
2698 parts->Add(ReplacementPart::SubjectCapture(capture_ref), zone);
2699 last = next_index + 1;
2710 if (length > last) {
2712 parts->Add(ReplacementPart::ReplacementString(), zone);
2715 parts->Add(ReplacementPart::ReplacementSubString(last, length), zone);
2721 ZoneList<ReplacementPart> parts_;
2722 ZoneList<Handle<String> > replacement_substrings_;
2730 int subject_length) {
2736 simple_hint_ = ParseReplacementPattern(&parts_,
2743 simple_hint_ = ParseReplacementPattern(&parts_,
2750 Isolate* isolate = replacement->GetIsolate();
2752 int substring_index = 0;
2753 for (
int i = 0, n = parts_.length(); i < n; i++) {
2754 int tag = parts_[i].tag;
2757 int to = parts_[i].data;
2758 replacement_substrings_.
Add(
2760 parts_[i].tag = REPLACEMENT_SUBSTRING;
2761 parts_[i].data = substring_index;
2763 }
else if (tag == REPLACEMENT_STRING) {
2764 replacement_substrings_.
Add(replacement,
zone());
2765 parts_[i].data = substring_index;
2776 for (
int i = 0, n = parts_.length(); i < n; i++) {
2777 ReplacementPart part = parts_[i];
2779 case SUBJECT_PREFIX:
2782 case SUBJECT_SUFFIX: {
2783 int subject_length = part.data;
2784 if (match_to < subject_length) {
2789 case SUBJECT_CAPTURE: {
2790 int capture = part.data;
2794 if (from >= 0 && to > from) {
2799 case REPLACEMENT_SUBSTRING:
2800 case REPLACEMENT_STRING:
2801 builder->
AddString(replacement_substrings_[part.data]);
2818 const char* subject_start =
reinterpret_cast<const char*
>(subject.
start());
2819 const char* subject_end = subject_start + subject.
length();
2820 const char* pos = subject_start;
2822 pos =
reinterpret_cast<const char*
>(
2823 memchr(pos, pattern, subject_end - pos));
2824 if (pos ==
NULL)
return;
2825 indices->
Add(static_cast<int>(pos - subject_start), zone);
2832 template <
typename SubjectChar,
typename PatternChar>
2842 int pattern_length = pattern.
length();
2846 index = search.
Search(subject, index);
2847 if (index < 0)
return;
2848 indices->
Add(index, zone);
2849 index += pattern_length;
2867 if (subject_content.
IsAscii()) {
2869 if (pattern_content.
IsAscii()) {
2871 if (pattern_vector.
length() == 1) {
2895 if (pattern_content.
IsAscii()) {
2935 template <
typename SubjectChar,
typename PatternChar>
2936 static bool SearchStringMultiple(
Isolate* isolate,
2937 Vector<const SubjectChar> subject,
2938 Vector<const PatternChar> pattern,
2940 FixedArrayBuilder* builder,
2942 int pos = *match_pos;
2943 int subject_length = subject.length();
2944 int pattern_length = pattern.length();
2945 int max_search_start = subject_length - pattern_length;
2946 StringSearch<PatternChar, SubjectChar> search(isolate, pattern);
2947 while (pos <= max_search_start) {
2953 int match_end = pos + pattern_length;
2954 int new_pos = search.Search(subject, match_end);
2957 if (new_pos > match_end) {
2963 builder->Add(pattern_string);
2969 if (pos < max_search_start) {
2971 pos + pattern_length,
2981 template<
typename ResultSeqString>
2982 MUST_USE_RESULT static MaybeObject* StringReplaceAtomRegExpWithString(
2984 Handle<String> subject,
2985 Handle<JSRegExp> pattern_regexp,
2986 Handle<String> replacement,
2987 Handle<JSArray> last_match_info,
2989 ASSERT(subject->IsFlat());
2990 ASSERT(replacement->IsFlat());
2993 ZoneList<int> indices(8, isolate->zone());
2997 int subject_len = subject->
length();
2998 int pattern_len = pattern->length();
2999 int replacement_len = replacement->length();
3004 int matches = indices.length();
3005 if (matches == 0)
return *subject;
3008 int64_t result_len_64 =
3009 (
static_cast<int64_t
>(replacement_len) -
3010 static_cast<int64_t>(pattern_len)) *
3011 static_cast<int64_t>(matches) +
3012 static_cast<int64_t
>(subject_len);
3014 int result_len =
static_cast<int>(result_len_64);
3016 int subject_pos = 0;
3019 Handle<ResultSeqString> result;
3020 if (ResultSeqString::kHasAsciiEncoding) {
3022 isolate->factory()->NewRawAsciiString(result_len));
3025 isolate->factory()->NewRawTwoByteString(result_len));
3028 for (
int i = 0; i < matches; i++) {
3030 if (subject_pos < indices.at(i)) {
3032 result->GetChars() + result_pos,
3035 result_pos += indices.at(i) - subject_pos;
3039 if (replacement_len > 0) {
3041 result->GetChars() + result_pos,
3044 result_pos += replacement_len;
3047 subject_pos = indices.at(i) + pattern_len;
3050 if (subject_pos < subject_len) {
3052 result->GetChars() + result_pos,
3057 SetLastMatchInfoNoCaptures(subject,
3059 indices.at(matches - 1),
3060 indices.at(matches - 1) + pattern_len);
3070 String* replacement,
3071 JSArray* last_match_info,
3073 ASSERT(subject->IsFlat());
3074 ASSERT(replacement->IsFlat());
3076 HandleScope handles(isolate);
3078 int length = subject->length();
3079 Handle<String> subject_handle(subject);
3080 Handle<JSRegExp> regexp_handle(regexp);
3081 Handle<String> replacement_handle(replacement);
3082 Handle<JSArray> last_match_info_handle(last_match_info);
3086 last_match_info_handle,
3088 if (match.is_null()) {
3091 if (match->IsNull()) {
3092 return *subject_handle;
3095 int capture_count = regexp_handle->CaptureCount();
3099 CompiledReplacement compiled_replacement(isolate->zone());
3100 compiled_replacement.Compile(replacement_handle,
3104 bool is_global = regexp_handle->GetFlags().is_global();
3109 compiled_replacement.simple_hint()) {
3110 if (subject_handle->HasOnlyAsciiChars() &&
3111 replacement_handle->HasOnlyAsciiChars()) {
3112 return StringReplaceAtomRegExpWithString<SeqAsciiString>(
3117 last_match_info_handle,
3120 return StringReplaceAtomRegExpWithString<SeqTwoByteString>(
3125 last_match_info_handle,
3133 int expected_parts =
3134 (compiled_replacement.parts() + 1) * (is_global ? 4 : 1) + 1;
3135 ReplacementStringBuilder builder(isolate->heap(),
3145 const int parts_added_per_loop = 2 * (compiled_replacement.parts() + 2);
3146 bool matched =
true;
3148 ASSERT(last_match_info_handle->HasFastObjectElements());
3151 builder.EnsureCapacity(parts_added_per_loop);
3153 HandleScope loop_scope(isolate);
3156 AssertNoAllocation match_info_array_is_not_in_a_handle;
3157 FixedArray* match_info_array =
3167 builder.AddSubjectSlice(prev, start);
3169 compiled_replacement.Apply(&builder,
3172 last_match_info_handle);
3176 if (!is_global)
break;
3182 if (next > length)
break;
3188 last_match_info_handle,
3190 if (match.is_null()) {
3193 matched = !match->IsNull();
3196 if (prev < length) {
3197 builder.AddSubjectSlice(prev, length);
3200 return *(builder.ToString());
3204 template <
typename ResultSeqString>
3205 MUST_USE_RESULT static MaybeObject* StringReplaceRegExpWithEmptyString(
3209 JSArray* last_match_info,
3211 ASSERT(subject->IsFlat());
3213 HandleScope handles(isolate);
3215 Handle<String> subject_handle(subject);
3216 Handle<JSRegExp> regexp_handle(regexp);
3217 Handle<JSArray> last_match_info_handle(last_match_info);
3220 if (regexp_handle->GetFlags().is_global() &&
3222 Handle<String> empty_string_handle(
HEAP->empty_string());
3223 if (subject_handle->HasOnlyAsciiChars()) {
3224 return StringReplaceAtomRegExpWithString<SeqAsciiString>(
3228 empty_string_handle,
3229 last_match_info_handle,
3232 return StringReplaceAtomRegExpWithString<SeqTwoByteString>(
3236 empty_string_handle,
3237 last_match_info_handle,
3245 last_match_info_handle,
3248 if (match->IsNull())
return *subject_handle;
3250 ASSERT(last_match_info_handle->HasFastObjectElements());
3254 AssertNoAllocation match_info_array_is_not_in_a_handle;
3255 FixedArray* match_info_array =
3262 bool global = regexp_handle->GetFlags().is_global();
3264 if (start == end && !global)
return *subject_handle;
3266 int length = subject_handle->length();
3267 int new_length = length - (end - start);
3268 if (new_length == 0) {
3269 return isolate->heap()->empty_string();
3271 Handle<ResultSeqString> answer;
3272 if (ResultSeqString::kHasAsciiEncoding) {
3274 isolate->factory()->NewRawAsciiString(new_length));
3277 isolate->factory()->NewRawTwoByteString(new_length));
3290 answer->GetChars() + start,
3305 answer->GetChars() + position,
3308 position += start - prev;
3315 if (next > length)
break;
3320 last_match_info_handle,
3323 if (match->IsNull())
break;
3325 ASSERT(last_match_info_handle->HasFastObjectElements());
3326 HandleScope loop_scope(isolate);
3328 AssertNoAllocation match_info_array_is_not_in_a_handle;
3329 FixedArray* match_info_array =
3336 if (prev < length) {
3339 answer->GetChars() + position,
3342 position += length - prev;
3345 if (position == 0) {
3346 return isolate->heap()->empty_string();
3350 int string_size = ResultSeqString::SizeFor(position);
3351 int allocated_string_size = ResultSeqString::SizeFor(new_length);
3352 int delta = allocated_string_size - string_size;
3354 answer->set_length(position);
3355 if (delta == 0)
return *answer;
3357 Address end_of_string = answer->address() + string_size;
3358 isolate->heap()->CreateFillerObjectAt(end_of_string, delta);
3368 ASSERT(args.length() == 4);
3371 if (!subject->IsFlat()) {
3373 { MaybeObject* maybe_flat_subject = subject->TryFlatten();
3374 if (!maybe_flat_subject->ToObject(&flat_subject)) {
3375 return maybe_flat_subject;
3382 if (!replacement->IsFlat()) {
3383 Object* flat_replacement;
3384 { MaybeObject* maybe_flat_replacement = replacement->TryFlatten();
3385 if (!maybe_flat_replacement->ToObject(&flat_replacement)) {
3386 return maybe_flat_replacement;
3395 ASSERT(last_match_info->HasFastObjectElements());
3397 Zone* zone = isolate->zone();
3398 if (replacement->length() == 0) {
3399 if (subject->HasOnlyAsciiChars()) {
3400 return StringReplaceRegExpWithEmptyString<SeqAsciiString>(
3401 isolate, subject, regexp, last_match_info, zone);
3403 return StringReplaceRegExpWithEmptyString<SeqTwoByteString>(
3404 isolate, subject, regexp, last_match_info, zone);
3408 return StringReplaceRegExpWithString(isolate,
3422 int recursion_limit) {
3424 if (subject->IsConsString()) {
3434 recursion_limit - 1);
3436 if (new_first.
is_null())
return new_first;
3444 recursion_limit - 1);
3446 if (new_second.
is_null())
return new_second;
3450 int index =
StringMatch(isolate, subject, search, 0);
3451 if (index == -1)
return subject;
3463 ASSERT(args.length() == 3);
3471 const int kRecursionLimit = 0x1000;
3480 if (!result.
is_null())
return *result;
3497 ASSERT(0 <= start_index);
3498 ASSERT(start_index <= sub->length());
3500 int pattern_length = pat->length();
3501 if (pattern_length == 0)
return start_index;
3503 int subject_length = sub->length();
3504 if (start_index + pattern_length > subject_length)
return -1;
3544 ASSERT(args.length() == 3);
3550 uint32_t start_index;
3553 RUNTIME_ASSERT(start_index <= static_cast<uint32_t>(sub->length()));
3560 template <
typename s
char,
typename p
char>
3561 static int StringMatchBackwards(Vector<const schar> subject,
3562 Vector<const pchar> pattern,
3564 int pattern_length = pattern.length();
3565 ASSERT(pattern_length >= 1);
3566 ASSERT(idx + pattern_length <= subject.length());
3568 if (
sizeof(schar) == 1 &&
sizeof(pchar) > 1) {
3569 for (
int i = 0; i < pattern_length; i++) {
3570 uc16 c = pattern[i];
3577 pchar pattern_first_char = pattern[0];
3578 for (
int i = idx; i >= 0; i--) {
3579 if (subject[i] != pattern_first_char)
continue;
3581 while (j < pattern_length) {
3582 if (pattern[j] != subject[i+j]) {
3587 if (j == pattern_length) {
3596 ASSERT(args.length() == 3);
3602 uint32_t start_index;
3605 uint32_t pat_length = pat->length();
3606 uint32_t sub_length = sub->length();
3608 if (start_index + pat_length > sub_length) {
3609 start_index = sub_length - pat_length;
3612 if (pat_length == 0) {
3628 position = StringMatchBackwards(sub_content.
ToAsciiVector(),
3632 position = StringMatchBackwards(sub_content.
ToUC16Vector(),
3639 position = StringMatchBackwards(sub_content.
ToAsciiVector(),
3643 position = StringMatchBackwards(sub_content.
ToUC16Vector(),
3654 NoHandleAllocation ha;
3655 ASSERT(args.length() == 2);
3661 int str1_length = str1->length();
3662 int str2_length = str2->length();
3665 if (str1_length == 0) {
3669 if (str2_length == 0)
return Smi::FromInt(str1_length);
3672 int end = str1_length < str2_length ? str1_length : str2_length;
3677 int d = str1->Get(0) - str2->Get(0);
3684 *isolate->runtime_state()->string_locale_compare_buf1();
3686 *isolate->runtime_state()->string_locale_compare_buf2();
3691 for (
int i = 0; i < end; i++) {
3694 if (char1 != char2)
return Smi::FromInt(char1 - char2);
3702 NoHandleAllocation ha;
3703 ASSERT(args.length() == 3);
3709 if (args[1]->IsSmi() && args[2]->IsSmi()) {
3712 start = from_number;
3723 isolate->counters()->sub_string_runtime()->Increment();
3724 return value->SubString(start, end);
3742 if (match->IsNull()) {
3743 return isolate->heap()->null_value();
3745 int length = subject->length();
3747 Zone* zone = isolate->zone();
3759 offsets.
Add(start, zone);
3760 offsets.
Add(end, zone);
3761 if (start == end)
if (++end > length)
break;
3767 }
while (!match->IsNull());
3768 int matches = offsets.length() / 2;
3771 NewSubString(subject, offsets.
at(0), offsets.
at(1));
3772 elements->set(0, *substring);
3773 for (
int i = 1; i < matches ; i++) {
3774 int from = offsets.
at(i * 2);
3775 int to = offsets.
at(i * 2 + 1);
3777 NewProperSubString(subject, from, to);
3778 elements->set(i, *substring);
3780 Handle<JSArray> result = isolate->factory()->NewJSArrayWithElements(elements);
3786 static bool SearchStringMultiple(
Isolate* isolate,
3790 FixedArrayBuilder* builder) {
3795 int match_pos = -pattern->
length();
3799 AssertNoAllocation no_gc;
3802 if (subject_content.IsAscii()) {
3803 Vector<const char> subject_vector = subject_content.
ToAsciiVector();
3804 if (pattern_content.IsAscii()) {
3805 if (SearchStringMultiple(isolate,
3807 pattern_content.ToAsciiVector(),
3812 if (SearchStringMultiple(isolate,
3814 pattern_content.ToUC16Vector(),
3820 Vector<const uc16> subject_vector = subject_content.ToUC16Vector();
3821 if (pattern_content.IsAscii()) {
3822 if (SearchStringMultiple(isolate,
3824 pattern_content.ToAsciiVector(),
3829 if (SearchStringMultiple(isolate,
3831 pattern_content.ToUC16Vector(),
3839 if (match_pos >= 0) {
3840 SetLastMatchInfoNoCaptures(subject,
3843 match_pos + pattern->
length());
3850 static int SearchRegExpNoCaptureMultiple(
3852 Handle<String> subject,
3853 Handle<JSRegExp> regexp,
3854 Handle<JSArray> last_match_array,
3855 FixedArrayBuilder* builder) {
3856 ASSERT(subject->IsFlat());
3857 ASSERT(regexp->CaptureCount() == 0);
3858 int match_start = -1;
3867 registers_per_match,
3869 OffsetsVector registers(num_registers, isolate);
3870 Vector<int32_t> register_vector(registers.vector(), registers.length());
3871 int subject_length = subject->length();
3879 if (num_matches > 0) {
3880 for (
int match_index = 0; match_index < num_matches; match_index++) {
3881 int32_t* current_match = ®ister_vector[match_index * 2];
3882 match_start = current_match[0];
3884 if (match_end < match_start) {
3889 match_end = current_match[1];
3890 HandleScope loop_scope(isolate);
3892 builder->Add(*isolate->factory()->NewProperSubString(subject,
3896 builder->Add(*isolate->factory()->NewSubString(subject,
3905 if (num_matches < max_matches)
break;
3907 if (match_start != match_end) {
3910 pos = match_end + 1;
3911 if (pos > subject_length)
break;
3913 }
else if (num_matches == 0) {
3921 if (match_start >= 0) {
3922 if (match_end < subject_length) {
3927 SetLastMatchInfoNoCaptures(subject,
3940 static int SearchRegExpMultiple(
3942 Handle<String> subject,
3943 Handle<JSRegExp> regexp,
3944 Handle<JSArray> last_match_array,
3945 FixedArrayBuilder* builder) {
3947 ASSERT(subject->IsFlat());
3954 registers_per_match,
3956 OffsetsVector registers(num_registers, isolate);
3957 Vector<int32_t> register_vector(registers.vector(), registers.length());
3965 int capture_count = regexp->CaptureCount();
3966 int subject_length = subject->length();
3974 if (num_matches > 0) {
3976 int match_start = 0;
3977 for (
int match_index = 0; match_index < num_matches; match_index++) {
3979 ®ister_vector[match_index * registers_per_match];
3980 match_start = current_match[0];
3982 if (match_end < match_start) {
3987 match_end = current_match[1];
3991 HandleScope temp_scope(isolate);
3994 Handle<FixedArray> elements =
3995 isolate->factory()->NewFixedArray(3 + capture_count);
3996 Handle<String> match;
3998 match = isolate->factory()->NewProperSubString(subject,
4002 match = isolate->factory()->NewSubString(subject,
4006 elements->set(0, *match);
4007 for (
int i = 1; i <= capture_count; i++) {
4008 int start = current_match[i * 2];
4010 int end = current_match[i * 2 + 1];
4012 Handle<String> substring;
4015 isolate->factory()->NewProperSubString(subject, start, end);
4018 isolate->factory()->NewSubString(subject, start, end);
4020 elements->set(i, *substring);
4022 ASSERT(current_match[i * 2 + 1] < 0);
4023 elements->set(i, isolate->heap()->undefined_value());
4026 elements->set(capture_count + 1,
Smi::FromInt(match_start));
4027 elements->set(capture_count + 2, *subject);
4028 builder->Add(*isolate->factory()->NewJSArrayWithElements(elements));
4035 if (num_matches < max_matches)
break;
4037 if (match_end > match_start) {
4040 pos = match_end + 1;
4041 if (pos > subject_length) {
4051 }
while (num_matches > 0);
4055 if (match_end < subject_length) {
4061 int last_match_capture_count = (capture_count + 1) * 2;
4062 int last_match_array_size =
4064 last_match_array->EnsureSize(last_match_array_size);
4065 AssertNoAllocation no_gc;
4085 ASSERT(args.length() == 4);
4095 ASSERT(regexp->GetFlags().is_global());
4097 if (result_array->HasFastObjectElements()) {
4101 if (result_elements.is_null() || result_elements->length() < 16) {
4102 result_elements = isolate->factory()->NewFixedArrayWithHoles(16);
4109 ASSERT(pattern->IsFlat());
4110 if (SearchStringMultiple(isolate, subject, pattern,
4111 last_match_info, &builder)) {
4112 return *builder.
ToJSArray(result_array);
4114 return isolate->heap()->null_value();
4120 if (regexp->CaptureCount() == 0) {
4121 result = SearchRegExpNoCaptureMultiple(isolate,
4127 result = SearchRegExpMultiple(isolate,
4141 NoHandleAllocation ha;
4142 ASSERT(args.length() == 2);
4147 if (args[0]->IsSmi()) {
4148 int value = args.smi_at(0);
4149 if (value >= 0 && value < radix) {
4151 static const char kCharTable[] =
"0123456789abcdefghijklmnopqrstuvwxyz";
4152 return isolate->heap()->
4160 return *isolate->factory()->nan_symbol();
4164 return *isolate->factory()->minus_infinity_symbol();
4166 return *isolate->factory()->infinity_symbol();
4169 MaybeObject* result =
4170 isolate->heap()->AllocateStringFromAscii(
CStrVector(str));
4177 NoHandleAllocation ha;
4178 ASSERT(args.length() == 2);
4182 return *isolate->factory()->nan_symbol();
4186 return *isolate->factory()->minus_infinity_symbol();
4188 return *isolate->factory()->infinity_symbol();
4195 isolate->heap()->AllocateStringFromAscii(
CStrVector(str));
4202 NoHandleAllocation ha;
4203 ASSERT(args.length() == 2);
4207 return *isolate->factory()->nan_symbol();
4211 return *isolate->factory()->minus_infinity_symbol();
4213 return *isolate->factory()->infinity_symbol();
4220 isolate->heap()->AllocateStringFromAscii(
CStrVector(str));
4227 NoHandleAllocation ha;
4228 ASSERT(args.length() == 2);
4232 return *isolate->factory()->nan_symbol();
4236 return *isolate->factory()->minus_infinity_symbol();
4238 return *isolate->factory()->infinity_symbol();
4245 isolate->heap()->AllocateStringFromAscii(
CStrVector(str));
4254 if (index < static_cast<uint32_t>(string->
length())) {
4255 string->TryFlatten();
4257 string->Get(index));
4267 if (object->IsString()) {
4269 if (!result->IsUndefined())
return *result;
4273 if (object->IsStringObjectWithCharacterAt(index)) {
4277 if (!result->IsUndefined())
return *result;
4280 if (object->IsString() ||
object->IsNumber() ||
object->IsBoolean()) {
4281 return object->GetPrototype()->GetElement(index);
4284 return object->GetElement(index);
4293 if (object->IsUndefined() ||
object->IsNull()) {
4298 return isolate->
Throw(*error);
4303 if (key->ToArrayIndex(&index)) {
4309 if (key->IsString()) {
4312 bool has_pending_exception =
false;
4321 if (name->AsArrayIndex(&index)) {
4324 return object->GetProperty(*name);
4330 NoHandleAllocation ha;
4331 ASSERT(args.length() == 2);
4342 NoHandleAllocation ha;
4343 ASSERT(args.length() == 2);
4356 if (args[0]->IsJSObject()) {
4357 if (!args[0]->IsJSGlobalProxy() &&
4358 !args[0]->IsAccessCheckNeeded() &&
4359 args[1]->IsString()) {
4364 Map* receiver_map = receiver->
map();
4366 int offset = keyed_lookup_cache->
Lookup(receiver_map, key);
4369 return value->IsTheHole()
4370 ? isolate->heap()->undefined_value()
4375 LookupResult result(isolate);
4377 if (result.IsFound() && result.type() ==
FIELD) {
4378 int offset = result.GetFieldIndex();
4379 keyed_lookup_cache->
Update(receiver_map, key, offset);
4389 if (!receiver->IsGlobalObject())
return value;
4391 if (!value->IsTheHole())
return value;
4395 }
else if (FLAG_smi_only_arrays && args.at<
Object>(1)->IsSmi()) {
4403 ElementsKind elements_kind = js_object->GetElementsKind();
4416 if (maybe_object->IsFailure())
return maybe_object;
4420 }
else if (args[0]->IsString() && args[1]->IsSmi()) {
4424 int index = args.smi_at(1);
4425 if (index >= 0 && index < str->length()) {
4439 return obj->IsUndefined() || obj->IsSpecFunction() || obj->IsNull();
4450 ASSERT(args.length() == 5);
4463 bool fast = obj->HasFastProperties();
4466 return isolate->heap()->undefined_value();
4476 ASSERT(args.length() == 4);
4485 LookupResult result(isolate);
4486 js_object->LocalLookupRealNamedProperty(*name, &result);
4489 if (result.IsFound() && result.type() ==
CALLBACKS) {
4490 Object* callback = result.GetCallbackObject();
4494 if (callback->IsAccessorInfo()) {
4495 return isolate->heap()->undefined_value();
4501 if (callback->IsForeign() && result.GetAttributes() == attr) {
4502 return js_object->SetPropertyWithCallback(callback,
4516 if (result.IsProperty() &&
4517 (attr != result.GetAttributes() || result.type() ==
CALLBACKS)) {
4519 if (js_object->IsJSGlobalProxy()) {
4527 return js_object->SetLocalPropertyIgnoreAttributes(*name,
4549 if (object->IsUndefined() ||
object->IsNull()) {
4554 return isolate->
Throw(*error);
4557 if (object->IsJSProxy()) {
4558 bool has_pending_exception =
false;
4566 if (!object->IsJSObject())
return *value;
4572 if (key->ToArrayIndex(&index)) {
4580 if (js_object->IsStringObjectWithCharacterAt(index)) {
4584 js_object->ValidateElements();
4586 js_object, index, value, attr, strict_mode, set_mode);
4587 js_object->ValidateElements();
4592 if (key->IsString()) {
4596 js_object, index, value, attr, strict_mode, set_mode);
4599 key_string->TryFlatten();
4601 js_object, key_string, value, attr, strict_mode);
4608 bool has_pending_exception =
false;
4613 if (name->AsArrayIndex(&index)) {
4614 return js_object->SetElement(
4615 index, *value, attr, strict_mode,
true, set_mode);
4617 return js_object->SetProperty(*name, *value, attr, strict_mode);
4631 if (key->ToArrayIndex(&index)) {
4639 if (js_object->IsStringObjectWithCharacterAt(index)) {
4643 return js_object->SetElement(
4647 if (key->IsString()) {
4649 return js_object->SetElement(
4653 key_string->TryFlatten();
4654 return js_object->SetLocalPropertyIgnoreAttributes(*key_string,
4661 bool has_pending_exception =
false;
4666 if (name->AsArrayIndex(&index)) {
4667 return js_object->SetElement(
4670 return js_object->SetLocalPropertyIgnoreAttributes(*name, *value, attr);
4682 if (key->ToArrayIndex(&index)) {
4689 if (receiver->IsStringObjectWithCharacterAt(index)) {
4690 return isolate->
heap()->true_value();
4697 if (key->IsString()) {
4701 bool has_pending_exception =
false;
4707 key_string->TryFlatten();
4713 NoHandleAllocation ha;
4727 if (args.length() == 5) {
4729 strict_mode = strict_mode_flag;
4742 NoHandleAllocation ha;
4745 if (object->IsJSObject()) {
4747 ElementsKind new_kind = js_object->HasFastHoleyElements()
4758 NoHandleAllocation ha;
4761 if (object->IsJSObject()) {
4763 ElementsKind new_kind = js_object->HasFastHoleyElements()
4777 NoHandleAllocation ha;
4782 if (object->IsJSFunction()) {
4784 func->shared()->set_native(
true);
4786 return isolate->heap()->undefined_value();
4799 Object* raw_boilerplate_object = literals->get(literal_index);
4801 ElementsKind elements_kind =
object->GetElementsKind();
4806 if (value->IsNumber()) {
4812 boilerplate_object->GetElementsKind(),
4813 transitioned_kind)) {
4820 double_array->
set(store_index, number->Number());
4829 boilerplate_object->GetElementsKind(),
4830 transitioned_kind)) {
4834 object_array->
set(store_index, *value);
4843 if (!isolate->IsDebuggerActive())
return isolate->heap()->false_value();
4847 return isolate->heap()->false_value();
4849 return isolate->heap()->true_value();
4856 Debug* debug = isolate->debug();
4857 if (!debug->IsStepping())
return NULL;
4864 debug->ClearStepOut();
4865 debug->FloodWithOneShot(shared_info);
4873 NoHandleAllocation ha;
4879 if (args.length() == 4) {
4888 SetLocalPropertyIgnoreAttributes(name, args[2], attributes);
4893 NoHandleAllocation ha;
4894 ASSERT(args.length() == 3);
4899 return object->DeleteProperty(key, (strict_mode ==
kStrictMode)
4905 static Object* HasLocalPropertyImplementation(
Isolate* isolate,
4913 if (proto->IsJSObject() &&
4915 return HasLocalPropertyImplementation(isolate,
4919 return isolate->heap()->false_value();
4924 NoHandleAllocation ha;
4925 ASSERT(args.length() == 2);
4929 const bool key_is_array_index = key->
AsArrayIndex(&index);
4933 if (obj->IsJSObject()) {
4939 Map* map =
object->
map();
4940 if (!key_is_array_index &&
4943 return isolate->heap()->false_value();
4947 return HasLocalPropertyImplementation(isolate,
4950 }
else if (obj->IsString() && key_is_array_index) {
4953 if (index < static_cast<uint32_t>(string->
length())) {
4954 return isolate->heap()->true_value();
4957 return isolate->heap()->false_value();
4962 NoHandleAllocation na;
4963 ASSERT(args.length() == 2);
4967 bool result = receiver->HasProperty(key);
4969 return isolate->heap()->ToBoolean(result);
4974 NoHandleAllocation na;
4975 ASSERT(args.length() == 2);
4979 bool result = receiver->HasElement(index);
4981 return isolate->heap()->ToBoolean(result);
4986 NoHandleAllocation ha;
4987 ASSERT(args.length() == 2);
4998 return isolate->heap()->false_value();
5001 return isolate->heap()->true_value();
5003 if (object->IsJSGlobalProxy()) {
5005 if (proto->IsNull()) {
5006 return isolate->heap()->false_value();
5008 ASSERT(proto->IsJSGlobalObject());
5013 if (elements->
map() ==
5014 isolate->heap()->non_strict_arguments_elements_map()) {
5019 int entry = dictionary->FindEntry(index);
5021 PropertyDetails details = dictionary->DetailsAt(entry);
5022 return isolate->heap()->ToBoolean(!details.IsDontEnum());
5028 return isolate->heap()->ToBoolean(att !=
ABSENT && (att &
DONT_ENUM) == 0);
5034 ASSERT(args.length() == 1);
5049 ASSERT(args.length() == 1);
5053 if (raw_object->IsSimpleEnum())
return raw_object->map();
5063 if (object->IsSimpleEnum())
return object->map();
5072 static int LocalPrototypeChainLength(JSObject* obj) {
5075 while (proto->IsJSObject() &&
5088 ASSERT(args.length() == 1);
5089 if (!args[0]->IsJSObject()) {
5090 return isolate->heap()->undefined_value();
5096 if (obj->IsJSGlobalProxy()) {
5098 if (obj->IsAccessCheckNeeded() &&
5099 !isolate->MayNamedAccess(*obj,
5100 isolate->heap()->undefined_value(),
5103 return *isolate->factory()->NewJSArray(0);
5109 int length = LocalPrototypeChainLength(*obj);
5113 int total_property_count = 0;
5115 for (
int i = 0; i < length; i++) {
5117 if (jsproto->IsAccessCheckNeeded() &&
5118 !isolate->MayNamedAccess(*jsproto,
5119 isolate->heap()->undefined_value(),
5122 return *isolate->factory()->NewJSArray(0);
5125 n = jsproto->NumberOfLocalProperties();
5126 local_property_count[i] = n;
5127 total_property_count += n;
5128 if (i < length - 1) {
5135 isolate->factory()->NewFixedArray(total_property_count);
5139 int proto_with_hidden_properties = 0;
5140 int next_copy_index = 0;
5141 for (
int i = 0; i < length; i++) {
5142 jsproto->GetLocalPropertyNames(*names, next_copy_index);
5143 next_copy_index += local_property_count[i];
5144 if (jsproto->HasHiddenProperties()) {
5145 proto_with_hidden_properties++;
5147 if (i < length - 1) {
5153 if (proto_with_hidden_properties > 0) {
5155 names = isolate->factory()->NewFixedArray(
5156 names->length() - proto_with_hidden_properties);
5158 for (
int i = 0; i < total_property_count; i++) {
5159 Object* name = old_names->get(i);
5160 if (name == isolate->heap()->hidden_symbol()) {
5163 names->set(dest_pos++, name);
5167 return *isolate->factory()->NewJSArrayWithElements(names);
5175 ASSERT(args.length() == 1);
5176 if (!args[0]->IsJSObject()) {
5177 return isolate->heap()->undefined_value();
5181 int n = obj->NumberOfLocalElements(static_cast<PropertyAttributes>(
NONE));
5183 obj->GetLocalElementKeys(*names, static_cast<PropertyAttributes>(
NONE));
5184 return *isolate->factory()->NewJSArrayWithElements(names);
5192 ASSERT(args.length() == 1);
5193 if (!args[0]->IsJSObject()) {
5199 if (obj->HasNamedInterceptor()) result |= 2;
5200 if (obj->HasIndexedInterceptor()) result |= 1;
5210 ASSERT(args.length() == 1);
5213 if (obj->HasNamedInterceptor()) {
5217 return isolate->heap()->undefined_value();
5225 ASSERT(args.length() == 1);
5228 if (obj->HasIndexedInterceptor()) {
5232 return isolate->heap()->undefined_value();
5242 if (object->IsJSGlobalProxy()) {
5244 if (object->IsAccessCheckNeeded() &&
5245 !isolate->MayNamedAccess(*
object, isolate->heap()->undefined_value(),
5248 return *isolate->factory()->NewJSArray(0);
5253 if (proto->
IsNull())
return *isolate->factory()->NewJSArray(0);
5265 int length = contents->length();
5267 for (
int i = 0; i < length; i++) {
5268 Object* entry = contents->get(i);
5269 if (entry->IsString()) {
5270 copy->set(i, entry);
5272 ASSERT(entry->IsNumber());
5276 isolate->factory()->NumberToString(entry_handle);
5277 copy->set(i, *entry_str);
5280 return *isolate->factory()->NewJSArrayWithElements(copy);
5285 NoHandleAllocation ha;
5286 ASSERT(args.length() == 1);
5290 it.AdvanceToArgumentsFrame();
5299 if (args[0]->ToArrayIndex(&index) && index < n) {
5305 bool exception =
false;
5312 if (key->AsArrayIndex(&index)) {
5316 return isolate->initial_object_prototype()->GetElement(index);
5321 if (key->Equals(isolate->heap()->length_symbol()))
return Smi::FromInt(n);
5322 if (key->Equals(isolate->heap()->callee_symbol())) {
5324 if (function->IsJSFunction() &&
5326 return isolate->Throw(*isolate->factory()->NewTypeError(
5327 "strict_arguments_callee", HandleVector<Object>(
NULL, 0)));
5333 return isolate->initial_object_prototype()->GetProperty(*key);
5338 ASSERT(args.length() == 1);
5339 Object*
object = args[0];
5340 return (object->IsJSObject() && !
object->IsGlobalObject())
5347 ASSERT(args.length() == 1);
5349 return (obj->IsJSObject() && !obj->IsJSGlobalProxy())
5356 NoHandleAllocation ha;
5357 ASSERT(args.length() == 1);
5366 NoHandleAllocation ha;
5369 if (obj->IsNumber())
return isolate->heap()->number_symbol();
5374 return isolate->heap()->undefined_symbol();
5379 return isolate->heap()->string_symbol();
5382 switch (instance_type) {
5384 if (heap_obj->IsTrue() || heap_obj->IsFalse()) {
5385 return isolate->heap()->boolean_symbol();
5387 if (heap_obj->IsNull()) {
5388 return FLAG_harmony_typeof
5389 ? isolate->heap()->null_symbol()
5390 : isolate->heap()->object_symbol();
5392 ASSERT(heap_obj->IsUndefined());
5393 return isolate->heap()->undefined_symbol();
5396 return isolate->heap()->function_symbol();
5400 return isolate->heap()->object_symbol();
5405 static bool AreDigits(
const char*s,
int from,
int to) {
5406 for (
int i = from; i < to; i++) {
5407 if (s[i] <
'0' || s[i] >
'9')
return false;
5414 static int ParseDecimalInteger(
const char*s,
int from,
int to) {
5417 int d = s[from] -
'0';
5419 for (
int i = from + 1; i < to; i++) {
5420 d = 10 * d + (s[i] -
'0');
5428 NoHandleAllocation ha;
5429 ASSERT(args.length() == 1);
5431 subject->TryFlatten();
5434 int len = subject->length();
5435 if (subject->IsSeqAsciiString()) {
5439 bool minus = (data[0] ==
'-');
5440 int start_pos = (minus ? 1 : 0);
5442 if (start_pos == len) {
5443 return isolate->heap()->nan_value();
5444 }
else if (data[start_pos] >
'9') {
5449 if (data[start_pos] !=
'I') {
5450 return isolate->heap()->nan_value();
5452 }
else if (len - start_pos < 10 && AreDigits(data, start_pos, len)) {
5455 int d = ParseDecimalInteger(data, start_pos, len);
5457 if (d == 0)
return isolate->heap()->minus_zero_value();
5459 }
else if (!subject->HasHashCode() &&
5461 (len == 1 || data[0] !=
'0')) {
5467 ASSERT_EQ(static_cast<int>(subject->hash_field()),
5468 static_cast<int>(hash));
5470 subject->set_hash_field(hash);
5477 return isolate->heap()->NumberFromDouble(
5483 NoHandleAllocation ha;
5484 ASSERT(args.length() == 1);
5487 int length =
Smi::cast(codes->length())->value();
5491 for (i = 0; i < length; i++) {
5493 { MaybeObject* maybe_element = codes->
GetElement(i);
5496 if (!maybe_element->ToObject(&element))
return maybe_element;
5503 MaybeObject* maybe_object =
NULL;
5505 maybe_object = isolate->heap()->AllocateRawAsciiString(length);
5507 maybe_object = isolate->heap()->AllocateRawTwoByteString(length);
5511 if (!maybe_object->ToObject(&
object))
return maybe_object;
5513 for (
int i = 0; i < length; i++) {
5515 { MaybeObject* maybe_element = codes->
GetElement(i);
5516 if (!maybe_element->ToObject(&element))
return maybe_element;
5519 result->
Set(i, chr & 0xffff);
5537 static bool IsNotEscaped(
uint16_t character) {
5540 static const char kNotEscaped[256] = {
5541 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5542 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5543 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1,
5544 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
5545 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
5546 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1,
5547 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
5548 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
5549 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5550 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5551 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5552 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5553 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5554 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5555 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5556 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5558 return kNotEscaped[character] != 0;
5563 const char hex_chars[] =
"0123456789ABCDEF";
5564 NoHandleAllocation ha;
5565 ASSERT(args.length() == 1);
5568 source->TryFlatten();
5570 int escaped_length = 0;
5571 int length = source->length();
5574 isolate->runtime_state()->string_input_buffer());
5575 buffer->Reset(source);
5576 while (buffer->has_more()) {
5577 uint16_t character = buffer->GetNext();
5578 if (character >= 256) {
5579 escaped_length += 6;
5580 }
else if (IsNotEscaped(character)) {
5583 escaped_length += 3;
5588 isolate->context()->mark_out_of_memory();
5594 if (escaped_length == length) {
5598 { MaybeObject* maybe_o =
5599 isolate->heap()->AllocateRawAsciiString(escaped_length);
5600 if (!maybe_o->ToObject(&o))
return maybe_o;
5603 int dest_position = 0;
5606 isolate->runtime_state()->string_input_buffer());
5608 while (buffer->has_more()) {
5611 destination->
Set(dest_position,
'%');
5612 destination->
Set(dest_position+1,
'u');
5613 destination->
Set(dest_position+2, hex_chars[chr >> 12]);
5614 destination->
Set(dest_position+3, hex_chars[(chr >> 8) & 0xf]);
5615 destination->
Set(dest_position+4, hex_chars[(chr >> 4) & 0xf]);
5616 destination->
Set(dest_position+5, hex_chars[chr & 0xf]);
5618 }
else if (IsNotEscaped(chr)) {
5619 destination->
Set(dest_position, chr);
5622 destination->
Set(dest_position,
'%');
5623 destination->
Set(dest_position+1, hex_chars[chr >> 4]);
5624 destination->
Set(dest_position+2, hex_chars[chr & 0xf]);
5633 static const signed char kHexValue[
'g'] = {
5634 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
5635 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
5636 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
5637 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1,
5638 -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
5639 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
5640 -1, 10, 11, 12, 13, 14, 15 };
5642 if (character1 >
'f')
return -1;
5643 int hi = kHexValue[character1];
5644 if (hi == -1)
return -1;
5645 if (character2 >
'f')
return -1;
5646 int lo = kHexValue[character2];
5647 if (lo == -1)
return -1;
5648 return (hi << 4) +
lo;
5652 static inline int Unescape(String* source,
5656 uint16_t character = source->Get(i);
5659 if (character ==
'%' &&
5661 source->Get(i + 1) ==
'u' &&
5662 (hi = TwoDigitHex(source->Get(i + 2),
5663 source->Get(i + 3))) != -1 &&
5664 (lo = TwoDigitHex(source->Get(i + 4),
5665 source->Get(i + 5))) != -1) {
5667 return (hi << 8) +
lo;
5668 }
else if (character ==
'%' &&
5670 (lo = TwoDigitHex(source->Get(i + 1),
5671 source->Get(i + 2))) != -1) {
5682 NoHandleAllocation ha;
5683 ASSERT(args.length() == 1);
5686 source->TryFlatten();
5689 int length = source->length();
5691 int unescaped_length = 0;
5692 for (
int i = 0; i < length; unescaped_length++) {
5701 if (unescaped_length == length)
5705 { MaybeObject* maybe_o =
5707 isolate->heap()->AllocateRawAsciiString(unescaped_length) :
5708 isolate->heap()->AllocateRawTwoByteString(unescaped_length);
5709 if (!maybe_o->ToObject(&o))
return maybe_o;
5713 int dest_position = 0;
5714 for (
int i = 0; i < length; dest_position++) {
5716 destination->
Set(dest_position, Unescape(source, i, length, &step));
5723 static const unsigned int kQuoteTableLength = 128u;
5725 static const int kJsonQuotesCharactersPerEntry = 8;
5726 static const char*
const JsonQuotes =
5727 "\\u0000 \\u0001 \\u0002 \\u0003 "
5728 "\\u0004 \\u0005 \\u0006 \\u0007 "
5729 "\\b \\t \\n \\u000b "
5730 "\\f \\r \\u000e \\u000f "
5731 "\\u0010 \\u0011 \\u0012 \\u0013 "
5732 "\\u0014 \\u0015 \\u0016 \\u0017 "
5733 "\\u0018 \\u0019 \\u001a \\u001b "
5734 "\\u001c \\u001d \\u001e \\u001f "
5763 static const int kMaxGuaranteedNewSpaceString = 32 * 1024;
5767 static const int kJsonQuoteWorstCaseBlowup = 6;
5769 static const int kSpaceForQuotesAndComma = 3;
5770 static const int kSpaceForBrackets = 2;
5774 static const byte JsonQuoteLengths[kQuoteTableLength] = {
5775 6, 6, 6, 6, 6, 6, 6, 6,
5776 2, 2, 2, 6, 2, 2, 6, 6,
5777 6, 6, 6, 6, 6, 6, 6, 6,
5778 6, 6, 6, 6, 6, 6, 6, 6,
5779 1, 1, 2, 1, 1, 1, 1, 1,
5780 1, 1, 1, 1, 1, 1, 1, 1,
5781 1, 1, 1, 1, 1, 1, 1, 1,
5782 1, 1, 1, 1, 1, 1, 1, 1,
5783 1, 1, 1, 1, 1, 1, 1, 1,
5784 1, 1, 1, 1, 1, 1, 1, 1,
5785 1, 1, 1, 1, 1, 1, 1, 1,
5786 1, 1, 1, 1, 2, 1, 1, 1,
5787 1, 1, 1, 1, 1, 1, 1, 1,
5788 1, 1, 1, 1, 1, 1, 1, 1,
5789 1, 1, 1, 1, 1, 1, 1, 1,
5790 1, 1, 1, 1, 1, 1, 1, 1,
5794 template <
typename StringType>
5800 return isolate->heap()->AllocateRawTwoByteString(length);
5806 return isolate->heap()->AllocateRawAsciiString(length);
5810 template <
typename Char,
typename StringType,
bool comma>
5811 static MaybeObject* SlowQuoteJsonString(
Isolate* isolate,
5812 Vector<const Char> characters) {
5813 int length = characters.length();
5814 const Char* read_cursor = characters.start();
5815 const Char* end = read_cursor + length;
5816 const int kSpaceForQuotes = 2 + (comma ? 1 :0);
5817 int quoted_length = kSpaceForQuotes;
5818 while (read_cursor < end) {
5819 Char c = *(read_cursor++);
5820 if (
sizeof(Char) > 1u &&
static_cast<unsigned>(c) >= kQuoteTableLength) {
5823 quoted_length += JsonQuoteLengths[
static_cast<unsigned>(c)];
5826 MaybeObject* new_alloc = AllocateRawString<StringType>(isolate,
5829 if (!new_alloc->ToObject(&new_object)) {
5832 StringType* new_string = StringType::cast(new_object);
5834 Char* write_cursor =
reinterpret_cast<Char*
>(
5836 if (comma) *(write_cursor++) =
',';
5837 *(write_cursor++) =
'"';
5839 read_cursor = characters.start();
5840 while (read_cursor < end) {
5841 Char c = *(read_cursor++);
5842 if (
sizeof(Char) > 1u &&
static_cast<unsigned>(c) >= kQuoteTableLength) {
5843 *(write_cursor++) = c;
5845 int len = JsonQuoteLengths[
static_cast<unsigned>(c)];
5846 const char* replacement = JsonQuotes +
5847 static_cast<unsigned>(c) * kJsonQuotesCharactersPerEntry;
5848 for (
int i = 0; i < len; i++) {
5849 *write_cursor++ = *replacement++;
5853 *(write_cursor++) =
'"';
5858 template <
typename SinkChar,
typename SourceChar>
5859 static inline SinkChar* WriteQuoteJsonString(
5861 SinkChar* write_cursor,
5862 Vector<const SourceChar> characters) {
5864 ASSERT(
sizeof(SinkChar) >=
sizeof(SourceChar));
5865 const SourceChar* read_cursor = characters.start();
5866 const SourceChar* end = read_cursor + characters.length();
5867 *(write_cursor++) =
'"';
5868 while (read_cursor < end) {
5869 SourceChar c = *(read_cursor++);
5870 if (
sizeof(SourceChar) > 1u &&
5871 static_cast<unsigned>(c) >= kQuoteTableLength) {
5872 *(write_cursor++) = static_cast<SinkChar>(c);
5874 int len = JsonQuoteLengths[
static_cast<unsigned>(c)];
5875 const char* replacement = JsonQuotes +
5876 static_cast<unsigned>(c) * kJsonQuotesCharactersPerEntry;
5877 write_cursor[0] = replacement[0];
5879 write_cursor[1] = replacement[1];
5882 write_cursor[2] = replacement[2];
5883 write_cursor[3] = replacement[3];
5884 write_cursor[4] = replacement[4];
5885 write_cursor[5] = replacement[5];
5888 write_cursor += len;
5891 *(write_cursor++) =
'"';
5892 return write_cursor;
5896 template <
typename Char,
typename StringType,
bool comma>
5897 static MaybeObject* QuoteJsonString(Isolate* isolate,
5898 Vector<const Char> characters) {
5899 int length = characters.length();
5900 isolate->counters()->quote_json_char_count()->Increment(length);
5901 int worst_case_length =
5902 length * kJsonQuoteWorstCaseBlowup + kSpaceForQuotesAndComma;
5903 if (worst_case_length > kMaxGuaranteedNewSpaceString) {
5904 return SlowQuoteJsonString<Char, StringType, comma>(isolate, characters);
5907 MaybeObject* new_alloc = AllocateRawString<StringType>(isolate,
5910 if (!new_alloc->ToObject(&new_object)) {
5913 if (!isolate->heap()->new_space()->Contains(new_object)) {
5918 return SlowQuoteJsonString<Char, StringType, comma>(isolate, characters);
5920 StringType* new_string = StringType::cast(new_object);
5921 ASSERT(isolate->heap()->new_space()->Contains(new_string));
5923 Char* write_cursor =
reinterpret_cast<Char*
>(
5925 if (comma) *(write_cursor++) =
',';
5926 write_cursor = WriteQuoteJsonString<Char, Char>(isolate,
5929 int final_length =
static_cast<int>(
5930 write_cursor -
reinterpret_cast<Char*
>(
5932 isolate->heap()->new_space()->
5933 template ShrinkStringAtAllocationBoundary<StringType>(
5934 new_string, final_length);
5940 NoHandleAllocation ha;
5942 if (!str->IsFlat()) {
5943 MaybeObject* try_flatten = str->TryFlatten();
5945 if (!try_flatten->ToObject(&flat)) {
5954 return QuoteJsonString<uc16, SeqTwoByteString, false>(isolate,
5957 return QuoteJsonString<char, SeqAsciiString, false>(isolate,
5964 NoHandleAllocation ha;
5966 if (!str->IsFlat()) {
5967 MaybeObject* try_flatten = str->TryFlatten();
5969 if (!try_flatten->ToObject(&flat)) {
5977 return QuoteJsonString<uc16, SeqTwoByteString, true>(isolate,
5980 return QuoteJsonString<char, SeqAsciiString, true>(isolate,
5986 template <
typename Char,
typename StringType>
5987 static MaybeObject* QuoteJsonStringArray(
Isolate* isolate,
5989 int worst_case_length) {
5990 int length = array->length();
5992 MaybeObject* new_alloc = AllocateRawString<StringType>(isolate,
5995 if (!new_alloc->ToObject(&new_object)) {
5998 if (!isolate->heap()->new_space()->Contains(new_object)) {
6003 return isolate->heap()->undefined_value();
6005 AssertNoAllocation no_gc;
6006 StringType* new_string = StringType::cast(new_object);
6007 ASSERT(isolate->heap()->new_space()->Contains(new_string));
6009 Char* write_cursor =
reinterpret_cast<Char*
>(
6011 *(write_cursor++) =
'[';
6012 for (
int i = 0; i < length; i++) {
6013 if (i != 0) *(write_cursor++) =
',';
6016 ASSERT(content.IsFlat());
6017 if (content.IsTwoByte()) {
6018 write_cursor = WriteQuoteJsonString<Char, uc16>(isolate,
6020 content.ToUC16Vector());
6022 write_cursor = WriteQuoteJsonString<Char, char>(isolate,
6024 content.ToAsciiVector());
6027 *(write_cursor++) =
']';
6029 int final_length =
static_cast<int>(
6030 write_cursor -
reinterpret_cast<Char*
>(
6032 isolate->heap()->new_space()->
6033 template ShrinkStringAtAllocationBoundary<StringType>(
6034 new_string, final_length);
6040 NoHandleAllocation ha;
6041 ASSERT(args.length() == 1);
6044 if (!array->HasFastObjectElements()) {
6045 return isolate->heap()->undefined_value();
6048 int n = elements->
length();
6050 int total_length = 0;
6052 for (
int i = 0; i < n; i++) {
6054 if (!elt->IsString())
return isolate->heap()->undefined_value();
6056 if (!element->
IsFlat())
return isolate->heap()->undefined_value();
6057 total_length += element->
length();
6063 int worst_case_length =
6064 kSpaceForBrackets + n * kSpaceForQuotesAndComma
6065 + total_length * kJsonQuoteWorstCaseBlowup;
6067 if (worst_case_length > kMaxGuaranteedNewSpaceString) {
6068 return isolate->heap()->undefined_value();
6072 return QuoteJsonStringArray<char, SeqAsciiString>(isolate,
6076 return QuoteJsonStringArray<uc16, SeqTwoByteString>(isolate,
6084 NoHandleAllocation ha;
6092 double value =
StringToInt(isolate->unicode_cache(), s, radix);
6093 return isolate->heap()->NumberFromDouble(value);
6098 NoHandleAllocation ha;
6106 return isolate->heap()->NumberFromDouble(value);
6110 template <
class Converter>
6115 int input_string_length,
6129 { MaybeObject* maybe_o = s->IsAsciiRepresentation()
6130 ? isolate->heap()->AllocateRawAsciiString(length)
6131 : isolate->heap()->AllocateRawTwoByteString(length);
6132 if (!maybe_o->ToObject(&o))
return maybe_o;
6135 bool has_changed_character =
false;
6139 Access<StringInputBuffer> buffer(
6140 isolate->runtime_state()->string_input_buffer());
6144 uc32 current = buffer->GetNext();
6145 for (
int i = 0; i < length;) {
6146 bool has_next = buffer->has_more();
6147 uc32 next = has_next ? buffer->GetNext() : 0;
6148 int char_length = mapping->
get(current, next, chars);
6149 if (char_length == 0) {
6151 result->Set(i, current);
6153 }
else if (char_length == 1) {
6155 ASSERT(static_cast<uc32>(chars[0]) != current);
6156 result->Set(i, chars[0]);
6157 has_changed_character =
true;
6159 }
else if (length == input_string_length) {
6171 int next_length = 0;
6173 next_length = mapping->
get(next, 0, chars);
6174 if (next_length == 0) next_length = 1;
6176 int current_length = i + char_length + next_length;
6177 while (buffer->has_more()) {
6178 current = buffer->GetNext();
6183 int char_length = mapping->
get(current, 0, chars);
6184 if (char_length == 0) char_length = 1;
6185 current_length += char_length;
6187 isolate->context()->mark_out_of_memory();
6194 for (
int j = 0; j < char_length; j++) {
6195 result->Set(i, chars[j]);
6198 has_changed_character =
true;
6202 if (has_changed_character) {
6226 static inline uintptr_t AsciiRangeMask(uintptr_t w,
char m,
char n) {
6228 ASSERT((w & (kOneInEveryByte * 0x7F)) == w);
6231 ASSERT(0 < m && m < n && n < 0x7F);
6233 uintptr_t tmp1 = kOneInEveryByte * (0x7F + n) - w;
6235 uintptr_t tmp2 = w + kOneInEveryByte * (0x7F - m);
6236 return (tmp1 & tmp2 & (kOneInEveryByte * 0x80));
6240 enum AsciiCaseConversion {
6246 template <AsciiCaseConversion dir>
6247 struct FastAsciiConverter {
6248 static bool Convert(
char* dst,
char* src,
int length) {
6250 char* saved_dst = dst;
6251 char* saved_src = src;
6255 ASSERT(
'a' -
'A' == (1 << 5));
6257 const char lo = (dir == ASCII_TO_LOWER) ?
'A' - 1 :
'a' - 1;
6258 const char hi = (dir == ASCII_TO_LOWER) ?
'Z' + 1 :
'z' + 1;
6259 bool changed =
false;
6260 char*
const limit = src + length;
6261 #ifdef V8_HOST_CAN_READ_UNALIGNED
6264 while (src <= limit -
sizeof(uintptr_t)) {
6265 uintptr_t w = *
reinterpret_cast<uintptr_t*
>(src);
6266 if (AsciiRangeMask(w, lo, hi) != 0) {
6270 *
reinterpret_cast<uintptr_t*
>(dst) = w;
6271 src +=
sizeof(uintptr_t);
6272 dst +=
sizeof(uintptr_t);
6276 while (src <= limit -
sizeof(uintptr_t)) {
6277 uintptr_t w = *
reinterpret_cast<uintptr_t*
>(src);
6278 uintptr_t m = AsciiRangeMask(w, lo, hi);
6282 *
reinterpret_cast<uintptr_t*
>(dst) = w ^ (m >> 2);
6283 src +=
sizeof(uintptr_t);
6284 dst +=
sizeof(uintptr_t);
6289 while (src < limit) {
6291 if (lo < c && c < hi) {
6300 CheckConvert(saved_dst, saved_src, length, changed);
6306 static void CheckConvert(
char* dst,
char* src,
int length,
bool changed) {
6307 bool expected_changed =
false;
6308 for (
int i = 0; i < length; i++) {
6309 if (dst[i] == src[i])
continue;
6310 expected_changed =
true;
6311 if (dir == ASCII_TO_LOWER) {
6312 ASSERT(
'A' <= src[i] && src[i] <=
'Z');
6313 ASSERT(dst[i] == src[i] + (
'a' -
'A'));
6315 ASSERT(dir == ASCII_TO_UPPER);
6316 ASSERT(
'a' <= src[i] && src[i] <=
'z');
6317 ASSERT(dst[i] == src[i] - (
'a' -
'A'));
6320 ASSERT(expected_changed == changed);
6326 struct ToLowerTraits {
6329 typedef FastAsciiConverter<ASCII_TO_LOWER> AsciiConverter;
6333 struct ToUpperTraits {
6336 typedef FastAsciiConverter<ASCII_TO_UPPER> AsciiConverter;
6342 template <
typename ConvertTraits>
6347 NoHandleAllocation ha;
6349 s = s->TryFlattenGetString();
6351 const int length = s->length();
6353 if (length == 0)
return s;
6361 if (s->IsSeqAsciiString()) {
6363 { MaybeObject* maybe_o = isolate->heap()->AllocateRawAsciiString(length);
6364 if (!maybe_o->ToObject(&o))
return maybe_o;
6367 bool has_changed_character = ConvertTraits::AsciiConverter::Convert(
6369 return has_changed_character ? result : s;
6373 { MaybeObject* maybe_answer =
6374 ConvertCaseHelper(isolate, s, length, length, mapping);
6375 if (!maybe_answer->ToObject(&answer))
return maybe_answer;
6377 if (answer->IsSmi()) {
6379 { MaybeObject* maybe_answer =
6380 ConvertCaseHelper(isolate,
6381 s,
Smi::cast(answer)->value(), length, mapping);
6382 if (!maybe_answer->ToObject(&answer))
return maybe_answer;
6390 return ConvertCase<ToLowerTraits>(
6391 args, isolate, isolate->runtime_state()->to_lower_mapping());
6396 return ConvertCase<ToUpperTraits>(
6397 args, isolate, isolate->runtime_state()->to_upper_mapping());
6407 NoHandleAllocation ha;
6408 ASSERT(args.length() == 3);
6415 int length = s->length();
6419 while (left < length && IsTrimWhiteSpace(s->Get(left))) {
6426 while (right > left && IsTrimWhiteSpace(s->Get(right - 1))) {
6430 return s->SubString(left, right);
6435 ASSERT(args.length() == 3);
6441 int subject_length = subject->length();
6442 int pattern_length = pattern->
length();
6445 if (limit == 0xffffffffu) {
6447 isolate->heap()->string_split_cache(),
6452 isolate->factory()->NewJSArrayWithElements(
6464 static const int kMaxInitialListCapacity = 16;
6466 Zone* zone = isolate->zone();
6470 int initial_capacity = Min<uint32_t>(kMaxInitialListCapacity, limit);
6476 if (static_cast<uint32_t>(indices.length()) < limit) {
6477 indices.Add(subject_length, zone);
6483 int part_count = indices.length();
6486 MaybeObject* maybe_result = result->EnsureCanContainHeapObjectElements();
6487 if (maybe_result->IsFailure())
return maybe_result;
6490 ASSERT(result->HasFastObjectElements());
6492 if (part_count == 1 && indices.at(0) == subject_length) {
6499 for (
int i = 0; i < part_count; i++) {
6501 int part_end = indices.at(i);
6503 isolate->factory()->NewProperSubString(subject, part_start, part_end);
6504 elements->set(i, *substring);
6505 part_start = part_end + pattern_length;
6508 if (limit == 0xffffffffu) {
6509 if (result->HasFastObjectElements()) {
6511 isolate->heap()->string_split_cache(),
6526 static int CopyCachedAsciiCharsToArray(Heap* heap,
6528 FixedArray* elements,
6530 AssertNoAllocation no_gc;
6531 FixedArray* ascii_cache = heap->single_character_string_cache();
6532 Object* undefined = heap->undefined_value();
6535 for (i = 0; i < length; ++i) {
6536 Object* value = ascii_cache->get(chars[i]);
6537 if (value == undefined)
break;
6538 elements->set(i, value, mode);
6542 memset(elements->data_start() + i, 0,
kPointerSize * (length - i));
6545 for (
int j = 0; j < length; ++j) {
6546 Object* element = elements->get(j);
6559 ASSERT(args.length() == 2);
6564 const int length =
static_cast<int>(Min<uint32_t>(s->length(), limit));
6568 if (s->IsFlat() && s->IsAsciiRepresentation()) {
6571 { MaybeObject* maybe_obj =
6572 isolate->heap()->AllocateUninitializedFixedArray(length);
6573 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
6577 if (content.IsAscii()) {
6581 position = CopyCachedAsciiCharsToArray(isolate->heap(),
6587 isolate->heap()->undefined_value(),
6591 elements = isolate->factory()->NewFixedArray(length);
6593 for (
int i = position; i < length; ++i) {
6595 elements->set(i, *str);
6599 for (
int i = 0; i < length; ++i) {
6604 return *isolate->factory()->NewJSArrayWithElements(elements);
6609 NoHandleAllocation ha;
6610 ASSERT(args.length() == 1);
6619 return char_length == 0;
6624 NoHandleAllocation ha;
6625 ASSERT(args.length() == 1);
6627 Object* number = args[0];
6630 return isolate->heap()->NumberToString(number);
6635 NoHandleAllocation ha;
6636 ASSERT(args.length() == 1);
6638 Object* number = args[0];
6641 return isolate->heap()->NumberToString(number,
false);
6646 NoHandleAllocation ha;
6647 ASSERT(args.length() == 1);
6660 NoHandleAllocation ha;
6661 ASSERT(args.length() == 1);
6672 if (double_value == 0) double_value = 0;
6674 return isolate->heap()->NumberFromDouble(double_value);
6679 NoHandleAllocation ha;
6680 ASSERT(args.length() == 1);
6683 return isolate->heap()->NumberFromUint32(number);
6688 NoHandleAllocation ha;
6689 ASSERT(args.length() == 1);
6697 return isolate->heap()->NumberFromInt32(
DoubleToInt32(number));
6704 NoHandleAllocation ha;
6705 ASSERT(args.length() == 1);
6711 if (obj->IsHeapNumber()) {
6713 int int_value =
FastD2I(value);
6718 return isolate->heap()->nan_value();
6723 NoHandleAllocation ha;
6724 ASSERT(args.length() == 0);
6725 return isolate->heap()->AllocateHeapNumber(0);
6730 NoHandleAllocation ha;
6731 ASSERT(args.length() == 2);
6735 return isolate->heap()->NumberFromDouble(x + y);
6740 NoHandleAllocation ha;
6741 ASSERT(args.length() == 2);
6745 return isolate->heap()->NumberFromDouble(x - y);
6750 NoHandleAllocation ha;
6751 ASSERT(args.length() == 2);
6755 return isolate->heap()->NumberFromDouble(x * y);
6760 NoHandleAllocation ha;
6761 ASSERT(args.length() == 1);
6764 return isolate->heap()->NumberFromDouble(-x);
6769 NoHandleAllocation ha;
6770 ASSERT(args.length() == 0);
6772 return isolate->heap()->NumberFromDouble(9876543210.0);
6777 NoHandleAllocation ha;
6778 ASSERT(args.length() == 2);
6782 return isolate->heap()->NumberFromDouble(x / y);
6787 NoHandleAllocation ha;
6788 ASSERT(args.length() == 2);
6795 return isolate->heap()->NumberFromDouble(x);
6800 NoHandleAllocation ha;
6801 ASSERT(args.length() == 2);
6804 isolate->counters()->string_add_runtime()->Increment();
6805 return isolate->heap()->AllocateConsString(str1, str2);
6809 template <
typename sink
char>
6810 static inline void StringBuilderConcatHelper(
String* special,
6812 FixedArray* fixed_array,
6815 for (
int i = 0; i < array_length; i++) {
6816 Object* element = fixed_array->get(i);
6817 if (element->IsSmi()) {
6822 if (encoded_slice > 0) {
6828 Object* obj = fixed_array->get(++i);
6831 len = -encoded_slice;
6840 int element_length =
string->length();
6842 position += element_length;
6849 NoHandleAllocation ha;
6850 ASSERT(args.length() == 3);
6852 if (!args[1]->IsSmi()) {
6853 isolate->context()->mark_out_of_memory();
6856 int array_length = args.smi_at(1);
6862 MaybeObject* maybe_result = array->EnsureCanContainHeapObjectElements();
6863 if (maybe_result->IsFailure())
return maybe_result;
6865 int special_length = special->length();
6866 if (!array->HasFastObjectElements()) {
6867 return isolate->Throw(isolate->heap()->illegal_argument_symbol());
6870 if (fixed_array->
length() < array_length) {
6871 array_length = fixed_array->
length();
6874 if (array_length == 0) {
6875 return isolate->heap()->empty_string();
6876 }
else if (array_length == 1) {
6878 if (first->IsString())
return first;
6881 bool ascii = special->HasOnlyAsciiChars();
6883 for (
int i = 0; i < array_length; i++) {
6891 if (smi_value > 0) {
6900 if (i >= array_length) {
6901 return isolate->Throw(isolate->heap()->illegal_argument_symbol());
6904 if (!next_smi->IsSmi()) {
6905 return isolate->Throw(isolate->heap()->illegal_argument_symbol());
6909 return isolate->Throw(isolate->heap()->illegal_argument_symbol());
6914 if (pos > special_length || len > special_length - pos) {
6915 return isolate->Throw(isolate->heap()->illegal_argument_symbol());
6918 }
else if (elt->IsString()) {
6920 int element_length = element->
length();
6921 increment = element_length;
6926 ASSERT(!elt->IsTheHole());
6927 return isolate->Throw(isolate->heap()->illegal_argument_symbol());
6930 isolate->context()->mark_out_of_memory();
6933 position += increment;
6936 int length = position;
6940 { MaybeObject* maybe_object =
6941 isolate->heap()->AllocateRawAsciiString(length);
6942 if (!maybe_object->ToObject(&
object))
return maybe_object;
6945 StringBuilderConcatHelper(special,
6951 { MaybeObject* maybe_object =
6952 isolate->heap()->AllocateRawTwoByteString(length);
6953 if (!maybe_object->ToObject(&
object))
return maybe_object;
6956 StringBuilderConcatHelper(special,
6966 NoHandleAllocation ha;
6967 ASSERT(args.length() == 3);
6969 if (!args[1]->IsSmi()) {
6970 isolate->context()->mark_out_of_memory();
6973 int array_length = args.smi_at(1);
6976 if (!array->HasFastObjectElements()) {
6977 return isolate->Throw(isolate->heap()->illegal_argument_symbol());
6980 if (fixed_array->
length() < array_length) {
6981 array_length = fixed_array->
length();
6984 if (array_length == 0) {
6985 return isolate->heap()->empty_string();
6986 }
else if (array_length == 1) {
6988 if (first->IsString())
return first;
6991 int separator_length = separator->length();
6992 int max_nof_separators =
6994 if (max_nof_separators < (array_length - 1)) {
6995 isolate->context()->mark_out_of_memory();
6998 int length = (array_length - 1) * separator_length;
6999 for (
int i = 0; i < array_length; i++) {
7000 Object* element_obj = fixed_array->
get(i);
7001 if (!element_obj->IsString()) {
7003 return isolate->Throw(isolate->heap()->illegal_argument_symbol());
7006 int increment = element->
length();
7008 isolate->context()->mark_out_of_memory();
7011 length += increment;
7015 { MaybeObject* maybe_object =
7016 isolate->heap()->AllocateRawTwoByteString(length);
7017 if (!maybe_object->ToObject(&
object))
return maybe_object;
7023 uc16* end = sink + length;
7027 int first_length = first->
length();
7029 sink += first_length;
7031 for (
int i = 1; i < array_length; i++) {
7032 ASSERT(sink + separator_length <= end);
7034 sink += separator_length;
7037 int element_length = element->
length();
7038 ASSERT(sink + element_length <= end);
7040 sink += element_length;
7048 template <
typename Char>
7049 static void JoinSparseArrayWithSeparator(FixedArray* elements,
7050 int elements_length,
7051 uint32_t array_length,
7053 Vector<Char> buffer) {
7054 int previous_separator_position = 0;
7055 int separator_length = separator->length();
7057 for (
int i = 0; i < elements_length; i += 2) {
7060 int string_length =
string->
length();
7061 if (string->length() > 0) {
7062 while (previous_separator_position < position) {
7063 String::WriteToFlat<Char>(separator, &buffer[cursor],
7064 0, separator_length);
7065 cursor += separator_length;
7066 previous_separator_position++;
7068 String::WriteToFlat<Char>(string, &buffer[cursor],
7070 cursor +=
string->length();
7073 if (separator_length > 0) {
7076 ASSERT(array_length <= 0x7fffffff);
7077 int last_array_index =
static_cast<int>(array_length - 1);
7078 while (previous_separator_position < last_array_index) {
7079 String::WriteToFlat<Char>(separator, &buffer[cursor],
7080 0, separator_length);
7081 cursor += separator_length;
7082 previous_separator_position++;
7085 ASSERT(cursor <= buffer.length());
7090 NoHandleAllocation ha;
7091 ASSERT(args.length() == 3);
7102 int string_length = 0;
7103 bool is_ascii = separator->IsAsciiRepresentation();
7104 int max_string_length;
7112 Int32, elements_array->length());
7115 for (
int i = 0; i < elements_length; i += 2) {
7119 int length =
string->
length();
7120 if (is_ascii && !string->IsAsciiRepresentation()) {
7124 if (length > max_string_length ||
7125 max_string_length - length < string_length) {
7129 string_length += length;
7131 int separator_length = separator->length();
7132 if (!overflow && separator_length > 0) {
7133 if (array_length <= 0x7fffffffu) {
7134 int separator_count =
static_cast<int>(array_length) - 1;
7135 int remaining_length = max_string_length - string_length;
7136 if ((remaining_length / separator_length) >= separator_count) {
7137 string_length += separator_length * (array_length - 1);
7155 MaybeObject* result_allocation =
7156 isolate->heap()->AllocateRawAsciiString(string_length);
7157 if (result_allocation->IsFailure())
return result_allocation;
7160 JoinSparseArrayWithSeparator<char>(elements,
7166 return result_string;
7168 MaybeObject* result_allocation =
7169 isolate->heap()->AllocateRawTwoByteString(string_length);
7170 if (result_allocation->IsFailure())
return result_allocation;
7173 JoinSparseArrayWithSeparator<uc16>(elements,
7179 return result_string;
7185 NoHandleAllocation ha;
7186 ASSERT(args.length() == 2);
7190 return isolate->heap()->NumberFromInt32(x | y);
7195 NoHandleAllocation ha;
7196 ASSERT(args.length() == 2);
7200 return isolate->heap()->NumberFromInt32(x & y);
7205 NoHandleAllocation ha;
7206 ASSERT(args.length() == 2);
7210 return isolate->heap()->NumberFromInt32(x ^ y);
7215 NoHandleAllocation ha;
7216 ASSERT(args.length() == 1);
7219 return isolate->heap()->NumberFromInt32(~x);
7224 NoHandleAllocation ha;
7225 ASSERT(args.length() == 2);
7229 return isolate->heap()->NumberFromInt32(x << (y & 0x1f));
7234 NoHandleAllocation ha;
7235 ASSERT(args.length() == 2);
7239 return isolate->heap()->NumberFromUint32(x >> (y & 0x1f));
7244 NoHandleAllocation ha;
7245 ASSERT(args.length() == 2);
7254 NoHandleAllocation ha;
7255 ASSERT(args.length() == 2);
7273 NoHandleAllocation ha;
7274 ASSERT(args.length() == 2);
7283 ASSERT(not_equal == 0 || not_equal == 1);
7291 NoHandleAllocation ha;
7292 ASSERT(args.length() == 3);
7306 NoHandleAllocation ha;
7307 ASSERT(args.length() == 2);
7316 if (x_value == 0 || y_value == 0)
7325 uint32_t x_scaled = x_value;
7326 uint32_t y_scaled = y_value;
7327 if (x_value < 0 || y_value < 0) {
7330 x_scaled = -x_value;
7331 y_scaled = -y_value;
7334 static const uint32_t kPowersOf10[] = {
7335 1, 10, 100, 1000, 10*1000, 100*1000,
7336 1000*1000, 10*1000*1000, 100*1000*1000,
7349 int x_log10 = ((x_log2 + 1) * 1233) >> 12;
7350 x_log10 -= x_scaled < kPowersOf10[x_log10];
7353 int y_log10 = ((y_log2 + 1) * 1233) >> 12;
7354 y_log10 -= y_scaled < kPowersOf10[y_log10];
7358 if (x_log10 < y_log10) {
7365 x_scaled *= kPowersOf10[y_log10 - x_log10 - 1];
7368 }
else if (y_log10 < x_log10) {
7369 y_scaled *= kPowersOf10[x_log10 - y_log10 - 1];
7380 static Object* StringInputBufferCompare(RuntimeState* state,
7383 StringInputBuffer& bufx = *state->string_input_buffer_compare_bufx();
7384 StringInputBuffer& bufy = *state->string_input_buffer_compare_bufy();
7387 while (bufx.has_more() && bufy.has_more()) {
7388 int d = bufx.GetNext() - bufy.GetNext();
7400 static Object* FlatStringCompare(String* x, String* y) {
7404 int prefix_length = x->length();
7405 if (y->length() < prefix_length) {
7406 prefix_length = y->length();
7408 }
else if (y->length() > prefix_length) {
7412 String::FlatContent x_content = x->GetFlatContent();
7413 String::FlatContent y_content = y->GetFlatContent();
7414 if (x_content.IsAscii()) {
7415 Vector<const char> x_chars = x_content.ToAsciiVector();
7416 if (y_content.IsAscii()) {
7417 Vector<const char> y_chars = y_content.ToAsciiVector();
7418 r =
CompareChars(x_chars.start(), y_chars.start(), prefix_length);
7420 Vector<const uc16> y_chars = y_content.ToUC16Vector();
7421 r =
CompareChars(x_chars.start(), y_chars.start(), prefix_length);
7424 Vector<const uc16> x_chars = x_content.ToUC16Vector();
7425 if (y_content.IsAscii()) {
7426 Vector<const char> y_chars = y_content.ToAsciiVector();
7427 r =
CompareChars(x_chars.start(), y_chars.start(), prefix_length);
7429 Vector<const uc16> y_chars = y_content.ToUC16Vector();
7430 r =
CompareChars(x_chars.start(), y_chars.start(), prefix_length);
7435 result = equal_prefix_result;
7440 StringInputBufferCompare(Isolate::Current()->runtime_state(), x, y));
7446 NoHandleAllocation ha;
7447 ASSERT(args.length() == 2);
7452 isolate->counters()->string_compare_runtime()->Increment();
7456 if (y->length() == 0) {
7459 }
else if (x->length() == 0) {
7463 int d = x->Get(0) - y->Get(0);
7468 { MaybeObject* maybe_obj = isolate->heap()->PrepareForCompare(x);
7469 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
7471 { MaybeObject* maybe_obj = isolate->heap()->PrepareForCompare(y);
7472 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
7475 return (x->IsFlat() && y->IsFlat()) ? FlatStringCompare(x, y)
7476 : StringInputBufferCompare(isolate->runtime_state(), x, y);
7481 NoHandleAllocation ha;
7482 ASSERT(args.length() == 1);
7483 isolate->counters()->math_acos()->Increment();
7491 NoHandleAllocation ha;
7492 ASSERT(args.length() == 1);
7493 isolate->counters()->math_asin()->Increment();
7501 NoHandleAllocation ha;
7502 ASSERT(args.length() == 1);
7503 isolate->counters()->math_atan()->Increment();
7510 static const double kPiDividedBy4 = 0.78539816339744830962;
7514 NoHandleAllocation ha;
7515 ASSERT(args.length() == 2);
7516 isolate->counters()->math_atan2()->Increment();
7526 int multiplier = (x < 0) ? -1 : 1;
7527 if (y < 0) multiplier *= 3;
7528 result = multiplier * kPiDividedBy4;
7530 result = atan2(x, y);
7532 return isolate->heap()->AllocateHeapNumber(result);
7537 NoHandleAllocation ha;
7538 ASSERT(args.length() == 1);
7539 isolate->counters()->math_ceil()->Increment();
7542 return isolate->heap()->NumberFromDouble(
ceiling(x));
7547 NoHandleAllocation ha;
7548 ASSERT(args.length() == 1);
7549 isolate->counters()->math_cos()->Increment();
7557 NoHandleAllocation ha;
7558 ASSERT(args.length() == 1);
7559 isolate->counters()->math_exp()->Increment();
7567 NoHandleAllocation ha;
7568 ASSERT(args.length() == 1);
7569 isolate->counters()->math_floor()->Increment();
7572 return isolate->heap()->NumberFromDouble(floor(x));
7577 NoHandleAllocation ha;
7578 ASSERT(args.length() == 1);
7579 isolate->counters()->math_log()->Increment();
7588 NoHandleAllocation ha;
7589 ASSERT(args.length() == 2);
7590 isolate->counters()->math_pow()->Increment();
7596 if (args[1]->IsSmi()) {
7597 int y = args.smi_at(1);
7602 int y_int =
static_cast<int>(y);
7606 }
else if (y == 0.5) {
7609 }
else if (y == -0.5) {
7610 result = (
isinf(x)) ? 0
7615 if (
isnan(result))
return isolate->heap()->nan_value();
7616 return isolate->heap()->AllocateHeapNumber(result);
7622 NoHandleAllocation ha;
7623 ASSERT(args.length() == 2);
7624 isolate->counters()->math_pow()->Increment();
7632 if (
isnan(result))
return isolate->heap()->nan_value();
7633 return isolate->heap()->AllocateHeapNumber(result);
7639 NoHandleAllocation ha;
7640 ASSERT(args.length() == 1);
7641 isolate->counters()->math_round()->Increment();
7643 if (!args[0]->IsHeapNumber()) {
7651 double value = number->
value();
7655 if (exponent < -1) {
7657 if (sign)
return isolate->heap()->minus_zero_value();
7670 if (exponent >= 52) {
7674 if (sign && value >= -0.5)
return isolate->heap()->minus_zero_value();
7677 return isolate->heap()->AllocateHeapNumber(floor(value + 0.5));
7682 NoHandleAllocation ha;
7683 ASSERT(args.length() == 1);
7684 isolate->counters()->math_sin()->Increment();
7692 NoHandleAllocation ha;
7693 ASSERT(args.length() == 1);
7694 isolate->counters()->math_sqrt()->Increment();
7697 return isolate->heap()->AllocateHeapNumber(
fast_sqrt(x));
7702 NoHandleAllocation ha;
7703 ASSERT(args.length() == 1);
7704 isolate->counters()->math_tan()->Increment();
7712 NoHandleAllocation ha;
7713 ASSERT(args.length() == 2);
7718 return Smi::FromInt(isolate->date_cache()->DaysFromYearMonth(year, month));
7724 ASSERT(args.length() == 3);
7730 DateCache* date_cache = isolate->date_cache();
7733 bool is_value_nan =
false;
7735 value = isolate->heap()->nan_value();
7736 is_value_nan =
true;
7737 }
else if (!is_utc &&
7740 value = isolate->heap()->nan_value();
7741 is_value_nan =
true;
7743 time = is_utc ? time : date_cache->
ToUTC(static_cast<int64_t>(time));
7746 value = isolate->heap()->nan_value();
7747 is_value_nan =
true;
7749 MaybeObject* maybe_result =
7751 if (!maybe_result->ToObject(&value))
return maybe_result;
7754 date->SetValue(value, is_value_nan);
7761 ASSERT(args.length() == 3);
7764 Object** parameters =
reinterpret_cast<Object**
>(args[1]);
7768 isolate->factory()->NewArgumentsObject(callee, argument_count);
7770 int parameter_count = callee->shared()->formal_parameter_count();
7771 if (argument_count > 0) {
7772 if (parameter_count > 0) {
7773 int mapped_count =
Min(argument_count, parameter_count);
7775 isolate->factory()->NewFixedArray(mapped_count + 2,
NOT_TENURED);
7776 parameter_map->set_map(
7777 isolate->heap()->non_strict_arguments_elements_map());
7781 isolate->factory()->CopyMapDropTransitions(old_map);
7784 result->set_map(*new_map);
7785 result->set_elements(*parameter_map);
7791 isolate->factory()->NewFixedArray(argument_count,
NOT_TENURED);
7792 parameter_map->set(0, *context);
7793 parameter_map->set(1, *arguments);
7796 int index = argument_count - 1;
7797 while (index >= mapped_count) {
7800 arguments->set(index, *(parameters - index - 1));
7805 while (index >= 0) {
7808 int context_local_count = scope_info->ContextLocalCount();
7809 bool duplicate =
false;
7810 for (
int j = index + 1; j < parameter_count; ++j) {
7811 if (scope_info->ParameterName(j) == *
name) {
7820 arguments->set(index, *(parameters - index - 1));
7821 parameter_map->set_the_hole(index + 2);
7825 int context_index = -1;
7826 for (
int j = 0; j < context_local_count; ++j) {
7827 if (scope_info->ContextLocalName(j) == *
name) {
7832 ASSERT(context_index >= 0);
7833 arguments->set_the_hole(index);
7844 isolate->factory()->NewFixedArray(argument_count,
NOT_TENURED);
7845 result->set_elements(*elements);
7846 for (
int i = 0; i < argument_count; ++i) {
7847 elements->set(i, *(parameters - i - 1));
7856 NoHandleAllocation ha;
7857 ASSERT(args.length() == 3);
7860 Object** parameters =
reinterpret_cast<Object**
>(args[1]);
7861 const int length = args.smi_at(2);
7864 { MaybeObject* maybe_result =
7865 isolate->heap()->AllocateArgumentsObject(callee, length);
7866 if (!maybe_result->ToObject(&result))
return maybe_result;
7872 { MaybeObject* maybe_obj = isolate->heap()->AllocateRawFixedArray(length);
7873 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
7882 for (
int i = 0; i < length; i++) {
7883 array->
set(i, *--parameters, mode);
7893 ASSERT(args.length() == 3);
7902 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared,
7912 static SmartArrayPointer<Handle<Object> > GetCallerArguments(
7917 JavaScriptFrame* frame = it.frame();
7918 List<JSFunction*> functions(2);
7919 frame->GetFunctions(&functions);
7920 if (functions.length() > 1) {
7921 int inlined_jsframe_index = functions.length() - 1;
7922 JSFunction* inlined_function = functions[inlined_jsframe_index];
7923 Vector<SlotRef> args_slots =
7924 SlotRef::ComputeSlotMappingForArguments(
7926 inlined_jsframe_index,
7927 inlined_function->shared()->formal_parameter_count());
7929 int args_count = args_slots.length();
7931 *total_argc = prefix_argc + args_count;
7932 SmartArrayPointer<Handle<Object> > param_data(
7934 for (
int i = 0; i < args_count; i++) {
7936 param_data[prefix_argc + i] = val;
7939 args_slots.Dispose();
7943 it.AdvanceToArgumentsFrame();
7945 int args_count = frame->ComputeParametersCount();
7947 *total_argc = prefix_argc + args_count;
7948 SmartArrayPointer<Handle<Object> > param_data(
7949 NewArray<Handle<Object> >(*total_argc));
7950 for (
int i = 0; i < args_count; i++) {
7951 Handle<Object> val = Handle<Object>(frame->GetParameter(i));
7952 param_data[prefix_argc + i] = val;
7961 ASSERT(args.length() == 4);
7967 bound_function->shared()->set_bound(
true);
7973 ASSERT(*arguments[0] == args[2]);
7976 ASSERT(args[2]->IsUndefined());
7982 if (bindee->IsJSFunction() &&
JSFunction::cast(*bindee)->shared()->bound()) {
7986 isolate->factory()->NewFixedArray(old_bindings->length() + argc);
7989 for (
int n = old_bindings->length(); i < n; i++) {
7990 new_bindings->set(i, old_bindings->get(i));
7994 new_bindings = isolate->factory()->NewFixedArray(array_size);
8000 for (
int j = 0; j < argc; j++, i++) {
8001 new_bindings->set(i, *arguments[j + 1]);
8003 new_bindings->set_map_no_write_barrier(
8004 isolate->heap()->fixed_cow_array_map());
8005 bound_function->set_function_bindings(*new_bindings);
8008 Handle<String> length_symbol = isolate->factory()->length_symbol();
8013 return *bound_function;
8019 ASSERT(args.length() == 1);
8021 if (callable->IsJSFunction()) {
8023 if (function->shared()->bound()) {
8025 ASSERT(bindings->map() == isolate->heap()->fixed_cow_array_map());
8026 return *isolate->factory()->NewJSArrayWithElements(bindings);
8029 return isolate->heap()->undefined_value();
8035 ASSERT(args.length() == 1);
8047 ASSERT(!bound_function->IsJSFunction() ||
8052 GetCallerArguments(bound_argc, &total_argc);
8053 for (
int i = 0; i < bound_argc; i++) {
8058 if (!bound_function->IsJSFunction()) {
8059 bool exception_thrown;
8064 ASSERT(bound_function->IsJSFunction());
8066 bool exception =
false;
8069 total_argc, *param_data, &exception);
8078 static void TrySettingInlineConstructStub(
Isolate* isolate,
8081 if (function->has_instance_prototype()) {
8082 prototype =
Handle<Object>(
function->instance_prototype(), isolate);
8084 if (function->shared()->CanGenerateInlineConstructor(*prototype)) {
8085 ConstructStubCompiler compiler(isolate);
8086 Handle<Code> code = compiler.CompileConstructStub(
function);
8087 function->shared()->set_construct_stub(*code);
8094 ASSERT(args.length() == 1);
8099 if (!constructor->IsJSFunction()) {
8102 isolate->factory()->NewTypeError(
"not_constructor", arguments);
8103 return isolate->Throw(*type_error);
8110 if (!function->should_have_prototype() && !
function->shared()->bound()) {
8113 isolate->factory()->NewTypeError(
"not_constructor", arguments);
8114 return isolate->Throw(*type_error);
8117 #ifdef ENABLE_DEBUGGER_SUPPORT
8118 Debug* debug = isolate->debug();
8120 if (debug->StepInActive()) {
8125 if (function->has_initial_map()) {
8138 return isolate->context()->global();
8146 if (!function->is_compiled()) {
8151 if (!function->has_initial_map() &&
8152 shared->IsInobjectSlackTrackingInProgress()) {
8156 shared->CompleteInobjectSlackTracking();
8159 bool first_allocation = !shared->live_objects_may_exist();
8163 if (first_allocation && !shared->IsInobjectSlackTrackingInProgress()) {
8164 TrySettingInlineConstructStub(isolate,
function);
8167 isolate->counters()->constructed_objects()->Increment();
8168 isolate->counters()->constructed_objects_runtime()->Increment();
8176 ASSERT(args.length() == 1);
8179 function->shared()->CompleteInobjectSlackTracking();
8180 TrySettingInlineConstructStub(isolate,
function);
8182 return isolate->heap()->undefined_value();
8188 ASSERT(args.length() == 1);
8192 if (FLAG_trace_lazy && !function->shared()->is_compiled()) {
8194 function->PrintName();
8200 ASSERT(!function->is_compiled());
8206 ASSERT(function->is_compiled());
8207 return function->code();
8213 ASSERT(args.length() == 1);
8219 if (!function->shared()->is_compiled()) {
8220 function->
ReplaceCode(function->shared()->code());
8221 return function->code();
8226 if (!function->shared()->code()->optimizable() ||
8227 isolate->DebuggerHasBreakPoints()) {
8228 if (FLAG_trace_opt) {
8229 PrintF(
"[failed to optimize ");
8230 function->PrintName();
8231 PrintF(
": is code optimizable: %s, is debugger enabled: %s]\n",
8232 function->shared()->code()->optimizable() ?
"T" :
"F",
8233 isolate->DebuggerHasBreakPoints() ?
"T" :
"F");
8235 function->ReplaceCode(function->shared()->code());
8236 return function->code();
8238 function->shared()->code()->set_profiler_ticks(0);
8242 return function->code();
8244 if (FLAG_trace_opt) {
8245 PrintF(
"[failed to optimize ");
8246 function->PrintName();
8247 PrintF(
": optimized compilation failed]\n");
8249 function->ReplaceCode(function->shared()->code());
8250 return function->code();
8257 : function_(function), has_activations_(
false) {}
8260 if (has_activations_)
return;
8264 if (frame->is_optimized() && frame->
function() == function_) {
8265 has_activations_ =
true;
8275 bool has_activations_;
8279 static void MaterializeArgumentsObjectInFrame(
Isolate* isolate,
8280 JavaScriptFrame* frame) {
8283 for (
int i = frame->ComputeExpressionsCount() - 1; i >= 0; --i) {
8284 if (frame->GetExpression(i) == isolate->heap()->arguments_marker()) {
8285 if (arguments.is_null()) {
8290 NULL)->ToObjectUnchecked());
8291 ASSERT(*arguments != isolate->heap()->null_value());
8292 ASSERT(*arguments != isolate->heap()->undefined_value());
8294 frame->SetExpression(i, *arguments);
8295 if (FLAG_trace_deopt) {
8296 PrintF(
"Materializing arguments object for frame %p - %p: %p ",
8297 reinterpret_cast<void*>(frame->sp()),
8298 reinterpret_cast<void*>(frame->fp()),
8299 reinterpret_cast<void*>(*arguments));
8310 ASSERT(args.length() == 1);
8315 ASSERT(isolate->heap()->IsAllocationAllowed());
8322 for (
int i = 0; i < jsframes - 1; i++) {
8323 MaterializeArgumentsObjectInFrame(isolate, it.frame());
8330 MaterializeArgumentsObjectInFrame(isolate, frame);
8339 return isolate->heap()->undefined_value();
8343 bool has_other_activations =
false;
8344 while (!it.done()) {
8346 if (frame->is_optimized() && frame->
function() == *
function) {
8347 has_other_activations =
true;
8353 if (!has_other_activations) {
8355 isolate->thread_manager()->IterateArchivedThreads(&activations_finder);
8359 if (!has_other_activations) {
8360 if (FLAG_trace_deopt) {
8361 PrintF(
"[removing optimized code for: ");
8362 function->PrintName();
8365 function->ReplaceCode(function->shared()->code());
8369 return isolate->heap()->undefined_value();
8376 return isolate->heap()->undefined_value();
8382 ASSERT(args.length() == 1);
8384 if (!function->IsOptimized())
return isolate->heap()->undefined_value();
8388 return isolate->heap()->undefined_value();
8394 ASSERT(args.length() == 1);
8396 Code* unoptimized =
function->shared()->code();
8401 return isolate->heap()->undefined_value();
8406 #if defined(USE_SIMULATOR)
8407 return isolate->heap()->true_value();
8409 return isolate->heap()->false_value();
8419 if (!function->IsOptimizable())
return isolate->heap()->undefined_value();
8420 function->MarkForLazyRecompilation();
8422 Code* unoptimized =
function->shared()->code();
8423 if (args.length() == 2 &&
8427 isolate->runtime_profiler()->AttemptOnStackReplacement(*
function);
8432 return isolate->heap()->undefined_value();
8438 ASSERT(args.length() == 1);
8445 if (FLAG_always_opt) {
8458 ASSERT(args.length() == 1);
8466 ASSERT(args.length() == 1);
8470 ASSERT(!function->shared()->uses_arguments());
8474 Handle<Code> unoptimized(function->shared()->code(), isolate);
8476 bool succeeded = unoptimized->optimizable();
8484 while (succeeded && !it.done()) {
8486 succeeded = !frame->is_optimized() || frame->
function() != *
function;
8498 ASSERT(frame->LookupCode() == *unoptimized);
8499 ASSERT(unoptimized->contains(frame->pc()));
8503 Address start = unoptimized->instruction_start();
8504 unsigned target_pc_offset =
static_cast<unsigned>(frame->pc() - start);
8505 Address table_cursor = start + unoptimized->stack_check_table_offset();
8508 for (
unsigned i = 0; i < table_length; ++i) {
8511 if (pc_offset == target_pc_offset) {
8518 if (FLAG_trace_osr) {
8519 PrintF(
"[replacing on-stack at AST id %d in ", ast_id);
8520 function->PrintName();
8528 function->IsOptimized()) {
8530 function->code()->deoptimization_data());
8531 if (data->OsrPcOffset()->value() >= 0) {
8532 if (FLAG_trace_osr) {
8533 PrintF(
"[on-stack replacement offset %d in optimized code]\n",
8534 data->OsrPcOffset()->value());
8536 ASSERT(data->OsrAstId()->value() == ast_id);
8548 if (FLAG_trace_osr) {
8549 PrintF(
"[restoring original stack checks in ");
8550 function->PrintName();
8554 if (FLAG_count_based_interrupts) {
8556 check_code = interrupt_stub.GetCode();
8560 check_code = check_stub.GetCode();
8562 Handle<Code> replacement_code = isolate->builtins()->OnStackReplacement();
8568 unoptimized->set_allow_osr_at_loop_nesting_level(0);
8577 if (function->IsMarkedForLazyRecompilation()) {
8578 function->ReplaceCode(function->shared()->code());
8587 return isolate->heap()->undefined_value();
8593 return isolate->heap()->nan_value();
8599 ASSERT(args.length() >= 2);
8600 int argc = args.length() - 2;
8602 Object* receiver = args[0];
8605 const int argv_small_size = 10;
8609 if (argc > argv_small_size) {
8611 if (argv ==
NULL)
return isolate->StackOverflow();
8615 for (
int i = 0; i < argc; ++i) {
8616 MaybeObject* maybe = args[1 + i];
8618 if (!maybe->To<
Object>(&
object))
return maybe;
8635 ASSERT(args.length() == 5);
8645 const int argv_small_size = 10;
8649 if (argc > argv_small_size) {
8651 if (argv ==
NULL)
return isolate->StackOverflow();
8655 for (
int i = 0; i < argc; ++i) {
8670 ASSERT(args.length() == 1);
8678 ASSERT(args.length() == 1);
8685 NoHandleAllocation ha;
8686 ASSERT(args.length() == 1);
8689 int length =
function->shared()->scope_info()->ContextLength();
8691 { MaybeObject* maybe_result =
8692 isolate->heap()->AllocateFunctionContext(length,
function);
8693 if (!maybe_result->ToObject(&result))
return maybe_result;
8703 NoHandleAllocation ha;
8704 ASSERT(args.length() == 2);
8706 if (args[0]->IsJSObject()) {
8710 MaybeObject* maybe_js_object = args[0]->ToObject();
8711 if (!maybe_js_object->To(&extension_object)) {
8716 isolate->factory()->NewTypeError(
"with_expression",
8718 return isolate->Throw(*result);
8720 return maybe_js_object;
8726 if (args[1]->IsSmi()) {
8730 function = isolate->context()->global_context()->closure();
8736 MaybeObject* maybe_context =
8737 isolate->heap()->AllocateWithContext(
function,
8740 if (!maybe_context->To(&context))
return maybe_context;
8741 isolate->set_context(context);
8747 NoHandleAllocation ha;
8748 ASSERT(args.length() == 3);
8750 Object* thrown_object = args[1];
8752 if (args[2]->IsSmi()) {
8756 function = isolate->context()->global_context()->closure();
8761 MaybeObject* maybe_context =
8762 isolate->heap()->AllocateCatchContext(
function,
8766 if (!maybe_context->To(&context))
return maybe_context;
8767 isolate->set_context(context);
8773 NoHandleAllocation ha;
8774 ASSERT(args.length() == 2);
8777 if (args[1]->IsSmi()) {
8781 function = isolate->context()->global_context()->closure();
8786 MaybeObject* maybe_context =
8787 isolate->heap()->AllocateBlockContext(
function,
8790 if (!maybe_context->To(&context))
return maybe_context;
8791 isolate->set_context(context);
8797 NoHandleAllocation ha;
8798 ASSERT(args.length() == 2);
8803 MaybeObject* maybe_context =
8804 isolate->heap()->AllocateModuleContext(isolate->context(),
8806 if (!maybe_context->To(&context))
return maybe_context;
8808 instance->set_context(context);
8809 isolate->set_context(context);
8817 ASSERT(args.length() == 2);
8834 return isolate->heap()->true_value();
8838 if (holder->IsContext()) {
8839 return isolate->heap()->false_value();
8858 #ifdef V8_HOST_ARCH_64_BIT
8864 static inline ObjectPair MakePair(MaybeObject* x, MaybeObject* y) {
8872 static inline ObjectPair MakePair(MaybeObject* x, MaybeObject* y) {
8873 return reinterpret_cast<uint32_t
>(x) |
8874 (reinterpret_cast<ObjectPair>(y) << 32);
8879 static inline MaybeObject* Unhole(Heap* heap,
8884 return x->IsTheHole() ? heap->undefined_value() : x;
8888 static Object* ComputeReceiverForNonGlobal(Isolate* isolate,
8890 ASSERT(!holder->IsGlobalObject());
8891 Context* top = isolate->context();
8893 JSFunction* context_extension_function =
8894 top->global_context()->context_extension_function();
8899 Object* constructor = holder->map()->constructor();
8900 if (constructor != context_extension_function)
return holder;
8905 return isolate->heap()->the_hole_value();
8909 static ObjectPair LoadContextSlotHelper(Arguments args,
8912 HandleScope scope(isolate);
8915 if (!args[0]->IsContext() || !args[1]->IsString()) {
8916 return MakePair(isolate->ThrowIllegalOperation(),
NULL);
8918 Handle<Context> context = args.at<Context>(0);
8919 Handle<String> name = args.at<String>(1);
8925 Handle<Object> holder = context->Lookup(name,
8933 ASSERT(holder->IsContext());
8940 Handle<Object> receiver = isolate->factory()->the_hole_value();
8943 switch (binding_flags) {
8946 if (value->IsTheHole()) {
8947 Handle<Object> reference_error =
8948 isolate->factory()->NewReferenceError(
"not_defined",
8950 return MakePair(isolate->Throw(*reference_error),
NULL);
8956 ASSERT(!value->IsTheHole());
8957 return MakePair(value, *receiver);
8959 return MakePair(Unhole(isolate->heap(), value, attributes), *receiver);
8969 if (!holder.is_null()) {
8971 ASSERT(object->HasProperty(*name));
8973 Handle<Object> receiver_handle(object->IsGlobalObject()
8975 : ComputeReceiverForNonGlobal(isolate, *
object));
8979 MaybeObject* value =
object->GetProperty(*name);
8980 return MakePair(value, *receiver_handle);
8985 Handle<Object> reference_error =
8986 isolate->factory()->NewReferenceError(
"not_defined",
8988 return MakePair(isolate->Throw(*reference_error),
NULL);
8991 return MakePair(isolate->heap()->undefined_value(),
8992 isolate->heap()->undefined_value());
8998 return LoadContextSlotHelper(args, isolate,
true);
9003 return LoadContextSlotHelper(args, isolate,
false);
9009 ASSERT(args.length() == 4);
9032 context->
get(index)->IsTheHole()) {
9034 isolate->factory()->NewReferenceError(
"not_defined",
9036 return isolate->Throw(*error);
9041 context->
set(index, *value);
9045 isolate->factory()->NewTypeError(
"strict_cannot_assign",
9047 return isolate->Throw(*error);
9067 isolate->factory()->NewReferenceError(
9069 return isolate->Throw(*error);
9078 (
object->GetLocalPropertyAttribute(*name) ==
ABSENT)) {
9082 }
else if (strict_mode ==
kStrictMode && (attributes & READ_ONLY) != 0) {
9085 isolate->factory()->NewTypeError(
9087 return isolate->Throw(*error);
9095 ASSERT(args.length() == 1);
9097 return isolate->Throw(args[0]);
9103 ASSERT(args.length() == 1);
9105 return isolate->ReThrow(args[0]);
9111 return isolate->PromoteScheduledException();
9117 ASSERT(args.length() == 1);
9121 isolate->factory()->NewReferenceError(
"not_defined",
9123 return isolate->Throw(*reference_error);
9128 ASSERT(args.length() == 0);
9131 if (isolate->stack_guard()->IsStackOverflow()) {
9132 NoHandleAllocation na;
9133 return isolate->StackOverflow();
9141 ASSERT(args.length() == 0);
9146 static int StackSize() {
9153 static void PrintTransition(
Object* result) {
9155 {
const int nmax = 80;
9156 int n = StackSize();
9158 PrintF(
"%4d:%*s", n, n,
"");
9160 PrintF(
"%4d:%*s", n, nmax,
"...");
9163 if (result ==
NULL) {
9169 result->ShortPrint();
9176 ASSERT(args.length() == 0);
9177 NoHandleAllocation ha;
9178 PrintTransition(
NULL);
9179 return isolate->heap()->undefined_value();
9184 NoHandleAllocation ha;
9185 PrintTransition(args[0]);
9191 NoHandleAllocation ha;
9192 ASSERT(args.length() == 1);
9195 if (args[0]->IsString()) {
9200 PrintF(
"fp = %p, sp = %p, caller_sp = %p: ",
9201 frame->fp(), frame->sp(), frame->caller_sp());
9206 if (args[0]->IsHeapObject()) {
9222 ASSERT(args.length() == 0);
9223 NoHandleAllocation ha;
9224 isolate->PrintStack();
9225 return isolate->heap()->undefined_value();
9230 NoHandleAllocation ha;
9231 ASSERT(args.length() == 0);
9238 return isolate->heap()->NumberFromDouble(millis);
9244 ASSERT(args.length() == 2);
9251 MaybeObject* maybe_result_array =
9252 output->EnsureCanContainHeapObjectElements();
9253 if (maybe_result_array->IsFailure())
return maybe_result_array;
9265 isolate->unicode_cache());
9270 isolate->unicode_cache());
9276 return isolate->heap()->null_value();
9282 NoHandleAllocation ha;
9283 ASSERT(args.length() == 1);
9286 int64_t time = isolate->date_cache()->EquivalentTime(static_cast<int64_t>(x));
9288 return isolate->heap()->AllocateStringFromUtf8(
CStrVector(zone));
9293 NoHandleAllocation ha;
9294 ASSERT(args.length() == 1);
9297 int64_t time = isolate->date_cache()->ToUTC(static_cast<int64_t>(x));
9299 return isolate->heap()->NumberFromDouble(static_cast<double>(time));
9304 ASSERT(args.length() == 1);
9305 Object* global = args[0];
9306 if (!global->IsJSGlobalObject())
return isolate->heap()->null_value();
9316 Zone* zone = isolate->zone();
9320 if (source->IsSeqAsciiString()) {
9321 result = JsonParser<true>::Parse(source, zone);
9323 result = JsonParser<false>::Parse(source, zone);
9327 ASSERT(isolate->has_pending_exception());
9336 ASSERT(context->allow_code_gen_from_strings()->IsFalse());
9339 isolate->allow_code_gen_callback();
9340 if (callback ==
NULL) {
9345 VMState state(isolate, EXTERNAL);
9361 if (context->allow_code_gen_from_strings()->IsFalse() &&
9363 return isolate->Throw(*isolate->factory()->NewError(
9364 "code_gen_from_strings", HandleVector<Object>(
NULL, 0)));
9369 source, context,
true,
CLASSIC_MODE, RelocInfo::kNoPosition);
9372 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared,
9383 int scope_position) {
9389 if (global_context->allow_code_gen_from_strings()->IsFalse() &&
9391 isolate->Throw(*isolate->factory()->NewError(
9392 "code_gen_from_strings", HandleVector<Object>(
NULL, 0)));
9400 Handle<Context>(isolate->context()),
9401 context->IsGlobalContext(),
9405 Handle<JSFunction> compiled =
9406 isolate->factory()->NewFunctionFromSharedFunctionInfo(
9408 return MakePair(*compiled, *receiver);
9413 ASSERT(args.length() == 5);
9423 if (*callee != isolate->global_context()->global_eval_fun() ||
9424 !args[1]->IsString()) {
9425 return MakePair(*callee, isolate->heap()->the_hole_value());
9429 ASSERT(args[4]->IsSmi());
9430 return CompileGlobalEval(isolate,
9444 ASSERT(args.length() == 1);
9447 Handle<Map> map = func->shared()->is_classic_mode()
9448 ? isolate->function_instance_map()
9449 : isolate->strict_mode_function_instance_map();
9451 ASSERT(func->map()->instance_type() == map->instance_type());
9452 ASSERT(func->map()->instance_size() == map->instance_size());
9453 func->set_map(*map);
9462 ASSERT(args.length() == 1);
9464 int size = size_smi->value();
9467 Heap* heap = isolate->heap();
9471 { MaybeObject* maybe_allocation = heap->
new_space()->AllocateRaw(size);
9472 if (maybe_allocation->ToObject(&allocation)) {
9475 return maybe_allocation;
9484 ASSERT(args.length() == 2);
9488 int length =
Smi::cast(array->length())->value();
9490 for (
int i = 0; i < length; i++) {
9491 if (elements->
get(i) == element)
return isolate->heap()->false_value();
9495 { MaybeObject* maybe_obj =
9497 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
9499 return isolate->heap()->true_value();
9518 bool fast_elements) :
9521 isolate->global_handles()->Create(*storage))),
9523 fast_elements_(fast_elements) { }
9531 uint32_t index = index_offset_ + i;
9533 if (fast_elements_) {
9534 if (index < static_cast<uint32_t>(storage_->length())) {
9535 storage_->set(index, *elm);
9542 SetDictionaryMode(index);
9553 set_storage(*result);
9561 index_offset_ += delta;
9570 if (fast_elements_) {
9577 array->set_map(*map);
9578 array->set_length(*length);
9579 array->set_elements(*storage_);
9585 void SetDictionaryMode(uint32_t index) {
9590 current_storage->length()));
9591 uint32_t current_length =
static_cast<uint32_t
>(current_storage->length());
9592 for (uint32_t i = 0; i < current_length; i++) {
9595 if (!element->IsTheHole()) {
9604 set_storage(*slow_storage);
9605 fast_elements_ =
false;
9608 inline void clear_storage() {
9613 inline void set_storage(FixedArray* storage) {
9619 Handle<FixedArray> storage_;
9622 uint32_t index_offset_;
9623 bool fast_elements_;
9627 static uint32_t EstimateElementCount(Handle<JSArray> array) {
9628 uint32_t length =
static_cast<uint32_t
>(array->length()->Number());
9629 int element_count = 0;
9630 switch (array->GetElementsKind()) {
9638 int fast_length =
static_cast<int>(length);
9640 for (
int i = 0; i < fast_length; i++) {
9641 if (!elements->get(i)->IsTheHole()) element_count++;
9651 Handle<SeededNumberDictionary> dictionary(
9653 int capacity = dictionary->Capacity();
9654 for (
int i = 0; i < capacity; i++) {
9655 Handle<Object> key(dictionary->KeyAt(i));
9656 if (dictionary->IsKey(*key)) {
9677 return element_count;
9682 template<
class ExternalArrayClass,
class ElementType>
9683 static void IterateExternalArrayElements(Isolate* isolate,
9684 Handle<JSObject> receiver,
9685 bool elements_are_ints,
9686 bool elements_are_guaranteed_smis,
9687 ArrayConcatVisitor* visitor) {
9688 Handle<ExternalArrayClass> array(
9689 ExternalArrayClass::cast(receiver->elements()));
9690 uint32_t len =
static_cast<uint32_t
>(array->length());
9693 if (elements_are_ints) {
9694 if (elements_are_guaranteed_smis) {
9695 for (uint32_t j = 0; j < len; j++) {
9696 HandleScope loop_scope;
9697 Handle<Smi> e(
Smi::FromInt(static_cast<int>(array->get_scalar(j))));
9698 visitor->visit(j, e);
9701 for (uint32_t j = 0; j < len; j++) {
9702 HandleScope loop_scope;
9703 int64_t val =
static_cast<int64_t
>(array->get_scalar(j));
9706 visitor->visit(j, e);
9709 isolate->factory()->NewNumber(static_cast<ElementType>(val));
9710 visitor->visit(j, e);
9715 for (uint32_t j = 0; j < len; j++) {
9716 HandleScope loop_scope(isolate);
9717 Handle<Object> e = isolate->factory()->NewNumber(array->get_scalar(j));
9718 visitor->visit(j, e);
9725 static int compareUInt32(
const uint32_t* ap,
const uint32_t* bp) {
9728 return (a == b) ? 0 : (a < b) ? -1 : 1;
9732 static void CollectElementIndices(Handle<JSObject>
object,
9734 List<uint32_t>* indices) {
9742 uint32_t length =
static_cast<uint32_t
>(elements->length());
9743 if (range < length) length = range;
9744 for (uint32_t i = 0; i < length; i++) {
9745 if (!elements->get(i)->IsTheHole()) {
9758 Handle<SeededNumberDictionary> dict(
9760 uint32_t capacity = dict->Capacity();
9761 for (uint32_t j = 0; j < capacity; j++) {
9762 HandleScope loop_scope;
9763 Handle<Object> k(dict->KeyAt(j));
9764 if (dict->IsKey(*k)) {
9766 uint32_t index =
static_cast<uint32_t
>(k->Number());
9767 if (index < range) {
9768 indices->Add(index);
9775 int dense_elements_length;
9778 dense_elements_length =
9783 dense_elements_length =
9788 dense_elements_length =
9793 dense_elements_length =
9798 dense_elements_length =
9803 dense_elements_length =
9808 dense_elements_length =
9813 dense_elements_length =
9818 dense_elements_length =
9824 dense_elements_length = 0;
9827 uint32_t length =
static_cast<uint32_t
>(dense_elements_length);
9828 if (range <= length) {
9834 for (uint32_t i = 0; i < length; i++) {
9837 if (length == range)
return;
9842 Handle<Object> prototype(object->GetPrototype());
9843 if (prototype->IsJSObject()) {
9846 CollectElementIndices(Handle<JSObject>::cast(prototype), range, indices);
9861 static bool IterateElements(Isolate* isolate,
9862 Handle<JSArray> receiver,
9863 ArrayConcatVisitor* visitor) {
9864 uint32_t length =
static_cast<uint32_t
>(receiver->length()->Number());
9865 switch (receiver->GetElementsKind()) {
9873 int fast_length =
static_cast<int>(length);
9874 ASSERT(fast_length <= elements->length());
9875 for (
int j = 0; j < fast_length; j++) {
9876 HandleScope loop_scope(isolate);
9877 Handle<Object> element_value(elements->get(j), isolate);
9878 if (!element_value->IsTheHole()) {
9879 visitor->visit(j, element_value);
9880 }
else if (receiver->HasElement(j)) {
9885 visitor->visit(j, element_value);
9897 Handle<SeededNumberDictionary> dict(receiver->element_dictionary());
9898 List<uint32_t> indices(dict->Capacity() / 2);
9901 CollectElementIndices(receiver, length, &indices);
9902 indices.Sort(&compareUInt32);
9904 int n = indices.length();
9906 HandleScope loop_scope;
9907 uint32_t index = indices[j];
9910 visitor->visit(index, element);
9914 }
while (j < n && indices[j] == index);
9920 receiver->elements()));
9921 for (uint32_t j = 0; j < length; j++) {
9923 visitor->visit(j, e);
9928 IterateExternalArrayElements<ExternalByteArray, int8_t>(
9929 isolate, receiver,
true,
true, visitor);
9933 IterateExternalArrayElements<ExternalUnsignedByteArray, uint8_t>(
9934 isolate, receiver,
true,
true, visitor);
9938 IterateExternalArrayElements<ExternalShortArray, int16_t>(
9939 isolate, receiver,
true,
true, visitor);
9943 IterateExternalArrayElements<ExternalUnsignedShortArray, uint16_t>(
9944 isolate, receiver,
true,
true, visitor);
9948 IterateExternalArrayElements<ExternalIntArray, int32_t>(
9949 isolate, receiver,
true,
false, visitor);
9953 IterateExternalArrayElements<ExternalUnsignedIntArray, uint32_t>(
9954 isolate, receiver,
true,
false, visitor);
9958 IterateExternalArrayElements<ExternalFloatArray, float>(
9959 isolate, receiver,
false,
false, visitor);
9963 IterateExternalArrayElements<ExternalDoubleArray, double>(
9964 isolate, receiver,
false,
false, visitor);
9971 visitor->increase_index_offset(length);
9983 ASSERT(args.length() == 1);
9987 int argument_count =
static_cast<int>(arguments->length()->
Number());
9996 uint32_t estimate_result_length = 0;
9997 uint32_t estimate_nof_elements = 0;
9999 for (
int i = 0; i < argument_count; i++) {
10002 uint32_t length_estimate;
10003 uint32_t element_estimate;
10004 if (obj->IsJSArray()) {
10009 if (array->HasFastDoubleElements()) {
10011 if (array->HasFastHoleyElements()) {
10018 static_cast<uint32_t
>(array->length()->Number());
10020 EstimateElementCount(array);
10022 length_estimate = 1;
10023 element_estimate = 1;
10030 estimate_result_length += length_estimate;
10033 element_estimate) {
10036 estimate_nof_elements += element_estimate;
10044 bool fast_case = (estimate_nof_elements * 2) >= estimate_result_length;
10050 storage = isolate->factory()->NewFixedArrayWithHoles(
10051 estimate_result_length);
10054 uint32_t at_least_space_for = estimate_nof_elements +
10055 (estimate_nof_elements >> 2);
10057 isolate->factory()->NewSeededNumberDictionary(at_least_space_for));
10062 for (
int i = 0; i < argument_count; i++) {
10064 if (obj->IsJSArray()) {
10066 if (!IterateElements(isolate, array, &visitor)) {
10070 visitor.
visit(0, obj);
10082 NoHandleAllocation ha;
10083 ASSERT(args.length() == 1);
10089 PrintF(
"%c", character);
10100 ASSERT(args.length() == 2);
10103 return object->PrepareElementsForSort(limit);
10109 ASSERT(args.length() == 2);
10112 from->ValidateElements();
10113 to->ValidateElements();
10116 MaybeObject* maybe_new_map;
10117 maybe_new_map = to->GetElementsTransitionMap(isolate, from_kind);
10119 if (!maybe_new_map->ToObject(&new_map))
return maybe_new_map;
10120 to->set_map_and_elements(
Map::cast(new_map), new_elements);
10121 to->set_length(from->length());
10123 { MaybeObject* maybe_obj = from->ResetElements();
10124 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
10127 to->ValidateElements();
10134 ASSERT(args.length() == 1);
10137 if (elements->IsDictionary()) {
10140 }
else if (object->IsJSArray()) {
10154 ASSERT(args.length() == 2);
10158 if (array->elements()->IsDictionary()) {
10161 bool threw =
false;
10166 int keys_length = keys->length();
10167 for (
int i = 0; i < keys_length; i++) {
10168 Object* key = keys->get(i);
10169 uint32_t index = 0;
10172 keys->set_undefined(i);
10175 return *isolate->factory()->NewJSArrayWithElements(keys);
10177 ASSERT(array->HasFastSmiOrObjectElements() ||
10178 array->HasFastDoubleElements());
10183 uint32_t actual_length =
10184 static_cast<uint32_t
>(elements->
length());
10185 uint32_t min_length = actual_length < length ? actual_length : length;
10187 isolate->factory()->NewNumber(static_cast<double>(min_length));
10188 single_interval->set(1, *length_object);
10189 return *isolate->factory()->NewJSArrayWithElements(single_interval);
10195 ASSERT(args.length() == 3);
10200 return obj->LookupAccessor(name, component);
10204 #ifdef ENABLE_DEBUGGER_SUPPORT
10206 ASSERT(args.length() == 0);
10207 return Execution::DebugBreakHelper();
10212 static Smi* WrapFrameId(StackFrame::Id
id) {
10218 static StackFrame::Id UnwrapFrameId(
int wrapped) {
10219 return static_cast<StackFrame::Id
>(wrapped << 2);
10228 ASSERT(args.length() == 2);
10230 args[0]->IsUndefined() ||
10231 args[0]->IsNull());
10232 Handle<Object> callback = args.at<
Object>(0);
10233 Handle<Object> data = args.at<
Object>(1);
10234 isolate->debugger()->SetEventListener(callback, data);
10236 return isolate->heap()->undefined_value();
10241 ASSERT(args.length() == 0);
10242 isolate->stack_guard()->DebugBreak();
10243 return isolate->heap()->undefined_value();
10247 static MaybeObject* DebugLookupResultValue(Heap* heap,
10250 LookupResult* result,
10251 bool* caught_exception) {
10253 switch (result->type()) {
10255 value = result->holder()->GetNormalizedProperty(result);
10256 if (value->IsTheHole()) {
10257 return heap->undefined_value();
10263 result->holder())->FastPropertyAt(result->GetFieldIndex());
10264 if (value->IsTheHole()) {
10265 return heap->undefined_value();
10269 return result->GetConstantFunction();
10271 Object* structure = result->GetCallbackObject();
10272 if (structure->IsForeign() || structure->IsAccessorInfo()) {
10273 MaybeObject* maybe_value = result->holder()->GetPropertyWithCallback(
10274 receiver, structure, name);
10275 if (!maybe_value->ToObject(&value)) {
10276 if (maybe_value->IsRetryAfterGC())
return maybe_value;
10277 ASSERT(maybe_value->IsException());
10278 maybe_value = heap->isolate()->pending_exception();
10279 heap->isolate()->clear_pending_exception();
10280 if (caught_exception !=
NULL) {
10281 *caught_exception =
true;
10283 return maybe_value;
10287 return heap->undefined_value();
10294 return heap->undefined_value();
10297 return heap->undefined_value();
10300 return heap->undefined_value();
10317 HandleScope scope(isolate);
10319 ASSERT(args.length() == 2);
10330 SaveContext save(isolate);
10331 if (isolate->debug()->InDebugger()) {
10332 isolate->set_context(*isolate->debug()->debugger_entry()->GetContext());
10337 if (obj->IsJSGlobalProxy()) {
10345 if (name->AsArrayIndex(&index)) {
10346 Handle<FixedArray> details = isolate->factory()->NewFixedArray(2);
10347 Object* element_or_char;
10348 { MaybeObject* maybe_element_or_char =
10350 if (!maybe_element_or_char->ToObject(&element_or_char)) {
10351 return maybe_element_or_char;
10354 details->set(0, element_or_char);
10355 details->set(1, PropertyDetails(
NONE,
NORMAL).AsSmi());
10356 return *isolate->factory()->NewJSArrayWithElements(details);
10360 int length = LocalPrototypeChainLength(*obj);
10363 Handle<JSObject> jsproto = obj;
10364 for (
int i = 0; i < length; i++) {
10365 LookupResult result(isolate);
10366 jsproto->LocalLookup(*name, &result);
10367 if (result.IsProperty()) {
10372 Handle<Object> result_callback_obj;
10374 result_callback_obj = Handle<Object>(result.GetCallbackObject(),
10377 Smi* property_details = result.GetPropertyDetails().AsSmi();
10380 bool caught_exception =
false;
10382 { MaybeObject* maybe_raw_value =
10383 DebugLookupResultValue(isolate->heap(), *obj, *
name,
10384 &result, &caught_exception);
10385 if (!maybe_raw_value->ToObject(&raw_value))
return maybe_raw_value;
10387 Handle<Object> value(raw_value, isolate);
10391 bool hasJavaScriptAccessors = result_type ==
CALLBACKS &&
10392 result_callback_obj->IsAccessorPair();
10393 Handle<FixedArray> details =
10394 isolate->factory()->NewFixedArray(hasJavaScriptAccessors ? 5 : 2);
10395 details->set(0, *value);
10396 details->set(1, property_details);
10397 if (hasJavaScriptAccessors) {
10399 details->set(2, isolate->heap()->ToBoolean(caught_exception));
10404 return *isolate->factory()->NewJSArrayWithElements(details);
10406 if (i < length - 1) {
10407 jsproto = Handle<JSObject>(
JSObject::cast(jsproto->GetPrototype()));
10411 return isolate->heap()->undefined_value();
10416 HandleScope scope(isolate);
10418 ASSERT(args.length() == 2);
10423 LookupResult result(isolate);
10424 obj->Lookup(*name, &result);
10425 if (result.IsProperty()) {
10426 return DebugLookupResultValue(isolate->heap(), *obj, *
name, &result,
NULL);
10428 return isolate->heap()->undefined_value();
10435 ASSERT(args.length() == 1);
10437 return Smi::FromInt(static_cast<int>(details.type()));
10443 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyAttributesFromDetails) {
10444 ASSERT(args.length() == 1);
10446 return Smi::FromInt(static_cast<int>(details.attributes()));
10453 ASSERT(args.length() == 1);
10462 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugNamedInterceptorPropertyValue) {
10463 HandleScope scope(isolate);
10464 ASSERT(args.length() == 2);
10470 return obj->GetPropertyWithInterceptor(*obj, *name, &attributes);
10477 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugIndexedInterceptorElementValue) {
10478 HandleScope scope(isolate);
10479 ASSERT(args.length() == 2);
10484 return obj->GetElementWithInterceptor(*obj, index);
10489 ASSERT(args.length() >= 1);
10492 if (isolate->debug()->break_id() == 0 ||
10493 break_id != isolate->debug()->break_id()) {
10494 return isolate->Throw(
10495 isolate->heap()->illegal_execution_state_symbol());
10498 return isolate->heap()->true_value();
10503 HandleScope scope(isolate);
10504 ASSERT(args.length() == 1);
10508 { MaybeObject* maybe_result = Runtime_CheckExecutionState(
10510 if (!maybe_result->ToObject(&result))
return maybe_result;
10515 StackFrame::Id
id = isolate->debug()->break_frame_id();
10516 if (
id == StackFrame::NO_ID) {
10522 n += it.frame()->GetInlineCount();
10528 class FrameInspector {
10530 FrameInspector(JavaScriptFrame* frame,
10531 int inlined_jsframe_index,
10533 : frame_(frame), deoptimized_frame_(
NULL), isolate_(isolate) {
10535 if (frame->is_optimized()) {
10536 deoptimized_frame_ = Deoptimizer::DebuggerInspectableFrame(
10537 frame, inlined_jsframe_index, isolate);
10539 has_adapted_arguments_ = frame_->has_adapted_arguments();
10540 is_bottommost_ = inlined_jsframe_index == 0;
10541 is_optimized_ = frame_->is_optimized();
10544 ~FrameInspector() {
10546 if (deoptimized_frame_ !=
NULL) {
10547 Deoptimizer::DeleteDebuggerInspectableFrame(deoptimized_frame_,
10552 int GetParametersCount() {
10553 return is_optimized_
10554 ? deoptimized_frame_->parameters_count()
10555 : frame_->ComputeParametersCount();
10557 int expression_count() {
return deoptimized_frame_->expression_count(); }
10559 return is_optimized_
10560 ? deoptimized_frame_->GetFunction()
10561 : frame_->function();
10563 Object* GetParameter(
int index) {
10564 return is_optimized_
10565 ? deoptimized_frame_->GetParameter(index)
10566 : frame_->GetParameter(index);
10568 Object* GetExpression(
int index) {
10569 return is_optimized_
10570 ? deoptimized_frame_->GetExpression(index)
10571 : frame_->GetExpression(index);
10573 int GetSourcePosition() {
10574 return is_optimized_
10575 ? deoptimized_frame_->GetSourcePosition()
10576 : frame_->LookupCode()->SourcePosition(frame_->pc());
10578 bool IsConstructor() {
10579 return is_optimized_ && !is_bottommost_
10580 ? deoptimized_frame_->HasConstructStub()
10581 : frame_->IsConstructor();
10586 void SetArgumentsFrame(JavaScriptFrame* frame) {
10587 ASSERT(has_adapted_arguments_);
10589 is_optimized_ = frame_->is_optimized();
10594 JavaScriptFrame* frame_;
10595 DeoptimizedFrameInfo* deoptimized_frame_;
10597 bool is_optimized_;
10598 bool is_bottommost_;
10599 bool has_adapted_arguments_;
10605 static const int kFrameDetailsFrameIdIndex = 0;
10606 static const int kFrameDetailsReceiverIndex = 1;
10607 static const int kFrameDetailsFunctionIndex = 2;
10608 static const int kFrameDetailsArgumentCountIndex = 3;
10609 static const int kFrameDetailsLocalCountIndex = 4;
10610 static const int kFrameDetailsSourcePositionIndex = 5;
10611 static const int kFrameDetailsConstructCallIndex = 6;
10612 static const int kFrameDetailsAtReturnIndex = 7;
10613 static const int kFrameDetailsFlagsIndex = 8;
10614 static const int kFrameDetailsFirstDynamicIndex = 9;
10617 static SaveContext* FindSavedContextForFrame(Isolate* isolate,
10618 JavaScriptFrame* frame) {
10619 SaveContext* save = isolate->save_context();
10620 while (save !=
NULL && !save->IsBelowFrame(frame)) {
10621 save = save->prev();
10646 HandleScope scope(isolate);
10647 ASSERT(args.length() == 2);
10651 { MaybeObject* maybe_check = Runtime_CheckExecutionState(
10653 if (!maybe_check->ToObject(&check))
return maybe_check;
10656 Heap* heap = isolate->heap();
10659 StackFrame::Id
id = isolate->debug()->break_frame_id();
10660 if (
id == StackFrame::NO_ID) {
10662 return heap->undefined_value();
10667 for (; !it.done(); it.Advance()) {
10668 if (index < count + it.frame()->GetInlineCount())
break;
10669 count += it.frame()->GetInlineCount();
10671 if (it.done())
return heap->undefined_value();
10673 bool is_optimized = it.frame()->is_optimized();
10675 int inlined_jsframe_index = 0;
10676 if (is_optimized) {
10677 inlined_jsframe_index =
10678 it.frame()->GetInlineCount() - (index - count) - 1;
10680 FrameInspector frame_inspector(it.frame(), inlined_jsframe_index, isolate);
10684 SaveContext* save = FindSavedContextForFrame(isolate, it.frame());
10687 Handle<Object> frame_id(WrapFrameId(it.frame()->id()), isolate);
10690 int position = frame_inspector.GetSourcePosition();
10693 bool constructor = frame_inspector.IsConstructor();
10696 Handle<JSFunction>
function(
JSFunction::cast(frame_inspector.GetFunction()));
10697 Handle<SharedFunctionInfo> shared(function->shared());
10698 Handle<ScopeInfo> scope_info(shared->scope_info());
10706 Handle<FixedArray> locals =
10707 isolate->factory()->NewFixedArray(scope_info->LocalCount() * 2);
10711 for (; i < scope_info->StackLocalCount(); ++i) {
10713 locals->set(i * 2, scope_info->LocalName(i));
10714 locals->set(i * 2 + 1, frame_inspector.GetExpression(i));
10716 if (i < scope_info->LocalCount()) {
10718 Handle<Context> context(
10719 Context::cast(it.frame()->context())->declaration_context());
10720 for (; i < scope_info->LocalCount(); ++i) {
10721 Handle<String>
name(scope_info->LocalName(i));
10724 locals->set(i * 2, *name);
10725 locals->set(i * 2 + 1, context->
get(
10726 scope_info->ContextSlotIndex(*name, &mode, &init_flag)));
10732 bool at_return =
false;
10733 if (!is_optimized && index == 0) {
10734 at_return = isolate->debug()->IsBreakAtReturn(it.frame());
10739 Handle<Object> return_value = isolate->factory()->undefined_value();
10741 StackFrameIterator it2(isolate);
10743 while (!it2.done()) {
10744 if (it2.frame()->is_internal()) {
10745 internal_frame_sp = it2.frame()->sp();
10747 if (it2.frame()->is_java_script()) {
10748 if (it2.frame()->id() == it.frame()->id()) {
10753 if (internal_frame_sp !=
NULL) {
10763 internal_frame_sp =
NULL;
10773 if ((inlined_jsframe_index == 0) && it.frame()->has_adapted_arguments()) {
10774 it.AdvanceToArgumentsFrame();
10775 frame_inspector.SetArgumentsFrame(it.frame());
10780 int argument_count = scope_info->ParameterCount();
10781 if (argument_count < frame_inspector.GetParametersCount()) {
10782 argument_count = frame_inspector.GetParametersCount();
10786 int details_size = kFrameDetailsFirstDynamicIndex +
10787 2 * (argument_count + scope_info->LocalCount()) +
10788 (at_return ? 1 : 0);
10789 Handle<FixedArray> details = isolate->factory()->NewFixedArray(details_size);
10792 details->set(kFrameDetailsFrameIdIndex, *frame_id);
10795 details->set(kFrameDetailsFunctionIndex, frame_inspector.GetFunction());
10798 details->set(kFrameDetailsArgumentCountIndex,
Smi::FromInt(argument_count));
10801 details->set(kFrameDetailsLocalCountIndex,
10805 if (position != RelocInfo::kNoPosition) {
10806 details->set(kFrameDetailsSourcePositionIndex,
Smi::FromInt(position));
10808 details->set(kFrameDetailsSourcePositionIndex, heap->undefined_value());
10812 details->set(kFrameDetailsConstructCallIndex, heap->ToBoolean(constructor));
10815 details->set(kFrameDetailsAtReturnIndex, heap->ToBoolean(at_return));
10822 if (*save->context() == *isolate->debug()->debug_context()) {
10825 if (is_optimized) {
10827 flags |= inlined_jsframe_index << 2;
10829 details->set(kFrameDetailsFlagsIndex,
Smi::FromInt(flags));
10832 int details_index = kFrameDetailsFirstDynamicIndex;
10835 for (
int i = 0; i < argument_count; i++) {
10837 if (i < scope_info->ParameterCount()) {
10838 details->set(details_index++, scope_info->ParameterName(i));
10840 details->set(details_index++, heap->undefined_value());
10844 if (i < frame_inspector.GetParametersCount()) {
10846 details->set(details_index++, frame_inspector.GetParameter(i));
10848 details->set(details_index++, heap->undefined_value());
10853 for (
int i = 0; i < scope_info->LocalCount() * 2; i++) {
10854 details->set(details_index++, locals->get(i));
10859 details->set(details_index++, *return_value);
10865 Handle<Object> receiver(it.frame()->receiver(), isolate);
10866 if (!receiver->IsJSObject() &&
10867 shared->is_classic_mode() &&
10868 !shared->native()) {
10876 Handle<Context> calling_frames_global_context(
10879 isolate->factory()->ToObject(receiver, calling_frames_global_context);
10881 details->set(kFrameDetailsReceiverIndex, *receiver);
10883 ASSERT_EQ(details_size, details_index);
10884 return *isolate->factory()->NewJSArrayWithElements(details);
10889 static bool CopyContextLocalsToScopeObject(
10891 Handle<ScopeInfo> scope_info,
10892 Handle<Context> context,
10893 Handle<JSObject> scope_object) {
10895 for (
int i = 0; i < scope_info->ContextLocalCount(); i++) {
10898 int context_index = scope_info->ContextSlotIndex(
10899 scope_info->ContextLocalName(i), &mode, &init_flag);
10904 Handle<String>(scope_info->ContextLocalName(i)),
10905 Handle<Object>(context->get(context_index), isolate),
10917 static Handle<JSObject> MaterializeLocalScopeWithFrameInspector(
10919 JavaScriptFrame* frame,
10920 FrameInspector* frame_inspector) {
10921 Handle<JSFunction>
function(
JSFunction::cast(frame_inspector->GetFunction()));
10922 Handle<SharedFunctionInfo> shared(function->shared());
10923 Handle<ScopeInfo> scope_info(shared->scope_info());
10927 Handle<JSObject> local_scope =
10928 isolate->factory()->NewJSObject(isolate->object_function());
10931 for (
int i = 0; i < scope_info->ParameterCount(); ++i) {
10932 Handle<Object> value(
10933 i < frame_inspector->GetParametersCount() ?
10934 frame_inspector->GetParameter(i) : isolate->heap()->undefined_value());
10939 Handle<String>(scope_info->ParameterName(i)),
10943 Handle<JSObject>());
10947 for (
int i = 0; i < scope_info->StackLocalCount(); ++i) {
10951 Handle<String>(scope_info->StackLocalName(i)),
10952 Handle<Object>(frame_inspector->GetExpression(i)),
10955 Handle<JSObject>());
10958 if (scope_info->HasContext()) {
10960 Handle<Context> frame_context(
Context::cast(frame->context()));
10961 Handle<Context> function_context(frame_context->declaration_context());
10962 if (!CopyContextLocalsToScopeObject(
10963 isolate, scope_info, function_context, local_scope)) {
10964 return Handle<JSObject>();
10969 if (function_context->closure() == *
function) {
10970 if (function_context->has_extension() &&
10971 !function_context->IsGlobalContext()) {
10972 Handle<JSObject> ext(
JSObject::cast(function_context->extension()));
10973 bool threw =
false;
10974 Handle<FixedArray> keys =
10976 if (threw)
return Handle<JSObject>();
10978 for (
int i = 0; i < keys->length(); i++) {
10980 ASSERT(keys->get(i)->IsString());
10989 Handle<JSObject>());
10995 return local_scope;
10999 static Handle<JSObject> MaterializeLocalScope(
11001 JavaScriptFrame* frame,
11002 int inlined_jsframe_index) {
11003 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate);
11004 return MaterializeLocalScopeWithFrameInspector(isolate,
11012 static Handle<JSObject> MaterializeClosure(Isolate* isolate,
11013 Handle<Context> context) {
11014 ASSERT(context->IsFunctionContext());
11016 Handle<SharedFunctionInfo> shared(context->closure()->shared());
11017 Handle<ScopeInfo> scope_info(shared->scope_info());
11021 Handle<JSObject> closure_scope =
11022 isolate->factory()->NewJSObject(isolate->object_function());
11025 if (!CopyContextLocalsToScopeObject(
11026 isolate, scope_info, context, closure_scope)) {
11027 return Handle<JSObject>();
11032 if (context->has_extension()) {
11034 bool threw =
false;
11035 Handle<FixedArray> keys =
11037 if (threw)
return Handle<JSObject>();
11039 for (
int i = 0; i < keys->length(); i++) {
11041 ASSERT(keys->get(i)->IsString());
11050 Handle<JSObject>());
11054 return closure_scope;
11060 static Handle<JSObject> MaterializeCatchScope(Isolate* isolate,
11061 Handle<Context> context) {
11062 ASSERT(context->IsCatchContext());
11065 Handle<JSObject> catch_scope =
11066 isolate->factory()->NewJSObject(isolate->object_function());
11070 Handle<JSObject>());
11071 return catch_scope;
11077 static Handle<JSObject> MaterializeBlockScope(
11079 Handle<Context> context) {
11080 ASSERT(context->IsBlockContext());
11085 Handle<JSObject> block_scope =
11086 isolate->factory()->NewJSObject(isolate->object_function());
11089 if (!CopyContextLocalsToScopeObject(
11090 isolate, scope_info, context, block_scope)) {
11091 return Handle<JSObject>();
11094 return block_scope;
11100 static Handle<JSObject> MaterializeModuleScope(
11102 Handle<Context> context) {
11103 ASSERT(context->IsModuleContext());
11108 Handle<JSObject> module_scope =
11109 isolate->factory()->NewJSObject(isolate->object_function());
11112 if (!CopyContextLocalsToScopeObject(
11113 isolate, scope_info, context, module_scope)) {
11114 return Handle<JSObject>();
11117 return module_scope;
11125 class ScopeIterator {
11128 ScopeTypeGlobal = 0,
11137 ScopeIterator(Isolate* isolate,
11138 JavaScriptFrame* frame,
11139 int inlined_jsframe_index)
11140 : isolate_(isolate),
11142 inlined_jsframe_index_(inlined_jsframe_index),
11143 function_(JSFunction::cast(frame->function())),
11144 context_(Context::cast(frame->context())),
11145 nested_scope_chain_(4) {
11148 Handle<SharedFunctionInfo> shared_info(function_->shared());
11149 Handle<ScopeInfo> scope_info(shared_info->scope_info());
11150 if (shared_info->script() == isolate->heap()->undefined_value()) {
11151 while (context_->closure() == *function_) {
11152 context_ = Handle<Context>(context_->previous(), isolate_);
11158 if (!isolate->debug()->EnsureDebugInfo(shared_info)) {
11162 Handle<DebugInfo> debug_info = Debug::GetDebugInfo(shared_info);
11165 BreakLocationIterator break_location_iterator(debug_info,
11166 ALL_BREAK_LOCATIONS);
11167 break_location_iterator.FindBreakLocationFromAddress(frame->pc());
11168 if (break_location_iterator.IsExit()) {
11173 if (scope_info->HasContext()) {
11174 context_ = Handle<Context>(context_->declaration_context(), isolate_);
11176 while (context_->closure() == *function_) {
11177 context_ = Handle<Context>(context_->previous(), isolate_);
11180 if (scope_info->Type() !=
EVAL_SCOPE) nested_scope_chain_.Add(scope_info);
11184 Handle<Script> script(
Script::cast(shared_info->script()));
11185 Scope* scope =
NULL;
11188 Handle<ScopeInfo> scope_info(shared_info->scope_info());
11191 CompilationInfo info(script);
11193 info.MarkAsGlobal();
11197 info.SetCallingContext(Handle<Context>(function_->context()));
11200 scope = info.function()->scope();
11204 CompilationInfo info(shared_info);
11206 scope = info.function()->scope();
11211 if (scope !=
NULL) {
11212 int source_position = shared_info->code()->SourcePosition(frame_->pc());
11213 scope->GetNestedScopeChain(&nested_scope_chain_, source_position);
11225 ScopeIterator(Isolate* isolate,
11226 Handle<JSFunction>
function)
11227 : isolate_(isolate),
11229 inlined_jsframe_index_(0),
11230 function_(function),
11231 context_(function->context()) {
11232 if (function->IsBuiltin()) {
11233 context_ = Handle<Context>();
11238 bool Done() {
return context_.is_null(); }
11243 if (scope_type == ScopeTypeGlobal) {
11245 ASSERT(context_->IsGlobalContext());
11246 context_ = Handle<Context>();
11249 if (nested_scope_chain_.is_empty()) {
11250 context_ = Handle<Context>(context_->previous(), isolate_);
11252 if (nested_scope_chain_.last()->HasContext()) {
11254 context_ = Handle<Context>(context_->previous(), isolate_);
11256 nested_scope_chain_.RemoveLast();
11262 if (!nested_scope_chain_.is_empty()) {
11263 Handle<ScopeInfo> scope_info = nested_scope_chain_.last();
11264 switch (scope_info->Type()) {
11266 ASSERT(context_->IsFunctionContext() ||
11267 !scope_info->HasContext());
11268 return ScopeTypeLocal;
11270 ASSERT(context_->IsModuleContext());
11271 return ScopeTypeModule;
11273 ASSERT(context_->IsGlobalContext());
11274 return ScopeTypeGlobal;
11276 ASSERT(context_->IsWithContext());
11277 return ScopeTypeWith;
11279 ASSERT(context_->IsCatchContext());
11280 return ScopeTypeCatch;
11282 ASSERT(!scope_info->HasContext() ||
11283 context_->IsBlockContext());
11284 return ScopeTypeBlock;
11289 if (context_->IsGlobalContext()) {
11290 ASSERT(context_->global()->IsGlobalObject());
11291 return ScopeTypeGlobal;
11293 if (context_->IsFunctionContext()) {
11294 return ScopeTypeClosure;
11296 if (context_->IsCatchContext()) {
11297 return ScopeTypeCatch;
11299 if (context_->IsBlockContext()) {
11300 return ScopeTypeBlock;
11302 if (context_->IsModuleContext()) {
11303 return ScopeTypeModule;
11305 ASSERT(context_->IsWithContext());
11306 return ScopeTypeWith;
11310 Handle<JSObject> ScopeObject() {
11312 case ScopeIterator::ScopeTypeGlobal:
11313 return Handle<JSObject>(CurrentContext()->global());
11314 case ScopeIterator::ScopeTypeLocal:
11316 ASSERT(nested_scope_chain_.length() == 1);
11317 return MaterializeLocalScope(isolate_, frame_, inlined_jsframe_index_);
11318 case ScopeIterator::ScopeTypeWith:
11320 return Handle<JSObject>(
JSObject::cast(CurrentContext()->extension()));
11321 case ScopeIterator::ScopeTypeCatch:
11322 return MaterializeCatchScope(isolate_, CurrentContext());
11323 case ScopeIterator::ScopeTypeClosure:
11325 return MaterializeClosure(isolate_, CurrentContext());
11326 case ScopeIterator::ScopeTypeBlock:
11327 return MaterializeBlockScope(isolate_, CurrentContext());
11328 case ScopeIterator::ScopeTypeModule:
11329 return MaterializeModuleScope(isolate_, CurrentContext());
11332 return Handle<JSObject>();
11335 Handle<ScopeInfo> CurrentScopeInfo() {
11336 if (!nested_scope_chain_.is_empty()) {
11337 return nested_scope_chain_.last();
11338 }
else if (context_->IsBlockContext()) {
11340 }
else if (context_->IsFunctionContext()) {
11341 return Handle<ScopeInfo>(context_->closure()->shared()->scope_info());
11348 Handle<Context> CurrentContext() {
11349 if (Type() == ScopeTypeGlobal ||
11350 nested_scope_chain_.is_empty()) {
11352 }
else if (nested_scope_chain_.last()->HasContext()) {
11355 return Handle<Context>();
11361 void DebugPrint() {
11363 case ScopeIterator::ScopeTypeGlobal:
11365 CurrentContext()->Print();
11368 case ScopeIterator::ScopeTypeLocal: {
11370 function_->shared()->scope_info()->Print();
11371 if (!CurrentContext().is_null()) {
11372 CurrentContext()->Print();
11373 if (CurrentContext()->has_extension()) {
11374 Handle<Object> extension(CurrentContext()->extension());
11375 if (extension->IsJSContextExtensionObject()) {
11376 extension->Print();
11383 case ScopeIterator::ScopeTypeWith:
11385 CurrentContext()->extension()->Print();
11388 case ScopeIterator::ScopeTypeCatch:
11390 CurrentContext()->extension()->Print();
11394 case ScopeIterator::ScopeTypeClosure:
11396 CurrentContext()->Print();
11397 if (CurrentContext()->has_extension()) {
11398 Handle<Object> extension(CurrentContext()->extension());
11399 if (extension->IsJSContextExtensionObject()) {
11400 extension->Print();
11414 JavaScriptFrame* frame_;
11415 int inlined_jsframe_index_;
11416 Handle<JSFunction> function_;
11417 Handle<Context> context_;
11418 List<Handle<ScopeInfo> > nested_scope_chain_;
11425 HandleScope scope(isolate);
11426 ASSERT(args.length() == 2);
11430 { MaybeObject* maybe_check = Runtime_CheckExecutionState(
11432 if (!maybe_check->ToObject(&check))
return maybe_check;
11437 StackFrame::Id
id = UnwrapFrameId(wrapped_id);
11439 JavaScriptFrame* frame = it.frame();
11443 for (ScopeIterator it(isolate, frame, 0);
11453 static const int kScopeDetailsTypeIndex = 0;
11454 static const int kScopeDetailsObjectIndex = 1;
11455 static const int kScopeDetailsSize = 2;
11458 static MaybeObject* MaterializeScopeDetails(Isolate* isolate,
11459 ScopeIterator* it) {
11461 int details_size = kScopeDetailsSize;
11462 Handle<FixedArray> details = isolate->factory()->NewFixedArray(details_size);
11465 details->set(kScopeDetailsTypeIndex,
Smi::FromInt(it->Type()));
11466 Handle<JSObject> scope_object = it->ScopeObject();
11468 details->set(kScopeDetailsObjectIndex, *scope_object);
11470 return *isolate->factory()->NewJSArrayWithElements(details);
11483 HandleScope scope(isolate);
11484 ASSERT(args.length() == 4);
11488 { MaybeObject* maybe_check = Runtime_CheckExecutionState(
11490 if (!maybe_check->ToObject(&check))
return maybe_check;
11497 StackFrame::Id
id = UnwrapFrameId(wrapped_id);
11499 JavaScriptFrame* frame = frame_it.frame();
11503 ScopeIterator it(isolate, frame, inlined_jsframe_index);
11504 for (; !it.Done() && n < index; it.Next()) {
11508 return isolate->heap()->undefined_value();
11510 return MaterializeScopeDetails(isolate, &it);
11515 HandleScope scope(isolate);
11516 ASSERT(args.length() == 1);
11523 for (ScopeIterator it(isolate, fun); !it.Done(); it.Next()) {
11532 HandleScope scope(isolate);
11533 ASSERT(args.length() == 2);
11541 ScopeIterator it(isolate, fun);
11542 for (; !it.Done() && n < index; it.Next()) {
11546 return isolate->heap()->undefined_value();
11549 return MaterializeScopeDetails(isolate, &it);
11554 HandleScope scope(isolate);
11555 ASSERT(args.length() == 0);
11559 StackFrameLocator locator;
11560 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0);
11561 for (ScopeIterator it(isolate, frame, 0);
11567 return isolate->heap()->undefined_value();
11572 HandleScope scope(isolate);
11573 ASSERT(args.length() == 1);
11577 { MaybeObject* maybe_result = Runtime_CheckExecutionState(
11579 if (!maybe_result->ToObject(&result))
return maybe_result;
11584 for (ThreadState* thread =
11585 isolate->thread_manager()->FirstThreadStateInUse();
11587 thread = thread->Next()) {
11596 static const int kThreadDetailsCurrentThreadIndex = 0;
11597 static const int kThreadDetailsThreadIdIndex = 1;
11598 static const int kThreadDetailsSize = 2;
11608 HandleScope scope(isolate);
11609 ASSERT(args.length() == 2);
11613 { MaybeObject* maybe_check = Runtime_CheckExecutionState(
11615 if (!maybe_check->ToObject(&check))
return maybe_check;
11620 Handle<FixedArray> details =
11621 isolate->factory()->NewFixedArray(kThreadDetailsSize);
11626 details->set(kThreadDetailsCurrentThreadIndex,
11627 isolate->heap()->true_value());
11628 details->set(kThreadDetailsThreadIdIndex,
11633 ThreadState* thread =
11634 isolate->thread_manager()->FirstThreadStateInUse();
11635 while (index != n && thread !=
NULL) {
11636 thread = thread->Next();
11639 if (thread ==
NULL) {
11640 return isolate->heap()->undefined_value();
11644 details->set(kThreadDetailsCurrentThreadIndex,
11645 isolate->heap()->false_value());
11646 details->set(kThreadDetailsThreadIdIndex,
11651 return *isolate->factory()->NewJSArrayWithElements(details);
11658 HandleScope scope(isolate);
11659 ASSERT(args.length() == 1);
11661 isolate->debug()->set_disable_break(disable_break);
11662 return isolate->heap()->undefined_value();
11667 HandleScope scope(isolate);
11668 ASSERT(args.length() == 1);
11671 Handle<SharedFunctionInfo> shared(fun->shared());
11673 Handle<Object> break_locations = Debug::GetSourceBreakLocations(shared);
11674 if (break_locations->IsUndefined())
return isolate->heap()->undefined_value();
11676 return *isolate->factory()->NewJSArrayWithElements(
11677 Handle<FixedArray>::cast(break_locations));
11686 HandleScope scope(isolate);
11687 ASSERT(args.length() == 3);
11689 Handle<SharedFunctionInfo> shared(fun->shared());
11692 Handle<Object> break_point_object_arg = args.at<
Object>(2);
11695 isolate->debug()->SetBreakPoint(shared, break_point_object_arg,
11703 Handle<Script> script,
11715 int target_start_position = RelocInfo::kNoPosition;
11716 Handle<SharedFunctionInfo> target;
11719 isolate->heap()->EnsureHeapIsIterable();
11720 AssertNoAllocation no_alloc_during_heap_iteration;
11721 HeapIterator iterator;
11722 for (HeapObject* obj = iterator.next();
11723 obj !=
NULL; obj = iterator.next()) {
11724 if (obj->IsSharedFunctionInfo()) {
11726 if (shared->script() == *script) {
11729 int start_position = shared->function_token_position();
11730 if (start_position == RelocInfo::kNoPosition) {
11731 start_position = shared->start_position();
11733 if (start_position <= position &&
11734 position <= shared->end_position()) {
11737 if (target.is_null()) {
11738 target_start_position = start_position;
11741 if (target_start_position == start_position &&
11742 shared->end_position() == target->end_position()) {
11747 if (!shared->is_toplevel()) {
11748 target_start_position = start_position;
11751 }
else if (target_start_position <= start_position &&
11752 shared->end_position() <= target->end_position()) {
11756 target_start_position = start_position;
11766 if (target.is_null()) {
11767 return isolate->heap()->undefined_value();
11773 done = target->is_compiled();
11792 HandleScope scope(isolate);
11793 ASSERT(args.length() == 3);
11797 Handle<Object> break_point_object_arg = args.at<
Object>(2);
11801 Handle<Script> script(
Script::cast(wrapper->value()));
11804 isolate, script, source_position);
11805 if (!result->IsUndefined()) {
11810 if (shared->start_position() > source_position) {
11813 position = source_position - shared->start_position();
11815 isolate->debug()->SetBreakPoint(shared, break_point_object_arg, &position);
11816 position += shared->start_position();
11819 return isolate->heap()->undefined_value();
11826 HandleScope scope(isolate);
11827 ASSERT(args.length() == 1);
11828 Handle<Object> break_point_object_arg = args.at<
Object>(0);
11831 isolate->debug()->ClearBreakPoint(break_point_object_arg);
11833 return isolate->heap()->undefined_value();
11841 HandleScope scope(isolate);
11842 ASSERT(args.length() == 2);
11848 ExceptionBreakType type =
11851 isolate->debug()->ChangeBreakOnException(type, enable);
11852 return isolate->heap()->undefined_value();
11859 HandleScope scope(isolate);
11860 ASSERT(args.length() == 1);
11863 ExceptionBreakType type =
11865 bool result = isolate->debug()->IsBreakOnException(type);
11876 HandleScope scope(isolate);
11877 ASSERT(args.length() == 3);
11880 { MaybeObject* maybe_check = Runtime_CheckExecutionState(
11882 if (!maybe_check->ToObject(&check))
return maybe_check;
11884 if (!args[1]->IsNumber() || !args[2]->IsNumber()) {
11885 return isolate->Throw(isolate->heap()->illegal_argument_symbol());
11889 StepAction step_action =
static_cast<StepAction
>(
NumberToInt32(args[1]));
11890 if (step_action != StepIn &&
11891 step_action != StepNext &&
11892 step_action != StepOut &&
11893 step_action != StepInMin &&
11894 step_action != StepMin) {
11895 return isolate->Throw(isolate->heap()->illegal_argument_symbol());
11900 if (step_count < 1) {
11901 return isolate->Throw(isolate->heap()->illegal_argument_symbol());
11905 isolate->debug()->ClearStepping();
11908 isolate->debug()->PrepareStep(static_cast<StepAction>(step_action),
11910 return isolate->heap()->undefined_value();
11916 HandleScope scope(isolate);
11917 ASSERT(args.length() == 0);
11918 isolate->debug()->ClearStepping();
11919 return isolate->heap()->undefined_value();
11925 static Handle<Context> CopyNestedScopeContextChain(Isolate* isolate,
11926 Handle<JSFunction>
function,
11927 Handle<Context> base,
11928 JavaScriptFrame* frame,
11929 int inlined_jsframe_index) {
11930 HandleScope scope(isolate);
11931 List<Handle<ScopeInfo> > scope_chain;
11932 List<Handle<Context> > context_chain;
11934 ScopeIterator it(isolate, frame, inlined_jsframe_index);
11935 for (; it.Type() != ScopeIterator::ScopeTypeGlobal &&
11936 it.Type() != ScopeIterator::ScopeTypeLocal ; it.Next()) {
11938 scope_chain.Add(it.CurrentScopeInfo());
11939 context_chain.Add(it.CurrentContext());
11943 Handle<Context> context = base;
11946 while (!scope_chain.is_empty()) {
11947 Handle<ScopeInfo> scope_info = scope_chain.RemoveLast();
11948 Handle<Context> current = context_chain.RemoveLast();
11949 ASSERT(!(scope_info->HasContext() & current.is_null()));
11955 isolate->factory()->NewCatchContext(
function,
11961 Handle<JSObject> block_scope_object =
11962 MaterializeBlockScope(isolate, current);
11963 if (block_scope_object.is_null()) {
11968 Handle<Context> new_context =
11971 new_context->set_extension(*block_scope_object);
11972 new_context->set_previous(*context);
11973 context = new_context;
11976 ASSERT(current->IsWithContext());
11977 Handle<JSObject> extension(
JSObject::cast(current->extension()));
11979 isolate->factory()->NewWithContext(
function, context, extension);
11983 return scope.CloseAndEscape(context);
11989 static Handle<Object> GetArgumentsObject(Isolate* isolate,
11990 JavaScriptFrame* frame,
11991 FrameInspector* frame_inspector,
11992 Handle<ScopeInfo> scope_info,
11993 Handle<Context> function_context) {
11998 if (scope_info->StackLocalCount() > 0) {
11999 index = scope_info->StackSlotIndex(isolate->heap()->arguments_symbol());
12001 return Handle<Object>(frame->GetExpression(index), isolate);
12005 if (scope_info->HasHeapAllocatedLocals()) {
12008 index = scope_info->ContextSlotIndex(
12009 isolate->heap()->arguments_symbol(), &mode, &init_flag);
12011 return Handle<Object>(function_context->get(index), isolate);
12015 Handle<JSFunction>
function(
JSFunction::cast(frame_inspector->GetFunction()));
12016 int length = frame_inspector->GetParametersCount();
12017 Handle<JSObject> arguments =
12018 isolate->factory()->NewArgumentsObject(
function, length);
12019 Handle<FixedArray> array = isolate->factory()->NewFixedArray(length);
12021 AssertNoAllocation no_gc;
12023 for (
int i = 0; i < length; i++) {
12024 array->set(i, frame_inspector->GetParameter(i), mode);
12026 arguments->set_elements(*array);
12031 static const char kSourceStr[] =
12032 "(function(arguments,__source__){return eval(__source__);})";
12047 HandleScope scope(isolate);
12051 ASSERT(args.length() == 6);
12053 { MaybeObject* maybe_check_result = Runtime_CheckExecutionState(
12055 if (!maybe_check_result->ToObject(&check_result)) {
12056 return maybe_check_result;
12063 Handle<Object> additional_context(args[5]);
12066 DisableBreak disable_break_save(disable_break);
12069 StackFrame::Id
id = UnwrapFrameId(wrapped_id);
12071 JavaScriptFrame* frame = it.frame();
12072 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate);
12073 Handle<JSFunction>
function(
JSFunction::cast(frame_inspector.GetFunction()));
12074 Handle<ScopeInfo> scope_info(function->shared()->scope_info());
12078 SaveContext* save = FindSavedContextForFrame(isolate, frame);
12080 SaveContext savex(isolate);
12081 isolate->set_context(*(save->context()));
12089 Handle<JSFunction> go_between =
12090 isolate->factory()->NewFunction(isolate->factory()->empty_string(),
12091 isolate->factory()->undefined_value());
12092 go_between->set_context(function->context());
12094 Handle<ScopeInfo> go_between_scope_info(go_between->shared()->scope_info());
12095 ASSERT(go_between_scope_info->ParameterCount() == 0);
12096 ASSERT(go_between_scope_info->ContextLocalCount() == 0);
12100 Handle<JSObject> local_scope = MaterializeLocalScopeWithFrameInspector(
12101 isolate, frame, &frame_inspector);
12106 Handle<Context> context =
12109 context->set_extension(*local_scope);
12111 Handle<Context> frame_context(
Context::cast(frame->context()));
12112 Handle<Context> function_context;
12114 if (scope_info->HasContext()) {
12115 function_context = Handle<Context>(frame_context->declaration_context());
12117 context = CopyNestedScopeContextChain(isolate,
12121 inlined_jsframe_index);
12123 if (additional_context->IsJSObject()) {
12126 isolate->factory()->NewWithContext(go_between, context, extension);
12135 Handle<String> function_source =
12136 isolate->factory()->NewStringFromAscii(
12137 Vector<const char>(kSourceStr,
sizeof(kSourceStr) - 1));
12141 Handle<SharedFunctionInfo> shared =
12144 context->IsGlobalContext(),
12146 RelocInfo::kNoPosition);
12148 Handle<JSFunction> compiled_function =
12149 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context);
12152 bool has_pending_exception;
12153 Handle<Object> receiver(frame->receiver(), isolate);
12154 Handle<Object> evaluation_function =
12156 &has_pending_exception);
12159 Handle<Object> arguments = GetArgumentsObject(isolate,
12166 Handle<Object> argv[] = { arguments, source };
12167 Handle<Object> result =
12172 &has_pending_exception);
12177 if (result->IsJSGlobalProxy()) {
12178 result = Handle<JSObject>(
JSObject::cast(result->GetPrototype()));
12186 HandleScope scope(isolate);
12190 ASSERT(args.length() == 4);
12192 { MaybeObject* maybe_check_result = Runtime_CheckExecutionState(
12194 if (!maybe_check_result->ToObject(&check_result)) {
12195 return maybe_check_result;
12200 Handle<Object> additional_context(args[3]);
12203 DisableBreak disable_break_save(disable_break);
12206 SaveContext save(isolate);
12207 SaveContext* top = &save;
12208 while (top !=
NULL && *top->context() == *isolate->debug()->debug_context()) {
12212 isolate->set_context(*top->context());
12217 Handle<Context> context = isolate->global_context();
12219 bool is_global =
true;
12221 if (additional_context->IsJSObject()) {
12224 context = isolate->factory()->NewWithContext(
12225 Handle<JSFunction>(context->closure()),
12227 Handle<JSObject>::cast(additional_context));
12234 Handle<SharedFunctionInfo> shared =
12239 RelocInfo::kNoPosition);
12241 Handle<JSFunction> compiled_function =
12242 Handle<JSFunction>(
12243 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared,
12247 bool has_pending_exception;
12248 Handle<Object> receiver = isolate->global();
12249 Handle<Object> result =
12251 &has_pending_exception);
12253 isolate->debug()->ClearStepping();
12260 HandleScope scope(isolate);
12261 ASSERT(args.length() == 0);
12264 Handle<FixedArray> instances = isolate->debug()->GetLoadedScripts();
12267 for (
int i = 0; i < instances->length(); i++) {
12268 Handle<Script> script = Handle<Script>(
Script::cast(instances->get(i)));
12275 instances->set(i, *wrapper);
12279 Handle<JSObject> result =
12280 isolate->factory()->NewJSObject(isolate->array_function());
12281 isolate->factory()->SetContent(Handle<JSArray>::cast(result), instances);
12287 static int DebugReferencedBy(HeapIterator* iterator,
12289 Object* instance_filter,
int max_references,
12290 FixedArray* instances,
int instances_size,
12291 JSFunction* arguments_function) {
12292 NoHandleAllocation ha;
12293 AssertNoAllocation no_alloc;
12297 JSObject* last =
NULL;
12298 HeapObject* heap_obj =
NULL;
12299 while (((heap_obj = iterator->next()) !=
NULL) &&
12300 (max_references == 0 || count < max_references)) {
12302 if (heap_obj->IsJSObject()) {
12306 if (obj->IsJSContextExtensionObject() ||
12307 obj->map()->constructor() == arguments_function) {
12312 if (obj->ReferencesObject(target)) {
12315 if (!instance_filter->IsUndefined()) {
12319 if (prototype->IsNull()) {
12322 if (instance_filter == prototype) {
12333 if (instances !=
NULL && count < instances_size) {
12334 instances->set(count, obj);
12347 if (count == 1 && last == target) {
12361 ASSERT(args.length() == 3);
12365 "%DebugReferencedBy");
12373 Object* instance_filter = args[1];
12375 instance_filter->IsJSObject());
12381 JSObject* arguments_boilerplate =
12382 isolate->context()->global_context()->arguments_boilerplate();
12383 JSFunction* arguments_function =
12388 HeapIterator heap_iterator;
12389 count = DebugReferencedBy(&heap_iterator,
12390 target, instance_filter, max_references,
12391 NULL, 0, arguments_function);
12395 { MaybeObject* maybe_object = isolate->heap()->AllocateFixedArray(count);
12396 if (!maybe_object->ToObject(&
object))
return maybe_object;
12403 HeapIterator heap_iterator2;
12404 count = DebugReferencedBy(&heap_iterator2,
12405 target, instance_filter, max_references,
12406 instances, count, arguments_function);
12410 MaybeObject* maybe_result = isolate->heap()->AllocateJSObject(
12411 isolate->context()->global_context()->array_function());
12412 if (!maybe_result->ToObject(&result))
return maybe_result;
12418 static int DebugConstructedBy(HeapIterator* iterator,
12419 JSFunction* constructor,
12420 int max_references,
12421 FixedArray* instances,
12422 int instances_size) {
12423 AssertNoAllocation no_alloc;
12427 HeapObject* heap_obj =
NULL;
12428 while (((heap_obj = iterator->next()) !=
NULL) &&
12429 (max_references == 0 || count < max_references)) {
12431 if (heap_obj->IsJSObject()) {
12433 if (obj->map()->constructor() == constructor) {
12436 if (instances !=
NULL && count < instances_size) {
12437 instances->set(count, obj);
12453 ASSERT(args.length() == 2);
12457 "%DebugConstructedBy");
12466 HeapIterator heap_iterator;
12467 count = DebugConstructedBy(&heap_iterator,
12475 { MaybeObject* maybe_object = isolate->heap()->AllocateFixedArray(count);
12476 if (!maybe_object->ToObject(&
object))
return maybe_object;
12482 HeapIterator heap_iterator2;
12483 count = DebugConstructedBy(&heap_iterator2,
12491 { MaybeObject* maybe_result = isolate->heap()->AllocateJSObject(
12492 isolate->context()->global_context()->array_function());
12493 if (!maybe_result->ToObject(&result))
return maybe_result;
12502 ASSERT(args.length() == 1);
12507 return Accessors::ObjectPrototype.getter(obj,
NULL);
12513 HandleScope scope(isolate);
12514 ASSERT(args.length() == 2);
12520 Handle<Script> script(
Script::cast(script_wrapper->value()));
12522 int compilation_state =
Smi::cast(script->compilation_state())->value();
12524 script->set_source(*source);
12526 return isolate->heap()->undefined_value();
12531 ASSERT(args.length() == 0);
12533 return isolate->heap()->undefined_value();
12539 HandleScope scope(isolate);
12540 ASSERT(args.length() == 1);
12546 func->code()->PrintLn();
12548 return isolate->heap()->undefined_value();
12554 HandleScope scope(isolate);
12555 ASSERT(args.length() == 1);
12561 func->shared()->construct_stub()->PrintLn();
12563 return isolate->heap()->undefined_value();
12568 NoHandleAllocation ha;
12569 ASSERT(args.length() == 1);
12572 return f->shared()->inferred_name();
12576 static int FindSharedFunctionInfosForScript(HeapIterator* iterator,
12578 FixedArray* buffer) {
12579 AssertNoAllocation no_allocations;
12581 int buffer_size = buffer->length();
12582 for (HeapObject* obj = iterator->next();
12584 obj = iterator->next()) {
12586 if (!obj->IsSharedFunctionInfo()) {
12590 if (shared->script() != script) {
12593 if (counter < buffer_size) {
12594 buffer->set(counter, shared);
12605 Runtime_LiveEditFindSharedFunctionInfosForScript) {
12606 ASSERT(args.length() == 1);
12607 HandleScope scope(isolate);
12611 Handle<Script> script = Handle<Script>(
Script::cast(script_value->value()));
12613 const int kBufferSize = 32;
12615 Handle<FixedArray> array;
12616 array = isolate->factory()->NewFixedArray(kBufferSize);
12619 isolate->heap()->EnsureHeapIsIterable();
12620 AssertNoAllocation no_allocations;
12621 HeapIterator heap_iterator;
12622 Script* scr = *script;
12623 FixedArray* arr = *array;
12624 number = FindSharedFunctionInfosForScript(&heap_iterator, scr, arr);
12626 if (number > kBufferSize) {
12627 array = isolate->factory()->NewFixedArray(number);
12628 isolate->heap()->EnsureHeapIsIterable();
12629 AssertNoAllocation no_allocations;
12630 HeapIterator heap_iterator;
12631 Script* scr = *script;
12632 FixedArray* arr = *array;
12633 FindSharedFunctionInfosForScript(&heap_iterator, scr, arr);
12636 Handle<JSArray> result = isolate->factory()->NewJSArrayWithElements(array);
12639 LiveEdit::WrapSharedFunctionInfos(result);
12652 ASSERT(args.length() == 2);
12653 HandleScope scope(isolate);
12656 Handle<Script> script_handle = Handle<Script>(
Script::cast(script->value()));
12658 JSArray* result = LiveEdit::GatherCompileInfo(script_handle, source);
12660 if (isolate->has_pending_exception()) {
12671 ASSERT(args.length() == 3);
12672 HandleScope scope(isolate);
12675 Handle<Object> old_script_name(args[2], isolate);
12678 Handle<Script> original_script(
Script::cast(original_script_value->value()));
12680 Object* old_script = LiveEdit::ChangeScriptSource(original_script,
12684 if (old_script->IsScript()) {
12685 Handle<Script> script_handle(
Script::cast(old_script));
12688 return isolate->heap()->null_value();
12694 ASSERT(args.length() == 1);
12695 HandleScope scope(isolate);
12697 return LiveEdit::FunctionSourceUpdated(shared_info);
12703 ASSERT(args.length() == 2);
12704 HandleScope scope(isolate);
12708 return LiveEdit::ReplaceFunctionCode(new_compile_info, shared_info);
12713 ASSERT(args.length() == 2);
12714 HandleScope scope(isolate);
12715 Handle<Object> function_object(args[0], isolate);
12716 Handle<Object> script_object(args[1], isolate);
12718 if (function_object->IsJSValue()) {
12720 if (script_object->IsJSValue()) {
12723 script_object = Handle<Object>(script, isolate);
12726 LiveEdit::SetFunctionScript(function_wrapper, script_object);
12732 return isolate->heap()->undefined_value();
12738 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditReplaceRefToNestedFunction) {
12739 ASSERT(args.length() == 3);
12740 HandleScope scope(isolate);
12746 LiveEdit::ReplaceRefToNestedFunction(parent_wrapper, orig_wrapper,
12749 return isolate->heap()->undefined_value();
12759 ASSERT(args.length() == 2);
12760 HandleScope scope(isolate);
12764 return LiveEdit::PatchFunctionPositions(shared_array, position_change_array);
12773 ASSERT(args.length() == 2);
12774 HandleScope scope(isolate);
12778 return *LiveEdit::CheckAndDropActivations(shared_array, do_drop,
12786 ASSERT(args.length() == 2);
12787 HandleScope scope(isolate);
12791 return *LiveEdit::CompareStrings(
s1,
s2);
12797 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFunctionCodePositionFromSource) {
12798 ASSERT(args.length() == 2);
12799 HandleScope scope(isolate);
12803 Handle<Code> code(function->code(), isolate);
12807 return isolate->heap()->undefined_value();
12810 RelocIterator it(*code, RelocInfo::ModeMask(RelocInfo::STATEMENT_POSITION));
12811 int closest_pc = 0;
12813 while (!it.done()) {
12814 int statement_position =
static_cast<int>(it.rinfo()->data());
12816 if (source_position <= statement_position &&
12817 statement_position - source_position < distance) {
12819 static_cast<int>(it.rinfo()->pc() - code->instruction_start());
12820 distance = statement_position - source_position;
12822 if (distance == 0)
break;
12835 ASSERT(args.length() == 2);
12836 HandleScope scope(isolate);
12840 Handle<Object> result;
12841 bool pending_exception;
12843 if (without_debugger) {
12845 &pending_exception);
12847 EnterDebugger enter_debugger;
12849 &pending_exception);
12852 if (!pending_exception) {
12863 SmartArrayPointer<char> flags =
12865 FlagList::SetFlagsFromString(*flags,
StrLength(*flags));
12866 return isolate->heap()->undefined_value();
12874 return isolate->heap()->undefined_value();
12880 int usage =
static_cast<int>(isolate->heap()->SizeOfObjects());
12882 return *isolate->factory()->NewNumberFromInt(usage);
12890 #ifdef LIVE_OBJECT_LIST
12891 return isolate->heap()->true_value();
12893 return isolate->heap()->false_value();
12900 #ifdef LIVE_OBJECT_LIST
12903 return isolate->heap()->undefined_value();
12910 #ifdef LIVE_OBJECT_LIST
12913 return isolate->heap()->ToBoolean(success);
12915 return isolate->heap()->undefined_value();
12926 #ifdef LIVE_OBJECT_LIST
12933 EnterDebugger enter_debugger;
12936 return isolate->heap()->undefined_value();
12944 #ifdef LIVE_OBJECT_LIST
12949 return isolate->heap()->undefined_value();
12957 #ifdef LIVE_OBJECT_LIST
12963 return isolate->heap()->undefined_value();
12970 #ifdef LIVE_OBJECT_LIST
12973 RUNTIME_ASSERT(args[1]->IsUndefined() || args[1]->IsJSObject());
12979 Handle<JSObject> instance_filter;
12980 if (args[1]->IsJSObject()) {
12981 instance_filter = args.at<JSObject>(1);
12983 bool verbose =
false;
12984 if (args[2]->IsBoolean()) {
12985 verbose = args[2]->IsTrue();
12988 if (args[3]->IsSmi()) {
12989 start = args.smi_at(3);
12992 if (args[4]->IsSmi()) {
12993 limit = args.smi_at(4);
13003 return isolate->heap()->undefined_value();
13010 #ifdef LIVE_OBJECT_LIST
13014 RUNTIME_ASSERT(args[2]->IsUndefined() || args[2]->IsJSObject());
13016 Handle<JSObject> instance_filter;
13017 if (args[2]->IsJSObject()) {
13018 instance_filter = args.at<JSObject>(2);
13025 return isolate->heap()->undefined_value();
13033 #ifdef LIVE_OBJECT_LIST
13038 return isolate->heap()->undefined_value();
13046 #ifdef LIVE_OBJECT_LIST
13052 return isolate->heap()->undefined_value();
13059 #ifdef LIVE_OBJECT_LIST
13061 return isolate->heap()->undefined_value();
13063 return isolate->heap()->undefined_value();
13074 #ifdef LIVE_OBJECT_LIST
13080 EnterDebugger enter_debugger;
13083 return isolate->heap()->undefined_value();
13087 #endif // ENABLE_DEBUGGER_SUPPORT
13091 NoHandleAllocation ha;
13093 return isolate->heap()->undefined_value();
13098 NoHandleAllocation ha;
13100 return isolate->heap()->undefined_value();
13116 AssertNoAllocation no_allocation_during_heap_iteration;
13117 HeapIterator iterator;
13118 HeapObject* obj =
NULL;
13119 while (script.is_null() && ((obj = iterator.next()) !=
NULL)) {
13121 if (obj->IsScript()) {
13131 if (script.is_null())
return FACTORY->undefined_value();
13144 ASSERT(args.length() == 1);
13161 static bool ShowFrameInStackTrace(
StackFrame* raw_frame,
13163 bool* seen_caller) {
13165 if (!raw_frame->is_java_script()) {
13169 Object* raw_fun = frame->function();
13171 if (!raw_fun->IsJSFunction()) {
13174 if ((raw_fun == caller) && !(*seen_caller)) {
13175 *seen_caller =
true;
13179 if (!(*seen_caller))
return false;
13185 if (!FLAG_builtins_in_stack_traces) {
13187 if (frame->receiver()->IsJSBuiltinsObject() ||
13188 (fun->IsBuiltin() && !fun->shared()->native())) {
13206 Factory* factory = isolate->factory();
13208 limit =
Max(limit, 0);
13209 int initial_size =
Min(limit, 10);
13213 StackFrameIterator iter(isolate);
13216 bool seen_caller = !caller->IsJSFunction();
13218 int frames_seen = 0;
13219 while (!iter.done() && frames_seen < limit) {
13221 if (ShowFrameInStackTrace(raw_frame, *caller, &seen_caller)) {
13228 for (
int i = frames.length() - 1; i >= 0; i--) {
13229 if (cursor + 4 > elements->length()) {
13233 for (
int i = 0; i < cursor; i++) {
13234 new_elements->set(i, elements->get(i));
13236 elements = new_elements;
13238 ASSERT(cursor + 4 <= elements->length());
13244 elements->set(cursor++, *recv);
13245 elements->set(cursor++, *fun);
13246 elements->set(cursor++, *code);
13247 elements->set(cursor++, *offset);
13254 isolate->CaptureAndSetCurrentStackTraceFor(error_object);
13264 NoHandleAllocation ha;
13268 return isolate->heap()->AllocateStringFromAscii(
CStrVector(version_string),
13274 ASSERT(args.length() == 2);
13276 reinterpret_cast<char*>(args[0]) + args.smi_at(1));
13277 isolate->PrintStack();
13289 int finger_index = cache->finger_index();
13290 Object* o = cache->get(finger_index);
13293 return cache->get(finger_index + 1);
13296 for (
int i = finger_index - 2;
13301 cache->set_finger_index(i);
13302 return cache->get(i + 1);
13306 int size = cache->size();
13307 ASSERT(size <= cache->length());
13309 for (
int i = size - 2; i > finger_index; i -= 2) {
13312 cache->set_finger_index(i);
13313 return cache->get(i + 1);
13330 bool pending_exception;
13335 &pending_exception);
13340 if (FLAG_verify_heap) {
13341 cache_handle->JSFunctionResultCacheVerify();
13346 finger_index = cache_handle->finger_index();
13347 size = cache_handle->size();
13352 if (size < cache_handle->length()) {
13357 if (index == cache_handle->length()) {
13364 ASSERT(index < cache_handle->length());
13366 cache_handle->set(index, *key_handle);
13367 cache_handle->set(index + 1, *value);
13368 cache_handle->set_finger_index(index);
13371 if (FLAG_verify_heap) {
13372 cache_handle->JSFunctionResultCacheVerify();
13384 return *isolate->factory()->NewJSMessageObject(
13389 isolate->factory()->undefined_value(),
13390 isolate->factory()->undefined_value(),
13391 isolate->factory()->undefined_value());
13397 return message->type();
13403 return message->arguments();
13415 return message->script();
13423 ASSERT(args.length() == 0);
13425 #define COUNT_ENTRY(Name, argc, ressize) + 1
13426 int entry_count = 0
13431 Factory* factory = isolate->factory();
13434 bool inline_runtime_functions =
false;
13435 #define ADD_ENTRY(Name, argc, ressize) \
13437 HandleScope inner; \
13438 Handle<String> name; \
13440 if (inline_runtime_functions) { \
13441 name = factory->NewStringFromAscii( \
13442 Vector<const char>("_" #Name, StrLength("_" #Name))); \
13444 name = factory->NewStringFromAscii( \
13445 Vector<const char>(#Name, StrLength(#Name))); \
13447 Handle<FixedArray> pair_elements = factory->NewFixedArray(2); \
13448 pair_elements->set(0, *name); \
13449 pair_elements->set(1, Smi::FromInt(argc)); \
13450 Handle<JSArray> pair = factory->NewJSArrayWithElements(pair_elements); \
13451 elements->set(index++, *pair); \
13453 inline_runtime_functions =
false;
13455 inline_runtime_functions =
true;
13467 ASSERT(args.length() == 2);
13473 LOGGER->LogRuntime(chars, elms);
13474 return isolate->heap()->undefined_value();
13484 #define ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(Name) \
13485 RUNTIME_FUNCTION(MaybeObject*, Runtime_Has##Name) { \
13486 CONVERT_ARG_CHECKED(JSObject, obj, 0); \
13487 return isolate->heap()->ToBoolean(obj->Has##Name()); \
13509 #undef ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION
13513 ASSERT(args.length() == 2);
13516 return isolate->heap()->ToBoolean(obj1->map() == obj2->map());
13522 #define F(name, number_of_args, result_size) \
13523 { Runtime::k##name, Runtime::RUNTIME, #name, \
13524 FUNCTION_ADDR(Runtime_##name), number_of_args, result_size },
13527 #define I(name, number_of_args, result_size) \
13528 { Runtime::kInline##name, Runtime::INLINE, \
13529 "_" #name, NULL, number_of_args, result_size },
13531 static const Runtime::Function kIntrinsicFunctions[] = {
13540 ASSERT(Isolate::Current()->heap() == heap);
13545 { MaybeObject* maybe_name_symbol =
13547 if (!maybe_name_symbol->ToObject(&name_symbol))
return maybe_name_symbol;
13550 { MaybeObject* maybe_dictionary = string_dictionary->
Add(
13554 if (!maybe_dictionary->ToObject(&dictionary)) {
13557 return maybe_dictionary;
13566 Heap* heap = name->GetHeap();
13567 int entry = heap->intrinsic_function_names()->FindEntry(*name);
13569 Object* smi_index = heap->intrinsic_function_names()->ValueAt(entry);
13571 return &(kIntrinsicFunctions[function_index]);
13578 return &(kIntrinsicFunctions[
static_cast<int>(id)]);
13583 Isolate* isolate = Isolate::Current();
13585 if (failure->IsRetryAfterGC()) {
13593 "Runtime::PerformGC");
13597 isolate->
counters()->gc_last_resort_from_js()->Increment();
13599 "Runtime::PerformGC");
static bool IsBlack(MarkBit mark_bit)
MaybeObject * AllocateRawString< SeqAsciiString >(Isolate *isolate, int length)
static Object * FindSharedFunctionInfoInScript(Isolate *isolate, Handle< Script > script, int position)
#define INLINE_FUNCTION_LIST(F)
void ClearTypeFeedbackCells(Heap *heap)
static Handle< Object > New(Handle< JSFunction > func, int argc, Handle< Object > argv[], bool *pending_exception)
STATIC_CHECK((kStringRepresentationMask|kStringEncodingMask)==Internals::kFullStringRepresentationMask)
static Handle< Object > SetProperty(Handle< JSReceiver > object, Handle< String > key, Handle< Object > value, PropertyAttributes attributes, StrictModeFlag strict_mode)
static const int kMaxLength
void Destroy(Object **location)
void FlattenString(Handle< String > string)
static bool CompileLazy(Handle< JSFunction > function, ClearExceptionFlag flag)
Handle< JSObject > NewJSObject(Handle< JSFunction > constructor, PretenureFlag pretenure=NOT_TENURED)
Object * function() const
static const int kNotFound
FixedArray * function_bindings()
static Object *& Object_at(Address addr)
static const int kMaxAsciiCharCode
static const int kNotFound
#define CONVERT_SMI_ARG_CHECKED(name, index)
static const int kGlobalFieldIndex
void set(int index, Object *value)
bool is_hidden_prototype()
#define CONVERT_DOUBLE_ARG_CHECKED(name, index)
static const Function * FunctionForSymbol(Handle< String > name)
void PrintF(const char *format,...)
static Object * GetObjId(Handle< String > address)
Handle< JSArray > GetParts()
static String * cast(Object *obj)
MUST_USE_RESULT MaybeObject * Add(Key key, Object *value, PropertyDetails details)
int64_t ToUTC(int64_t time_ms)
static bool UseCrankshaft()
uint32_t NumberToUint32(Object *number)
static DescriptorArray * cast(Object *obj)
Object * ToBoolean(bool condition)
double DoubleToInteger(double x)
static void PerformGC(Object *result)
void set_length(Smi *length)
void Compile(Handle< String > replacement, int capture_count, int subject_length)
Handle< FixedArray > NewFixedArrayWithHoles(int size, PretenureFlag pretenure=NOT_TENURED)
static uint32_t encode(T value)
static Smi * FromInt(int value)
bool IsFastObjectElementsKind(ElementsKind kind)
Handle< String > NewSubString(Handle< String > str, int begin, int end)
v8::Handle< v8::Array > GetKeysForIndexedInterceptor(Handle< JSReceiver > receiver, Handle< JSObject > object)
MUST_USE_RESULT MaybeObject * AllocateJSFunctionProxy(Object *handler, Object *call_trap, Object *construct_trap, Object *prototype)
Handle< SeqAsciiString > NewRawAsciiString(int length, PretenureFlag pretenure=NOT_TENURED)
Handle< ObjectHashTable > NewObjectHashTable(int at_least_space_for)
void ReportFailedAccessCheck(JSObject *receiver, v8::AccessType type)
static void RevertStackCheckCode(Code *unoptimized_code, Code *check_code, Code *replacement_code)
bool HasRealNamedProperty(String *key)
int isless(double x, double y)
MUST_USE_RESULT MaybeObject * CopyInsert(Descriptor *descriptor, TransitionFlag transition_flag)
void CollectAllGarbage(int flags, const char *gc_reason=NULL)
Handle< JSArray > NewJSArray(int capacity, ElementsKind elements_kind=TERMINAL_FAST_ELEMENTS_KIND, PretenureFlag pretenure=NOT_TENURED)
value format" "after each garbage collection") DEFINE_bool(print_cumulative_gc_stat, false, "print cumulative GC statistics in name=value format on exit") DEFINE_bool(trace_gc_verbose, false, "print more details following each garbage collection") DEFINE_bool(trace_fragmentation, false, "report fragmentation for old pointer and data pages") DEFINE_bool(collect_maps, true, "garbage collect maps from which no objects can be reached") DEFINE_bool(flush_code, true, "flush code that we expect not to use again before full gc") DEFINE_bool(incremental_marking, true, "use incremental marking") DEFINE_bool(incremental_marking_steps, true, "do incremental marking steps") DEFINE_bool(trace_incremental_marking, false, "trace progress of the incremental marking") DEFINE_bool(use_idle_notification, true, "Use idle notification to reduce memory footprint.") DEFINE_bool(send_idle_notification, false, "Send idle notifcation between stress runs.") DEFINE_bool(use_ic, true, "use inline caching") DEFINE_bool(native_code_counters, false, "generate extra code for manipulating stats counters") DEFINE_bool(always_compact, false, "Perform compaction on every full GC") DEFINE_bool(lazy_sweeping, true, "Use lazy sweeping for old pointer and data spaces") DEFINE_bool(never_compact, false, "Never perform compaction on full GC-testing only") DEFINE_bool(compact_code_space, true, "Compact code space on full non-incremental collections") DEFINE_bool(cleanup_code_caches_at_gc, true, "Flush inline caches prior to mark compact collection and" "flush code caches in maps during mark compact cycle.") DEFINE_int(random_seed, 0, "Default seed for initializing random generator" "(0, the default, means to use system random).") DEFINE_bool(use_verbose_printer, true, "allows verbose printing") DEFINE_bool(allow_natives_syntax, false, "allow natives syntax") DEFINE_bool(trace_sim, false, "Trace simulator execution") DEFINE_bool(check_icache, false, "Check icache flushes in ARM and MIPS simulator") DEFINE_int(stop_sim_at, 0, "Simulator stop after x number of instructions") DEFINE_int(sim_stack_alignment, 8, "Stack alingment in bytes in simulator(4 or 8, 8 is default)") DEFINE_bool(trace_exception, false, "print stack trace when throwing exceptions") DEFINE_bool(preallocate_message_memory, false, "preallocate some memory to build stack traces.") DEFINE_bool(randomize_hashes, true, "randomize hashes to avoid predictable hash collisions" "(with snapshots this option cannot override the baked-in seed)") DEFINE_int(hash_seed, 0, "Fixed seed to use to hash property keys(0 means random)" "(with snapshots this option cannot override the baked-in seed)") DEFINE_bool(preemption, false, "activate a 100ms timer that switches between V8 threads") DEFINE_bool(regexp_optimization, true, "generate optimized regexp code") DEFINE_bool(testing_bool_flag, true, "testing_bool_flag") DEFINE_int(testing_int_flag, 13, "testing_int_flag") DEFINE_float(testing_float_flag, 2.5, "float-flag") DEFINE_string(testing_string_flag, "Hello, world!", "string-flag") DEFINE_int(testing_prng_seed, 42, "Seed used for threading test randomness") DEFINE_string(testing_serialization_file, "/tmp/serdes", "file in which to serialize heap") DEFINE_bool(help, false, "Print usage message, including flags, on console") DEFINE_bool(dump_counters, false, "Dump counters on exit") DEFINE_string(map_counters, "", "Map counters to a file") DEFINE_args(js_arguments, JSARGUMENTS_INIT, "Pass all remaining arguments to the script.Alias for\"--\".") DEFINE_bool(debug_compile_events, true,"Enable debugger compile events") DEFINE_bool(debug_script_collected_events, true,"Enable debugger script collected events") DEFINE_bool(gdbjit, false,"enable GDBJIT interface (disables compacting GC)") DEFINE_bool(gdbjit_full, false,"enable GDBJIT interface for all code objects") DEFINE_bool(gdbjit_dump, false,"dump elf objects with debug info to disk") DEFINE_string(gdbjit_dump_filter,"","dump only objects containing this substring") DEFINE_bool(force_marking_deque_overflows, false,"force overflows of marking deque by reducing it's size ""to 64 words") DEFINE_bool(stress_compaction, false,"stress the GC compactor to flush out bugs (implies ""--force_marking_deque_overflows)")#define FLAG DEFINE_bool(enable_slow_asserts, false,"enable asserts that are slow to execute") DEFINE_bool(trace_codegen, false,"print name of functions for which code is generated") DEFINE_bool(print_source, false,"pretty print source code") DEFINE_bool(print_builtin_source, false,"pretty print source code for builtins") DEFINE_bool(print_ast, false,"print source AST") DEFINE_bool(print_builtin_ast, false,"print source AST for builtins") DEFINE_string(stop_at,"","function name where to insert a breakpoint") DEFINE_bool(print_builtin_scopes, false,"print scopes for builtins") DEFINE_bool(print_scopes, false,"print scopes") DEFINE_bool(trace_contexts, false,"trace contexts operations") DEFINE_bool(gc_greedy, false,"perform GC prior to some allocations") DEFINE_bool(gc_verbose, false,"print stuff during garbage collection") DEFINE_bool(heap_stats, false,"report heap statistics before and after GC") DEFINE_bool(code_stats, false,"report code statistics after GC") DEFINE_bool(verify_heap, false,"verify heap pointers before and after GC") DEFINE_bool(print_handles, false,"report handles after GC") DEFINE_bool(print_global_handles, false,"report global handles after GC") DEFINE_bool(trace_ic, false,"trace inline cache state transitions") DEFINE_bool(print_interfaces, false,"print interfaces") DEFINE_bool(print_interface_details, false,"print interface inference details") DEFINE_int(print_interface_depth, 5,"depth for printing interfaces") DEFINE_bool(trace_normalization, false,"prints when objects are turned into dictionaries.") DEFINE_bool(trace_lazy, false,"trace lazy compilation") DEFINE_bool(collect_heap_spill_statistics, false,"report heap spill statistics along with heap_stats ""(requires heap_stats)") DEFINE_bool(trace_isolates, false,"trace isolate state changes") DEFINE_bool(log_state_changes, false,"Log state changes.") DEFINE_bool(regexp_possessive_quantifier, false,"enable possessive quantifier syntax for testing") DEFINE_bool(trace_regexp_bytecodes, false,"trace regexp bytecode execution") DEFINE_bool(trace_regexp_assembler, false,"trace regexp macro assembler calls.")#define FLAG DEFINE_bool(log, false,"Minimal logging (no API, code, GC, suspect, or handles samples).") DEFINE_bool(log_all, false,"Log all events to the log file.") DEFINE_bool(log_runtime, false,"Activate runtime system %Log call.") DEFINE_bool(log_api, false,"Log API events to the log file.") DEFINE_bool(log_code, false,"Log code events to the log file without profiling.") DEFINE_bool(log_gc, false,"Log heap samples on garbage collection for the hp2ps tool.") DEFINE_bool(log_handles, false,"Log global handle events.") DEFINE_bool(log_snapshot_positions, false,"log positions of (de)serialized objects in the snapshot.") DEFINE_bool(log_suspect, false,"Log suspect operations.") DEFINE_bool(prof, false,"Log statistical profiling information (implies --log-code).") DEFINE_bool(prof_auto, true,"Used with --prof, starts profiling automatically") DEFINE_bool(prof_lazy, false,"Used with --prof, only does sampling and logging"" when profiler is active (implies --noprof_auto).") DEFINE_bool(prof_browser_mode, true,"Used with --prof, turns on browser-compatible mode for profiling.") DEFINE_bool(log_regexp, false,"Log regular expression execution.") DEFINE_bool(sliding_state_window, false,"Update sliding state window counters.") DEFINE_string(logfile,"v8.log","Specify the name of the log file.") DEFINE_bool(ll_prof, false,"Enable low-level linux profiler.")#define FLAG DEFINE_bool(trace_elements_transitions, false,"trace elements transitions") DEFINE_bool(print_code_stubs, false,"print code stubs") DEFINE_bool(test_secondary_stub_cache, false,"test secondary stub cache by disabling the primary one") DEFINE_bool(test_primary_stub_cache, false,"test primary stub cache by disabling the secondary one") DEFINE_bool(print_code, false,"print generated code") DEFINE_bool(print_opt_code, false,"print optimized code") DEFINE_bool(print_unopt_code, false,"print unoptimized code before ""printing optimized code based on it") DEFINE_bool(print_code_verbose, false,"print more information for code") DEFINE_bool(print_builtin_code, false,"print generated code for builtins")#43"/Users/thlorenz/dev/dx/v8-perf/build/v8/src/flags.cc"2#define FLAG_MODE_DEFINE_DEFAULTS#1"/Users/thlorenz/dev/dx/v8-perf/build/v8/src/flag-definitions.h"1#define FLAG_FULL(ftype, ctype, nam, def, cmt)#define FLAG_READONLY(ftype, ctype, nam, def, cmt)#define DEFINE_implication(whenflag, thenflag)#define DEFINE_bool(nam, def, cmt)#define DEFINE_int(nam, def, cmt)#define DEFINE_float(nam, def, cmt)#define DEFINE_string(nam, def, cmt)#define DEFINE_args(nam, def, cmt)#define FLAG DEFINE_bool(use_strict, false,"enforce strict mode") DEFINE_bool(es5_readonly, false,"activate correct semantics for inheriting readonliness") DEFINE_bool(es52_globals, false,"activate new semantics for global var declarations") DEFINE_bool(harmony_typeof, false,"enable harmony semantics for typeof") DEFINE_bool(harmony_scoping, false,"enable harmony block scoping") DEFINE_bool(harmony_modules, false,"enable harmony modules (implies block scoping)") DEFINE_bool(harmony_proxies, false,"enable harmony proxies") DEFINE_bool(harmony_collections, false,"enable harmony collections (sets, maps, and weak maps)") DEFINE_bool(harmony, false,"enable all harmony features (except typeof)") DEFINE_implication(harmony, harmony_scoping) DEFINE_implication(harmony, harmony_modules) DEFINE_implication(harmony, harmony_proxies) DEFINE_implication(harmony, harmony_collections) DEFINE_implication(harmony_modules, harmony_scoping) DEFINE_bool(packed_arrays, false,"optimizes arrays that have no holes") DEFINE_bool(smi_only_arrays, true,"tracks arrays with only smi values") DEFINE_bool(clever_optimizations, true,"Optimize object size, Array shift, DOM strings and string +") DEFINE_bool(unbox_double_arrays, true,"automatically unbox arrays of doubles") DEFINE_bool(string_slices, true,"use string slices") DEFINE_bool(crankshaft, true,"use crankshaft") DEFINE_string(hydrogen_filter,"","optimization filter") DEFINE_bool(use_range, true,"use hydrogen range analysis") DEFINE_bool(eliminate_dead_phis, true,"eliminate dead phis") DEFINE_bool(use_gvn, true,"use hydrogen global value numbering") DEFINE_bool(use_canonicalizing, true,"use hydrogen instruction canonicalizing") DEFINE_bool(use_inlining, true,"use function inlining") DEFINE_int(max_inlined_source_size, 600,"maximum source size in bytes considered for a single inlining") DEFINE_int(max_inlined_nodes, 196,"maximum number of AST nodes considered for a single inlining") DEFINE_int(max_inlined_nodes_cumulative, 196,"maximum cumulative number of AST nodes considered for inlining") DEFINE_bool(loop_invariant_code_motion, true,"loop invariant code motion") DEFINE_bool(collect_megamorphic_maps_from_stub_cache, true,"crankshaft harvests type feedback from stub cache") DEFINE_bool(hydrogen_stats, false,"print statistics for hydrogen") DEFINE_bool(trace_hydrogen, false,"trace generated hydrogen to file") DEFINE_string(trace_phase,"Z","trace generated IR for specified phases") DEFINE_bool(trace_inlining, false,"trace inlining decisions") DEFINE_bool(trace_alloc, false,"trace register allocator") DEFINE_bool(trace_all_uses, false,"trace all use positions") DEFINE_bool(trace_range, false,"trace range analysis") DEFINE_bool(trace_gvn, false,"trace global value numbering") DEFINE_bool(trace_representation, false,"trace representation types") DEFINE_bool(stress_pointer_maps, false,"pointer map for every instruction") DEFINE_bool(stress_environments, false,"environment for every instruction") DEFINE_int(deopt_every_n_times, 0,"deoptimize every n times a deopt point is passed") DEFINE_bool(trap_on_deopt, false,"put a break point before deoptimizing") DEFINE_bool(deoptimize_uncommon_cases, true,"deoptimize uncommon cases") DEFINE_bool(polymorphic_inlining, true,"polymorphic inlining") DEFINE_bool(use_osr, true,"use on-stack replacement") DEFINE_bool(array_bounds_checks_elimination, false,"perform array bounds checks elimination") DEFINE_bool(array_index_dehoisting, false,"perform array index dehoisting") DEFINE_bool(trace_osr, false,"trace on-stack replacement") DEFINE_int(stress_runs, 0,"number of stress runs") DEFINE_bool(optimize_closures, true,"optimize closures") DEFINE_bool(inline_construct, true,"inline constructor calls") DEFINE_bool(inline_arguments, true,"inline functions with arguments object") DEFINE_int(loop_weight, 1,"loop weight for representation inference") DEFINE_bool(optimize_for_in, true,"optimize functions containing for-in loops") DEFINE_bool(experimental_profiler, true,"enable all profiler experiments") DEFINE_bool(watch_ic_patching, false,"profiler considers IC stability") DEFINE_int(frame_count, 1,"number of stack frames inspected by the profiler") DEFINE_bool(self_optimization, false,"primitive functions trigger their own optimization") DEFINE_bool(direct_self_opt, false,"call recompile stub directly when self-optimizing") DEFINE_bool(retry_self_opt, false,"re-try self-optimization if it failed") DEFINE_bool(count_based_interrupts, false,"trigger profiler ticks based on counting instead of timing") DEFINE_bool(interrupt_at_exit, false,"insert an interrupt check at function exit") DEFINE_bool(weighted_back_edges, false,"weight back edges by jump distance for interrupt triggering") DEFINE_int(interrupt_budget, 5900,"execution budget before interrupt is triggered") DEFINE_int(type_info_threshold, 15,"percentage of ICs that must have type info to allow optimization") DEFINE_int(self_opt_count, 130,"call count before self-optimization") DEFINE_implication(experimental_profiler, watch_ic_patching) DEFINE_implication(experimental_profiler, self_optimization) DEFINE_implication(experimental_profiler, retry_self_opt) DEFINE_implication(experimental_profiler, count_based_interrupts) DEFINE_implication(experimental_profiler, interrupt_at_exit) DEFINE_implication(experimental_profiler, weighted_back_edges) DEFINE_bool(trace_opt_verbose, false,"extra verbose compilation tracing") DEFINE_implication(trace_opt_verbose, trace_opt) DEFINE_bool(debug_code, false,"generate extra code (assertions) for debugging") DEFINE_bool(code_comments, false,"emit comments in code disassembly") DEFINE_bool(enable_sse2, true,"enable use of SSE2 instructions if available") DEFINE_bool(enable_sse3, true,"enable use of SSE3 instructions if available") DEFINE_bool(enable_sse4_1, true,"enable use of SSE4.1 instructions if available") DEFINE_bool(enable_cmov, true,"enable use of CMOV instruction if available") DEFINE_bool(enable_rdtsc, true,"enable use of RDTSC instruction if available") DEFINE_bool(enable_sahf, true,"enable use of SAHF instruction if available (X64 only)") DEFINE_bool(enable_vfp3, true,"enable use of VFP3 instructions if available - this implies ""enabling ARMv7 instructions (ARM only)") DEFINE_bool(enable_armv7, true,"enable use of ARMv7 instructions if available (ARM only)") DEFINE_bool(enable_fpu, true,"enable use of MIPS FPU instructions if available (MIPS only)") DEFINE_string(expose_natives_as, NULL,"expose natives in global object") DEFINE_string(expose_debug_as, NULL,"expose debug in global object") DEFINE_bool(expose_gc, false,"expose gc extension") DEFINE_bool(expose_externalize_string, false,"expose externalize string extension") DEFINE_int(stack_trace_limit, 10,"number of stack frames to capture") DEFINE_bool(builtins_in_stack_traces, false,"show built-in functions in stack traces") DEFINE_bool(disable_native_files, false,"disable builtin natives files") DEFINE_bool(inline_new, true,"use fast inline allocation") DEFINE_bool(stack_trace_on_abort, true,"print a stack trace if an assertion failure occurs") DEFINE_bool(trace, false,"trace function calls") DEFINE_bool(mask_constants_with_cookie, true,"use random jit cookie to mask large constants") DEFINE_bool(lazy, true,"use lazy compilation") DEFINE_bool(trace_opt, false,"trace lazy optimization") DEFINE_bool(trace_opt_stats, false,"trace lazy optimization statistics") DEFINE_bool(opt, true,"use adaptive optimizations") DEFINE_bool(always_opt, false,"always try to optimize functions") DEFINE_bool(prepare_always_opt, false,"prepare for turning on always opt") DEFINE_bool(trace_deopt, false,"trace deoptimization") DEFINE_int(min_preparse_length, 1024,"minimum length for automatic enable preparsing") DEFINE_bool(always_full_compiler, false,"try to use the dedicated run-once backend for all code") DEFINE_bool(trace_bailout, false,"print reasons for falling back to using the classic V8 backend") DEFINE_bool(compilation_cache, true,"enable compilation cache") DEFINE_bool(cache_prototype_transitions, true,"cache prototype transitions") DEFINE_bool(trace_debug_json, false,"trace debugging JSON request/response") DEFINE_bool(debugger_auto_break, true,"automatically set the debug break flag when debugger commands are ""in the queue") DEFINE_bool(enable_liveedit, true,"enable liveedit experimental feature") DEFINE_bool(break_on_abort, true,"always cause a debug break before aborting") DEFINE_int(stack_size, kPointerSize *123,"default size of stack region v8 is allowed to use (in kBytes)") DEFINE_int(max_stack_trace_source_length, 300,"maximum length of function source code printed in a stack trace.") DEFINE_bool(always_inline_smi_code, false,"always inline smi code in non-opt code") DEFINE_int(max_new_space_size, 0,"max size of the new generation (in kBytes)") DEFINE_int(max_old_space_size, 0,"max size of the old generation (in Mbytes)") DEFINE_int(max_executable_size, 0,"max size of executable memory (in Mbytes)") DEFINE_bool(gc_global, false,"always perform global GCs") DEFINE_int(gc_interval,-1,"garbage collect after <n> allocations") DEFINE_bool(trace_gc, false,"print one trace line following each garbage collection") DEFINE_bool(trace_gc_nvp, false,"print one detailed trace line in name=value format ""after each garbage collection") DEFINE_bool(print_cumulative_gc_stat, false,"print cumulative GC statistics in name=value format on exit") DEFINE_bool(trace_gc_verbose, false,"print more details following each garbage collection") DEFINE_bool(trace_fragmentation, false,"report fragmentation for old pointer and data pages") DEFINE_bool(collect_maps, true,"garbage collect maps from which no objects can be reached") DEFINE_bool(flush_code, true,"flush code that we expect not to use again before full gc") DEFINE_bool(incremental_marking, true,"use incremental marking") DEFINE_bool(incremental_marking_steps, true,"do incremental marking steps") DEFINE_bool(trace_incremental_marking, false,"trace progress of the incremental marking") DEFINE_bool(use_idle_notification, true,"Use idle notification to reduce memory footprint.") DEFINE_bool(send_idle_notification, false,"Send idle notifcation between stress runs.") DEFINE_bool(use_ic, true,"use inline caching") DEFINE_bool(native_code_counters, false,"generate extra code for manipulating stats counters") DEFINE_bool(always_compact, false,"Perform compaction on every full GC") DEFINE_bool(lazy_sweeping, true,"Use lazy sweeping for old pointer and data spaces") DEFINE_bool(never_compact, false,"Never perform compaction on full GC - testing only") DEFINE_bool(compact_code_space, true,"Compact code space on full non-incremental collections") DEFINE_bool(cleanup_code_caches_at_gc, true,"Flush inline caches prior to mark compact collection and ""flush code caches in maps during mark compact cycle.") DEFINE_int(random_seed, 0,"Default seed for initializing random generator ""(0, the default, means to use system random).") DEFINE_bool(use_verbose_printer, true,"allows verbose printing") DEFINE_bool(allow_natives_syntax, false,"allow natives syntax") DEFINE_bool(trace_sim, false,"Trace simulator execution") DEFINE_bool(check_icache, false,"Check icache flushes in ARM and MIPS simulator") DEFINE_int(stop_sim_at, 0,"Simulator stop after x number of instructions") DEFINE_int(sim_stack_alignment, 8,"Stack alingment in bytes in simulator (4 or 8, 8 is default)") DEFINE_bool(trace_exception, false,"print stack trace when throwing exceptions") DEFINE_bool(preallocate_message_memory, false,"preallocate some memory to build stack traces.") DEFINE_bool(randomize_hashes, true,"randomize hashes to avoid predictable hash collisions ""(with snapshots this option cannot override the baked-in seed)") DEFINE_int(hash_seed, 0,"Fixed seed to use to hash property keys (0 means random)""(with snapshots this option cannot override the baked-in seed)") DEFINE_bool(preemption, false,"activate a 100ms timer that switches between V8 threads") DEFINE_bool(regexp_optimization, true,"generate optimized regexp code") DEFINE_bool(testing_bool_flag, true,"testing_bool_flag") DEFINE_int(testing_int_flag, 13,"testing_int_flag") DEFINE_float(testing_float_flag, 2.5,"float-flag") DEFINE_string(testing_string_flag,"Hello, world!","string-flag") DEFINE_int(testing_prng_seed, 42,"Seed used for threading test randomness") DEFINE_string(testing_serialization_file,"/tmp/serdes","file in which to serialize heap") DEFINE_bool(help, false,"Print usage message, including flags, on console") DEFINE_bool(dump_counters, false,"Dump counters on exit") DEFINE_string(map_counters,"","Map counters to a file") DEFINE_args(js_arguments, JSARGUMENTS_INIT,"Pass all remaining arguments to the script. Alias for \"--\".") DEFINE_bool(debug_compile_events, true,"Enable debugger compile events") DEFINE_bool(debug_script_collected_events, true,"Enable debugger script collected events") DEFINE_bool(gdbjit, false,"enable GDBJIT interface (disables compacting GC)") DEFINE_bool(gdbjit_full, false,"enable GDBJIT interface for all code objects") DEFINE_bool(gdbjit_dump, false,"dump elf objects with debug info to disk") DEFINE_string(gdbjit_dump_filter,"","dump only objects containing this substring") DEFINE_bool(force_marking_deque_overflows, false,"force overflows of marking deque by reducing it's size ""to 64 words") DEFINE_bool(stress_compaction, false,"stress the GC compactor to flush out bugs (implies ""--force_marking_deque_overflows)")#define FLAG DEFINE_bool(enable_slow_asserts, false,"enable asserts that are slow to execute") DEFINE_bool(trace_codegen, false,"print name of functions for which code is generated") DEFINE_bool(print_source, false,"pretty print source code") DEFINE_bool(print_builtin_source, false,"pretty print source code for builtins") DEFINE_bool(print_ast, false,"print source AST") DEFINE_bool(print_builtin_ast, false,"print source AST for builtins") DEFINE_string(stop_at,"","function name where to insert a breakpoint") DEFINE_bool(print_builtin_scopes, false,"print scopes for builtins") DEFINE_bool(print_scopes, false,"print scopes") DEFINE_bool(trace_contexts, false,"trace contexts operations") DEFINE_bool(gc_greedy, false,"perform GC prior to some allocations") DEFINE_bool(gc_verbose, false,"print stuff during garbage collection") DEFINE_bool(heap_stats, false,"report heap statistics before and after GC") DEFINE_bool(code_stats, false,"report code statistics after GC") DEFINE_bool(verify_heap, false,"verify heap pointers before and after GC") DEFINE_bool(print_handles, false,"report handles after GC") DEFINE_bool(print_global_handles, false,"report global handles after GC") DEFINE_bool(trace_ic, false,"trace inline cache state transitions") DEFINE_bool(print_interfaces, false,"print interfaces") DEFINE_bool(print_interface_details, false,"print interface inference details") DEFINE_int(print_interface_depth, 5,"depth for printing interfaces") DEFINE_bool(trace_normalization, false,"prints when objects are turned into dictionaries.") DEFINE_bool(trace_lazy, false,"trace lazy compilation") DEFINE_bool(collect_heap_spill_statistics, false,"report heap spill statistics along with heap_stats ""(requires heap_stats)") DEFINE_bool(trace_isolates, false,"trace isolate state changes") DEFINE_bool(log_state_changes, false,"Log state changes.") DEFINE_bool(regexp_possessive_quantifier, false,"enable possessive quantifier syntax for testing") DEFINE_bool(trace_regexp_bytecodes, false,"trace regexp bytecode execution") DEFINE_bool(trace_regexp_assembler, false,"trace regexp macro assembler calls.")#define FLAG DEFINE_bool(log, false,"Minimal logging (no API, code, GC, suspect, or handles samples).") DEFINE_bool(log_all, false,"Log all events to the log file.") DEFINE_bool(log_runtime, false,"Activate runtime system %Log call.") DEFINE_bool(log_api, false,"Log API events to the log file.") DEFINE_bool(log_code, false,"Log code events to the log file without profiling.") DEFINE_bool(log_gc, false,"Log heap samples on garbage collection for the hp2ps tool.") DEFINE_bool(log_handles, false,"Log global handle events.") DEFINE_bool(log_snapshot_positions, false,"log positions of (de)serialized objects in the snapshot.") DEFINE_bool(log_suspect, false,"Log suspect operations.") DEFINE_bool(prof, false,"Log statistical profiling information (implies --log-code).") DEFINE_bool(prof_auto, true,"Used with --prof, starts profiling automatically") DEFINE_bool(prof_lazy, false,"Used with --prof, only does sampling and logging"" when profiler is active (implies --noprof_auto).") DEFINE_bool(prof_browser_mode, true,"Used with --prof, turns on browser-compatible mode for profiling.") DEFINE_bool(log_regexp, false,"Log regular expression execution.") DEFINE_bool(sliding_state_window, false,"Update sliding state window counters.") DEFINE_string(logfile,"v8.log","Specify the name of the log file.") DEFINE_bool(ll_prof, false,"Enable low-level linux profiler.")#define FLAG DEFINE_bool(trace_elements_transitions, false,"trace elements transitions") DEFINE_bool(print_code_stubs, false,"print code stubs") DEFINE_bool(test_secondary_stub_cache, false,"test secondary stub cache by disabling the primary one") DEFINE_bool(test_primary_stub_cache, false,"test primary stub cache by disabling the secondary one") DEFINE_bool(print_code, false,"print generated code") DEFINE_bool(print_opt_code, false,"print optimized code") DEFINE_bool(print_unopt_code, false,"print unoptimized code before ""printing optimized code based on it") DEFINE_bool(print_code_verbose, false,"print more information for code") DEFINE_bool(print_builtin_code, false,"print generated code for builtins")#47"/Users/thlorenz/dev/dx/v8-perf/build/v8/src/flags.cc"2 namespace{struct Flag{enum FlagType{TYPE_BOOL, TYPE_INT, TYPE_FLOAT, TYPE_STRING, TYPE_ARGS} name
static MUST_USE_RESULT MaybeObject * ForceDeleteObjectProperty(Isolate *isolate, Handle< JSReceiver > object, Handle< Object > key)
MaybeObject * TransitionElements(Handle< Object > object, ElementsKind to_kind, Isolate *isolate)
static HeapObject * cast(Object *obj)
static Handle< T > cast(Handle< S > that)
bool MayNamedAccess(JSObject *receiver, Object *key, v8::AccessType type)
bool is_access_check_needed()
static const int kSourceFieldIndex
static bool Analyze(CompilationInfo *info)
static AccessorPair * cast(Object *obj)
MaybeObject * AllocateRawString< SeqTwoByteString >(Isolate *isolate, int length)
static const int64_t kMaxTimeBeforeUTCInMs
MUST_USE_RESULT MaybeObject * LookupAsciiSymbol(Vector< const char > str)
static Failure * OutOfMemoryException()
static Handle< FixedArray > GetElements(Handle< FixedArray > value)
static const char * LocalTimezone(double time)
double fast_sqrt(double input)
bool is_identical_to(const Handle< T > other) const
static Handle< Object > CreateRegExpLiteral(Handle< JSFunction > constructor, Handle< String > pattern, Handle< String > flags, bool *has_pending_exception)
Vector< const char > ToAsciiVector()
static Map * cast(Object *obj)
static bool Parse(Vector< Char > str, FixedArray *output, UnicodeCache *cache)
void IncrementCharacterCount(int by)
static bool Delete(int id)
static const uint32_t kMaxElementCount
static int IrregexpPrepare(Handle< JSRegExp > regexp, Handle< String > subject, Zone *zone)
static Handle< Object > GetConstructorDelegate(Handle< Object > object)
static int IrregexpExecRaw(Handle< JSRegExp > regexp, Handle< String > subject, int index, Vector< int > registers, Zone *zone)
static const int kNoNumber
static Object * Lookup(FixedArray *cache, String *string, String *pattern)
static Failure * Exception()
int Search(Vector< const SubjectChar > subject, int index)
#define CONVERT_STRICT_MODE_ARG_CHECKED(name, index)
static MUST_USE_RESULT MaybeObject * SetObjectProperty(Isolate *isolate, Handle< Object > object, Handle< Object > key, Handle< Object > value, PropertyAttributes attr, StrictModeFlag strict_mode)
virtual void Summarize(List< FrameSummary > *frames)
PropertyDescriptorIndices
#define RUNTIME_ARGUMENTS(isolate, args)
void FindAsciiStringIndices(Vector< const char > subject, char pattern, ZoneList< int > *indices, unsigned int limit, Zone *zone)
static const Function * FunctionForId(FunctionId id)
Context * global_context()
static Handle< Object > TransitionElementsKind(Handle< JSObject > object, ElementsKind to_kind)
static int GlobalOffsetsVectorSize(Handle< JSRegExp > regexp, int registers_per_match, int *max_matches)
BitField< int, 0, kStringBuilderConcatHelperLengthBits > StringBuilderSubstringLength
#define ASSERT(condition)
static Handle< Object > SetOwnElement(Handle< JSObject > object, uint32_t index, Handle< Object > value, StrictModeFlag strict_mode)
static void DeoptimizeFunction(JSFunction *function)
Handle< JSArray > ToArray()
void Apply(ReplacementStringBuilder *builder, int match_from, int match_to, Handle< JSArray > last_match_info)
Handle< JSArray > ToJSArray()
int IntegerLog2(uint32_t value)
static ExternalUnsignedShortArray * cast(Object *obj)
Handle< JSArray > GetKeysFor(Handle< JSReceiver > object, bool *threw)
static MaybeObject * Summarize(int id1, int id2, Handle< JSObject > filter_obj)
static Script * cast(Object *obj)
ArrayConcatVisitor(Isolate *isolate, Handle< FixedArray > storage, bool fast_elements)
static Context * cast(Object *context)
static const int kMaxLength
static SharedFunctionInfo * cast(Object *obj)
Handle< Object > NewNumber(double value, PretenureFlag pretenure=NOT_TENURED)
static Type GetType(Handle< FixedArray > value)
bool IsInternalError() const
FixedArrayBuilder(Handle< FixedArray > backing_store)
Handle< Object > GetProperty(Handle< JSReceiver > obj, const char *name)
MUST_USE_RESULT MaybeObject * CopyJSObject(JSObject *source)
#define RETURN_IF_EMPTY_HANDLE(isolate, call)
void ReplaceCode(Code *code)
bool IsFastElementsKind(ElementsKind kind)
static Handle< SharedFunctionInfo > CompileEval(Handle< String > source, Handle< Context > context, bool is_global, LanguageMode language_mode, int scope_position)
void visit(uint32_t i, Handle< Object > elm)
int ComputeParametersCount() const
#define CONVERT_LANGUAGE_MODE_ARG(name, index)
static void SetLastSubject(FixedArray *array, String *to)
void EnsureCapacity(int elements)
bool AsArrayIndex(uint32_t *index)
#define RUNTIME_FUNCTION_LIST(F)
Object * GetValue(int descriptor_number)
static Object ** RawField(HeapObject *obj, int offset)
#define RETURN_IF_EMPTY_HANDLE_VALUE(isolate, call, value)
static Smi * cast(Object *object)
Handle< String > FlattenGetString(Handle< String > string)
static bool Parse(CompilationInfo *info, int flags)
const int kMaxBuilderEntriesPerRegExpMatch
void FindStringIndices(Isolate *isolate, Vector< const SubjectChar > subject, Vector< const PatternChar > pattern, ZoneList< int > *indices, unsigned int limit, Zone *zone)
bool Equals(String *other)
Handle< String > SubString(Handle< String > str, int start, int end, PretenureFlag pretenure)
static const int kHeaderSize
static MUST_USE_RESULT MaybeObject * InitializeIntrinsicFunctionNames(Heap *heap, Object *dictionary)
static const int kMultilineFieldIndex
bool CollectGarbage(AllocationSpace space, GarbageCollector collector, const char *gc_reason, const char *collector_reason)
static ExternalShortArray * cast(Object *obj)
static ScopeInfo * cast(Object *object)
int get(uchar c, uchar n, uchar *result)
static MarkBit MarkBitFrom(Address addr)
#define CONVERT_ARG_CHECKED(Type, name, index)
static const char * GetVersion()
double StringToDouble(UnicodeCache *unicode_cache, const char *str, int flags, double empty_string_val)
Object * ValueAt(int entry)
const int kStringBuilderConcatHelperPositionBits
Object * InObjectPropertyAtPut(int index, Object *value, WriteBarrierMode mode=UPDATE_WRITE_BARRIER)
static void SetLastInput(FixedArray *array, String *to)
static MaybeObject * Info(int start_idx, int dump_limit)
Handle< SeededNumberDictionary > DictionaryAtNumberPut(Handle< SeededNumberDictionary >, uint32_t key, Handle< Object > value)
Handle< Map > GetElementsTransitionMap(Handle< JSObject > object, ElementsKind elements_kind)
static Handle< Object > CharAt(Handle< String > str, uint32_t index)
Handle< Object > Lookup(Handle< String > name, ContextLookupFlags flags, int *index, PropertyAttributes *attributes, BindingFlags *binding_flags)
HANDLE HANDLE LPSTACKFRAME64 StackFrame
static Handle< String > StringReplaceOneCharWithString(Isolate *isolate, Handle< String > subject, Handle< String > search, Handle< String > replace, bool *found, int recursion_limit)
void EnsureHeapIsIterable()
Handle< JSArray > ToJSArray(Handle< JSArray > target_array)
double StringToInt(UnicodeCache *unicode_cache, String *str, int radix)
static void PrintTop(FILE *file, bool print_args, bool print_line_number)
STATIC_ASSERT((FixedDoubleArray::kHeaderSize &kDoubleAlignmentMask)==0)
Handle< SeqTwoByteString > NewRawTwoByteString(int length, PretenureFlag pretenure=NOT_TENURED)
static SeededNumberDictionary * cast(Object *obj)
Handle< Object > LookupSingleCharacterStringFromCode(uint32_t index)
static const int kFactoryIndex
MUST_USE_RESULT MaybeObject * SetContent(FixedArrayBase *storage)
static void SetLastCaptureCount(FixedArray *array, int to)
static Context * GlobalContextFromLiterals(FixedArray *literals)
static const int kInputIndex
void SetExpectedNofProperties(Handle< JSFunction > func, int nof)
#define CONVERT_BOOLEAN_ARG_CHECKED(name, index)
static ExternalIntArray * cast(Object *obj)
static const int kLiteralGlobalContextIndex
static ThreadId Current()
V8EXPORT Local< Value > GetPrototype()
static MUST_USE_RESULT MaybeObject * HandleStackGuardInterrupt(Isolate *isolate)
Handle< Object > Create(Object *value)
bool CodeGenerationFromStringsAllowed(Isolate *isolate, Handle< Context > context)
static bool IsValidElementsTransition(ElementsKind from_kind, ElementsKind to_kind)
static bool IsValid(intptr_t value)
static Failure * cast(MaybeObject *object)
bool ToArrayIndex(uint32_t *index)
bool(* AllowCodeGenerationFromStringsCallback)(Local< Context > context)
static const int kNoGCFlags
Handle< ObjectHashSet > ObjectHashSetAdd(Handle< ObjectHashSet > table, Handle< Object > key)
static void AddSubjectSlice(FixedArrayBuilder *builder, int from, int to)
T * NewArray(size_t size)
static const int kMaxWidth
Handle< Object > SetProperty(Handle< Object > object, Handle< Object > key, Handle< Object > value, PropertyAttributes attributes, StrictModeFlag strict_mode)
static void ResumeProfiler()
const char * DoubleToCString(double v, Vector< char > buffer)
static int GetCapture(FixedArray *array, int index)
bool IsAligned(T value, U alignment)
static MaybeObject * Dump(int id1, int id2, int start_idx, int dump_limit, Handle< JSObject > filter_obj)
#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName)
static SeqAsciiString * cast(Object *obj)
static const int64_t kMaxTimeInMs
double power_double_double(double x, double y)
GlobalHandles * global_handles()
Handle< JSValue > GetScriptWrapper(Handle< Script > script)
static ExternalUnsignedByteArray * cast(Object *obj)
bool IsMoreGeneralElementsKindTransition(ElementsKind from_kind, ElementsKind to_kind)
AllocationSpace allocation_space() const
void increase_index_offset(uint32_t delta)
static void TransformToFastProperties(Handle< JSObject > object, int unused_property_fields)
const uintptr_t kUintptrAllBitsSet
static const int kFirstCapture
static bool decode(uint32_t value)
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
void Update(Map *map, String *name, int field_offset)
static Handle< Object > SetLocalPropertyIgnoreAttributes(Handle< JSObject > object, Handle< String > key, Handle< Object > value, PropertyAttributes attributes)
Vector< const uc16 > ToUC16Vector()
double modulo(double x, double y)
static Handle< Object > Exec(Handle< JSRegExp > regexp, Handle< String > subject, int index, Handle< JSArray > lastMatchInfo, Zone *zone)
void EnsureCapacity(int elements)
Handle< FixedArray > GetKeysInFixedArrayFor(Handle< JSReceiver > object, KeyCollectionType type, bool *threw)
static double TimeCurrentMillis()
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)
bool IsTwoByteRepresentation()
Object * FastPropertyAt(int index)
static ExternalPixelArray * cast(Object *obj)
bool IsFastSmiElementsKind(ElementsKind kind)
static int GetLastCaptureCount(FixedArray *array)
Handle< String > ToString()
void set_length(int value)
static const int kMakeHeapIterableMask
static const int kIgnoreCaseFieldIndex
double power_double_int(double x, int y)
static const int kHeaderSize
WriteBarrierMode GetWriteBarrierMode(const AssertNoAllocation &)
int CompareChars(const lchar *lhs, const rchar *rhs, int chars)
PropertyDetails GetDetails(int descriptor_number)
static JavaScriptFrame * cast(StackFrame *frame)
Failure * Throw(Object *exception, MessageLocation *location=NULL)
static MaybeObject * GetObjRetainers(int obj_id, Handle< JSObject > instance_filter, bool verbose, int start, int count, Handle< JSObject > filter_obj)
static MaybeObject * FunctionGetArguments(Object *object, void *)
static ScopeInfo * Empty()
unibrow::Mapping< unibrow::ToUppercase, 128 > * to_upper_mapping()
static uint32_t MakeArrayIndexHash(uint32_t value, int length)
void Lookup(String *name, LookupResult *result)
void set_map_no_write_barrier(Map *value)
Handle< FixedArray > CopyFixedArray(Handle< FixedArray > array)
static Handle< Object > Call(Handle< Object > callable, Handle< Object > receiver, int argc, Handle< Object > argv[], bool *pending_exception, bool convert_receiver=false)
Vector< const char > CStrVector(const char *data)
Handle< ObjectHashTable > PutIntoObjectHashTable(Handle< ObjectHashTable > table, Handle< Object > key, Handle< Object > value)
void VisitThread(Isolate *isolate, ThreadLocalTop *top)
int StrLength(const char *string)
static Local< Context > ToLocal(v8::internal::Handle< v8::internal::Context > obj)
ReplacementStringBuilder(Heap *heap, Handle< String > subject, int estimated_part_count)
static JSArray * cast(Object *obj)
CompiledReplacement(Zone *zone)
Handle< JSArray > NewJSArrayWithElements(Handle< FixedArrayBase > elements, ElementsKind elements_kind=TERMINAL_FAST_ELEMENTS_KIND, PretenureFlag pretenure=NOT_TENURED)
static const int kMaxLoopNestingMarker
bool IsFastSmiOrObjectElementsKind(ElementsKind kind)
void FindStringIndicesDispatch(Isolate *isolate, String *subject, String *pattern, ZoneList< int > *indices, unsigned int limit, Zone *zone)
static int StringMatch(Isolate *isolate, Handle< String > sub, Handle< String > pat, int index)
static SeqTwoByteString * cast(Object *obj)
static const int kLastMatchOverhead
MUST_USE_RESULT MaybeObject * AllocateJSProxy(Object *handler, Object *prototype)
LocalElementType HasLocalElement(uint32_t index)
static ExternalDoubleArray * cast(Object *obj)
static ExternalFloatArray * cast(Object *obj)
FlatContent GetFlatContent()
int ArithmeticShiftRight(int x, int s)
void set(int index, double value)
MaybeObject * AllocateRawString(Isolate *isolate, int length)
bool has_named_interceptor()
static MUST_USE_RESULT MaybeObject * FunctionSetPrototype(JSObject *object, Object *value, void *)
int Lookup(Map *map, String *name)
char * DoubleToPrecisionCString(double value, int p)
int32_t DoubleToInt32(double x)
int InitialSemiSpaceSize()
void LocalLookup(String *name, LookupResult *result)
static HeapNumber * cast(Object *obj)
static void WriteToFlat(String *source, sinkchar *sink, int from, int to)
const int kStringBuilderConcatHelperLengthBits
MUST_USE_RESULT MaybeObject * NormalizeElements()
static StringDictionary * cast(Object *obj)
v8::Handle< v8::Array > GetKeysForNamedInterceptor(Handle< JSReceiver > receiver, Handle< JSObject > object)
static double nan_value()
static ObjectHashTable * cast(Object *obj)
JavaScriptFrameIteratorTemp< StackFrameIterator > JavaScriptFrameIterator
#define RUNTIME_ASSERT(value)
void MaterializeHeapNumbers()
static const int kAtomPatternIndex
void AddSubjectSlice(int from, int to)
static void Enter(Heap *heap, FixedArray *cache, String *string, String *pattern, FixedArray *array)
static JSGlobalPropertyCell * cast(Object *obj)
static Deoptimizer * Grab(Isolate *isolate)
static bool CompileOptimized(Handle< JSFunction > function, int osr_ast_id, ClearExceptionFlag flag)
static bool IsUpperCaseChar(RuntimeState *runtime_state, uint16_t ch)
void set_extension(Object *object)
static const int kEntriesIndex
PropertyDetails DetailsAt(int entry)
Handle< Object > NewTypeError(const char *type, Vector< Handle< Object > > args)
static Handle< Object > CreateArrayLiteralBoilerplate(Isolate *isolate, Handle< FixedArray > literals, Handle< FixedArray > elements)
static Handle< Object > GetFunctionDelegate(Handle< Object > object)
static JSReceiver * cast(Object *obj)
static JSValue * cast(Object *obj)
void AddString(Handle< String > string)
static void PrintError(const char *format,...)
static Handle< T > null()
void MemsetPointer(T **dest, U *value, int counter)
kPropertyAccessorsOffset kNamedPropertyHandlerOffset kInstanceTemplateOffset kAccessCheckInfoOffset kEvalFrominstructionsOffsetOffset kThisPropertyAssignmentsOffset flag
int SearchString(Isolate *isolate, Vector< const SubjectChar > subject, Vector< const PatternChar > pattern, int start_index)
void Set(int index, uint16_t value)
static void IncrementLiveBytesFromMutator(Address address, int by)
void set_is_access_check_needed(bool access_check_needed)
MUST_USE_RESULT MaybeObject * GetProperty(String *key)
static MUST_USE_RESULT MaybeObject * GetObjectProperty(Isolate *isolate, Handle< Object > object, Handle< Object > key)
#define ASSERT_EQ(v1, v2)
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 trace on stack replacement optimize closures functions with arguments object optimize functions containing for in loops profiler considers IC stability primitive functions trigger their own optimization re try self optimization if it failed insert an interrupt check at function exit execution budget before interrupt is triggered call count before self optimization self_optimization count_based_interrupts weighted_back_edges trace_opt 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 enable use of ARMv7 instructions if enable use of MIPS FPU instructions if NULL
static const int kIndexIndex
bool HasFastObjectElements()
static bool CompileLazy(Handle< SharedFunctionInfo > shared, ClearExceptionFlag flag)
InstanceType instance_type()
static MUST_USE_RESULT MaybeObject * ForceSetObjectProperty(Isolate *isolate, Handle< JSObject > object, Handle< Object > key, Handle< Object > value, PropertyAttributes attr)
static JSProxy * cast(Object *obj)
#define CONVERT_ARG_HANDLE_CHECKED(Type, name, index)
int32_t NumberToInt32(Object *number)
static Object * GetPath(int obj_id1, int obj_id2, Handle< JSObject > instance_filter)
MUST_USE_RESULT MaybeObject * CopyDropTransitions(DescriptorArray::SharedMode shared_mode)
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 true
static AccessorInfo * cast(Object *obj)
static FixedArray * cast(Object *obj)
static const int kHeaderSize
Handle< FixedDoubleArray > CopyFixedDoubleArray(Handle< FixedDoubleArray > array)
static const int kBoundFunctionIndex
Failure * ThrowIllegalOperation()
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())
bool HasCapacity(int elements)
static void NormalizeProperties(Handle< JSObject > object, PropertyNormalizationMode mode, int expected_additional_properties)
int FindEntry(String *key)
static Handle< Object > ToString(Handle< Object > obj, bool *exc)
bool IsFastHoleyElementsKind(ElementsKind kind)
static const int kMaxInliningLevels
Handle< FixedArray > array()
V8EXPORT Local< Object > ToObject() const
static uint32_t & uint32_at(Address addr)
void CreateFillerObjectAt(Address addr, int size)
Handle< Object > ForceSetProperty(Handle< JSObject > object, Handle< Object > key, Handle< Object > value, PropertyAttributes attributes)
char * DoubleToExponentialCString(double value, int f)
Handle< ObjectHashSet > ObjectHashSetRemove(Handle< ObjectHashSet > table, Handle< Object > key)
static bool is_valid(T value)
BitField< int, kStringBuilderConcatHelperLengthBits, kStringBuilderConcatHelperPositionBits > StringBuilderSubstringPosition
static Object * GetObj(int obj_id)
static const int kMaxLength
static Handle< Object > Compile(Handle< JSRegExp > re, Handle< String > pattern, Handle< String > flags)
static const int kEntrySize
bool HasLocalProperty(String *name)
static ExternalByteArray * cast(Object *obj)
Vector< Handle< Object > > HandleVector(v8::internal::Handle< T > *elms, int length)
char * DoubleToRadixCString(double value, int radix)
static MaybeObject * Capture()
static const int kLastIndexFieldIndex
ActivationsFinder(JSFunction *function)
static GlobalObject * cast(Object *obj)
static const int kBoundThisIndex
static Object * PrintObj(int obj_id)
void DeleteArray(T *array)
#define INLINE_RUNTIME_FUNCTION_LIST(F)
static ConsString * cast(Object *obj)
static Handle< Object > TryGetConstructorDelegate(Handle< Object > object, bool *has_pending_exception)
static int NewElementsCapacity(int old_capacity)
static FixedArrayBase * cast(Object *object)
#define CONVERT_NUMBER_CHECKED(type, name, Type, obj)
int jsframe_count() const
#define CONVERT_PROPERTY_DETAILS_CHECKED(name, index)
Handle< String > NewConsString(Handle< String > first, Handle< String > second)
static const int kMaxValue
static const int kBoundArgumentsStartIndex
static ExternalUnsignedIntArray * cast(Object *obj)
static const int kNotFound
static void DefineAccessor(Handle< JSObject > object, Handle< String > name, Handle< Object > getter, Handle< Object > setter, PropertyAttributes attributes)
void check(i::Vector< const char > string)
static void FatalProcessOutOfMemory(const char *location, bool take_snapshot=false)
StringDictionary * property_dictionary()
Handle< ObjectHashSet > NewObjectHashSet(int at_least_space_for)
static void PauseProfiler()
static const int kMaxLength
Object * GetParameter(int index) const
static Handle< Object > TryGetFunctionDelegate(Handle< Object > object, bool *has_pending_exception)
#define ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(Name)
void set_allow_osr_at_loop_nesting_level(int level)
static ObjectHashSet * cast(Object *obj)
static JSObject * cast(Object *obj)
static const int kMaxArrayIndexSize
static MUST_USE_RESULT MaybeObject * GetElementOrCharAt(Isolate *isolate, Handle< Object > object, uint32_t index)
V8EXPORT Local< Uint32 > ToArrayIndex() const
Handle< T > CloseAndEscape(Handle< T > handle_value)
bool IsFastDoubleElementsKind(ElementsKind kind)
char * DoubleToFixedCString(double value, int f)
static v8::internal::Handle< v8::internal::TemplateInfo > OpenHandle(const Template *that)
Handle< SeededNumberDictionary > NewSeededNumberDictionary(int at_least_space_for)
FixedArrayBuilder(Isolate *isolate, int initial_capacity)
static void SetCapture(FixedArray *array, int index, int to)
static JSGlobalObject * cast(Object *obj)
static JSFunction * cast(Object *obj)