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()) {
401 ASSERT(!name->AsArrayIndex(&element_index));
403 boilerplate, name, value,
NONE);
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 = native_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()) {
638 ASSERT(*elements != isolate->
heap()->empty_fixed_array());
643 literals->set(literals_index, *boilerplate);
645 return DeepCopyBoilerplate(isolate,
JSObject::cast(*boilerplate));
651 ASSERT(args.length() == 3);
657 Handle<Object> boilerplate(literals->get(literals_index), isolate);
658 if (*boilerplate == isolate->
heap()->undefined_value()) {
659 ASSERT(*elements != isolate->
heap()->empty_fixed_array());
664 literals->set(literals_index, *boilerplate);
667 isolate->
heap()->fixed_cow_array_map()) {
668 isolate->
counters()->cow_arrays_created_runtime()->Increment();
675 ASSERT(args.length() == 2);
677 Object* prototype = args[1];
679 prototype->IsJSReceiver() ? prototype : isolate->
heap()->null_value();
685 ASSERT(args.length() == 4);
687 Object* call_trap = args[1];
688 RUNTIME_ASSERT(call_trap->IsJSFunction() || call_trap->IsJSFunctionProxy());
690 Object* prototype = args[3];
692 prototype->IsJSReceiver() ? prototype : isolate->
heap()->null_value();
694 handler, call_trap, construct_trap, used_prototype);
699 ASSERT(args.length() == 1);
706 ASSERT(args.length() == 1);
713 ASSERT(args.length() == 1);
715 return proxy->handler();
720 ASSERT(args.length() == 1);
722 return proxy->call_trap();
727 ASSERT(args.length() == 1);
729 return proxy->construct_trap();
734 ASSERT(args.length() == 1);
737 return isolate->
heap()->undefined_value();
743 ASSERT(args.length() == 1);
746 holder->set_table(*table);
753 ASSERT(args.length() == 2);
758 holder->set_table(*table);
759 return isolate->
heap()->undefined_value();
765 ASSERT(args.length() == 2);
775 ASSERT(args.length() == 2);
780 holder->set_table(*table);
781 return isolate->
heap()->undefined_value();
787 ASSERT(args.length() == 1);
790 holder->set_table(*table);
797 ASSERT(args.length() == 2);
802 return lookup->IsTheHole() ? isolate->
heap()->undefined_value() : *lookup;
808 ASSERT(args.length() == 2);
819 ASSERT(args.length() == 2);
826 holder->set_table(*new_table);
833 ASSERT(args.length() == 3);
839 holder->set_table(*new_table);
840 return isolate->
heap()->undefined_value();
846 ASSERT(args.length() == 1);
848 ASSERT(weakmap->map()->inobject_properties() == 0);
850 weakmap->set_table(*table);
858 ASSERT(args.length() == 2);
863 return lookup->IsTheHole() ? isolate->
heap()->undefined_value() : *lookup;
869 ASSERT(args.length() == 2);
880 ASSERT(args.length() == 2);
887 weakmap->set_table(*new_table);
894 ASSERT(args.length() == 3);
900 weakmap->set_table(*new_table);
901 return isolate->
heap()->undefined_value();
906 NoHandleAllocation ha;
907 ASSERT(args.length() == 1);
909 if (!obj->IsJSObject())
return isolate->
heap()->null_value();
915 NoHandleAllocation ha;
916 ASSERT(args.length() == 1);
920 ASSERT(!obj->IsAccessCheckNeeded() || obj->IsJSObject());
922 if (obj->IsAccessCheckNeeded() &&
924 isolate->
heap()->Proto_symbol(),
927 return isolate->
heap()->undefined_value();
930 }
while (obj->IsJSObject() &&
937 NoHandleAllocation ha;
938 ASSERT(args.length() == 2);
944 if (prototype->IsNull())
return isolate->
heap()->false_value();
945 if (O == prototype)
return isolate->
heap()->true_value();
952 static void GetOwnPropertyImplementation(JSObject* obj,
954 LookupResult* result) {
955 obj->LocalLookupRealNamedProperty(name, result);
957 if (result->IsFound())
return;
960 if (proto->IsJSObject() &&
967 static bool CheckAccessException(LookupResult* result,
970 Object* callback = result->GetCallbackObject();
971 if (callback->IsAccessorInfo()) {
975 (info->all_can_read() || info->all_can_write())) ||
986 static bool CheckAccess(JSObject* obj,
988 LookupResult* result,
990 ASSERT(result->IsProperty());
992 JSObject* holder = result->holder();
993 JSObject* current = obj;
994 Isolate* isolate = obj->GetIsolate();
996 if (current->IsAccessCheckNeeded() &&
997 !isolate->MayNamedAccess(current, name, access_type)) {
1004 if (current == holder) {
1012 switch (result->type()) {
1014 if (CheckAccessException(result, access_type)) {
1022 holder->LookupRealNamedProperty(name, result);
1023 if (result->IsProperty()) {
1024 if (CheckAccessException(result, access_type)) {
1034 isolate->ReportFailedAccessCheck(current, access_type);
1040 static bool CheckElementAccess(JSObject* obj,
1043 if (obj->IsAccessCheckNeeded() &&
1044 !obj->GetIsolate()->MayIndexedAccess(obj, index, access_type)) {
1065 static MaybeObject* GetOwnProperty(
Isolate* isolate,
1068 Heap* heap = isolate->heap();
1070 Handle<JSArray> desc = isolate->factory()->NewJSArrayWithElements(elms);
1071 LookupResult result(isolate);
1077 return heap->undefined_value();
1110 if (obj->IsJSGlobalProxy()) {
1112 if (proto->
IsNull())
return heap->undefined_value();
1113 ASSERT(proto->IsJSGlobalObject());
1117 SeededNumberDictionary* dictionary =
NULL;
1118 if (elements->map() == heap->non_strict_arguments_elements_map()) {
1123 int entry = dictionary->FindEntry(index);
1125 PropertyDetails details = dictionary->DetailsAt(entry);
1126 switch (details.type()) {
1129 AccessorPair* accessors =
1144 ASSERT(!value.is_null());
1161 GetOwnPropertyImplementation(*obj, *name, &result);
1163 if (!result.IsProperty()) {
1164 return heap->undefined_value();
1168 return heap->false_value();
1174 bool is_js_accessor = result.IsPropertyCallbacks() &&
1175 (result.GetCallbackObject()->IsAccessorPair());
1177 if (is_js_accessor) {
1183 if (!getter->IsMap() && CheckAccess(*obj, *name, &result,
v8::ACCESS_GET)) {
1187 if (!setter->IsMap() && CheckAccess(*obj, *name, &result,
v8::ACCESS_SET)) {
1197 { MaybeObject* maybe_value = obj->
GetProperty(*obj, &result, *name, &attrs);
1198 if (!maybe_value->ToObject(&value))
return maybe_value;
1215 ASSERT(args.length() == 2);
1219 return GetOwnProperty(isolate, obj, name);
1224 ASSERT(args.length() == 1);
1231 ASSERT(args.length() == 1);
1233 if (obj->IsJSGlobalProxy()) {
1235 if (proto->IsNull())
return isolate->heap()->false_value();
1236 ASSERT(proto->IsJSGlobalObject());
1245 ASSERT(args.length() == 3);
1258 ASSERT(args.length() == 1);
1260 return *isolate->factory()->CreateApiFunction(data);
1265 ASSERT(args.length() == 1);
1267 bool result = arg->IsObjectTemplateInfo() || arg->IsFunctionTemplateInfo();
1268 return isolate->heap()->ToBoolean(result);
1273 ASSERT(args.length() == 2);
1291 ASSERT(args.length() == 1);
1293 Map* old_map =
object->
map();
1295 if (needs_access_checks) {
1298 MaybeObject* maybe_new_map = old_map->
Copy();
1299 if (!maybe_new_map->To(&new_map))
return maybe_new_map;
1302 object->set_map(new_map);
1304 return isolate->heap()->ToBoolean(needs_access_checks);
1309 ASSERT(args.length() == 1);
1311 Map* old_map =
object->
map();
1315 MaybeObject* maybe_new_map = old_map->
Copy();
1316 if (!maybe_new_map->To(&new_map))
return maybe_new_map;
1319 object->set_map(new_map);
1321 return isolate->heap()->undefined_value();
1325 static Failure* ThrowRedeclarationError(
Isolate* isolate,
1330 isolate->factory()->NewStringFromAscii(
CStrVector(type));
1332 Handle<Object> error =
1333 isolate->factory()->NewTypeError(
"redeclaration",
HandleVector(args, 2));
1334 return isolate->Throw(*error);
1339 ASSERT(args.length() == 3);
1342 isolate->context()->global_object());
1349 int length =
pairs->length();
1350 for (
int i = 0; i < length; i += 2) {
1358 bool is_var = value->IsUndefined();
1359 bool is_const = value->IsTheHole();
1360 bool is_function = value->IsSharedFunctionInfo();
1361 bool is_module = value->IsJSModule();
1362 ASSERT(is_var + is_const + is_function + is_module == 1);
1364 if (is_var || is_const) {
1368 LookupResult lookup(isolate);
1369 if (FLAG_es52_globals) {
1373 if (lookup.IsFound())
break;
1375 }
while (obj->IsJSObject() &&
1378 global->Lookup(*name, &lookup);
1380 if (lookup.IsFound()) {
1383 if (!lookup.IsInterceptor())
continue;
1385 if (attributes !=
ABSENT)
continue;
1389 }
else if (is_function) {
1394 isolate->factory()->NewFunctionFromSharedFunctionInfo(
1399 LookupResult lookup(isolate);
1400 global->LocalLookup(*name, &lookup);
1406 if (!is_eval || is_module) {
1410 if (is_const || is_module || (is_native && is_function)) {
1416 if (!lookup.IsFound() || is_function || is_module) {
1419 if (lookup.IsFound() && lookup.IsDontDelete()) {
1420 if (lookup.IsReadOnly() || lookup.IsDontEnum() ||
1421 lookup.IsPropertyCallbacks()) {
1422 return ThrowRedeclarationError(
1423 isolate, is_function ?
"function" :
"module", name);
1426 attr = lookup.GetAttributes();
1431 global, name, value, static_cast<PropertyAttributes>(attr)));
1436 global, name, value, static_cast<PropertyAttributes>(attr),
1441 ASSERT(!isolate->has_pending_exception());
1442 return isolate->heap()->undefined_value();
1448 ASSERT(args.length() == 4);
1466 context->
Lookup(name, flags, &index, &attributes, &binding_flags);
1468 if (attributes !=
ABSENT) {
1472 if (((attributes &
READ_ONLY) != 0) || (mode == READ_ONLY)) {
1474 ASSERT(mode != READ_ONLY || initial_value->IsTheHole());
1475 const char* type = ((attributes &
READ_ONLY) != 0) ?
"const" :
"var";
1476 return ThrowRedeclarationError(isolate, type, name);
1480 if (*initial_value !=
NULL) {
1483 if (((attributes & READ_ONLY) == 0) ||
1484 context->
get(index)->IsTheHole()) {
1485 context->
set(index, *initial_value);
1508 object = isolate->factory()->NewJSObject(
1509 isolate->context_extension_function());
1517 ASSERT(!object->HasLocalProperty(*name));
1518 Handle<Object> value(isolate->heap()->undefined_value(), isolate);
1519 if (*initial_value !=
NULL) value = initial_value;
1526 if (initial_value->IsTheHole() &&
1527 !
object->IsJSContextExtensionObject()) {
1528 LookupResult lookup(isolate);
1529 object->Lookup(*name, &lookup);
1530 if (lookup.IsPropertyCallbacks()) {
1531 return ThrowRedeclarationError(isolate,
"const", name);
1534 if (object->IsJSGlobalObject()) {
1544 return isolate->heap()->undefined_value();
1549 NoHandleAllocation nha;
1557 bool assign = args.length() == 3;
1560 GlobalObject* global = isolate->context()->global_object();
1578 LookupResult lookup(isolate);
1579 while (object->IsJSObject() &&
1583 if (lookup.IsInterceptor()) {
1588 raw_holder = *holder;
1593 &lookup, *name, args[2], attributes, strict_mode_flag);
1595 return isolate->heap()->undefined_value();
1603 global = isolate->context()->global_object();
1605 return global->
SetProperty(*name, args[2], attributes, strict_mode_flag);
1607 return isolate->heap()->undefined_value();
1620 GlobalObject* global = isolate->context()->global_object();
1632 LookupResult lookup(isolate);
1633 global->LocalLookup(*name, &lookup);
1634 if (!lookup.IsFound()) {
1635 return global->SetLocalPropertyIgnoreAttributes(*name,
1640 if (!lookup.IsReadOnly()) {
1661 if (lookup.IsField()) {
1662 FixedArray* properties = global->properties();
1663 int index = lookup.GetFieldIndex();
1664 if (properties->
get(index)->IsTheHole() || !lookup.IsReadOnly()) {
1665 properties->
set(index, *value);
1667 }
else if (lookup.IsNormal()) {
1668 if (global->GetNormalizedProperty(&lookup)->IsTheHole() ||
1669 !lookup.IsReadOnly()) {
1670 global->SetNormalizedProperty(&lookup, *value);
1675 ASSERT(lookup.IsReadOnly() && lookup.IsConstantFunction());
1685 ASSERT(args.length() == 3);
1688 ASSERT(!value->IsTheHole());
1701 context->
Lookup(name, flags, &index, &attributes, &binding_flags);
1704 ASSERT(holder->IsContext());
1708 if ((attributes &
READ_ONLY) == 0 || context->get(index)->IsTheHole()) {
1709 context->set(index, *value);
1716 if (attributes ==
ABSENT) {
1718 isolate->context()->global_object());
1746 LookupResult lookup(isolate);
1747 object->LocalLookupRealNamedProperty(*name, &lookup);
1748 ASSERT(lookup.IsFound());
1749 ASSERT(lookup.IsReadOnly());
1751 if (lookup.IsField()) {
1752 FixedArray* properties =
object->properties();
1753 int index = lookup.GetFieldIndex();
1754 if (properties->
get(index)->IsTheHole()) {
1755 properties->
set(index, *value);
1757 }
else if (lookup.IsNormal()) {
1758 if (object->GetNormalizedProperty(&lookup)->IsTheHole()) {
1759 object->SetNormalizedProperty(&lookup, *value);
1783 Runtime_OptimizeObjectForAddingMultipleProperties) {
1785 ASSERT(args.length() == 2);
1788 if (object->HasFastProperties()) {
1797 ASSERT(args.length() == 4);
1807 isolate->counters()->regexp_entry_runtime()->Increment();
1818 ASSERT(args.length() == 3);
1820 if (elements_count < 0 ||
1823 return isolate->ThrowIllegalOperation();
1826 { MaybeObject* maybe_new_object =
1827 isolate->heap()->AllocateFixedArrayWithHoles(elements_count);
1828 if (!maybe_new_object->ToObject(&new_object))
return maybe_new_object;
1831 { MaybeObject* maybe_new_object = isolate->heap()->AllocateRaw(
1833 if (!maybe_new_object->ToObject(&new_object))
return maybe_new_object;
1839 set_map(isolate->native_context()->regexp_result_map());
1842 array->set_properties(isolate->heap()->empty_fixed_array());
1843 array->set_elements(elements);
1854 ASSERT(args.length() == 5);
1859 if (source->length() == 0) source = isolate->heap()->query_colon_symbol();
1861 Object* global = args[2];
1862 if (!global->IsTrue()) global = isolate->heap()->false_value();
1864 Object* ignoreCase = args[3];
1865 if (!ignoreCase->IsTrue()) ignoreCase = isolate->heap()->false_value();
1867 Object* multiline = args[4];
1868 if (!multiline->IsTrue()) multiline = isolate->heap()->false_value();
1870 Map* map = regexp->
map();
1871 Object* constructor = map->constructor();
1872 if (constructor->IsJSFunction() &&
1878 regexp->InObjectPropertyAtPut(
1880 regexp->InObjectPropertyAtPut(
1882 regexp->InObjectPropertyAtPut(
1895 Heap* heap = isolate->heap();
1896 MaybeObject* result;
1897 result = regexp->SetLocalPropertyIgnoreAttributes(heap->source_symbol(),
1900 ASSERT(!result->IsFailure());
1901 result = regexp->SetLocalPropertyIgnoreAttributes(heap->global_symbol(),
1904 ASSERT(!result->IsFailure());
1906 regexp->SetLocalPropertyIgnoreAttributes(heap->ignore_case_symbol(),
1909 ASSERT(!result->IsFailure());
1910 result = regexp->SetLocalPropertyIgnoreAttributes(heap->multiline_symbol(),
1913 ASSERT(!result->IsFailure());
1915 regexp->SetLocalPropertyIgnoreAttributes(heap->last_index_symbol(),
1918 ASSERT(!result->IsFailure());
1926 ASSERT(args.length() == 1);
1930 prototype->set_elements(isolate->heap()->empty_fixed_array());
1939 Handle<String> key = isolate->factory()->LookupAsciiSymbol(name);
1942 isolate->factory()->NewFunction(key,
1947 optimized->shared()->DontAdaptArguments();
1955 ASSERT(args.length() == 1);
1958 InstallBuiltin(isolate, holder,
"pop", Builtins::kArrayPop);
1959 InstallBuiltin(isolate, holder,
"push", Builtins::kArrayPush);
1960 InstallBuiltin(isolate, holder,
"shift", Builtins::kArrayShift);
1961 InstallBuiltin(isolate, holder,
"unshift", Builtins::kArrayUnshift);
1962 InstallBuiltin(isolate, holder,
"slice", Builtins::kArraySlice);
1963 InstallBuiltin(isolate, holder,
"splice", Builtins::kArraySplice);
1964 InstallBuiltin(isolate, holder,
"concat", Builtins::kArrayConcat);
1971 ASSERT(args.length() == 1);
1974 if (!callable->IsJSFunction()) {
1986 return isolate->heap()->undefined_value();
1999 ASSERT(args.length() == 4);
2001 int index = args.smi_at(1);
2014 bool has_pending_exception;
2017 &has_pending_exception);
2018 if (has_pending_exception) {
2019 ASSERT(isolate->has_pending_exception());
2022 literals->set(index, *regexp);
2028 NoHandleAllocation ha;
2029 ASSERT(args.length() == 1);
2032 return f->shared()->name();
2037 NoHandleAllocation ha;
2038 ASSERT(args.length() == 2);
2042 f->shared()->set_name(name);
2043 return isolate->heap()->undefined_value();
2048 NoHandleAllocation ha;
2049 ASSERT(args.length() == 1);
2051 return isolate->heap()->ToBoolean(
2052 f->shared()->name_should_print_as_anonymous());
2057 NoHandleAllocation ha;
2058 ASSERT(args.length() == 1);
2060 f->shared()->set_name_should_print_as_anonymous(
true);
2061 return isolate->heap()->undefined_value();
2066 NoHandleAllocation ha;
2067 ASSERT(args.length() == 1);
2070 f->RemovePrototype();
2072 return isolate->heap()->undefined_value();
2078 ASSERT(args.length() == 1);
2082 if (!script->IsScript())
return isolate->heap()->undefined_value();
2090 ASSERT(args.length() == 1);
2094 return *shared->GetSourceCode();
2099 NoHandleAllocation ha;
2100 ASSERT(args.length() == 1);
2103 int pos = fun->shared()->start_position();
2109 ASSERT(args.length() == 2);
2122 NoHandleAllocation ha;
2123 ASSERT(args.length() == 2);
2127 fun->SetInstanceClassName(name);
2128 return isolate->heap()->undefined_value();
2133 NoHandleAllocation ha;
2134 ASSERT(args.length() == 2);
2138 fun->shared()->set_length(length);
2139 return isolate->heap()->undefined_value();
2144 NoHandleAllocation ha;
2145 ASSERT(args.length() == 2);
2148 ASSERT(fun->should_have_prototype());
2150 { MaybeObject* maybe_obj =
2152 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
2159 NoHandleAllocation ha;
2163 String* name = isolate->heap()->prototype_symbol();
2165 if (function->HasFastProperties()) {
2169 int index = instance_desc->SearchWithCache(name, function->
map());
2171 PropertyDetails details = instance_desc->
GetDetails(index);
2176 details.descriptor_index());
2180 MaybeObject* maybe_map =
2183 if (!maybe_map->To(&new_map))
return maybe_map;
2185 function->set_map(new_map);
2188 int entry =
function->property_dictionary()->FindEntry(name);
2190 PropertyDetails details =
function->property_dictionary()->DetailsAt(entry);
2191 PropertyDetails new_details(
2192 static_cast<PropertyAttributes>(details.attributes() |
READ_ONLY),
2194 details.dictionary_index());
2195 function->property_dictionary()->DetailsAtPut(entry, new_details);
2202 NoHandleAllocation ha;
2203 ASSERT(args.length() == 1);
2206 return isolate->heap()->ToBoolean(f->shared()->IsApiFunction());
2211 NoHandleAllocation ha;
2212 ASSERT(args.length() == 1);
2215 return isolate->heap()->ToBoolean(f->IsBuiltin());
2221 ASSERT(args.length() == 2);
2226 if (code->IsNull())
return *target;
2241 target_shared->set_code(source_shared->code());
2242 target_shared->set_scope_info(source_shared->scope_info());
2243 target_shared->set_length(source_shared->length());
2244 target_shared->set_formal_parameter_count(
2245 source_shared->formal_parameter_count());
2246 target_shared->set_script(isolate->heap()->undefined_value());
2249 target_shared->code()->set_optimizable(
false);
2253 target_shared->ClearThisPropertyAssignmentsInfo();
2256 target->ReplaceCode(source_shared->code());
2257 ASSERT(target->next_function_link()->IsUndefined());
2262 int number_of_literals = source->NumberOfLiterals();
2264 isolate->factory()->NewFixedArray(number_of_literals,
TENURED);
2265 if (number_of_literals > 0) {
2267 context->native_context());
2269 target->set_context(*context);
2270 target->set_literals(*literals);
2272 if (isolate->logger()->is_logging_code_events() ||
2273 CpuProfiler::is_profiling(isolate)) {
2274 isolate->logger()->LogExistingFunction(
2284 ASSERT(args.length() == 2);
2289 return isolate->heap()->undefined_value();
2297 if (code <= 0xffff) {
2298 return isolate->heap()->LookupSingleCharacterStringFromCode(code);
2301 return isolate->heap()->empty_string();
2306 NoHandleAllocation ha;
2307 ASSERT(args.length() == 2);
2316 { MaybeObject* maybe_flat = subject->TryFlatten();
2317 if (!maybe_flat->ToObject(&flat))
return maybe_flat;
2321 if (i >= static_cast<uint32_t>(subject->length())) {
2322 return isolate->heap()->nan_value();
2330 NoHandleAllocation ha;
2331 ASSERT(args.length() == 1);
2332 return CharFromCode(isolate, args[0]);
2339 : array_(isolate->factory()->NewFixedArrayWithHoles(initial_capacity)),
2341 has_non_smi_elements_(
false) {
2344 ASSERT(initial_capacity > 0);
2348 : array_(backing_store),
2350 has_non_smi_elements_(
false) {
2353 ASSERT(backing_store->length() > 0);
2357 int length = array_->length();
2358 int required_length = length_ + elements;
2359 return (length >= required_length);
2363 int length = array_->length();
2364 int required_length = length_ + elements;
2365 if (length < required_length) {
2369 }
while (new_length < required_length);
2371 array_->GetIsolate()->factory()->NewFixedArrayWithHoles(new_length);
2372 array_->CopyTo(0, *extended_array, 0, length_);
2373 array_ = extended_array;
2380 array_->set(length_, value);
2382 has_non_smi_elements_ =
true;
2388 array_->set(length_, value);
2401 return array_->length();
2405 FACTORY->SetContent(target_array, array_);
2407 return target_array;
2414 bool has_non_smi_elements_;
2422 template <
typename s
char>
2423 static inline void StringBuilderConcatHelper(
String*,
2440 int estimated_part_count)
2442 array_builder_(heap->isolate(), estimated_part_count),
2444 character_count_(0),
2445 is_ascii_(subject->IsAsciiRepresentation()) {
2448 ASSERT(estimated_part_count > 0);
2455 int length = to - from;
2482 int length =
string->length();
2484 AddElement(*
string);
2485 if (!string->IsAsciiRepresentation()) {
2493 if (array_builder_.
length() == 0) {
2501 char* char_buffer = seq->GetChars();
2502 StringBuilderConcatHelper(*subject_,
2504 *array_builder_.
array(),
2505 array_builder_.
length());
2511 uc16* char_buffer = seq->GetChars();
2512 StringBuilderConcatHelper(*subject_,
2514 *array_builder_.
array(),
2515 array_builder_.
length());
2518 return joined_string;
2526 character_count_ += by;
2540 void AddElement(
Object* element) {
2541 ASSERT(element->IsSmi() || element->IsString());
2543 array_builder_.
Add(element);
2547 FixedArrayBuilder array_builder_;
2548 Handle<String> subject_;
2549 int character_count_;
2557 : parts_(1, zone), replacement_substrings_(0, zone), zone_(zone) {}
2562 int subject_length);
2572 return parts_.length();
2582 REPLACEMENT_SUBSTRING,
2585 NUMBER_OF_PART_TYPES
2588 struct ReplacementPart {
2589 static inline ReplacementPart SubjectMatch() {
2590 return ReplacementPart(SUBJECT_CAPTURE, 0);
2592 static inline ReplacementPart SubjectCapture(
int capture_index) {
2593 return ReplacementPart(SUBJECT_CAPTURE, capture_index);
2595 static inline ReplacementPart SubjectPrefix() {
2596 return ReplacementPart(SUBJECT_PREFIX, 0);
2598 static inline ReplacementPart SubjectSuffix(
int subject_length) {
2599 return ReplacementPart(SUBJECT_SUFFIX, subject_length);
2601 static inline ReplacementPart ReplacementString() {
2602 return ReplacementPart(REPLACEMENT_STRING, 0);
2604 static inline ReplacementPart ReplacementSubString(
int from,
int to) {
2607 return ReplacementPart(-from, to);
2612 ReplacementPart(
int tag,
int data)
2613 : tag(tag), data(data) {
2615 ASSERT(tag < NUMBER_OF_PART_TYPES);
2634 template<
typename Char>
2635 bool ParseReplacementPattern(ZoneList<ReplacementPart>*
parts,
2636 Vector<Char> characters,
2640 int length = characters.length();
2642 for (
int i = 0; i < length; i++) {
2643 Char c = characters[i];
2645 int next_index = i + 1;
2646 if (next_index == length) {
2649 Char c2 = characters[next_index];
2654 parts->Add(ReplacementPart::ReplacementSubString(last, next_index),
2656 last = next_index + 1;
2665 parts->Add(ReplacementPart::ReplacementSubString(last, i), zone);
2667 parts->Add(ReplacementPart::SubjectPrefix(), zone);
2673 parts->Add(ReplacementPart::ReplacementSubString(last, i), zone);
2675 parts->Add(ReplacementPart::SubjectSuffix(subject_length), zone);
2681 parts->Add(ReplacementPart::ReplacementSubString(last, i), zone);
2683 parts->Add(ReplacementPart::SubjectMatch(), zone);
2697 int capture_ref = c2 -
'0';
2698 if (capture_ref > capture_count) {
2702 int second_digit_index = next_index + 1;
2703 if (second_digit_index < length) {
2705 Char c3 = characters[second_digit_index];
2706 if (
'0' <= c3 && c3 <=
'9') {
2707 int double_digit_ref = capture_ref * 10 + c3 -
'0';
2708 if (double_digit_ref <= capture_count) {
2709 next_index = second_digit_index;
2710 capture_ref = double_digit_ref;
2714 if (capture_ref > 0) {
2716 parts->Add(ReplacementPart::ReplacementSubString(last, i), zone);
2718 ASSERT(capture_ref <= capture_count);
2719 parts->Add(ReplacementPart::SubjectCapture(capture_ref), zone);
2720 last = next_index + 1;
2731 if (length > last) {
2736 parts->Add(ReplacementPart::ReplacementSubString(last, length), zone);
2742 ZoneList<ReplacementPart> parts_;
2743 ZoneList<Handle<String> > replacement_substrings_;
2750 int subject_length) {
2755 bool simple =
false;
2757 simple = ParseReplacementPattern(&parts_,
2764 simple = ParseReplacementPattern(&parts_,
2770 if (simple)
return true;
2773 Isolate* isolate = replacement->GetIsolate();
2775 int substring_index = 0;
2776 for (
int i = 0, n = parts_.length(); i < n; i++) {
2777 int tag = parts_[i].tag;
2780 int to = parts_[i].data;
2781 replacement_substrings_.
Add(
2783 parts_[i].tag = REPLACEMENT_SUBSTRING;
2784 parts_[i].data = substring_index;
2786 }
else if (tag == REPLACEMENT_STRING) {
2787 replacement_substrings_.
Add(replacement,
zone());
2788 parts_[i].data = substring_index;
2801 for (
int i = 0, n = parts_.length(); i < n; i++) {
2802 ReplacementPart part = parts_[i];
2804 case SUBJECT_PREFIX:
2807 case SUBJECT_SUFFIX: {
2808 int subject_length = part.data;
2809 if (match_to < subject_length) {
2814 case SUBJECT_CAPTURE: {
2815 int capture = part.data;
2816 int from = match[capture * 2];
2817 int to = match[capture * 2 + 1];
2818 if (from >= 0 && to > from) {
2823 case REPLACEMENT_SUBSTRING:
2824 case REPLACEMENT_STRING:
2825 builder->
AddString(replacement_substrings_[part.data]);
2842 const char* subject_start =
reinterpret_cast<const char*
>(subject.
start());
2843 const char* subject_end = subject_start + subject.
length();
2844 const char* pos = subject_start;
2846 pos =
reinterpret_cast<const char*
>(
2847 memchr(pos, pattern, subject_end - pos));
2848 if (pos ==
NULL)
return;
2849 indices->
Add(static_cast<int>(pos - subject_start), zone);
2856 template <
typename SubjectChar,
typename PatternChar>
2866 int pattern_length = pattern.
length();
2870 index = search.
Search(subject, index);
2871 if (index < 0)
return;
2872 indices->
Add(index, zone);
2873 index += pattern_length;
2891 if (subject_content.
IsAscii()) {
2893 if (pattern_content.
IsAscii()) {
2895 if (pattern_vector.
length() == 1) {
2919 if (pattern_content.
IsAscii()) {
2939 template<
typename ResultSeqString>
2940 MUST_USE_RESULT static MaybeObject* StringReplaceAtomRegExpWithString(
2949 Zone* zone = isolate->runtime_zone();
2951 ZoneList<int> indices(8, zone);
2955 int subject_len = subject->
length();
2956 int pattern_len = pattern->length();
2957 int replacement_len = replacement->
length();
2960 isolate, *subject, pattern, &indices, 0xffffffff, zone);
2962 int matches = indices.length();
2963 if (matches == 0)
return *subject;
2966 int64_t result_len_64 =
2967 (
static_cast<int64_t
>(replacement_len) -
2968 static_cast<int64_t>(pattern_len)) *
2969 static_cast<int64_t>(matches) +
2970 static_cast<int64_t
>(subject_len);
2972 int result_len =
static_cast<int>(result_len_64);
2974 int subject_pos = 0;
2978 if (ResultSeqString::kHasAsciiEncoding) {
2980 isolate->factory()->NewRawAsciiString(result_len));
2983 isolate->factory()->NewRawTwoByteString(result_len));
2986 for (
int i = 0; i < matches; i++) {
2988 if (subject_pos < indices.at(i)) {
2990 result->GetChars() + result_pos,
2993 result_pos += indices.at(i) - subject_pos;
2997 if (replacement_len > 0) {
2999 result->GetChars() + result_pos,
3002 result_pos += replacement_len;
3005 subject_pos = indices.at(i) + pattern_len;
3008 if (subject_pos < subject_len) {
3010 result->GetChars() + result_pos,
3015 int32_t match_indices[] = { indices.at(matches - 1),
3016 indices.at(matches - 1) + pattern_len };
3025 Handle<String> subject,
3026 Handle<JSRegExp> regexp,
3027 Handle<String> replacement,
3028 Handle<JSArray> last_match_info) {
3029 ASSERT(subject->IsFlat());
3030 ASSERT(replacement->IsFlat());
3032 bool is_global = regexp->GetFlags().is_global();
3033 int capture_count = regexp->CaptureCount();
3034 int subject_length = subject->length();
3037 Zone* zone = isolate->runtime_zone();
3039 CompiledReplacement compiled_replacement(zone);
3040 bool simple_replace = compiled_replacement.Compile(replacement,
3048 if (subject->HasOnlyAsciiChars() && replacement->HasOnlyAsciiChars()) {
3049 return StringReplaceAtomRegExpWithString<SeqAsciiString>(
3050 isolate, subject, regexp, replacement, last_match_info);
3052 return StringReplaceAtomRegExpWithString<SeqTwoByteString>(
3053 isolate, subject, regexp, replacement, last_match_info);
3057 RegExpImpl::GlobalCache global_cache(regexp, subject, is_global, isolate);
3060 int32_t* current_match = global_cache.FetchNext();
3061 if (current_match ==
NULL) {
3069 int expected_parts =
3070 (compiled_replacement.parts() + 1) * (is_global ? 4 : 1) + 1;
3071 ReplacementStringBuilder builder(isolate->heap(),
3078 const int parts_added_per_loop = 2 * (compiled_replacement.parts() + 2);
3083 builder.EnsureCapacity(parts_added_per_loop);
3085 int start = current_match[0];
3086 int end = current_match[1];
3089 builder.AddSubjectSlice(prev, start);
3092 if (simple_replace) {
3093 builder.AddString(replacement);
3095 compiled_replacement.Apply(&builder,
3103 if (!is_global)
break;
3105 current_match = global_cache.FetchNext();
3106 }
while (current_match !=
NULL);
3110 if (prev < subject_length) {
3111 builder.EnsureCapacity(2);
3112 builder.AddSubjectSlice(prev, subject_length);
3118 global_cache.LastSuccessfulMatch());
3120 return *(builder.ToString());
3124 template <
typename ResultSeqString>
3125 MUST_USE_RESULT static MaybeObject* StringReplaceRegExpWithEmptyString(
3127 Handle<String> subject,
3128 Handle<JSRegExp> regexp,
3129 Handle<JSArray> last_match_info) {
3130 ASSERT(subject->IsFlat());
3132 bool is_global = regexp->GetFlags().is_global();
3137 Handle<String> empty_string(
HEAP->empty_string());
3138 if (subject->HasOnlyAsciiChars()) {
3139 return StringReplaceAtomRegExpWithString<SeqAsciiString>(
3146 return StringReplaceAtomRegExpWithString<SeqTwoByteString>(
3155 RegExpImpl::GlobalCache global_cache(regexp, subject, is_global, isolate);
3158 int32_t* current_match = global_cache.FetchNext();
3159 if (current_match ==
NULL) {
3164 int start = current_match[0];
3165 int end = current_match[1];
3166 int capture_count = regexp->CaptureCount();
3167 int subject_length = subject->length();
3169 int new_length = subject_length - (end - start);
3170 if (new_length == 0)
return isolate->heap()->empty_string();
3172 Handle<ResultSeqString> answer;
3173 if (ResultSeqString::kHasAsciiEncoding) {
3175 isolate->factory()->NewRawAsciiString(new_length));
3178 isolate->factory()->NewRawTwoByteString(new_length));
3183 last_match_info, subject, capture_count, current_match);
3190 if (end < subject_length) {
3192 *subject, answer->GetChars() + start, end, subject_length);
3202 start = current_match[0];
3203 end = current_match[1];
3207 *subject, answer->GetChars() + position, prev, start);
3208 position += start - prev;
3212 current_match = global_cache.FetchNext();
3213 }
while (current_match !=
NULL);
3220 global_cache.LastSuccessfulMatch());
3222 if (prev < subject_length) {
3225 *subject, answer->GetChars() + position, prev, subject_length);
3226 position += subject_length - prev;
3229 if (position == 0)
return isolate->heap()->empty_string();
3232 int string_size = ResultSeqString::SizeFor(position);
3233 int allocated_string_size = ResultSeqString::SizeFor(new_length);
3234 int delta = allocated_string_size - string_size;
3236 answer->set_length(position);
3237 if (delta == 0)
return *answer;
3239 Address end_of_string = answer->address() + string_size;
3240 isolate->heap()->CreateFillerObjectAt(end_of_string, delta);
3250 ASSERT(args.length() == 4);
3263 ASSERT(last_match_info->HasFastObjectElements());
3265 if (replacement->length() == 0) {
3266 if (subject->HasOnlyAsciiChars()) {
3267 return StringReplaceRegExpWithEmptyString<SeqAsciiString>(
3268 isolate, subject, regexp, last_match_info);
3270 return StringReplaceRegExpWithEmptyString<SeqTwoByteString>(
3271 isolate, subject, regexp, last_match_info);
3275 return StringReplaceRegExpWithString(
3276 isolate, subject, regexp, replacement, last_match_info);
3285 int recursion_limit) {
3287 if (subject->IsConsString()) {
3297 recursion_limit - 1);
3299 if (new_first.
is_null())
return new_first;
3307 recursion_limit - 1);
3309 if (new_second.
is_null())
return new_second;
3314 if (index == -1)
return subject;
3326 ASSERT(args.length() == 3);
3334 const int kRecursionLimit = 0x1000;
3342 if (!result.
is_null())
return *result;
3359 ASSERT(0 <= start_index);
3360 ASSERT(start_index <= sub->length());
3362 int pattern_length = pat->length();
3363 if (pattern_length == 0)
return start_index;
3365 int subject_length = sub->length();
3366 if (start_index + pattern_length > subject_length)
return -1;
3406 ASSERT(args.length() == 3);
3412 uint32_t start_index;
3415 RUNTIME_ASSERT(start_index <= static_cast<uint32_t>(sub->length()));
3422 template <
typename s
char,
typename p
char>
3423 static int StringMatchBackwards(Vector<const schar> subject,
3424 Vector<const pchar> pattern,
3426 int pattern_length = pattern.length();
3427 ASSERT(pattern_length >= 1);
3428 ASSERT(idx + pattern_length <= subject.length());
3430 if (
sizeof(schar) == 1 &&
sizeof(pchar) > 1) {
3431 for (
int i = 0; i < pattern_length; i++) {
3432 uc16 c = pattern[i];
3439 pchar pattern_first_char = pattern[0];
3440 for (
int i = idx; i >= 0; i--) {
3441 if (subject[i] != pattern_first_char)
continue;
3443 while (j < pattern_length) {
3444 if (pattern[j] != subject[i+j]) {
3449 if (j == pattern_length) {
3458 ASSERT(args.length() == 3);
3464 uint32_t start_index;
3467 uint32_t pat_length = pat->length();
3468 uint32_t sub_length = sub->length();
3470 if (start_index + pat_length > sub_length) {
3471 start_index = sub_length - pat_length;
3474 if (pat_length == 0) {
3490 position = StringMatchBackwards(sub_content.
ToAsciiVector(),
3494 position = StringMatchBackwards(sub_content.
ToUC16Vector(),
3501 position = StringMatchBackwards(sub_content.
ToAsciiVector(),
3505 position = StringMatchBackwards(sub_content.
ToUC16Vector(),
3516 NoHandleAllocation ha;
3517 ASSERT(args.length() == 2);
3523 int str1_length = str1->length();
3524 int str2_length = str2->length();
3527 if (str1_length == 0) {
3531 if (str2_length == 0)
return Smi::FromInt(str1_length);
3534 int end = str1_length < str2_length ? str1_length : str2_length;
3539 int d = str1->Get(0) - str2->Get(0);
3546 *isolate->runtime_state()->string_locale_compare_buf1();
3548 *isolate->runtime_state()->string_locale_compare_buf2();
3553 for (
int i = 0; i < end; i++) {
3556 if (char1 != char2)
return Smi::FromInt(char1 - char2);
3564 NoHandleAllocation ha;
3565 ASSERT(args.length() == 3);
3571 if (args[1]->IsSmi() && args[2]->IsSmi()) {
3574 start = from_number;
3585 isolate->counters()->sub_string_runtime()->Increment();
3586 return value->SubString(start, end);
3601 int capture_count = regexp->CaptureCount();
3603 Zone* zone = isolate->runtime_zone();
3609 if (match ==
NULL)
break;
3610 offsets.
Add(match[0], zone);
3611 offsets.
Add(match[1], zone);
3616 if (offsets.length() == 0) {
3618 return isolate->heap()->null_value();
3626 int matches = offsets.length() / 2;
3629 isolate->factory()->NewSubString(subject, offsets.
at(0), offsets.
at(1));
3630 elements->set(0, *substring);
3631 for (
int i = 1; i < matches; i++) {
3633 int from = offsets.
at(i * 2);
3634 int to = offsets.
at(i * 2 + 1);
3636 isolate->factory()->NewProperSubString(subject, from, to);
3637 elements->set(i, *substring);
3639 Handle<JSArray> result = isolate->factory()->NewJSArrayWithElements(elements);
3647 template<
bool has_capture>
3648 static MaybeObject* SearchRegExpMultiple(
3658 int subject_length = subject->
length();
3660 static const int kMinLengthToCache = 0x1000;
3662 if (subject_length > kMinLengthToCache) {
3672 isolate->factory()->SetContent(result_array, cached_fixed_array);
3675 Object* cached_fixed_array_last_element =
3676 cached_fixed_array->
get(cached_fixed_array->
length() - 1);
3677 Smi* js_array_length =
Smi::cast(cached_fixed_array_last_element);
3680 last_match_array, subject, capture_count,
NULL);
3681 return *result_array;
3685 RegExpImpl::GlobalCache global_cache(regexp, subject,
true, isolate);
3688 Handle<FixedArray> result_elements;
3693 if (result_elements.is_null() || result_elements->length() < 16) {
3694 result_elements = isolate->factory()->NewFixedArrayWithHoles(16);
3697 FixedArrayBuilder builder(result_elements);
3700 int match_start = -1;
3705 static const int kMaxBuilderEntriesPerRegExpMatch = 5;
3708 int32_t* current_match = global_cache.FetchNext();
3709 if (current_match ==
NULL)
break;
3710 match_start = current_match[0];
3711 builder.EnsureCapacity(kMaxBuilderEntriesPerRegExpMatch);
3712 if (match_end < match_start) {
3717 match_end = current_match[1];
3720 HandleScope temp_scope(isolate);
3721 Handle<String> match;
3723 match = isolate->factory()->NewProperSubString(subject,
3727 match = isolate->factory()->NewSubString(subject,
3736 Handle<FixedArray> elements =
3737 isolate->factory()->NewFixedArray(3 + capture_count);
3739 elements->set(0, *match);
3740 for (
int i = 1; i <= capture_count; i++) {
3741 int start = current_match[i * 2];
3743 int end = current_match[i * 2 + 1];
3745 Handle<String> substring =
3746 isolate->factory()->NewSubString(subject, start, end);
3747 elements->set(i, *substring);
3749 ASSERT(current_match[i * 2 + 1] < 0);
3750 elements->set(i, isolate->heap()->undefined_value());
3753 elements->set(capture_count + 1,
Smi::FromInt(match_start));
3754 elements->set(capture_count + 2, *subject);
3755 builder.Add(*isolate->factory()->NewJSArrayWithElements(elements));
3757 builder.Add(*match);
3764 if (match_start >= 0) {
3766 if (match_end < subject_length) {
3773 last_match_array, subject, capture_count,
NULL);
3775 if (subject_length > kMinLengthToCache) {
3778 builder.EnsureCapacity(1);
3779 Handle<FixedArray> fixed_array = builder.array();
3780 fixed_array->set(fixed_array->length() - 1,
3789 return *builder.ToJSArray(result_array);
3791 return isolate->heap()->null_value();
3800 ASSERT(args.length() == 4);
3809 ASSERT(last_match_info->HasFastObjectElements());
3813 return SearchRegExpMultiple<false>(
3814 isolate, subject, regexp, last_match_info, result_array);
3816 return SearchRegExpMultiple<true>(
3817 isolate, subject, regexp, last_match_info, result_array);
3823 NoHandleAllocation ha;
3824 ASSERT(args.length() == 2);
3829 if (args[0]->IsSmi()) {
3830 int value = args.smi_at(0);
3831 if (value >= 0 && value < radix) {
3833 static const char kCharTable[] =
"0123456789abcdefghijklmnopqrstuvwxyz";
3834 return isolate->heap()->
3842 return *isolate->factory()->nan_symbol();
3846 return *isolate->factory()->minus_infinity_symbol();
3848 return *isolate->factory()->infinity_symbol();
3851 MaybeObject* result =
3852 isolate->heap()->AllocateStringFromAscii(
CStrVector(str));
3859 NoHandleAllocation ha;
3860 ASSERT(args.length() == 2);
3864 return *isolate->factory()->nan_symbol();
3868 return *isolate->factory()->minus_infinity_symbol();
3870 return *isolate->factory()->infinity_symbol();
3877 isolate->heap()->AllocateStringFromAscii(
CStrVector(str));
3884 NoHandleAllocation ha;
3885 ASSERT(args.length() == 2);
3889 return *isolate->factory()->nan_symbol();
3893 return *isolate->factory()->minus_infinity_symbol();
3895 return *isolate->factory()->infinity_symbol();
3902 isolate->heap()->AllocateStringFromAscii(
CStrVector(str));
3909 NoHandleAllocation ha;
3910 ASSERT(args.length() == 2);
3914 return *isolate->factory()->nan_symbol();
3918 return *isolate->factory()->minus_infinity_symbol();
3920 return *isolate->factory()->infinity_symbol();
3927 isolate->heap()->AllocateStringFromAscii(
CStrVector(str));
3936 if (index < static_cast<uint32_t>(string->
length())) {
3937 string->TryFlatten();
3939 string->Get(index));
3949 if (object->IsString()) {
3951 if (!result->IsUndefined())
return *result;
3955 if (object->IsStringObjectWithCharacterAt(index)) {
3959 if (!result->IsUndefined())
return *result;
3962 if (object->IsString() ||
object->IsNumber() ||
object->IsBoolean()) {
3963 return object->GetPrototype()->GetElement(index);
3966 return object->GetElement(index);
3975 if (object->IsUndefined() ||
object->IsNull()) {
3980 return isolate->
Throw(*error);
3985 if (key->ToArrayIndex(&index)) {
3991 if (key->IsString()) {
3994 bool has_pending_exception =
false;
4003 if (name->AsArrayIndex(&index)) {
4006 return object->GetProperty(*name);
4012 NoHandleAllocation ha;
4013 ASSERT(args.length() == 2);
4024 NoHandleAllocation ha;
4025 ASSERT(args.length() == 2);
4038 if (args[0]->IsJSObject()) {
4039 if (!args[0]->IsJSGlobalProxy() &&
4040 !args[0]->IsAccessCheckNeeded() &&
4041 args[1]->IsString()) {
4046 Map* receiver_map = receiver->
map();
4048 int offset = keyed_lookup_cache->
Lookup(receiver_map, key);
4051 return value->IsTheHole()
4052 ? isolate->heap()->undefined_value()
4057 LookupResult result(isolate);
4059 if (result.IsField()) {
4060 int offset = result.GetFieldIndex();
4061 keyed_lookup_cache->
Update(receiver_map, key, offset);
4071 if (!receiver->IsGlobalObject())
return value;
4073 if (!value->IsTheHole())
return value;
4077 }
else if (FLAG_smi_only_arrays && args.at<
Object>(1)->IsSmi()) {
4085 ElementsKind elements_kind = js_object->GetElementsKind();
4098 if (maybe_object->IsFailure())
return maybe_object;
4102 }
else if (args[0]->IsString() && args[1]->IsSmi()) {
4106 int index = args.smi_at(1);
4107 if (index >= 0 && index < str->length()) {
4121 return obj->IsUndefined() || obj->IsSpecFunction() || obj->IsNull();
4132 ASSERT(args.length() == 5);
4145 bool fast = obj->HasFastProperties();
4148 return isolate->heap()->undefined_value();
4158 ASSERT(args.length() == 4);
4167 LookupResult result(isolate);
4168 js_object->LocalLookupRealNamedProperty(*name, &result);
4171 if (result.IsPropertyCallbacks()) {
4172 Object* callback = result.GetCallbackObject();
4176 if (callback->IsAccessorInfo()) {
4177 return isolate->heap()->undefined_value();
4183 if (callback->IsForeign() && result.GetAttributes() == attr) {
4184 return js_object->SetPropertyWithCallback(callback,
4198 if (result.IsFound() &&
4199 (attr != result.GetAttributes() || result.IsPropertyCallbacks())) {
4201 if (js_object->IsJSGlobalProxy()) {
4209 return js_object->SetLocalPropertyIgnoreAttributes(*name,
4231 if (object->IsUndefined() ||
object->IsNull()) {
4236 return isolate->
Throw(*error);
4239 if (object->IsJSProxy()) {
4240 bool has_pending_exception =
false;
4248 if (!object->IsJSObject())
return *value;
4254 if (key->ToArrayIndex(&index)) {
4262 if (js_object->IsStringObjectWithCharacterAt(index)) {
4266 js_object->ValidateElements();
4268 js_object, index, value, attr, strict_mode, set_mode);
4269 js_object->ValidateElements();
4274 if (key->IsString()) {
4278 js_object, index, value, attr, strict_mode, set_mode);
4281 key_string->TryFlatten();
4283 js_object, key_string, value, attr, strict_mode);
4290 bool has_pending_exception =
false;
4295 if (name->AsArrayIndex(&index)) {
4296 return js_object->SetElement(
4297 index, *value, attr, strict_mode,
true, set_mode);
4299 return js_object->SetProperty(*name, *value, attr, strict_mode);
4313 if (key->ToArrayIndex(&index)) {
4321 if (js_object->IsStringObjectWithCharacterAt(index)) {
4325 return js_object->SetElement(
4329 if (key->IsString()) {
4331 return js_object->SetElement(
4335 key_string->TryFlatten();
4336 return js_object->SetLocalPropertyIgnoreAttributes(*key_string,
4343 bool has_pending_exception =
false;
4348 if (name->AsArrayIndex(&index)) {
4349 return js_object->SetElement(
4352 return js_object->SetLocalPropertyIgnoreAttributes(*name, *value, attr);
4364 if (key->ToArrayIndex(&index)) {
4371 if (receiver->IsStringObjectWithCharacterAt(index)) {
4372 return isolate->
heap()->true_value();
4379 if (key->IsString()) {
4383 bool has_pending_exception =
false;
4389 key_string->TryFlatten();
4395 NoHandleAllocation ha;
4409 if (args.length() == 5) {
4411 strict_mode = strict_mode_flag;
4424 NoHandleAllocation ha;
4427 if (object->IsJSObject()) {
4429 ElementsKind new_kind = js_object->HasFastHoleyElements()
4440 NoHandleAllocation ha;
4443 if (object->IsJSObject()) {
4445 ElementsKind new_kind = js_object->HasFastHoleyElements()
4459 NoHandleAllocation ha;
4464 if (object->IsJSFunction()) {
4466 func->shared()->set_native(
true);
4468 return isolate->heap()->undefined_value();
4481 Object* raw_boilerplate_object = literals->get(literal_index);
4483 ElementsKind elements_kind =
object->GetElementsKind();
4488 if (value->IsNumber()) {
4494 boilerplate_object->GetElementsKind(),
4495 transitioned_kind)) {
4502 double_array->
set(store_index, number->Number());
4511 boilerplate_object->GetElementsKind(),
4512 transitioned_kind)) {
4516 object_array->
set(store_index, *value);
4525 #ifdef ENABLE_DEBUGGER_SUPPORT
4526 if (!isolate->IsDebuggerActive() || !isolate->debug()->StepInActive()) {
4527 return isolate->heap()->false_value();
4532 return isolate->heap()->false_value();
4534 return isolate->heap()->true_value();
4536 return isolate->heap()->false_value();
4537 #endif // ENABLE_DEBUGGER_SUPPORT
4544 #ifdef ENABLE_DEBUGGER_SUPPORT
4545 Debug* debug = isolate->debug();
4546 if (!debug->IsStepping())
return isolate->heap()->undefined_value();
4552 debug->ClearStepOut();
4553 debug->FloodWithOneShot(callback);
4554 #endif // ENABLE_DEBUGGER_SUPPORT
4555 return isolate->heap()->undefined_value();
4562 NoHandleAllocation ha;
4568 if (args.length() == 4) {
4577 SetLocalPropertyIgnoreAttributes(name, args[2], attributes);
4582 NoHandleAllocation ha;
4583 ASSERT(args.length() == 3);
4588 return object->DeleteProperty(key, (strict_mode ==
kStrictMode)
4594 static Object* HasLocalPropertyImplementation(
Isolate* isolate,
4602 if (proto->IsJSObject() &&
4604 return HasLocalPropertyImplementation(isolate,
4608 return isolate->heap()->false_value();
4613 NoHandleAllocation ha;
4614 ASSERT(args.length() == 2);
4618 const bool key_is_array_index = key->
AsArrayIndex(&index);
4622 if (obj->IsJSObject()) {
4628 Map* map =
object->
map();
4629 if (!key_is_array_index &&
4632 return isolate->heap()->false_value();
4636 return HasLocalPropertyImplementation(isolate,
4639 }
else if (obj->IsString() && key_is_array_index) {
4642 if (index < static_cast<uint32_t>(string->
length())) {
4643 return isolate->heap()->true_value();
4646 return isolate->heap()->false_value();
4651 NoHandleAllocation na;
4652 ASSERT(args.length() == 2);
4656 bool result = receiver->HasProperty(key);
4658 return isolate->heap()->ToBoolean(result);
4663 NoHandleAllocation na;
4664 ASSERT(args.length() == 2);
4668 bool result = receiver->HasElement(index);
4670 return isolate->heap()->ToBoolean(result);
4675 NoHandleAllocation ha;
4676 ASSERT(args.length() == 2);
4687 return isolate->heap()->false_value();
4690 return isolate->heap()->true_value();
4692 if (object->IsJSGlobalProxy()) {
4694 if (proto->IsNull()) {
4695 return isolate->heap()->false_value();
4697 ASSERT(proto->IsJSGlobalObject());
4702 if (elements->
map() ==
4703 isolate->heap()->non_strict_arguments_elements_map()) {
4708 int entry = dictionary->FindEntry(index);
4710 PropertyDetails details = dictionary->DetailsAt(entry);
4711 return isolate->heap()->ToBoolean(!details.IsDontEnum());
4717 return isolate->heap()->ToBoolean(att !=
ABSENT && (att &
DONT_ENUM) == 0);
4723 ASSERT(args.length() == 1);
4738 ASSERT(args.length() == 1);
4742 if (raw_object->IsSimpleEnum())
return raw_object->map();
4752 if (object->IsSimpleEnum())
return object->map();
4761 static int LocalPrototypeChainLength(JSObject* obj) {
4764 while (proto->IsJSObject() &&
4777 ASSERT(args.length() == 1);
4778 if (!args[0]->IsJSObject()) {
4779 return isolate->heap()->undefined_value();
4785 if (obj->IsJSGlobalProxy()) {
4787 if (obj->IsAccessCheckNeeded() &&
4788 !isolate->MayNamedAccess(*obj,
4789 isolate->heap()->undefined_value(),
4792 return *isolate->factory()->NewJSArray(0);
4798 int length = LocalPrototypeChainLength(*obj);
4802 int total_property_count = 0;
4804 for (
int i = 0; i < length; i++) {
4806 if (jsproto->IsAccessCheckNeeded() &&
4807 !isolate->MayNamedAccess(*jsproto,
4808 isolate->heap()->undefined_value(),
4811 return *isolate->factory()->NewJSArray(0);
4814 n = jsproto->NumberOfLocalProperties();
4815 local_property_count[i] = n;
4816 total_property_count += n;
4817 if (i < length - 1) {
4824 isolate->factory()->NewFixedArray(total_property_count);
4828 int proto_with_hidden_properties = 0;
4829 int next_copy_index = 0;
4830 for (
int i = 0; i < length; i++) {
4831 jsproto->GetLocalPropertyNames(*names, next_copy_index);
4832 next_copy_index += local_property_count[i];
4833 if (jsproto->HasHiddenProperties()) {
4834 proto_with_hidden_properties++;
4836 if (i < length - 1) {
4842 if (proto_with_hidden_properties > 0) {
4844 names = isolate->factory()->NewFixedArray(
4845 names->length() - proto_with_hidden_properties);
4847 for (
int i = 0; i < total_property_count; i++) {
4848 Object* name = old_names->get(i);
4849 if (name == isolate->heap()->hidden_symbol()) {
4852 names->set(dest_pos++, name);
4856 return *isolate->factory()->NewJSArrayWithElements(names);
4864 ASSERT(args.length() == 1);
4865 if (!args[0]->IsJSObject()) {
4866 return isolate->heap()->undefined_value();
4870 int n = obj->NumberOfLocalElements(static_cast<PropertyAttributes>(
NONE));
4872 obj->GetLocalElementKeys(*names, static_cast<PropertyAttributes>(
NONE));
4873 return *isolate->factory()->NewJSArrayWithElements(names);
4881 ASSERT(args.length() == 1);
4882 if (!args[0]->IsJSObject()) {
4888 if (obj->HasNamedInterceptor()) result |= 2;
4889 if (obj->HasIndexedInterceptor()) result |= 1;
4899 ASSERT(args.length() == 1);
4902 if (obj->HasNamedInterceptor()) {
4904 if (!result.
IsEmpty())
return *v8::Utils::OpenHandle(*result);
4906 return isolate->heap()->undefined_value();
4914 ASSERT(args.length() == 1);
4917 if (obj->HasIndexedInterceptor()) {
4919 if (!result.
IsEmpty())
return *v8::Utils::OpenHandle(*result);
4921 return isolate->heap()->undefined_value();
4931 if (object->IsJSGlobalProxy()) {
4933 if (object->IsAccessCheckNeeded() &&
4934 !isolate->MayNamedAccess(*
object, isolate->heap()->undefined_value(),
4937 return *isolate->factory()->NewJSArray(0);
4942 if (proto->
IsNull())
return *isolate->factory()->NewJSArray(0);
4954 int length = contents->length();
4956 for (
int i = 0; i < length; i++) {
4957 Object* entry = contents->get(i);
4958 if (entry->IsString()) {
4959 copy->set(i, entry);
4961 ASSERT(entry->IsNumber());
4965 isolate->factory()->NumberToString(entry_handle);
4966 copy->set(i, *entry_str);
4969 return *isolate->factory()->NewJSArrayWithElements(copy);
4974 NoHandleAllocation ha;
4975 ASSERT(args.length() == 1);
4979 it.AdvanceToArgumentsFrame();
4988 if (args[0]->ToArrayIndex(&index) && index < n) {
4994 bool exception =
false;
5001 if (key->AsArrayIndex(&index)) {
5005 return isolate->initial_object_prototype()->GetElement(index);
5010 if (key->Equals(isolate->heap()->length_symbol()))
return Smi::FromInt(n);
5011 if (key->Equals(isolate->heap()->callee_symbol())) {
5013 if (function->IsJSFunction() &&
5015 return isolate->Throw(*isolate->factory()->NewTypeError(
5016 "strict_arguments_callee", HandleVector<Object>(
NULL, 0)));
5022 return isolate->initial_object_prototype()->GetProperty(*key);
5027 ASSERT(args.length() == 1);
5028 Object*
object = args[0];
5029 return (object->IsJSObject() && !
object->IsGlobalObject())
5036 NoHandleAllocation ha;
5037 ASSERT(args.length() == 1);
5046 NoHandleAllocation ha;
5049 if (obj->IsNumber())
return isolate->heap()->number_symbol();
5054 return isolate->heap()->undefined_symbol();
5059 return isolate->heap()->string_symbol();
5062 switch (instance_type) {
5064 if (heap_obj->IsTrue() || heap_obj->IsFalse()) {
5065 return isolate->heap()->boolean_symbol();
5067 if (heap_obj->IsNull()) {
5068 return FLAG_harmony_typeof
5069 ? isolate->heap()->null_symbol()
5070 : isolate->heap()->object_symbol();
5072 ASSERT(heap_obj->IsUndefined());
5073 return isolate->heap()->undefined_symbol();
5076 return isolate->heap()->function_symbol();
5080 return isolate->heap()->object_symbol();
5085 static bool AreDigits(
const char*s,
int from,
int to) {
5086 for (
int i = from; i < to; i++) {
5087 if (s[i] <
'0' || s[i] >
'9')
return false;
5094 static int ParseDecimalInteger(
const char*s,
int from,
int to) {
5097 int d = s[from] -
'0';
5099 for (
int i = from + 1; i < to; i++) {
5100 d = 10 * d + (s[i] -
'0');
5108 NoHandleAllocation ha;
5109 ASSERT(args.length() == 1);
5114 int len = subject->
length();
5115 if (subject->IsSeqAsciiString()) {
5119 bool minus = (data[0] ==
'-');
5120 int start_pos = (minus ? 1 : 0);
5122 if (start_pos == len) {
5123 return isolate->heap()->nan_value();
5124 }
else if (data[start_pos] >
'9') {
5129 if (data[start_pos] !=
'I') {
5130 return isolate->heap()->nan_value();
5132 }
else if (len - start_pos < 10 && AreDigits(data, start_pos, len)) {
5135 int d = ParseDecimalInteger(data, start_pos, len);
5137 if (d == 0)
return isolate->heap()->minus_zero_value();
5141 (len == 1 || data[0] !=
'0')) {
5148 static_cast<int>(hash));
5157 return isolate->heap()->NumberFromDouble(
5163 NoHandleAllocation ha;
5164 ASSERT(args.length() == 1);
5167 int length =
Smi::cast(codes->length())->value();
5171 for (i = 0; i < length; i++) {
5173 { MaybeObject* maybe_element = codes->
GetElement(i);
5176 if (!maybe_element->ToObject(&element))
return maybe_element;
5183 MaybeObject* maybe_object =
NULL;
5185 maybe_object = isolate->heap()->AllocateRawAsciiString(length);
5187 maybe_object = isolate->heap()->AllocateRawTwoByteString(length);
5191 if (!maybe_object->ToObject(&
object))
return maybe_object;
5193 for (
int i = 0; i < length; i++) {
5195 { MaybeObject* maybe_element = codes->
GetElement(i);
5196 if (!maybe_element->ToObject(&element))
return maybe_element;
5199 result->
Set(i, chr & 0xffff);
5217 static bool IsNotEscaped(
uint16_t character) {
5220 static const char kNotEscaped[256] = {
5221 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5222 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5223 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1,
5224 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
5225 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
5226 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1,
5227 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
5228 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
5229 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5230 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5231 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5232 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5233 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5234 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5235 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5236 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5238 return kNotEscaped[character] != 0;
5243 const char hex_chars[] =
"0123456789ABCDEF";
5244 NoHandleAllocation ha;
5245 ASSERT(args.length() == 1);
5248 source->TryFlatten();
5250 int escaped_length = 0;
5251 int length = source->length();
5254 isolate->runtime_state()->string_input_buffer());
5255 buffer->Reset(source);
5256 while (buffer->has_more()) {
5257 uint16_t character = buffer->GetNext();
5258 if (character >= 256) {
5259 escaped_length += 6;
5260 }
else if (IsNotEscaped(character)) {
5263 escaped_length += 3;
5268 isolate->context()->mark_out_of_memory();
5274 if (escaped_length == length) {
5278 { MaybeObject* maybe_o =
5279 isolate->heap()->AllocateRawAsciiString(escaped_length);
5280 if (!maybe_o->ToObject(&o))
return maybe_o;
5283 int dest_position = 0;
5286 isolate->runtime_state()->string_input_buffer());
5288 while (buffer->has_more()) {
5291 destination->
Set(dest_position,
'%');
5292 destination->
Set(dest_position+1,
'u');
5293 destination->
Set(dest_position+2, hex_chars[chr >> 12]);
5294 destination->
Set(dest_position+3, hex_chars[(chr >> 8) & 0xf]);
5295 destination->
Set(dest_position+4, hex_chars[(chr >> 4) & 0xf]);
5296 destination->
Set(dest_position+5, hex_chars[chr & 0xf]);
5298 }
else if (IsNotEscaped(chr)) {
5299 destination->
Set(dest_position, chr);
5302 destination->
Set(dest_position,
'%');
5303 destination->
Set(dest_position+1, hex_chars[chr >> 4]);
5304 destination->
Set(dest_position+2, hex_chars[chr & 0xf]);
5313 static const signed char kHexValue[
'g'] = {
5314 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
5315 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
5316 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
5317 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1,
5318 -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
5319 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
5320 -1, 10, 11, 12, 13, 14, 15 };
5322 if (character1 >
'f')
return -1;
5323 int hi = kHexValue[character1];
5324 if (hi == -1)
return -1;
5325 if (character2 >
'f')
return -1;
5326 int lo = kHexValue[character2];
5327 if (lo == -1)
return -1;
5328 return (hi << 4) +
lo;
5332 static inline int Unescape(String* source,
5336 uint16_t character = source->Get(i);
5339 if (character ==
'%' &&
5341 source->Get(i + 1) ==
'u' &&
5342 (hi = TwoDigitHex(source->Get(i + 2),
5343 source->Get(i + 3))) != -1 &&
5344 (lo = TwoDigitHex(source->Get(i + 4),
5345 source->Get(i + 5))) != -1) {
5347 return (hi << 8) +
lo;
5348 }
else if (character ==
'%' &&
5350 (lo = TwoDigitHex(source->Get(i + 1),
5351 source->Get(i + 2))) != -1) {
5362 NoHandleAllocation ha;
5363 ASSERT(args.length() == 1);
5366 source->TryFlatten();
5369 int length = source->length();
5371 int unescaped_length = 0;
5372 for (
int i = 0; i < length; unescaped_length++) {
5381 if (unescaped_length == length)
5385 { MaybeObject* maybe_o =
5387 isolate->heap()->AllocateRawAsciiString(unescaped_length) :
5388 isolate->heap()->AllocateRawTwoByteString(unescaped_length);
5389 if (!maybe_o->ToObject(&o))
return maybe_o;
5393 int dest_position = 0;
5394 for (
int i = 0; i < length; dest_position++) {
5396 destination->
Set(dest_position, Unescape(source, i, length, &step));
5403 static const unsigned int kQuoteTableLength = 128u;
5405 static const int kJsonQuotesCharactersPerEntry = 8;
5406 static const char*
const JsonQuotes =
5407 "\\u0000 \\u0001 \\u0002 \\u0003 "
5408 "\\u0004 \\u0005 \\u0006 \\u0007 "
5409 "\\b \\t \\n \\u000b "
5410 "\\f \\r \\u000e \\u000f "
5411 "\\u0010 \\u0011 \\u0012 \\u0013 "
5412 "\\u0014 \\u0015 \\u0016 \\u0017 "
5413 "\\u0018 \\u0019 \\u001a \\u001b "
5414 "\\u001c \\u001d \\u001e \\u001f "
5443 static const int kMaxGuaranteedNewSpaceString = 32 * 1024;
5447 static const int kJsonQuoteWorstCaseBlowup = 6;
5449 static const int kSpaceForQuotesAndComma = 3;
5450 static const int kSpaceForBrackets = 2;
5454 static const byte JsonQuoteLengths[kQuoteTableLength] = {
5455 6, 6, 6, 6, 6, 6, 6, 6,
5456 2, 2, 2, 6, 2, 2, 6, 6,
5457 6, 6, 6, 6, 6, 6, 6, 6,
5458 6, 6, 6, 6, 6, 6, 6, 6,
5459 1, 1, 2, 1, 1, 1, 1, 1,
5460 1, 1, 1, 1, 1, 1, 1, 1,
5461 1, 1, 1, 1, 1, 1, 1, 1,
5462 1, 1, 1, 1, 1, 1, 1, 1,
5463 1, 1, 1, 1, 1, 1, 1, 1,
5464 1, 1, 1, 1, 1, 1, 1, 1,
5465 1, 1, 1, 1, 1, 1, 1, 1,
5466 1, 1, 1, 1, 2, 1, 1, 1,
5467 1, 1, 1, 1, 1, 1, 1, 1,
5468 1, 1, 1, 1, 1, 1, 1, 1,
5469 1, 1, 1, 1, 1, 1, 1, 1,
5470 1, 1, 1, 1, 1, 1, 1, 1,
5474 template <
typename StringType>
5480 return isolate->heap()->AllocateRawTwoByteString(length);
5486 return isolate->heap()->AllocateRawAsciiString(length);
5490 template <
typename Char,
typename StringType,
bool comma>
5491 static MaybeObject* SlowQuoteJsonString(
Isolate* isolate,
5492 Vector<const Char> characters) {
5493 int length = characters.length();
5494 const Char* read_cursor = characters.start();
5495 const Char* end = read_cursor + length;
5496 const int kSpaceForQuotes = 2 + (comma ? 1 :0);
5497 int quoted_length = kSpaceForQuotes;
5498 while (read_cursor < end) {
5499 Char c = *(read_cursor++);
5500 if (
sizeof(Char) > 1u &&
static_cast<unsigned>(c) >= kQuoteTableLength) {
5503 quoted_length += JsonQuoteLengths[
static_cast<unsigned>(c)];
5506 MaybeObject* new_alloc = AllocateRawString<StringType>(isolate,
5509 if (!new_alloc->ToObject(&new_object)) {
5512 StringType* new_string = StringType::cast(new_object);
5514 Char* write_cursor =
reinterpret_cast<Char*
>(
5516 if (comma) *(write_cursor++) =
',';
5517 *(write_cursor++) =
'"';
5519 read_cursor = characters.start();
5520 while (read_cursor < end) {
5521 Char c = *(read_cursor++);
5522 if (
sizeof(Char) > 1u &&
static_cast<unsigned>(c) >= kQuoteTableLength) {
5523 *(write_cursor++) = c;
5525 int len = JsonQuoteLengths[
static_cast<unsigned>(c)];
5526 const char* replacement = JsonQuotes +
5527 static_cast<unsigned>(c) * kJsonQuotesCharactersPerEntry;
5528 for (
int i = 0; i < len; i++) {
5529 *write_cursor++ = *replacement++;
5533 *(write_cursor++) =
'"';
5538 template <
typename SinkChar,
typename SourceChar>
5539 static inline SinkChar* WriteQuoteJsonString(
5541 SinkChar* write_cursor,
5542 Vector<const SourceChar> characters) {
5544 ASSERT(
sizeof(SinkChar) >=
sizeof(SourceChar));
5545 const SourceChar* read_cursor = characters.start();
5546 const SourceChar* end = read_cursor + characters.length();
5547 *(write_cursor++) =
'"';
5548 while (read_cursor < end) {
5549 SourceChar c = *(read_cursor++);
5550 if (
sizeof(SourceChar) > 1u &&
5551 static_cast<unsigned>(c) >= kQuoteTableLength) {
5552 *(write_cursor++) = static_cast<SinkChar>(c);
5554 int len = JsonQuoteLengths[
static_cast<unsigned>(c)];
5555 const char* replacement = JsonQuotes +
5556 static_cast<unsigned>(c) * kJsonQuotesCharactersPerEntry;
5557 write_cursor[0] = replacement[0];
5559 write_cursor[1] = replacement[1];
5562 write_cursor[2] = replacement[2];
5563 write_cursor[3] = replacement[3];
5564 write_cursor[4] = replacement[4];
5565 write_cursor[5] = replacement[5];
5568 write_cursor += len;
5571 *(write_cursor++) =
'"';
5572 return write_cursor;
5576 template <
typename Char,
typename StringType,
bool comma>
5577 static MaybeObject* QuoteJsonString(Isolate* isolate,
5578 Vector<const Char> characters) {
5579 int length = characters.length();
5580 isolate->counters()->quote_json_char_count()->Increment(length);
5581 int worst_case_length =
5582 length * kJsonQuoteWorstCaseBlowup + kSpaceForQuotesAndComma;
5583 if (worst_case_length > kMaxGuaranteedNewSpaceString) {
5584 return SlowQuoteJsonString<Char, StringType, comma>(isolate, characters);
5587 MaybeObject* new_alloc = AllocateRawString<StringType>(isolate,
5590 if (!new_alloc->ToObject(&new_object)) {
5593 if (!isolate->heap()->new_space()->Contains(new_object)) {
5598 return SlowQuoteJsonString<Char, StringType, comma>(isolate, characters);
5600 StringType* new_string = StringType::cast(new_object);
5601 ASSERT(isolate->heap()->new_space()->Contains(new_string));
5603 Char* write_cursor =
reinterpret_cast<Char*
>(
5605 if (comma) *(write_cursor++) =
',';
5606 write_cursor = WriteQuoteJsonString<Char, Char>(isolate,
5609 int final_length =
static_cast<int>(
5610 write_cursor -
reinterpret_cast<Char*
>(
5612 isolate->heap()->new_space()->
5613 template ShrinkStringAtAllocationBoundary<StringType>(
5614 new_string, final_length);
5620 NoHandleAllocation ha;
5622 if (!str->IsFlat()) {
5623 MaybeObject* try_flatten = str->TryFlatten();
5625 if (!try_flatten->ToObject(&flat)) {
5634 return QuoteJsonString<uc16, SeqTwoByteString, false>(isolate,
5637 return QuoteJsonString<char, SeqAsciiString, false>(isolate,
5644 NoHandleAllocation ha;
5646 if (!str->IsFlat()) {
5647 MaybeObject* try_flatten = str->TryFlatten();
5649 if (!try_flatten->ToObject(&flat)) {
5657 return QuoteJsonString<uc16, SeqTwoByteString, true>(isolate,
5660 return QuoteJsonString<char, SeqAsciiString, true>(isolate,
5666 template <
typename Char,
typename StringType>
5667 static MaybeObject* QuoteJsonStringArray(
Isolate* isolate,
5669 int worst_case_length) {
5670 int length = array->length();
5672 MaybeObject* new_alloc = AllocateRawString<StringType>(isolate,
5675 if (!new_alloc->ToObject(&new_object)) {
5678 if (!isolate->heap()->new_space()->Contains(new_object)) {
5683 return isolate->heap()->undefined_value();
5685 AssertNoAllocation no_gc;
5686 StringType* new_string = StringType::cast(new_object);
5687 ASSERT(isolate->heap()->new_space()->Contains(new_string));
5689 Char* write_cursor =
reinterpret_cast<Char*
>(
5691 *(write_cursor++) =
'[';
5692 for (
int i = 0; i < length; i++) {
5693 if (i != 0) *(write_cursor++) =
',';
5696 ASSERT(content.IsFlat());
5697 if (content.IsTwoByte()) {
5698 write_cursor = WriteQuoteJsonString<Char, uc16>(isolate,
5700 content.ToUC16Vector());
5702 write_cursor = WriteQuoteJsonString<Char, char>(isolate,
5704 content.ToAsciiVector());
5707 *(write_cursor++) =
']';
5709 int final_length =
static_cast<int>(
5710 write_cursor -
reinterpret_cast<Char*
>(
5712 isolate->heap()->new_space()->
5713 template ShrinkStringAtAllocationBoundary<StringType>(
5714 new_string, final_length);
5720 NoHandleAllocation ha;
5721 ASSERT(args.length() == 1);
5724 if (!array->HasFastObjectElements()) {
5725 return isolate->heap()->undefined_value();
5728 int n = elements->
length();
5730 int total_length = 0;
5732 for (
int i = 0; i < n; i++) {
5734 if (!elt->IsString())
return isolate->heap()->undefined_value();
5736 if (!element->
IsFlat())
return isolate->heap()->undefined_value();
5737 total_length += element->
length();
5743 int worst_case_length =
5744 kSpaceForBrackets + n * kSpaceForQuotesAndComma
5745 + total_length * kJsonQuoteWorstCaseBlowup;
5747 if (worst_case_length > kMaxGuaranteedNewSpaceString) {
5748 return isolate->heap()->undefined_value();
5752 return QuoteJsonStringArray<char, SeqAsciiString>(isolate,
5756 return QuoteJsonStringArray<uc16, SeqTwoByteString>(isolate,
5764 NoHandleAllocation ha;
5772 double value =
StringToInt(isolate->unicode_cache(), s, radix);
5773 return isolate->heap()->NumberFromDouble(value);
5778 NoHandleAllocation ha;
5786 return isolate->heap()->NumberFromDouble(value);
5790 template <
class Converter>
5795 int input_string_length,
5809 { MaybeObject* maybe_o = s->IsAsciiRepresentation()
5810 ? isolate->heap()->AllocateRawAsciiString(length)
5811 : isolate->heap()->AllocateRawTwoByteString(length);
5812 if (!maybe_o->ToObject(&o))
return maybe_o;
5815 bool has_changed_character =
false;
5819 Access<StringInputBuffer> buffer(
5820 isolate->runtime_state()->string_input_buffer());
5824 uc32 current = buffer->GetNext();
5825 for (
int i = 0; i < length;) {
5826 bool has_next = buffer->has_more();
5827 uc32 next = has_next ? buffer->GetNext() : 0;
5828 int char_length = mapping->
get(current, next, chars);
5829 if (char_length == 0) {
5831 result->Set(i, current);
5833 }
else if (char_length == 1) {
5835 ASSERT(static_cast<uc32>(chars[0]) != current);
5836 result->Set(i, chars[0]);
5837 has_changed_character =
true;
5839 }
else if (length == input_string_length) {
5851 int next_length = 0;
5853 next_length = mapping->
get(next, 0, chars);
5854 if (next_length == 0) next_length = 1;
5856 int current_length = i + char_length + next_length;
5857 while (buffer->has_more()) {
5858 current = buffer->GetNext();
5863 int char_length = mapping->
get(current, 0, chars);
5864 if (char_length == 0) char_length = 1;
5865 current_length += char_length;
5867 isolate->context()->mark_out_of_memory();
5874 for (
int j = 0; j < char_length; j++) {
5875 result->Set(i, chars[j]);
5878 has_changed_character =
true;
5882 if (has_changed_character) {
5906 static inline uintptr_t AsciiRangeMask(uintptr_t w,
char m,
char n) {
5908 ASSERT((w & (kOneInEveryByte * 0x7F)) == w);
5911 ASSERT(0 < m && m < n && n < 0x7F);
5913 uintptr_t tmp1 = kOneInEveryByte * (0x7F + n) - w;
5915 uintptr_t tmp2 = w + kOneInEveryByte * (0x7F - m);
5916 return (tmp1 & tmp2 & (kOneInEveryByte * 0x80));
5920 enum AsciiCaseConversion {
5926 template <AsciiCaseConversion dir>
5927 struct FastAsciiConverter {
5928 static bool Convert(
char* dst,
char* src,
int length) {
5930 char* saved_dst = dst;
5931 char* saved_src = src;
5935 ASSERT(
'a' -
'A' == (1 << 5));
5937 const char lo = (dir == ASCII_TO_LOWER) ?
'A' - 1 :
'a' - 1;
5938 const char hi = (dir == ASCII_TO_LOWER) ?
'Z' + 1 :
'z' + 1;
5939 bool changed =
false;
5940 char*
const limit = src + length;
5941 #ifdef V8_HOST_CAN_READ_UNALIGNED
5944 while (src <= limit -
sizeof(uintptr_t)) {
5945 uintptr_t w = *
reinterpret_cast<uintptr_t*
>(src);
5946 if (AsciiRangeMask(w, lo, hi) != 0) {
5950 *
reinterpret_cast<uintptr_t*
>(dst) = w;
5951 src +=
sizeof(uintptr_t);
5952 dst +=
sizeof(uintptr_t);
5956 while (src <= limit -
sizeof(uintptr_t)) {
5957 uintptr_t w = *
reinterpret_cast<uintptr_t*
>(src);
5958 uintptr_t m = AsciiRangeMask(w, lo, hi);
5962 *
reinterpret_cast<uintptr_t*
>(dst) = w ^ (m >> 2);
5963 src +=
sizeof(uintptr_t);
5964 dst +=
sizeof(uintptr_t);
5969 while (src < limit) {
5971 if (lo < c && c < hi) {
5980 CheckConvert(saved_dst, saved_src, length, changed);
5986 static void CheckConvert(
char* dst,
char* src,
int length,
bool changed) {
5987 bool expected_changed =
false;
5988 for (
int i = 0; i < length; i++) {
5989 if (dst[i] == src[i])
continue;
5990 expected_changed =
true;
5991 if (dir == ASCII_TO_LOWER) {
5992 ASSERT(
'A' <= src[i] && src[i] <=
'Z');
5993 ASSERT(dst[i] == src[i] + (
'a' -
'A'));
5995 ASSERT(dir == ASCII_TO_UPPER);
5996 ASSERT(
'a' <= src[i] && src[i] <=
'z');
5997 ASSERT(dst[i] == src[i] - (
'a' -
'A'));
6000 ASSERT(expected_changed == changed);
6006 struct ToLowerTraits {
6009 typedef FastAsciiConverter<ASCII_TO_LOWER> AsciiConverter;
6013 struct ToUpperTraits {
6016 typedef FastAsciiConverter<ASCII_TO_UPPER> AsciiConverter;
6022 template <
typename ConvertTraits>
6027 NoHandleAllocation ha;
6029 s = s->TryFlattenGetString();
6031 const int length = s->length();
6033 if (length == 0)
return s;
6041 if (s->IsSeqAsciiString()) {
6043 { MaybeObject* maybe_o = isolate->heap()->AllocateRawAsciiString(length);
6044 if (!maybe_o->ToObject(&o))
return maybe_o;
6047 bool has_changed_character = ConvertTraits::AsciiConverter::Convert(
6049 return has_changed_character ? result : s;
6053 { MaybeObject* maybe_answer =
6054 ConvertCaseHelper(isolate, s, length, length, mapping);
6055 if (!maybe_answer->ToObject(&answer))
return maybe_answer;
6057 if (answer->IsSmi()) {
6059 { MaybeObject* maybe_answer =
6060 ConvertCaseHelper(isolate,
6061 s,
Smi::cast(answer)->value(), length, mapping);
6062 if (!maybe_answer->ToObject(&answer))
return maybe_answer;
6070 return ConvertCase<ToLowerTraits>(
6071 args, isolate, isolate->runtime_state()->to_lower_mapping());
6076 return ConvertCase<ToUpperTraits>(
6077 args, isolate, isolate->runtime_state()->to_upper_mapping());
6087 NoHandleAllocation ha;
6088 ASSERT(args.length() == 3);
6095 int length = s->length();
6099 while (left < length && IsTrimWhiteSpace(s->Get(left))) {
6106 while (right > left && IsTrimWhiteSpace(s->Get(right - 1))) {
6110 return s->SubString(left, right);
6115 ASSERT(args.length() == 3);
6121 int subject_length = subject->
length();
6122 int pattern_length = pattern->length();
6125 if (limit == 0xffffffffu) {
6134 isolate->factory()->NewJSArrayWithElements(
6146 static const int kMaxInitialListCapacity = 16;
6148 Zone* zone = isolate->runtime_zone();
6152 int initial_capacity = Min<uint32_t>(kMaxInitialListCapacity, limit);
6158 if (static_cast<uint32_t>(indices.length()) < limit) {
6159 indices.Add(subject_length, zone);
6165 int part_count = indices.length();
6168 MaybeObject* maybe_result = result->EnsureCanContainHeapObjectElements();
6169 if (maybe_result->IsFailure())
return maybe_result;
6172 ASSERT(result->HasFastObjectElements());
6174 if (part_count == 1 && indices.at(0) == subject_length) {
6181 for (
int i = 0; i < part_count; i++) {
6183 int part_end = indices.at(i);
6185 isolate->factory()->NewProperSubString(subject, part_start, part_end);
6186 elements->set(i, *substring);
6187 part_start = part_end + pattern_length;
6190 if (limit == 0xffffffffu) {
6191 if (result->HasFastObjectElements()) {
6208 static int CopyCachedAsciiCharsToArray(Heap* heap,
6210 FixedArray* elements,
6212 AssertNoAllocation no_gc;
6213 FixedArray* ascii_cache = heap->single_character_string_cache();
6214 Object* undefined = heap->undefined_value();
6217 for (i = 0; i < length; ++i) {
6218 Object* value = ascii_cache->get(chars[i]);
6219 if (value == undefined)
break;
6220 elements->set(i, value, mode);
6224 memset(elements->data_start() + i, 0,
kPointerSize * (length - i));
6227 for (
int j = 0; j < length; ++j) {
6228 Object* element = elements->get(j);
6241 ASSERT(args.length() == 2);
6246 const int length =
static_cast<int>(Min<uint32_t>(s->length(), limit));
6250 if (s->IsFlat() && s->IsAsciiRepresentation()) {
6253 { MaybeObject* maybe_obj =
6254 isolate->heap()->AllocateUninitializedFixedArray(length);
6255 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
6259 if (content.IsAscii()) {
6263 position = CopyCachedAsciiCharsToArray(isolate->heap(),
6269 isolate->heap()->undefined_value(),
6273 elements = isolate->factory()->NewFixedArray(length);
6275 for (
int i = position; i < length; ++i) {
6277 elements->set(i, *str);
6281 for (
int i = 0; i < length; ++i) {
6286 return *isolate->factory()->NewJSArrayWithElements(elements);
6291 NoHandleAllocation ha;
6292 ASSERT(args.length() == 1);
6301 return char_length == 0;
6306 NoHandleAllocation ha;
6307 ASSERT(args.length() == 1);
6309 Object* number = args[0];
6312 return isolate->heap()->NumberToString(number);
6317 NoHandleAllocation ha;
6318 ASSERT(args.length() == 1);
6320 Object* number = args[0];
6323 return isolate->heap()->NumberToString(number,
false);
6328 NoHandleAllocation ha;
6329 ASSERT(args.length() == 1);
6342 NoHandleAllocation ha;
6343 ASSERT(args.length() == 1);
6354 if (double_value == 0) double_value = 0;
6356 return isolate->heap()->NumberFromDouble(double_value);
6361 NoHandleAllocation ha;
6362 ASSERT(args.length() == 1);
6365 return isolate->heap()->NumberFromUint32(number);
6370 NoHandleAllocation ha;
6371 ASSERT(args.length() == 1);
6379 return isolate->heap()->NumberFromInt32(
DoubleToInt32(number));
6386 NoHandleAllocation ha;
6387 ASSERT(args.length() == 1);
6393 if (obj->IsHeapNumber()) {
6395 int int_value =
FastD2I(value);
6400 return isolate->heap()->nan_value();
6405 NoHandleAllocation ha;
6406 ASSERT(args.length() == 0);
6407 return isolate->heap()->AllocateHeapNumber(0);
6412 NoHandleAllocation ha;
6413 ASSERT(args.length() == 2);
6417 return isolate->heap()->NumberFromDouble(x + y);
6422 NoHandleAllocation ha;
6423 ASSERT(args.length() == 2);
6427 return isolate->heap()->NumberFromDouble(x - y);
6432 NoHandleAllocation ha;
6433 ASSERT(args.length() == 2);
6437 return isolate->heap()->NumberFromDouble(x * y);
6442 NoHandleAllocation ha;
6443 ASSERT(args.length() == 1);
6446 return isolate->heap()->NumberFromDouble(-x);
6451 NoHandleAllocation ha;
6452 ASSERT(args.length() == 0);
6454 return isolate->heap()->NumberFromDouble(9876543210.0);
6459 NoHandleAllocation ha;
6460 ASSERT(args.length() == 2);
6464 return isolate->heap()->NumberFromDouble(x / y);
6469 NoHandleAllocation ha;
6470 ASSERT(args.length() == 2);
6477 return isolate->heap()->NumberFromDouble(x);
6482 NoHandleAllocation ha;
6483 ASSERT(args.length() == 2);
6486 isolate->counters()->string_add_runtime()->Increment();
6487 return isolate->heap()->AllocateConsString(str1, str2);
6491 template <
typename sink
char>
6492 static inline void StringBuilderConcatHelper(
String* special,
6494 FixedArray* fixed_array,
6497 for (
int i = 0; i < array_length; i++) {
6498 Object* element = fixed_array->get(i);
6499 if (element->IsSmi()) {
6504 if (encoded_slice > 0) {
6510 Object* obj = fixed_array->get(++i);
6513 len = -encoded_slice;
6522 int element_length =
string->length();
6524 position += element_length;
6531 NoHandleAllocation ha;
6532 ASSERT(args.length() == 3);
6534 if (!args[1]->IsSmi()) {
6535 isolate->context()->mark_out_of_memory();
6538 int array_length = args.smi_at(1);
6544 MaybeObject* maybe_result = array->EnsureCanContainHeapObjectElements();
6545 if (maybe_result->IsFailure())
return maybe_result;
6547 int special_length = special->length();
6548 if (!array->HasFastObjectElements()) {
6549 return isolate->Throw(isolate->heap()->illegal_argument_symbol());
6552 if (fixed_array->
length() < array_length) {
6553 array_length = fixed_array->
length();
6556 if (array_length == 0) {
6557 return isolate->heap()->empty_string();
6558 }
else if (array_length == 1) {
6560 if (first->IsString())
return first;
6563 bool ascii = special->HasOnlyAsciiChars();
6565 for (
int i = 0; i < array_length; i++) {
6573 if (smi_value > 0) {
6582 if (i >= array_length) {
6583 return isolate->Throw(isolate->heap()->illegal_argument_symbol());
6586 if (!next_smi->IsSmi()) {
6587 return isolate->Throw(isolate->heap()->illegal_argument_symbol());
6591 return isolate->Throw(isolate->heap()->illegal_argument_symbol());
6596 if (pos > special_length || len > special_length - pos) {
6597 return isolate->Throw(isolate->heap()->illegal_argument_symbol());
6600 }
else if (elt->IsString()) {
6602 int element_length = element->
length();
6603 increment = element_length;
6608 ASSERT(!elt->IsTheHole());
6609 return isolate->Throw(isolate->heap()->illegal_argument_symbol());
6612 isolate->context()->mark_out_of_memory();
6615 position += increment;
6618 int length = position;
6622 { MaybeObject* maybe_object =
6623 isolate->heap()->AllocateRawAsciiString(length);
6624 if (!maybe_object->ToObject(&
object))
return maybe_object;
6627 StringBuilderConcatHelper(special,
6633 { MaybeObject* maybe_object =
6634 isolate->heap()->AllocateRawTwoByteString(length);
6635 if (!maybe_object->ToObject(&
object))
return maybe_object;
6638 StringBuilderConcatHelper(special,
6648 NoHandleAllocation ha;
6649 ASSERT(args.length() == 3);
6651 if (!args[1]->IsSmi()) {
6652 isolate->context()->mark_out_of_memory();
6655 int array_length = args.smi_at(1);
6658 if (!array->HasFastObjectElements()) {
6659 return isolate->Throw(isolate->heap()->illegal_argument_symbol());
6662 if (fixed_array->
length() < array_length) {
6663 array_length = fixed_array->
length();
6666 if (array_length == 0) {
6667 return isolate->heap()->empty_string();
6668 }
else if (array_length == 1) {
6670 if (first->IsString())
return first;
6673 int separator_length = separator->length();
6674 int max_nof_separators =
6676 if (max_nof_separators < (array_length - 1)) {
6677 isolate->context()->mark_out_of_memory();
6680 int length = (array_length - 1) * separator_length;
6681 for (
int i = 0; i < array_length; i++) {
6682 Object* element_obj = fixed_array->
get(i);
6683 if (!element_obj->IsString()) {
6685 return isolate->Throw(isolate->heap()->illegal_argument_symbol());
6688 int increment = element->
length();
6690 isolate->context()->mark_out_of_memory();
6693 length += increment;
6697 { MaybeObject* maybe_object =
6698 isolate->heap()->AllocateRawTwoByteString(length);
6699 if (!maybe_object->ToObject(&
object))
return maybe_object;
6705 uc16* end = sink + length;
6709 int first_length = first->
length();
6711 sink += first_length;
6713 for (
int i = 1; i < array_length; i++) {
6714 ASSERT(sink + separator_length <= end);
6716 sink += separator_length;
6719 int element_length = element->
length();
6720 ASSERT(sink + element_length <= end);
6722 sink += element_length;
6730 template <
typename Char>
6731 static void JoinSparseArrayWithSeparator(FixedArray* elements,
6732 int elements_length,
6733 uint32_t array_length,
6735 Vector<Char> buffer) {
6736 int previous_separator_position = 0;
6737 int separator_length = separator->length();
6739 for (
int i = 0; i < elements_length; i += 2) {
6742 int string_length =
string->
length();
6743 if (string->length() > 0) {
6744 while (previous_separator_position < position) {
6745 String::WriteToFlat<Char>(separator, &buffer[cursor],
6746 0, separator_length);
6747 cursor += separator_length;
6748 previous_separator_position++;
6750 String::WriteToFlat<Char>(string, &buffer[cursor],
6752 cursor +=
string->length();
6755 if (separator_length > 0) {
6758 ASSERT(array_length <= 0x7fffffff);
6759 int last_array_index =
static_cast<int>(array_length - 1);
6760 while (previous_separator_position < last_array_index) {
6761 String::WriteToFlat<Char>(separator, &buffer[cursor],
6762 0, separator_length);
6763 cursor += separator_length;
6764 previous_separator_position++;
6767 ASSERT(cursor <= buffer.length());
6772 NoHandleAllocation ha;
6773 ASSERT(args.length() == 3);
6784 int string_length = 0;
6785 bool is_ascii = separator->IsAsciiRepresentation();
6786 int max_string_length;
6794 Int32, elements_array->length());
6797 for (
int i = 0; i < elements_length; i += 2) {
6801 int length =
string->
length();
6802 if (is_ascii && !string->IsAsciiRepresentation()) {
6806 if (length > max_string_length ||
6807 max_string_length - length < string_length) {
6811 string_length += length;
6813 int separator_length = separator->length();
6814 if (!overflow && separator_length > 0) {
6815 if (array_length <= 0x7fffffffu) {
6816 int separator_count =
static_cast<int>(array_length) - 1;
6817 int remaining_length = max_string_length - string_length;
6818 if ((remaining_length / separator_length) >= separator_count) {
6819 string_length += separator_length * (array_length - 1);
6837 MaybeObject* result_allocation =
6838 isolate->heap()->AllocateRawAsciiString(string_length);
6839 if (result_allocation->IsFailure())
return result_allocation;
6842 JoinSparseArrayWithSeparator<char>(elements,
6848 return result_string;
6850 MaybeObject* result_allocation =
6851 isolate->heap()->AllocateRawTwoByteString(string_length);
6852 if (result_allocation->IsFailure())
return result_allocation;
6855 JoinSparseArrayWithSeparator<uc16>(elements,
6861 return result_string;
6867 NoHandleAllocation ha;
6868 ASSERT(args.length() == 2);
6872 return isolate->heap()->NumberFromInt32(x | y);
6877 NoHandleAllocation ha;
6878 ASSERT(args.length() == 2);
6882 return isolate->heap()->NumberFromInt32(x & y);
6887 NoHandleAllocation ha;
6888 ASSERT(args.length() == 2);
6892 return isolate->heap()->NumberFromInt32(x ^ y);
6897 NoHandleAllocation ha;
6898 ASSERT(args.length() == 1);
6901 return isolate->heap()->NumberFromInt32(~x);
6906 NoHandleAllocation ha;
6907 ASSERT(args.length() == 2);
6911 return isolate->heap()->NumberFromInt32(x << (y & 0x1f));
6916 NoHandleAllocation ha;
6917 ASSERT(args.length() == 2);
6921 return isolate->heap()->NumberFromUint32(x >> (y & 0x1f));
6926 NoHandleAllocation ha;
6927 ASSERT(args.length() == 2);
6936 NoHandleAllocation ha;
6937 ASSERT(args.length() == 2);
6955 NoHandleAllocation ha;
6956 ASSERT(args.length() == 2);
6965 ASSERT(not_equal == 0 || not_equal == 1);
6973 NoHandleAllocation ha;
6974 ASSERT(args.length() == 3);
6988 NoHandleAllocation ha;
6989 ASSERT(args.length() == 2);
6998 if (x_value == 0 || y_value == 0)
7007 uint32_t x_scaled = x_value;
7008 uint32_t y_scaled = y_value;
7009 if (x_value < 0 || y_value < 0) {
7012 x_scaled = -x_value;
7013 y_scaled = -y_value;
7016 static const uint32_t kPowersOf10[] = {
7017 1, 10, 100, 1000, 10*1000, 100*1000,
7018 1000*1000, 10*1000*1000, 100*1000*1000,
7031 int x_log10 = ((x_log2 + 1) * 1233) >> 12;
7032 x_log10 -= x_scaled < kPowersOf10[x_log10];
7035 int y_log10 = ((y_log2 + 1) * 1233) >> 12;
7036 y_log10 -= y_scaled < kPowersOf10[y_log10];
7040 if (x_log10 < y_log10) {
7047 x_scaled *= kPowersOf10[y_log10 - x_log10 - 1];
7050 }
else if (y_log10 < x_log10) {
7051 y_scaled *= kPowersOf10[x_log10 - y_log10 - 1];
7062 static Object* StringInputBufferCompare(RuntimeState* state,
7065 StringInputBuffer& bufx = *state->string_input_buffer_compare_bufx();
7066 StringInputBuffer& bufy = *state->string_input_buffer_compare_bufy();
7069 while (bufx.has_more() && bufy.has_more()) {
7070 int d = bufx.GetNext() - bufy.GetNext();
7082 static Object* FlatStringCompare(String* x, String* y) {
7086 int prefix_length = x->length();
7087 if (y->length() < prefix_length) {
7088 prefix_length = y->length();
7090 }
else if (y->length() > prefix_length) {
7094 String::FlatContent x_content = x->GetFlatContent();
7095 String::FlatContent y_content = y->GetFlatContent();
7096 if (x_content.IsAscii()) {
7097 Vector<const char> x_chars = x_content.ToAsciiVector();
7098 if (y_content.IsAscii()) {
7099 Vector<const char> y_chars = y_content.ToAsciiVector();
7100 r =
CompareChars(x_chars.start(), y_chars.start(), prefix_length);
7102 Vector<const uc16> y_chars = y_content.ToUC16Vector();
7103 r =
CompareChars(x_chars.start(), y_chars.start(), prefix_length);
7106 Vector<const uc16> x_chars = x_content.ToUC16Vector();
7107 if (y_content.IsAscii()) {
7108 Vector<const char> y_chars = y_content.ToAsciiVector();
7109 r =
CompareChars(x_chars.start(), y_chars.start(), prefix_length);
7111 Vector<const uc16> y_chars = y_content.ToUC16Vector();
7112 r =
CompareChars(x_chars.start(), y_chars.start(), prefix_length);
7117 result = equal_prefix_result;
7122 StringInputBufferCompare(Isolate::Current()->runtime_state(), x, y));
7128 NoHandleAllocation ha;
7129 ASSERT(args.length() == 2);
7134 isolate->counters()->string_compare_runtime()->Increment();
7138 if (y->length() == 0) {
7141 }
else if (x->length() == 0) {
7145 int d = x->Get(0) - y->Get(0);
7150 { MaybeObject* maybe_obj = isolate->heap()->PrepareForCompare(x);
7151 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
7153 { MaybeObject* maybe_obj = isolate->heap()->PrepareForCompare(y);
7154 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
7157 return (x->IsFlat() && y->IsFlat()) ? FlatStringCompare(x, y)
7158 : StringInputBufferCompare(isolate->runtime_state(), x, y);
7163 NoHandleAllocation ha;
7164 ASSERT(args.length() == 1);
7165 isolate->counters()->math_acos()->Increment();
7173 NoHandleAllocation ha;
7174 ASSERT(args.length() == 1);
7175 isolate->counters()->math_asin()->Increment();
7183 NoHandleAllocation ha;
7184 ASSERT(args.length() == 1);
7185 isolate->counters()->math_atan()->Increment();
7192 static const double kPiDividedBy4 = 0.78539816339744830962;
7196 NoHandleAllocation ha;
7197 ASSERT(args.length() == 2);
7198 isolate->counters()->math_atan2()->Increment();
7208 int multiplier = (x < 0) ? -1 : 1;
7209 if (y < 0) multiplier *= 3;
7210 result = multiplier * kPiDividedBy4;
7212 result = atan2(x, y);
7214 return isolate->heap()->AllocateHeapNumber(result);
7219 NoHandleAllocation ha;
7220 ASSERT(args.length() == 1);
7221 isolate->counters()->math_ceil()->Increment();
7224 return isolate->heap()->NumberFromDouble(
ceiling(x));
7229 NoHandleAllocation ha;
7230 ASSERT(args.length() == 1);
7231 isolate->counters()->math_cos()->Increment();
7239 NoHandleAllocation ha;
7240 ASSERT(args.length() == 1);
7241 isolate->counters()->math_exp()->Increment();
7249 NoHandleAllocation ha;
7250 ASSERT(args.length() == 1);
7251 isolate->counters()->math_floor()->Increment();
7254 return isolate->heap()->NumberFromDouble(floor(x));
7259 NoHandleAllocation ha;
7260 ASSERT(args.length() == 1);
7261 isolate->counters()->math_log()->Increment();
7270 NoHandleAllocation ha;
7271 ASSERT(args.length() == 2);
7272 isolate->counters()->math_pow()->Increment();
7278 if (args[1]->IsSmi()) {
7279 int y = args.smi_at(1);
7284 int y_int =
static_cast<int>(y);
7288 }
else if (y == 0.5) {
7291 }
else if (y == -0.5) {
7292 result = (
isinf(x)) ? 0
7297 if (
isnan(result))
return isolate->heap()->nan_value();
7298 return isolate->heap()->AllocateHeapNumber(result);
7304 NoHandleAllocation ha;
7305 ASSERT(args.length() == 2);
7306 isolate->counters()->math_pow()->Increment();
7314 if (
isnan(result))
return isolate->heap()->nan_value();
7315 return isolate->heap()->AllocateHeapNumber(result);
7321 NoHandleAllocation ha;
7322 ASSERT(args.length() == 1);
7323 isolate->counters()->math_round()->Increment();
7325 if (!args[0]->IsHeapNumber()) {
7333 double value = number->
value();
7337 if (exponent < -1) {
7339 if (sign)
return isolate->heap()->minus_zero_value();
7352 if (exponent >= 52) {
7356 if (sign && value >= -0.5)
return isolate->heap()->minus_zero_value();
7359 return isolate->heap()->AllocateHeapNumber(floor(value + 0.5));
7364 NoHandleAllocation ha;
7365 ASSERT(args.length() == 1);
7366 isolate->counters()->math_sin()->Increment();
7374 NoHandleAllocation ha;
7375 ASSERT(args.length() == 1);
7376 isolate->counters()->math_sqrt()->Increment();
7379 return isolate->heap()->AllocateHeapNumber(
fast_sqrt(x));
7384 NoHandleAllocation ha;
7385 ASSERT(args.length() == 1);
7386 isolate->counters()->math_tan()->Increment();
7394 NoHandleAllocation ha;
7395 ASSERT(args.length() == 2);
7400 return Smi::FromInt(isolate->date_cache()->DaysFromYearMonth(year, month));
7406 ASSERT(args.length() == 3);
7412 DateCache* date_cache = isolate->date_cache();
7415 bool is_value_nan =
false;
7417 value = isolate->heap()->nan_value();
7418 is_value_nan =
true;
7419 }
else if (!is_utc &&
7422 value = isolate->heap()->nan_value();
7423 is_value_nan =
true;
7425 time = is_utc ? time : date_cache->
ToUTC(static_cast<int64_t>(time));
7428 value = isolate->heap()->nan_value();
7429 is_value_nan =
true;
7431 MaybeObject* maybe_result =
7433 if (!maybe_result->ToObject(&value))
return maybe_result;
7436 date->SetValue(value, is_value_nan);
7443 ASSERT(args.length() == 3);
7446 Object** parameters =
reinterpret_cast<Object**
>(args[1]);
7450 isolate->factory()->NewArgumentsObject(callee, argument_count);
7452 int parameter_count = callee->shared()->formal_parameter_count();
7453 if (argument_count > 0) {
7454 if (parameter_count > 0) {
7455 int mapped_count =
Min(argument_count, parameter_count);
7457 isolate->factory()->NewFixedArray(mapped_count + 2,
NOT_TENURED);
7458 parameter_map->set_map(
7459 isolate->heap()->non_strict_arguments_elements_map());
7462 Handle<Map> new_map = isolate->factory()->CopyMap(old_map);
7465 result->set_map(*new_map);
7466 result->set_elements(*parameter_map);
7472 isolate->factory()->NewFixedArray(argument_count,
NOT_TENURED);
7473 parameter_map->set(0, *context);
7474 parameter_map->set(1, *arguments);
7477 int index = argument_count - 1;
7478 while (index >= mapped_count) {
7481 arguments->set(index, *(parameters - index - 1));
7486 while (index >= 0) {
7489 int context_local_count = scope_info->ContextLocalCount();
7490 bool duplicate =
false;
7491 for (
int j = index + 1; j < parameter_count; ++j) {
7492 if (scope_info->ParameterName(j) == *name) {
7501 arguments->set(index, *(parameters - index - 1));
7502 parameter_map->set_the_hole(index + 2);
7506 int context_index = -1;
7507 for (
int j = 0; j < context_local_count; ++j) {
7508 if (scope_info->ContextLocalName(j) == *name) {
7513 ASSERT(context_index >= 0);
7514 arguments->set_the_hole(index);
7525 isolate->factory()->NewFixedArray(argument_count,
NOT_TENURED);
7526 result->set_elements(*elements);
7527 for (
int i = 0; i < argument_count; ++i) {
7528 elements->set(i, *(parameters - i - 1));
7537 NoHandleAllocation ha;
7538 ASSERT(args.length() == 3);
7541 Object** parameters =
reinterpret_cast<Object**
>(args[1]);
7542 const int length = args.smi_at(2);
7545 { MaybeObject* maybe_result =
7546 isolate->heap()->AllocateArgumentsObject(callee, length);
7547 if (!maybe_result->ToObject(&result))
return maybe_result;
7553 { MaybeObject* maybe_obj = isolate->heap()->AllocateRawFixedArray(length);
7554 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
7563 for (
int i = 0; i < length; i++) {
7564 array->
set(i, *--parameters, mode);
7574 ASSERT(args.length() == 3);
7583 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared,
7593 static SmartArrayPointer<Handle<Object> > GetCallerArguments(
7598 JavaScriptFrame* frame = it.frame();
7599 List<JSFunction*> functions(2);
7600 frame->GetFunctions(&functions);
7601 if (functions.length() > 1) {
7602 int inlined_jsframe_index = functions.length() - 1;
7603 JSFunction* inlined_function = functions[inlined_jsframe_index];
7604 Vector<SlotRef> args_slots =
7605 SlotRef::ComputeSlotMappingForArguments(
7607 inlined_jsframe_index,
7608 inlined_function->shared()->formal_parameter_count());
7610 int args_count = args_slots.length();
7612 *total_argc = prefix_argc + args_count;
7613 SmartArrayPointer<Handle<Object> > param_data(
7615 for (
int i = 0; i < args_count; i++) {
7617 param_data[prefix_argc + i] = val;
7620 args_slots.Dispose();
7624 it.AdvanceToArgumentsFrame();
7626 int args_count = frame->ComputeParametersCount();
7628 *total_argc = prefix_argc + args_count;
7629 SmartArrayPointer<Handle<Object> > param_data(
7630 NewArray<Handle<Object> >(*total_argc));
7631 for (
int i = 0; i < args_count; i++) {
7632 Handle<Object> val = Handle<Object>(frame->GetParameter(i));
7633 param_data[prefix_argc + i] = val;
7642 ASSERT(args.length() == 4);
7648 bound_function->shared()->set_bound(
true);
7654 ASSERT(*arguments[0] == args[2]);
7657 ASSERT(args[2]->IsUndefined());
7663 if (bindee->IsJSFunction() &&
JSFunction::cast(*bindee)->shared()->bound()) {
7667 isolate->factory()->NewFixedArray(old_bindings->length() + argc);
7670 for (
int n = old_bindings->length(); i < n; i++) {
7671 new_bindings->set(i, old_bindings->get(i));
7675 new_bindings = isolate->factory()->NewFixedArray(array_size);
7681 for (
int j = 0; j < argc; j++, i++) {
7682 new_bindings->set(i, *arguments[j + 1]);
7684 new_bindings->set_map_no_write_barrier(
7685 isolate->heap()->fixed_cow_array_map());
7686 bound_function->set_function_bindings(*new_bindings);
7689 Handle<String> length_symbol = isolate->factory()->length_symbol();
7694 return *bound_function;
7700 ASSERT(args.length() == 1);
7702 if (callable->IsJSFunction()) {
7704 if (function->shared()->bound()) {
7706 ASSERT(bindings->map() == isolate->heap()->fixed_cow_array_map());
7707 return *isolate->factory()->NewJSArrayWithElements(bindings);
7710 return isolate->heap()->undefined_value();
7716 ASSERT(args.length() == 1);
7728 ASSERT(!bound_function->IsJSFunction() ||
7733 GetCallerArguments(bound_argc, &total_argc);
7734 for (
int i = 0; i < bound_argc; i++) {
7739 if (!bound_function->IsJSFunction()) {
7740 bool exception_thrown;
7745 ASSERT(bound_function->IsJSFunction());
7747 bool exception =
false;
7750 total_argc, *param_data, &exception);
7759 static void TrySettingInlineConstructStub(
Isolate* isolate,
7762 if (function->has_instance_prototype()) {
7763 prototype =
Handle<Object>(
function->instance_prototype(), isolate);
7765 if (function->shared()->CanGenerateInlineConstructor(*prototype)) {
7766 ConstructStubCompiler compiler(isolate);
7767 Handle<Code> code = compiler.CompileConstructStub(
function);
7768 function->shared()->set_construct_stub(*code);
7775 ASSERT(args.length() == 1);
7780 if (!constructor->IsJSFunction()) {
7783 isolate->factory()->NewTypeError(
"not_constructor", arguments);
7784 return isolate->Throw(*type_error);
7791 if (!function->should_have_prototype() && !
function->shared()->bound()) {
7794 isolate->factory()->NewTypeError(
"not_constructor", arguments);
7795 return isolate->Throw(*type_error);
7798 #ifdef ENABLE_DEBUGGER_SUPPORT
7799 Debug* debug = isolate->debug();
7801 if (debug->StepInActive()) {
7806 if (function->has_initial_map()) {
7819 return isolate->context()->global_object();
7828 if (!function->has_initial_map() &&
7829 shared->IsInobjectSlackTrackingInProgress()) {
7833 shared->CompleteInobjectSlackTracking();
7836 bool first_allocation = !shared->live_objects_may_exist();
7840 if (first_allocation && !shared->IsInobjectSlackTrackingInProgress()) {
7841 TrySettingInlineConstructStub(isolate,
function);
7844 isolate->counters()->constructed_objects()->Increment();
7845 isolate->counters()->constructed_objects_runtime()->Increment();
7853 ASSERT(args.length() == 1);
7856 function->shared()->CompleteInobjectSlackTracking();
7857 TrySettingInlineConstructStub(isolate,
function);
7859 return isolate->heap()->undefined_value();
7865 ASSERT(args.length() == 1);
7869 if (FLAG_trace_lazy && !function->shared()->is_compiled()) {
7871 function->PrintName();
7877 ASSERT(!function->is_compiled());
7883 ASSERT(function->is_compiled());
7884 return function->code();
7890 ASSERT(args.length() == 1);
7896 if (!function->shared()->is_compiled()) {
7897 function->
ReplaceCode(function->shared()->code());
7898 return function->code();
7903 if (!FLAG_crankshaft ||
7904 !function->shared()->code()->optimizable() ||
7905 isolate->DebuggerHasBreakPoints()) {
7906 if (FLAG_trace_opt) {
7907 PrintF(
"[failed to optimize ");
7908 function->PrintName();
7909 PrintF(
": is code optimizable: %s, is debugger enabled: %s]\n",
7910 function->shared()->code()->optimizable() ?
"T" :
"F",
7911 isolate->DebuggerHasBreakPoints() ?
"T" :
"F");
7913 function->ReplaceCode(function->shared()->code());
7914 return function->code();
7916 function->shared()->code()->set_profiler_ticks(0);
7920 return function->code();
7922 if (FLAG_trace_opt) {
7923 PrintF(
"[failed to optimize ");
7924 function->PrintName();
7925 PrintF(
": optimized compilation failed]\n");
7927 function->ReplaceCode(function->shared()->code());
7928 return function->code();
7934 ASSERT(FLAG_parallel_recompilation);
7936 return *isolate->factory()->undefined_value();
7943 : function_(function), has_activations_(
false) {}
7946 if (has_activations_)
return;
7950 if (frame->is_optimized() && frame->
function() == function_) {
7951 has_activations_ =
true;
7961 bool has_activations_;
7967 ASSERT(args.length() == 1);
7972 ASSERT(isolate->heap()->IsAllocationAllowed());
7987 return isolate->heap()->undefined_value();
7992 bool has_other_activations =
false;
7993 while (!it.done()) {
7996 if (frame->is_optimized() && other_function->
code() ==
function->code()) {
7997 has_other_activations =
true;
8003 if (!has_other_activations) {
8005 isolate->thread_manager()->IterateArchivedThreads(&activations_finder);
8009 if (!has_other_activations) {
8010 if (FLAG_trace_deopt) {
8011 PrintF(
"[removing optimized code for: ");
8012 function->PrintName();
8015 function->ReplaceCode(function->shared()->code());
8020 function->shared()->ClearOptimizedCodeMap();
8022 return isolate->heap()->undefined_value();
8029 return isolate->heap()->undefined_value();
8035 ASSERT(args.length() == 1);
8037 if (!function->IsOptimized())
return isolate->heap()->undefined_value();
8041 return isolate->heap()->undefined_value();
8047 ASSERT(args.length() == 1);
8049 Code* unoptimized =
function->shared()->code();
8050 if (unoptimized->
kind() == Code::FUNCTION) {
8054 return isolate->heap()->undefined_value();
8059 #if defined(USE_SIMULATOR)
8060 return isolate->heap()->true_value();
8062 return isolate->heap()->false_value();
8072 if (!function->IsOptimizable())
return isolate->heap()->undefined_value();
8073 function->MarkForLazyRecompilation();
8075 Code* unoptimized =
function->shared()->code();
8076 if (args.length() == 2 &&
8077 unoptimized->
kind() == Code::FUNCTION) {
8080 isolate->runtime_profiler()->AttemptOnStackReplacement(*
function);
8085 return isolate->heap()->undefined_value();
8091 ASSERT(args.length() == 1);
8098 if (FLAG_parallel_recompilation) {
8099 if (function->IsMarkedForLazyRecompilation()) {
8103 if (FLAG_always_opt) {
8116 ASSERT(args.length() == 1);
8124 ASSERT(args.length() == 1);
8128 ASSERT(!function->shared()->uses_arguments());
8132 Handle<Code> unoptimized(function->shared()->code(), isolate);
8134 bool succeeded = unoptimized->optimizable();
8142 while (succeeded && !it.done()) {
8144 succeeded = !frame->is_optimized() || frame->
function() != *
function;
8156 ASSERT(frame->LookupCode() == *unoptimized);
8157 ASSERT(unoptimized->contains(frame->pc()));
8161 Address start = unoptimized->instruction_start();
8162 unsigned target_pc_offset =
static_cast<unsigned>(frame->pc() - start);
8163 Address table_cursor = start + unoptimized->stack_check_table_offset();
8166 for (
unsigned i = 0; i < table_length; ++i) {
8169 if (pc_offset == target_pc_offset) {
8176 if (FLAG_trace_osr) {
8177 PrintF(
"[replacing on-stack at AST id %d in ", ast_id.
ToInt());
8178 function->PrintName();
8186 function->IsOptimized()) {
8188 function->code()->deoptimization_data());
8189 if (data->OsrPcOffset()->value() >= 0) {
8190 if (FLAG_trace_osr) {
8191 PrintF(
"[on-stack replacement offset %d in optimized code]\n",
8192 data->OsrPcOffset()->value());
8206 if (FLAG_trace_osr) {
8207 PrintF(
"[restoring original stack checks in ");
8208 function->PrintName();
8212 if (FLAG_count_based_interrupts) {
8214 check_code = interrupt_stub.GetCode();
8218 check_code = check_stub.GetCode();
8220 Handle<Code> replacement_code = isolate->builtins()->OnStackReplacement();
8226 unoptimized->set_allow_osr_at_loop_nesting_level(0);
8232 ASSERT(function->code()->kind() == Code::OPTIMIZED_FUNCTION);
8235 if (function->IsMarkedForLazyRecompilation()) {
8236 function->ReplaceCode(function->shared()->code());
8245 return isolate->heap()->undefined_value();
8251 return isolate->heap()->nan_value();
8257 ASSERT(args.length() >= 2);
8258 int argc = args.length() - 2;
8260 Object* receiver = args[0];
8263 const int argv_small_size = 10;
8267 if (argc > argv_small_size) {
8269 if (argv ==
NULL)
return isolate->StackOverflow();
8273 for (
int i = 0; i < argc; ++i) {
8274 MaybeObject* maybe = args[1 + i];
8276 if (!maybe->To<
Object>(&
object))
return maybe;
8293 ASSERT(args.length() == 5);
8303 const int argv_small_size = 10;
8307 if (argc > argv_small_size) {
8309 if (argv ==
NULL)
return isolate->StackOverflow();
8313 for (
int i = 0; i < argc; ++i) {
8328 ASSERT(args.length() == 1);
8336 ASSERT(args.length() == 1);
8343 NoHandleAllocation ha;
8344 ASSERT(args.length() == 2);
8349 MaybeObject* maybe_result =
8350 isolate->heap()->AllocateGlobalContext(
function, scope_info);
8351 if (!maybe_result->To(&result))
return maybe_result;
8353 ASSERT(function->context() == isolate->context());
8355 isolate->set_context(result);
8363 NoHandleAllocation ha;
8364 ASSERT(args.length() == 1);
8367 int length =
function->shared()->scope_info()->ContextLength();
8369 MaybeObject* maybe_result =
8370 isolate->heap()->AllocateFunctionContext(length,
function);
8371 if (!maybe_result->To(&result))
return maybe_result;
8373 isolate->set_context(result);
8380 NoHandleAllocation ha;
8381 ASSERT(args.length() == 2);
8383 if (args[0]->IsJSObject()) {
8387 MaybeObject* maybe_js_object = args[0]->ToObject();
8388 if (!maybe_js_object->To(&extension_object)) {
8393 isolate->factory()->NewTypeError(
"with_expression",
8395 return isolate->Throw(*result);
8397 return maybe_js_object;
8403 if (args[1]->IsSmi()) {
8407 function = isolate->context()->native_context()->closure();
8413 MaybeObject* maybe_context =
8414 isolate->heap()->AllocateWithContext(
function,
8417 if (!maybe_context->To(&context))
return maybe_context;
8418 isolate->set_context(context);
8424 NoHandleAllocation ha;
8425 ASSERT(args.length() == 3);
8427 Object* thrown_object = args[1];
8429 if (args[2]->IsSmi()) {
8433 function = isolate->context()->native_context()->closure();
8438 MaybeObject* maybe_context =
8439 isolate->heap()->AllocateCatchContext(
function,
8443 if (!maybe_context->To(&context))
return maybe_context;
8444 isolate->set_context(context);
8450 NoHandleAllocation ha;
8451 ASSERT(args.length() == 2);
8454 if (args[1]->IsSmi()) {
8458 function = isolate->context()->native_context()->closure();
8463 MaybeObject* maybe_context =
8464 isolate->heap()->AllocateBlockContext(
function,
8467 if (!maybe_context->To(&context))
return maybe_context;
8468 isolate->set_context(context);
8474 ASSERT(args.length() == 1);
8476 return isolate->heap()->ToBoolean(obj->IsJSModule());
8481 NoHandleAllocation ha;
8482 ASSERT(args.length() == 1);
8486 Context* previous = isolate->context();
8492 isolate->set_context(context);
8500 ASSERT(args.length() == 2);
8517 return isolate->heap()->true_value();
8521 if (holder->IsContext()) {
8522 return isolate->heap()->false_value();
8541 #ifdef V8_HOST_ARCH_64_BIT
8547 static inline ObjectPair MakePair(MaybeObject* x, MaybeObject* y) {
8555 static inline ObjectPair MakePair(MaybeObject* x, MaybeObject* y) {
8556 return reinterpret_cast<uint32_t
>(x) |
8557 (reinterpret_cast<ObjectPair>(y) << 32);
8562 static inline MaybeObject* Unhole(Heap* heap,
8567 return x->IsTheHole() ? heap->undefined_value() : x;
8571 static Object* ComputeReceiverForNonGlobal(Isolate* isolate,
8573 ASSERT(!holder->IsGlobalObject());
8574 Context* top = isolate->context();
8576 JSFunction* context_extension_function =
8577 top->native_context()->context_extension_function();
8582 Object* constructor = holder->map()->constructor();
8583 if (constructor != context_extension_function)
return holder;
8588 return isolate->heap()->the_hole_value();
8592 static ObjectPair LoadContextSlotHelper(Arguments args,
8595 HandleScope scope(isolate);
8598 if (!args[0]->IsContext() || !args[1]->IsString()) {
8599 return MakePair(isolate->ThrowIllegalOperation(),
NULL);
8601 Handle<Context> context = args.at<Context>(0);
8602 Handle<String> name = args.at<String>(1);
8608 Handle<Object> holder = context->Lookup(name,
8616 ASSERT(holder->IsContext());
8623 Handle<Object> receiver = isolate->factory()->the_hole_value();
8626 switch (binding_flags) {
8629 if (value->IsTheHole()) {
8630 Handle<Object> reference_error =
8631 isolate->factory()->NewReferenceError(
"not_defined",
8633 return MakePair(isolate->Throw(*reference_error),
NULL);
8639 ASSERT(!value->IsTheHole());
8640 return MakePair(value, *receiver);
8642 return MakePair(Unhole(isolate->heap(), value, attributes), *receiver);
8652 if (!holder.is_null()) {
8654 ASSERT(object->HasProperty(*name));
8656 Handle<Object> receiver_handle(object->IsGlobalObject()
8658 : ComputeReceiverForNonGlobal(isolate, *
object));
8662 MaybeObject* value =
object->GetProperty(*name);
8663 return MakePair(value, *receiver_handle);
8668 Handle<Object> reference_error =
8669 isolate->factory()->NewReferenceError(
"not_defined",
8671 return MakePair(isolate->Throw(*reference_error),
NULL);
8674 return MakePair(isolate->heap()->undefined_value(),
8675 isolate->heap()->undefined_value());
8681 return LoadContextSlotHelper(args, isolate,
true);
8686 return LoadContextSlotHelper(args, isolate,
false);
8692 ASSERT(args.length() == 4);
8715 context->
get(index)->IsTheHole()) {
8717 isolate->factory()->NewReferenceError(
"not_defined",
8719 return isolate->Throw(*error);
8724 context->
set(index, *value);
8728 isolate->factory()->NewTypeError(
"strict_cannot_assign",
8730 return isolate->Throw(*error);
8750 isolate->factory()->NewReferenceError(
8752 return isolate->Throw(*error);
8761 (
object->GetLocalPropertyAttribute(*name) ==
ABSENT)) {
8765 }
else if (strict_mode ==
kStrictMode && (attributes & READ_ONLY) != 0) {
8768 isolate->factory()->NewTypeError(
8770 return isolate->Throw(*error);
8778 ASSERT(args.length() == 1);
8780 return isolate->Throw(args[0]);
8786 ASSERT(args.length() == 1);
8788 return isolate->ReThrow(args[0]);
8794 return isolate->PromoteScheduledException();
8800 ASSERT(args.length() == 1);
8804 isolate->factory()->NewReferenceError(
"not_defined",
8806 return isolate->Throw(*reference_error);
8812 ASSERT(args.length() == 0);
8813 return isolate->Throw(*isolate->factory()->NewTypeError(
8814 "not_date_object", HandleVector<Object>(
NULL, 0)));
8820 ASSERT(args.length() == 0);
8823 if (isolate->stack_guard()->IsStackOverflow()) {
8824 NoHandleAllocation na;
8825 return isolate->StackOverflow();
8833 ASSERT(args.length() == 0);
8838 static int StackSize() {
8845 static void PrintTransition(
Object* result) {
8847 {
const int nmax = 80;
8848 int n = StackSize();
8850 PrintF(
"%4d:%*s", n, n,
"");
8852 PrintF(
"%4d:%*s", n, nmax,
"...");
8855 if (result ==
NULL) {
8861 result->ShortPrint();
8868 ASSERT(args.length() == 0);
8869 NoHandleAllocation ha;
8870 PrintTransition(
NULL);
8871 return isolate->heap()->undefined_value();
8876 NoHandleAllocation ha;
8877 PrintTransition(args[0]);
8883 NoHandleAllocation ha;
8884 ASSERT(args.length() == 1);
8887 if (args[0]->IsString()) {
8892 PrintF(
"fp = %p, sp = %p, caller_sp = %p: ",
8893 frame->fp(), frame->sp(), frame->caller_sp());
8898 if (args[0]->IsHeapObject()) {
8914 ASSERT(args.length() == 0);
8915 NoHandleAllocation ha;
8916 isolate->PrintStack();
8917 return isolate->heap()->undefined_value();
8922 NoHandleAllocation ha;
8923 ASSERT(args.length() == 0);
8930 return isolate->heap()->NumberFromDouble(millis);
8936 ASSERT(args.length() == 2);
8943 MaybeObject* maybe_result_array =
8944 output->EnsureCanContainHeapObjectElements();
8945 if (maybe_result_array->IsFailure())
return maybe_result_array;
8957 isolate->unicode_cache());
8962 isolate->unicode_cache());
8968 return isolate->heap()->null_value();
8974 NoHandleAllocation ha;
8975 ASSERT(args.length() == 1);
8978 int64_t time = isolate->date_cache()->EquivalentTime(static_cast<int64_t>(x));
8980 return isolate->heap()->AllocateStringFromUtf8(
CStrVector(zone));
8985 NoHandleAllocation ha;
8986 ASSERT(args.length() == 1);
8989 int64_t time = isolate->date_cache()->ToUTC(static_cast<int64_t>(x));
8991 return isolate->heap()->NumberFromDouble(static_cast<double>(time));
8996 ASSERT(args.length() == 1);
8997 Object* global = args[0];
8998 if (!global->IsJSGlobalObject())
return isolate->heap()->null_value();
9008 Zone* zone = isolate->runtime_zone();
9012 if (source->IsSeqAsciiString()) {
9013 result = JsonParser<true>::Parse(source, zone);
9015 result = JsonParser<false>::Parse(source, zone);
9019 ASSERT(isolate->has_pending_exception());
9028 ASSERT(context->allow_code_gen_from_strings()->IsFalse());
9031 isolate->allow_code_gen_callback();
9032 if (callback ==
NULL) {
9037 VMState state(isolate, EXTERNAL);
9053 if (context->allow_code_gen_from_strings()->IsFalse() &&
9056 context->ErrorMessageForCodeGenerationFromStrings();
9057 return isolate->Throw(*isolate->factory()->NewEvalError(
9058 "code_gen_from_strings", HandleVector<Object>(&error_message, 1)));
9063 source, context,
true,
CLASSIC_MODE, RelocInfo::kNoPosition);
9066 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared,
9077 int scope_position) {
9083 if (native_context->allow_code_gen_from_strings()->IsFalse() &&
9087 isolate->Throw(*isolate->factory()->NewEvalError(
9088 "code_gen_from_strings", HandleVector<Object>(&error_message, 1)));
9096 Handle<Context>(isolate->context()),
9097 context->IsNativeContext(),
9101 Handle<JSFunction> compiled =
9102 isolate->factory()->NewFunctionFromSharedFunctionInfo(
9104 return MakePair(*compiled, *receiver);
9109 ASSERT(args.length() == 5);
9119 if (*callee != isolate->native_context()->global_eval_fun() ||
9120 !args[1]->IsString()) {
9121 return MakePair(*callee, isolate->heap()->the_hole_value());
9125 ASSERT(args[4]->IsSmi());
9126 return CompileGlobalEval(isolate,
9140 ASSERT(args.length() == 1);
9143 Handle<Map> map = func->shared()->is_classic_mode()
9144 ? isolate->function_instance_map()
9145 : isolate->strict_mode_function_instance_map();
9147 ASSERT(func->map()->instance_type() == map->instance_type());
9148 ASSERT(func->map()->instance_size() == map->instance_size());
9149 func->set_map(*map);
9158 ASSERT(args.length() == 1);
9160 int size = size_smi->value();
9163 Heap* heap = isolate->heap();
9167 { MaybeObject* maybe_allocation = heap->
new_space()->AllocateRaw(size);
9168 if (maybe_allocation->ToObject(&allocation)) {
9171 return maybe_allocation;
9180 ASSERT(args.length() == 2);
9184 int length =
Smi::cast(array->length())->value();
9186 for (
int i = 0; i < length; i++) {
9187 if (elements->
get(i) == element)
return isolate->heap()->false_value();
9191 { MaybeObject* maybe_obj =
9193 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
9195 return isolate->heap()->true_value();
9214 bool fast_elements) :
9217 isolate->global_handles()->Create(*storage))),
9219 fast_elements_(fast_elements) { }
9227 uint32_t index = index_offset_ + i;
9229 if (fast_elements_) {
9230 if (index < static_cast<uint32_t>(storage_->length())) {
9231 storage_->set(index, *elm);
9238 SetDictionaryMode(index);
9249 set_storage(*result);
9257 index_offset_ += delta;
9266 if (fast_elements_) {
9273 array->set_map(*map);
9274 array->set_length(*length);
9275 array->set_elements(*storage_);
9281 void SetDictionaryMode(uint32_t index) {
9286 current_storage->length()));
9287 uint32_t current_length =
static_cast<uint32_t
>(current_storage->length());
9288 for (uint32_t i = 0; i < current_length; i++) {
9291 if (!element->IsTheHole()) {
9300 set_storage(*slow_storage);
9301 fast_elements_ =
false;
9304 inline void clear_storage() {
9309 inline void set_storage(FixedArray* storage) {
9315 Handle<FixedArray> storage_;
9318 uint32_t index_offset_;
9319 bool fast_elements_;
9323 static uint32_t EstimateElementCount(Handle<JSArray> array) {
9324 uint32_t length =
static_cast<uint32_t
>(array->length()->Number());
9325 int element_count = 0;
9326 switch (array->GetElementsKind()) {
9334 int fast_length =
static_cast<int>(length);
9336 for (
int i = 0; i < fast_length; i++) {
9337 if (!elements->get(i)->IsTheHole()) element_count++;
9347 Handle<SeededNumberDictionary> dictionary(
9349 int capacity = dictionary->Capacity();
9350 for (
int i = 0; i < capacity; i++) {
9351 Handle<Object> key(dictionary->KeyAt(i));
9352 if (dictionary->IsKey(*key)) {
9373 return element_count;
9378 template<
class ExternalArrayClass,
class ElementType>
9379 static void IterateExternalArrayElements(Isolate* isolate,
9380 Handle<JSObject> receiver,
9381 bool elements_are_ints,
9382 bool elements_are_guaranteed_smis,
9383 ArrayConcatVisitor* visitor) {
9384 Handle<ExternalArrayClass> array(
9385 ExternalArrayClass::cast(receiver->elements()));
9386 uint32_t len =
static_cast<uint32_t
>(array->length());
9389 if (elements_are_ints) {
9390 if (elements_are_guaranteed_smis) {
9391 for (uint32_t j = 0; j < len; j++) {
9392 HandleScope loop_scope;
9393 Handle<Smi> e(
Smi::FromInt(static_cast<int>(array->get_scalar(j))));
9394 visitor->visit(j, e);
9397 for (uint32_t j = 0; j < len; j++) {
9398 HandleScope loop_scope;
9399 int64_t val =
static_cast<int64_t
>(array->get_scalar(j));
9402 visitor->visit(j, e);
9405 isolate->factory()->NewNumber(static_cast<ElementType>(val));
9406 visitor->visit(j, e);
9411 for (uint32_t j = 0; j < len; j++) {
9412 HandleScope loop_scope(isolate);
9413 Handle<Object> e = isolate->factory()->NewNumber(array->get_scalar(j));
9414 visitor->visit(j, e);
9421 static int compareUInt32(
const uint32_t* ap,
const uint32_t* bp) {
9424 return (a == b) ? 0 : (a < b) ? -1 : 1;
9428 static void CollectElementIndices(Handle<JSObject>
object,
9430 List<uint32_t>* indices) {
9438 uint32_t length =
static_cast<uint32_t
>(elements->length());
9439 if (range < length) length = range;
9440 for (uint32_t i = 0; i < length; i++) {
9441 if (!elements->get(i)->IsTheHole()) {
9454 Handle<SeededNumberDictionary> dict(
9456 uint32_t capacity = dict->Capacity();
9457 for (uint32_t j = 0; j < capacity; j++) {
9458 HandleScope loop_scope;
9459 Handle<Object> k(dict->KeyAt(j));
9460 if (dict->IsKey(*k)) {
9462 uint32_t index =
static_cast<uint32_t
>(k->Number());
9463 if (index < range) {
9464 indices->Add(index);
9471 int dense_elements_length;
9474 dense_elements_length =
9479 dense_elements_length =
9484 dense_elements_length =
9489 dense_elements_length =
9494 dense_elements_length =
9499 dense_elements_length =
9504 dense_elements_length =
9509 dense_elements_length =
9514 dense_elements_length =
9520 dense_elements_length = 0;
9523 uint32_t length =
static_cast<uint32_t
>(dense_elements_length);
9524 if (range <= length) {
9530 for (uint32_t i = 0; i < length; i++) {
9533 if (length == range)
return;
9538 Handle<Object> prototype(object->GetPrototype());
9539 if (prototype->IsJSObject()) {
9542 CollectElementIndices(Handle<JSObject>::cast(prototype), range, indices);
9557 static bool IterateElements(Isolate* isolate,
9558 Handle<JSArray> receiver,
9559 ArrayConcatVisitor* visitor) {
9560 uint32_t length =
static_cast<uint32_t
>(receiver->length()->Number());
9561 switch (receiver->GetElementsKind()) {
9569 int fast_length =
static_cast<int>(length);
9570 ASSERT(fast_length <= elements->length());
9571 for (
int j = 0; j < fast_length; j++) {
9572 HandleScope loop_scope(isolate);
9573 Handle<Object> element_value(elements->get(j), isolate);
9574 if (!element_value->IsTheHole()) {
9575 visitor->visit(j, element_value);
9576 }
else if (receiver->HasElement(j)) {
9581 visitor->visit(j, element_value);
9593 Handle<SeededNumberDictionary> dict(receiver->element_dictionary());
9594 List<uint32_t> indices(dict->Capacity() / 2);
9597 CollectElementIndices(receiver, length, &indices);
9598 indices.Sort(&compareUInt32);
9600 int n = indices.length();
9602 HandleScope loop_scope;
9603 uint32_t index = indices[j];
9606 visitor->visit(index, element);
9610 }
while (j < n && indices[j] == index);
9616 receiver->elements()));
9617 for (uint32_t j = 0; j < length; j++) {
9619 visitor->visit(j, e);
9624 IterateExternalArrayElements<ExternalByteArray, int8_t>(
9625 isolate, receiver,
true,
true, visitor);
9629 IterateExternalArrayElements<ExternalUnsignedByteArray, uint8_t>(
9630 isolate, receiver,
true,
true, visitor);
9634 IterateExternalArrayElements<ExternalShortArray, int16_t>(
9635 isolate, receiver,
true,
true, visitor);
9639 IterateExternalArrayElements<ExternalUnsignedShortArray, uint16_t>(
9640 isolate, receiver,
true,
true, visitor);
9644 IterateExternalArrayElements<ExternalIntArray, int32_t>(
9645 isolate, receiver,
true,
false, visitor);
9649 IterateExternalArrayElements<ExternalUnsignedIntArray, uint32_t>(
9650 isolate, receiver,
true,
false, visitor);
9654 IterateExternalArrayElements<ExternalFloatArray, float>(
9655 isolate, receiver,
false,
false, visitor);
9659 IterateExternalArrayElements<ExternalDoubleArray, double>(
9660 isolate, receiver,
false,
false, visitor);
9667 visitor->increase_index_offset(length);
9679 ASSERT(args.length() == 1);
9683 int argument_count =
static_cast<int>(arguments->length()->Number());
9692 uint32_t estimate_result_length = 0;
9693 uint32_t estimate_nof_elements = 0;
9695 for (
int i = 0; i < argument_count; i++) {
9698 uint32_t length_estimate;
9699 uint32_t element_estimate;
9700 if (obj->IsJSArray()) {
9705 if (array->HasFastDoubleElements()) {
9707 if (array->HasFastHoleyElements()) {
9714 static_cast<uint32_t
>(array->length()->Number());
9716 EstimateElementCount(array);
9718 length_estimate = 1;
9719 element_estimate = 1;
9726 estimate_result_length += length_estimate;
9732 estimate_nof_elements += element_estimate;
9740 bool fast_case = (estimate_nof_elements * 2) >= estimate_result_length;
9746 storage = isolate->factory()->NewFixedArrayWithHoles(
9747 estimate_result_length);
9750 uint32_t at_least_space_for = estimate_nof_elements +
9751 (estimate_nof_elements >> 2);
9753 isolate->factory()->NewSeededNumberDictionary(at_least_space_for));
9758 for (
int i = 0; i < argument_count; i++) {
9760 if (obj->IsJSArray()) {
9762 if (!IterateElements(isolate, array, &visitor)) {
9766 visitor.
visit(0, obj);
9778 NoHandleAllocation ha;
9779 ASSERT(args.length() == 1);
9796 ASSERT(args.length() == 2);
9799 return object->PrepareElementsForSort(limit);
9805 ASSERT(args.length() == 2);
9808 from->ValidateElements();
9809 to->ValidateElements();
9812 MaybeObject* maybe_new_map;
9813 maybe_new_map = to->GetElementsTransitionMap(isolate, from_kind);
9815 if (!maybe_new_map->ToObject(&new_map))
return maybe_new_map;
9816 to->set_map_and_elements(
Map::cast(new_map), new_elements);
9817 to->set_length(from->length());
9819 { MaybeObject* maybe_obj = from->ResetElements();
9820 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
9823 to->ValidateElements();
9830 ASSERT(args.length() == 1);
9833 if (elements->IsDictionary()) {
9836 }
else if (object->IsJSArray()) {
9850 ASSERT(args.length() == 2);
9854 if (array->elements()->IsDictionary()) {
9862 int keys_length = keys->length();
9863 for (
int i = 0; i < keys_length; i++) {
9864 Object* key = keys->get(i);
9868 keys->set_undefined(i);
9871 return *isolate->factory()->NewJSArrayWithElements(keys);
9873 ASSERT(array->HasFastSmiOrObjectElements() ||
9874 array->HasFastDoubleElements());
9879 uint32_t actual_length =
9880 static_cast<uint32_t
>(elements->
length());
9881 uint32_t min_length = actual_length < length ? actual_length : length;
9883 isolate->factory()->NewNumber(static_cast<double>(min_length));
9884 single_interval->set(1, *length_object);
9885 return *isolate->factory()->NewJSArrayWithElements(single_interval);
9891 ASSERT(args.length() == 3);
9896 if (!receiver->IsJSObject())
return isolate->heap()->undefined_value();
9901 #ifdef ENABLE_DEBUGGER_SUPPORT
9903 ASSERT(args.length() == 0);
9904 return Execution::DebugBreakHelper();
9909 static Smi* WrapFrameId(StackFrame::Id
id) {
9915 static StackFrame::Id UnwrapFrameId(
int wrapped) {
9916 return static_cast<StackFrame::Id
>(wrapped << 2);
9925 ASSERT(args.length() == 2);
9927 args[0]->IsUndefined() ||
9929 Handle<Object> callback = args.at<
Object>(0);
9930 Handle<Object> data = args.at<
Object>(1);
9931 isolate->debugger()->SetEventListener(callback, data);
9933 return isolate->heap()->undefined_value();
9938 ASSERT(args.length() == 0);
9939 isolate->stack_guard()->DebugBreak();
9940 return isolate->heap()->undefined_value();
9944 static MaybeObject* DebugLookupResultValue(Heap* heap,
9947 LookupResult* result,
9948 bool* caught_exception) {
9950 switch (result->type()) {
9952 value = result->holder()->GetNormalizedProperty(result);
9953 if (value->IsTheHole()) {
9954 return heap->undefined_value();
9960 result->holder())->FastPropertyAt(result->GetFieldIndex());
9961 if (value->IsTheHole()) {
9962 return heap->undefined_value();
9966 return result->GetConstantFunction();
9968 Object* structure = result->GetCallbackObject();
9969 if (structure->IsForeign() || structure->IsAccessorInfo()) {
9970 MaybeObject* maybe_value = result->holder()->GetPropertyWithCallback(
9971 receiver, structure, name);
9972 if (!maybe_value->ToObject(&value)) {
9973 if (maybe_value->IsRetryAfterGC())
return maybe_value;
9974 ASSERT(maybe_value->IsException());
9975 maybe_value = heap->isolate()->pending_exception();
9976 heap->isolate()->clear_pending_exception();
9977 if (caught_exception !=
NULL) {
9978 *caught_exception =
true;
9984 return heap->undefined_value();
9989 return heap->undefined_value();
9993 return heap->undefined_value();
9996 return heap->undefined_value();
10013 HandleScope scope(isolate);
10015 ASSERT(args.length() == 2);
10026 SaveContext save(isolate);
10027 if (isolate->debug()->InDebugger()) {
10028 isolate->set_context(*isolate->debug()->debugger_entry()->GetContext());
10033 if (obj->IsJSGlobalProxy()) {
10041 if (name->AsArrayIndex(&index)) {
10042 Handle<FixedArray> details = isolate->factory()->NewFixedArray(2);
10043 Object* element_or_char;
10044 { MaybeObject* maybe_element_or_char =
10046 if (!maybe_element_or_char->ToObject(&element_or_char)) {
10047 return maybe_element_or_char;
10050 details->set(0, element_or_char);
10051 details->set(1, PropertyDetails(
NONE,
NORMAL).AsSmi());
10052 return *isolate->factory()->NewJSArrayWithElements(details);
10056 int length = LocalPrototypeChainLength(*obj);
10059 Handle<JSObject> jsproto = obj;
10060 for (
int i = 0; i < length; i++) {
10061 LookupResult result(isolate);
10062 jsproto->LocalLookup(*name, &result);
10063 if (result.IsFound()) {
10067 Handle<Object> result_callback_obj;
10068 if (result.IsPropertyCallbacks()) {
10069 result_callback_obj = Handle<Object>(result.GetCallbackObject(),
10072 Smi* property_details = result.GetPropertyDetails().AsSmi();
10075 bool caught_exception =
false;
10077 { MaybeObject* maybe_raw_value =
10078 DebugLookupResultValue(isolate->heap(), *obj, *name,
10079 &result, &caught_exception);
10080 if (!maybe_raw_value->ToObject(&raw_value))
return maybe_raw_value;
10082 Handle<Object> value(raw_value, isolate);
10086 bool hasJavaScriptAccessors = result.IsPropertyCallbacks() &&
10087 result_callback_obj->IsAccessorPair();
10088 Handle<FixedArray> details =
10089 isolate->factory()->NewFixedArray(hasJavaScriptAccessors ? 5 : 2);
10090 details->set(0, *value);
10091 details->set(1, property_details);
10092 if (hasJavaScriptAccessors) {
10094 details->set(2, isolate->heap()->ToBoolean(caught_exception));
10099 return *isolate->factory()->NewJSArrayWithElements(details);
10101 if (i < length - 1) {
10102 jsproto = Handle<JSObject>(
JSObject::cast(jsproto->GetPrototype()));
10106 return isolate->heap()->undefined_value();
10111 HandleScope scope(isolate);
10113 ASSERT(args.length() == 2);
10118 LookupResult result(isolate);
10119 obj->Lookup(*name, &result);
10120 if (result.IsFound()) {
10121 return DebugLookupResultValue(isolate->heap(), *obj, *name, &result,
NULL);
10123 return isolate->heap()->undefined_value();
10130 ASSERT(args.length() == 1);
10132 return Smi::FromInt(static_cast<int>(details.type()));
10138 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyAttributesFromDetails) {
10139 ASSERT(args.length() == 1);
10141 return Smi::FromInt(static_cast<int>(details.attributes()));
10148 ASSERT(args.length() == 1);
10158 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugNamedInterceptorPropertyValue) {
10159 HandleScope scope(isolate);
10160 ASSERT(args.length() == 2);
10166 return obj->GetPropertyWithInterceptor(*obj, *name, &attributes);
10173 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugIndexedInterceptorElementValue) {
10174 HandleScope scope(isolate);
10175 ASSERT(args.length() == 2);
10180 return obj->GetElementWithInterceptor(*obj, index);
10185 ASSERT(args.length() >= 1);
10188 if (isolate->debug()->break_id() == 0 ||
10189 break_id != isolate->debug()->break_id()) {
10190 return isolate->Throw(
10191 isolate->heap()->illegal_execution_state_symbol());
10194 return isolate->heap()->true_value();
10199 HandleScope scope(isolate);
10200 ASSERT(args.length() == 1);
10204 { MaybeObject* maybe_result = Runtime_CheckExecutionState(
10206 if (!maybe_result->ToObject(&result))
return maybe_result;
10211 StackFrame::Id
id = isolate->debug()->break_frame_id();
10212 if (
id == StackFrame::NO_ID) {
10218 n += it.frame()->GetInlineCount();
10224 class FrameInspector {
10226 FrameInspector(JavaScriptFrame* frame,
10227 int inlined_jsframe_index,
10229 : frame_(frame), deoptimized_frame_(
NULL), isolate_(isolate) {
10231 if (frame->is_optimized()) {
10232 deoptimized_frame_ = Deoptimizer::DebuggerInspectableFrame(
10233 frame, inlined_jsframe_index, isolate);
10235 has_adapted_arguments_ = frame_->has_adapted_arguments();
10236 is_bottommost_ = inlined_jsframe_index == 0;
10237 is_optimized_ = frame_->is_optimized();
10240 ~FrameInspector() {
10242 if (deoptimized_frame_ !=
NULL) {
10243 Deoptimizer::DeleteDebuggerInspectableFrame(deoptimized_frame_,
10248 int GetParametersCount() {
10249 return is_optimized_
10250 ? deoptimized_frame_->parameters_count()
10251 : frame_->ComputeParametersCount();
10253 int expression_count() {
return deoptimized_frame_->expression_count(); }
10255 return is_optimized_
10256 ? deoptimized_frame_->GetFunction()
10257 : frame_->function();
10259 Object* GetParameter(
int index) {
10260 return is_optimized_
10261 ? deoptimized_frame_->GetParameter(index)
10262 : frame_->GetParameter(index);
10264 Object* GetExpression(
int index) {
10265 return is_optimized_
10266 ? deoptimized_frame_->GetExpression(index)
10267 : frame_->GetExpression(index);
10269 int GetSourcePosition() {
10270 return is_optimized_
10271 ? deoptimized_frame_->GetSourcePosition()
10272 : frame_->LookupCode()->SourcePosition(frame_->pc());
10274 bool IsConstructor() {
10275 return is_optimized_ && !is_bottommost_
10276 ? deoptimized_frame_->HasConstructStub()
10277 : frame_->IsConstructor();
10282 void SetArgumentsFrame(JavaScriptFrame* frame) {
10283 ASSERT(has_adapted_arguments_);
10285 is_optimized_ = frame_->is_optimized();
10290 JavaScriptFrame* frame_;
10291 DeoptimizedFrameInfo* deoptimized_frame_;
10293 bool is_optimized_;
10294 bool is_bottommost_;
10295 bool has_adapted_arguments_;
10301 static const int kFrameDetailsFrameIdIndex = 0;
10302 static const int kFrameDetailsReceiverIndex = 1;
10303 static const int kFrameDetailsFunctionIndex = 2;
10304 static const int kFrameDetailsArgumentCountIndex = 3;
10305 static const int kFrameDetailsLocalCountIndex = 4;
10306 static const int kFrameDetailsSourcePositionIndex = 5;
10307 static const int kFrameDetailsConstructCallIndex = 6;
10308 static const int kFrameDetailsAtReturnIndex = 7;
10309 static const int kFrameDetailsFlagsIndex = 8;
10310 static const int kFrameDetailsFirstDynamicIndex = 9;
10313 static SaveContext* FindSavedContextForFrame(Isolate* isolate,
10314 JavaScriptFrame* frame) {
10315 SaveContext* save = isolate->save_context();
10316 while (save !=
NULL && !save->IsBelowFrame(frame)) {
10317 save = save->prev();
10342 HandleScope scope(isolate);
10343 ASSERT(args.length() == 2);
10347 { MaybeObject* maybe_check = Runtime_CheckExecutionState(
10349 if (!maybe_check->ToObject(&check))
return maybe_check;
10352 Heap* heap = isolate->heap();
10355 StackFrame::Id
id = isolate->debug()->break_frame_id();
10356 if (
id == StackFrame::NO_ID) {
10358 return heap->undefined_value();
10363 for (; !it.done(); it.Advance()) {
10364 if (index < count + it.frame()->GetInlineCount())
break;
10365 count += it.frame()->GetInlineCount();
10367 if (it.done())
return heap->undefined_value();
10369 bool is_optimized = it.frame()->is_optimized();
10371 int inlined_jsframe_index = 0;
10372 if (is_optimized) {
10373 inlined_jsframe_index =
10374 it.frame()->GetInlineCount() - (index - count) - 1;
10376 FrameInspector frame_inspector(it.frame(), inlined_jsframe_index, isolate);
10380 SaveContext* save = FindSavedContextForFrame(isolate, it.frame());
10383 Handle<Object> frame_id(WrapFrameId(it.frame()->id()), isolate);
10386 int position = frame_inspector.GetSourcePosition();
10389 bool constructor = frame_inspector.IsConstructor();
10392 Handle<JSFunction>
function(
JSFunction::cast(frame_inspector.GetFunction()));
10393 Handle<SharedFunctionInfo> shared(function->shared());
10394 Handle<ScopeInfo> scope_info(shared->scope_info());
10402 Handle<FixedArray> locals =
10403 isolate->factory()->NewFixedArray(scope_info->LocalCount() * 2);
10407 for (; i < scope_info->StackLocalCount(); ++i) {
10409 locals->set(i * 2, scope_info->LocalName(i));
10410 locals->set(i * 2 + 1, frame_inspector.GetExpression(i));
10412 if (i < scope_info->LocalCount()) {
10414 Handle<Context> context(
10415 Context::cast(it.frame()->context())->declaration_context());
10416 for (; i < scope_info->LocalCount(); ++i) {
10417 Handle<String> name(scope_info->LocalName(i));
10420 locals->set(i * 2, *name);
10421 locals->set(i * 2 + 1, context->
get(
10422 scope_info->ContextSlotIndex(*name, &mode, &init_flag)));
10428 bool at_return =
false;
10429 if (!is_optimized && index == 0) {
10430 at_return = isolate->debug()->IsBreakAtReturn(it.frame());
10435 Handle<Object> return_value = isolate->factory()->undefined_value();
10437 StackFrameIterator it2(isolate);
10439 while (!it2.done()) {
10440 if (it2.frame()->is_internal()) {
10441 internal_frame_sp = it2.frame()->sp();
10443 if (it2.frame()->is_java_script()) {
10444 if (it2.frame()->id() == it.frame()->id()) {
10449 if (internal_frame_sp !=
NULL) {
10459 internal_frame_sp =
NULL;
10469 if ((inlined_jsframe_index == 0) && it.frame()->has_adapted_arguments()) {
10470 it.AdvanceToArgumentsFrame();
10471 frame_inspector.SetArgumentsFrame(it.frame());
10476 int argument_count = scope_info->ParameterCount();
10477 if (argument_count < frame_inspector.GetParametersCount()) {
10478 argument_count = frame_inspector.GetParametersCount();
10482 int details_size = kFrameDetailsFirstDynamicIndex +
10483 2 * (argument_count + scope_info->LocalCount()) +
10484 (at_return ? 1 : 0);
10485 Handle<FixedArray> details = isolate->factory()->NewFixedArray(details_size);
10488 details->set(kFrameDetailsFrameIdIndex, *frame_id);
10491 details->set(kFrameDetailsFunctionIndex, frame_inspector.GetFunction());
10494 details->set(kFrameDetailsArgumentCountIndex,
Smi::FromInt(argument_count));
10497 details->set(kFrameDetailsLocalCountIndex,
10501 if (position != RelocInfo::kNoPosition) {
10502 details->set(kFrameDetailsSourcePositionIndex,
Smi::FromInt(position));
10504 details->set(kFrameDetailsSourcePositionIndex, heap->undefined_value());
10508 details->set(kFrameDetailsConstructCallIndex, heap->ToBoolean(constructor));
10511 details->set(kFrameDetailsAtReturnIndex, heap->ToBoolean(at_return));
10518 if (*save->context() == *isolate->debug()->debug_context()) {
10521 if (is_optimized) {
10523 flags |= inlined_jsframe_index << 2;
10525 details->set(kFrameDetailsFlagsIndex,
Smi::FromInt(flags));
10528 int details_index = kFrameDetailsFirstDynamicIndex;
10531 for (
int i = 0; i < argument_count; i++) {
10533 if (i < scope_info->ParameterCount()) {
10534 details->set(details_index++, scope_info->ParameterName(i));
10536 details->set(details_index++, heap->undefined_value());
10540 if (i < frame_inspector.GetParametersCount()) {
10542 details->set(details_index++, frame_inspector.GetParameter(i));
10544 details->set(details_index++, heap->undefined_value());
10549 for (
int i = 0; i < scope_info->LocalCount() * 2; i++) {
10550 details->set(details_index++, locals->get(i));
10555 details->set(details_index++, *return_value);
10561 Handle<Object> receiver(it.frame()->receiver(), isolate);
10562 if (!receiver->IsJSObject() &&
10563 shared->is_classic_mode() &&
10564 !shared->native()) {
10572 Handle<Context> calling_frames_native_context(
10575 isolate->factory()->ToObject(receiver, calling_frames_native_context);
10577 details->set(kFrameDetailsReceiverIndex, *receiver);
10579 ASSERT_EQ(details_size, details_index);
10580 return *isolate->factory()->NewJSArrayWithElements(details);
10585 static bool CopyContextLocalsToScopeObject(
10587 Handle<ScopeInfo> scope_info,
10588 Handle<Context> context,
10589 Handle<JSObject> scope_object) {
10591 for (
int i = 0; i < scope_info->ContextLocalCount(); i++) {
10594 int context_index = scope_info->ContextSlotIndex(
10595 scope_info->ContextLocalName(i), &mode, &init_flag);
10600 Handle<String>(scope_info->ContextLocalName(i)),
10601 Handle<Object>(context->get(context_index), isolate),
10613 static Handle<JSObject> MaterializeLocalScopeWithFrameInspector(
10615 JavaScriptFrame* frame,
10616 FrameInspector* frame_inspector) {
10617 Handle<JSFunction>
function(
JSFunction::cast(frame_inspector->GetFunction()));
10618 Handle<SharedFunctionInfo> shared(function->shared());
10619 Handle<ScopeInfo> scope_info(shared->scope_info());
10623 Handle<JSObject> local_scope =
10624 isolate->factory()->NewJSObject(isolate->object_function());
10627 for (
int i = 0; i < scope_info->ParameterCount(); ++i) {
10628 Handle<Object> value(
10629 i < frame_inspector->GetParametersCount() ?
10630 frame_inspector->GetParameter(i) : isolate->heap()->undefined_value());
10635 Handle<String>(scope_info->ParameterName(i)),
10639 Handle<JSObject>());
10643 for (
int i = 0; i < scope_info->StackLocalCount(); ++i) {
10647 Handle<String>(scope_info->StackLocalName(i)),
10648 Handle<Object>(frame_inspector->GetExpression(i)),
10651 Handle<JSObject>());
10654 if (scope_info->HasContext()) {
10656 Handle<Context> frame_context(
Context::cast(frame->context()));
10657 Handle<Context> function_context(frame_context->declaration_context());
10658 if (!CopyContextLocalsToScopeObject(
10659 isolate, scope_info, function_context, local_scope)) {
10660 return Handle<JSObject>();
10665 if (function_context->closure() == *
function) {
10666 if (function_context->has_extension() &&
10667 !function_context->IsNativeContext()) {
10668 Handle<JSObject> ext(
JSObject::cast(function_context->extension()));
10669 bool threw =
false;
10670 Handle<FixedArray> keys =
10672 if (threw)
return Handle<JSObject>();
10674 for (
int i = 0; i < keys->length(); i++) {
10676 ASSERT(keys->get(i)->IsString());
10685 Handle<JSObject>());
10691 return local_scope;
10695 static Handle<JSObject> MaterializeLocalScope(
10697 JavaScriptFrame* frame,
10698 int inlined_jsframe_index) {
10699 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate);
10700 return MaterializeLocalScopeWithFrameInspector(isolate,
10708 static Handle<JSObject> MaterializeClosure(Isolate* isolate,
10709 Handle<Context> context) {
10710 ASSERT(context->IsFunctionContext());
10712 Handle<SharedFunctionInfo> shared(context->closure()->shared());
10713 Handle<ScopeInfo> scope_info(shared->scope_info());
10717 Handle<JSObject> closure_scope =
10718 isolate->factory()->NewJSObject(isolate->object_function());
10721 if (!CopyContextLocalsToScopeObject(
10722 isolate, scope_info, context, closure_scope)) {
10723 return Handle<JSObject>();
10728 if (context->has_extension()) {
10730 bool threw =
false;
10731 Handle<FixedArray> keys =
10733 if (threw)
return Handle<JSObject>();
10735 for (
int i = 0; i < keys->length(); i++) {
10737 ASSERT(keys->get(i)->IsString());
10746 Handle<JSObject>());
10750 return closure_scope;
10756 static Handle<JSObject> MaterializeCatchScope(Isolate* isolate,
10757 Handle<Context> context) {
10758 ASSERT(context->IsCatchContext());
10759 Handle<String> name(
String::cast(context->extension()));
10761 Handle<JSObject> catch_scope =
10762 isolate->factory()->NewJSObject(isolate->object_function());
10766 Handle<JSObject>());
10767 return catch_scope;
10773 static Handle<JSObject> MaterializeBlockScope(
10775 Handle<Context> context) {
10776 ASSERT(context->IsBlockContext());
10781 Handle<JSObject> block_scope =
10782 isolate->factory()->NewJSObject(isolate->object_function());
10785 if (!CopyContextLocalsToScopeObject(
10786 isolate, scope_info, context, block_scope)) {
10787 return Handle<JSObject>();
10790 return block_scope;
10796 static Handle<JSObject> MaterializeModuleScope(
10798 Handle<Context> context) {
10799 ASSERT(context->IsModuleContext());
10804 Handle<JSObject> module_scope =
10805 isolate->factory()->NewJSObject(isolate->object_function());
10808 if (!CopyContextLocalsToScopeObject(
10809 isolate, scope_info, context, module_scope)) {
10810 return Handle<JSObject>();
10813 return module_scope;
10821 class ScopeIterator {
10824 ScopeTypeGlobal = 0,
10833 ScopeIterator(Isolate* isolate,
10834 JavaScriptFrame* frame,
10835 int inlined_jsframe_index)
10836 : isolate_(isolate),
10838 inlined_jsframe_index_(inlined_jsframe_index),
10839 function_(JSFunction::cast(frame->function())),
10840 context_(Context::cast(frame->context())),
10841 nested_scope_chain_(4),
10845 Handle<SharedFunctionInfo> shared_info(function_->shared());
10846 Handle<ScopeInfo> scope_info(shared_info->scope_info());
10847 if (shared_info->script() == isolate->heap()->undefined_value()) {
10848 while (context_->closure() == *function_) {
10849 context_ = Handle<Context>(context_->previous(), isolate_);
10855 if (!isolate->debug()->EnsureDebugInfo(shared_info, function_)) {
10859 Handle<DebugInfo> debug_info = Debug::GetDebugInfo(shared_info);
10862 BreakLocationIterator break_location_iterator(debug_info,
10863 ALL_BREAK_LOCATIONS);
10864 break_location_iterator.FindBreakLocationFromAddress(frame->pc());
10865 if (break_location_iterator.IsExit()) {
10870 if (scope_info->HasContext()) {
10871 context_ = Handle<Context>(context_->declaration_context(), isolate_);
10873 while (context_->closure() == *function_) {
10874 context_ = Handle<Context>(context_->previous(), isolate_);
10877 if (scope_info->Type() !=
EVAL_SCOPE) nested_scope_chain_.Add(scope_info);
10880 Handle<Script> script(
Script::cast(shared_info->script()));
10881 Scope* scope =
NULL;
10884 Handle<ScopeInfo> scope_info(shared_info->scope_info());
10887 CompilationInfoWithZone info(script);
10889 info.MarkAsGlobal();
10893 info.SetContext(Handle<Context>(function_->context()));
10896 scope = info.function()->scope();
10898 RetrieveScopeChain(scope, shared_info);
10901 CompilationInfoWithZone info(shared_info);
10903 scope = info.function()->scope();
10905 RetrieveScopeChain(scope, shared_info);
10910 ScopeIterator(Isolate* isolate,
10911 Handle<JSFunction>
function)
10912 : isolate_(isolate),
10914 inlined_jsframe_index_(0),
10915 function_(function),
10916 context_(function->context()),
10918 if (function->IsBuiltin()) {
10919 context_ = Handle<Context>();
10926 return context_.is_null();
10929 bool Failed() {
return failed_; }
10935 if (scope_type == ScopeTypeGlobal) {
10937 ASSERT(context_->IsNativeContext());
10938 context_ = Handle<Context>();
10941 if (nested_scope_chain_.is_empty()) {
10942 context_ = Handle<Context>(context_->previous(), isolate_);
10944 if (nested_scope_chain_.last()->HasContext()) {
10946 context_ = Handle<Context>(context_->previous(), isolate_);
10948 nested_scope_chain_.RemoveLast();
10955 if (!nested_scope_chain_.is_empty()) {
10956 Handle<ScopeInfo> scope_info = nested_scope_chain_.last();
10957 switch (scope_info->Type()) {
10959 ASSERT(context_->IsFunctionContext() ||
10960 !scope_info->HasContext());
10961 return ScopeTypeLocal;
10963 ASSERT(context_->IsModuleContext());
10964 return ScopeTypeModule;
10966 ASSERT(context_->IsNativeContext());
10967 return ScopeTypeGlobal;
10969 ASSERT(context_->IsWithContext());
10970 return ScopeTypeWith;
10972 ASSERT(context_->IsCatchContext());
10973 return ScopeTypeCatch;
10975 ASSERT(!scope_info->HasContext() ||
10976 context_->IsBlockContext());
10977 return ScopeTypeBlock;
10982 if (context_->IsNativeContext()) {
10983 ASSERT(context_->global_object()->IsGlobalObject());
10984 return ScopeTypeGlobal;
10986 if (context_->IsFunctionContext()) {
10987 return ScopeTypeClosure;
10989 if (context_->IsCatchContext()) {
10990 return ScopeTypeCatch;
10992 if (context_->IsBlockContext()) {
10993 return ScopeTypeBlock;
10995 if (context_->IsModuleContext()) {
10996 return ScopeTypeModule;
10998 ASSERT(context_->IsWithContext());
10999 return ScopeTypeWith;
11003 Handle<JSObject> ScopeObject() {
11006 case ScopeIterator::ScopeTypeGlobal:
11007 return Handle<JSObject>(CurrentContext()->global_object());
11008 case ScopeIterator::ScopeTypeLocal:
11010 ASSERT(nested_scope_chain_.length() == 1);
11011 return MaterializeLocalScope(isolate_, frame_, inlined_jsframe_index_);
11012 case ScopeIterator::ScopeTypeWith:
11014 return Handle<JSObject>(
JSObject::cast(CurrentContext()->extension()));
11015 case ScopeIterator::ScopeTypeCatch:
11016 return MaterializeCatchScope(isolate_, CurrentContext());
11017 case ScopeIterator::ScopeTypeClosure:
11019 return MaterializeClosure(isolate_, CurrentContext());
11020 case ScopeIterator::ScopeTypeBlock:
11021 return MaterializeBlockScope(isolate_, CurrentContext());
11022 case ScopeIterator::ScopeTypeModule:
11023 return MaterializeModuleScope(isolate_, CurrentContext());
11026 return Handle<JSObject>();
11029 Handle<ScopeInfo> CurrentScopeInfo() {
11031 if (!nested_scope_chain_.is_empty()) {
11032 return nested_scope_chain_.last();
11033 }
else if (context_->IsBlockContext()) {
11035 }
else if (context_->IsFunctionContext()) {
11036 return Handle<ScopeInfo>(context_->closure()->shared()->scope_info());
11043 Handle<Context> CurrentContext() {
11045 if (Type() == ScopeTypeGlobal ||
11046 nested_scope_chain_.is_empty()) {
11048 }
else if (nested_scope_chain_.last()->HasContext()) {
11051 return Handle<Context>();
11057 void DebugPrint() {
11060 case ScopeIterator::ScopeTypeGlobal:
11062 CurrentContext()->Print();
11065 case ScopeIterator::ScopeTypeLocal: {
11067 function_->shared()->scope_info()->Print();
11068 if (!CurrentContext().is_null()) {
11069 CurrentContext()->Print();
11070 if (CurrentContext()->has_extension()) {
11071 Handle<Object> extension(CurrentContext()->extension());
11072 if (extension->IsJSContextExtensionObject()) {
11073 extension->Print();
11080 case ScopeIterator::ScopeTypeWith:
11082 CurrentContext()->extension()->Print();
11085 case ScopeIterator::ScopeTypeCatch:
11087 CurrentContext()->extension()->Print();
11091 case ScopeIterator::ScopeTypeClosure:
11093 CurrentContext()->Print();
11094 if (CurrentContext()->has_extension()) {
11095 Handle<Object> extension(CurrentContext()->extension());
11096 if (extension->IsJSContextExtensionObject()) {
11097 extension->Print();
11111 JavaScriptFrame* frame_;
11112 int inlined_jsframe_index_;
11113 Handle<JSFunction> function_;
11114 Handle<Context> context_;
11115 List<Handle<ScopeInfo> > nested_scope_chain_;
11118 void RetrieveScopeChain(Scope* scope,
11119 Handle<SharedFunctionInfo> shared_info) {
11120 if (scope !=
NULL) {
11121 int source_position = shared_info->code()->SourcePosition(frame_->pc());
11122 scope->GetNestedScopeChain(&nested_scope_chain_, source_position);
11130 ASSERT(isolate_->has_pending_exception());
11140 HandleScope scope(isolate);
11141 ASSERT(args.length() == 2);
11145 { MaybeObject* maybe_check = Runtime_CheckExecutionState(
11147 if (!maybe_check->ToObject(&check))
return maybe_check;
11152 StackFrame::Id
id = UnwrapFrameId(wrapped_id);
11154 JavaScriptFrame* frame = it.frame();
11158 for (ScopeIterator it(isolate, frame, 0);
11168 static const int kScopeDetailsTypeIndex = 0;
11169 static const int kScopeDetailsObjectIndex = 1;
11170 static const int kScopeDetailsSize = 2;
11173 static MaybeObject* MaterializeScopeDetails(Isolate* isolate,
11174 ScopeIterator* it) {
11176 int details_size = kScopeDetailsSize;
11177 Handle<FixedArray> details = isolate->factory()->NewFixedArray(details_size);
11180 details->set(kScopeDetailsTypeIndex,
Smi::FromInt(it->Type()));
11181 Handle<JSObject> scope_object = it->ScopeObject();
11183 details->set(kScopeDetailsObjectIndex, *scope_object);
11185 return *isolate->factory()->NewJSArrayWithElements(details);
11198 HandleScope scope(isolate);
11199 ASSERT(args.length() == 4);
11203 { MaybeObject* maybe_check = Runtime_CheckExecutionState(
11205 if (!maybe_check->ToObject(&check))
return maybe_check;
11212 StackFrame::Id
id = UnwrapFrameId(wrapped_id);
11214 JavaScriptFrame* frame = frame_it.frame();
11218 ScopeIterator it(isolate, frame, inlined_jsframe_index);
11219 for (; !it.Done() && n < index; it.Next()) {
11223 return isolate->heap()->undefined_value();
11225 return MaterializeScopeDetails(isolate, &it);
11230 HandleScope scope(isolate);
11231 ASSERT(args.length() == 1);
11238 for (ScopeIterator it(isolate, fun); !it.Done(); it.Next()) {
11247 HandleScope scope(isolate);
11248 ASSERT(args.length() == 2);
11256 ScopeIterator it(isolate, fun);
11257 for (; !it.Done() && n < index; it.Next()) {
11261 return isolate->heap()->undefined_value();
11264 return MaterializeScopeDetails(isolate, &it);
11269 HandleScope scope(isolate);
11270 ASSERT(args.length() == 0);
11274 StackFrameLocator locator;
11275 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0);
11276 for (ScopeIterator it(isolate, frame, 0);
11282 return isolate->heap()->undefined_value();
11287 HandleScope scope(isolate);
11288 ASSERT(args.length() == 1);
11292 { MaybeObject* maybe_result = Runtime_CheckExecutionState(
11294 if (!maybe_result->ToObject(&result))
return maybe_result;
11299 for (ThreadState* thread =
11300 isolate->thread_manager()->FirstThreadStateInUse();
11302 thread = thread->Next()) {
11311 static const int kThreadDetailsCurrentThreadIndex = 0;
11312 static const int kThreadDetailsThreadIdIndex = 1;
11313 static const int kThreadDetailsSize = 2;
11323 HandleScope scope(isolate);
11324 ASSERT(args.length() == 2);
11328 { MaybeObject* maybe_check = Runtime_CheckExecutionState(
11330 if (!maybe_check->ToObject(&check))
return maybe_check;
11335 Handle<FixedArray> details =
11336 isolate->factory()->NewFixedArray(kThreadDetailsSize);
11341 details->set(kThreadDetailsCurrentThreadIndex,
11342 isolate->heap()->true_value());
11343 details->set(kThreadDetailsThreadIdIndex,
11348 ThreadState* thread =
11349 isolate->thread_manager()->FirstThreadStateInUse();
11350 while (index != n && thread !=
NULL) {
11351 thread = thread->Next();
11354 if (thread ==
NULL) {
11355 return isolate->heap()->undefined_value();
11359 details->set(kThreadDetailsCurrentThreadIndex,
11360 isolate->heap()->false_value());
11361 details->set(kThreadDetailsThreadIdIndex,
11366 return *isolate->factory()->NewJSArrayWithElements(details);
11373 HandleScope scope(isolate);
11374 ASSERT(args.length() == 1);
11376 isolate->debug()->set_disable_break(disable_break);
11377 return isolate->heap()->undefined_value();
11382 HandleScope scope(isolate);
11383 ASSERT(args.length() == 1);
11386 Handle<SharedFunctionInfo> shared(fun->shared());
11388 Handle<Object> break_locations = Debug::GetSourceBreakLocations(shared);
11389 if (break_locations->IsUndefined())
return isolate->heap()->undefined_value();
11391 return *isolate->factory()->NewJSArrayWithElements(
11392 Handle<FixedArray>::cast(break_locations));
11401 HandleScope scope(isolate);
11402 ASSERT(args.length() == 3);
11406 Handle<Object> break_point_object_arg = args.at<
Object>(2);
11409 isolate->debug()->SetBreakPoint(
function, break_point_object_arg,
11423 HandleScope scope(isolate);
11424 ASSERT(args.length() == 3);
11428 Handle<Object> break_point_object_arg = args.at<
Object>(2);
11432 Handle<Script> script(
Script::cast(wrapper->value()));
11435 if (!isolate->debug()->SetBreakPointForScript(script, break_point_object_arg,
11436 &source_position)) {
11437 return isolate->heap()->undefined_value();
11447 HandleScope scope(isolate);
11448 ASSERT(args.length() == 1);
11449 Handle<Object> break_point_object_arg = args.at<
Object>(0);
11452 isolate->debug()->ClearBreakPoint(break_point_object_arg);
11454 return isolate->heap()->undefined_value();
11462 HandleScope scope(isolate);
11463 ASSERT(args.length() == 2);
11469 ExceptionBreakType type =
11472 isolate->debug()->ChangeBreakOnException(type, enable);
11473 return isolate->heap()->undefined_value();
11480 HandleScope scope(isolate);
11481 ASSERT(args.length() == 1);
11484 ExceptionBreakType type =
11486 bool result = isolate->debug()->IsBreakOnException(type);
11497 HandleScope scope(isolate);
11498 ASSERT(args.length() == 3);
11501 { MaybeObject* maybe_check = Runtime_CheckExecutionState(
11503 if (!maybe_check->ToObject(&check))
return maybe_check;
11505 if (!args[1]->IsNumber() || !args[2]->IsNumber()) {
11506 return isolate->Throw(isolate->heap()->illegal_argument_symbol());
11510 StepAction step_action =
static_cast<StepAction
>(
NumberToInt32(args[1]));
11511 if (step_action != StepIn &&
11512 step_action != StepNext &&
11513 step_action != StepOut &&
11514 step_action != StepInMin &&
11515 step_action != StepMin) {
11516 return isolate->Throw(isolate->heap()->illegal_argument_symbol());
11521 if (step_count < 1) {
11522 return isolate->Throw(isolate->heap()->illegal_argument_symbol());
11526 isolate->debug()->ClearStepping();
11529 isolate->debug()->PrepareStep(static_cast<StepAction>(step_action),
11531 return isolate->heap()->undefined_value();
11537 HandleScope scope(isolate);
11538 ASSERT(args.length() == 0);
11539 isolate->debug()->ClearStepping();
11540 return isolate->heap()->undefined_value();
11546 static Handle<Context> CopyNestedScopeContextChain(Isolate* isolate,
11547 Handle<JSFunction>
function,
11548 Handle<Context> base,
11549 JavaScriptFrame* frame,
11550 int inlined_jsframe_index) {
11551 HandleScope scope(isolate);
11552 List<Handle<ScopeInfo> > scope_chain;
11553 List<Handle<Context> > context_chain;
11555 ScopeIterator it(isolate, frame, inlined_jsframe_index);
11556 if (it.Failed())
return Handle<Context>::null();
11558 for (; it.Type() != ScopeIterator::ScopeTypeGlobal &&
11559 it.Type() != ScopeIterator::ScopeTypeLocal ; it.Next()) {
11561 scope_chain.Add(it.CurrentScopeInfo());
11562 context_chain.Add(it.CurrentContext());
11566 Handle<Context> context = base;
11569 while (!scope_chain.is_empty()) {
11570 Handle<ScopeInfo> scope_info = scope_chain.RemoveLast();
11571 Handle<Context> current = context_chain.RemoveLast();
11572 ASSERT(!(scope_info->HasContext() & current.is_null()));
11575 Handle<String> name(
String::cast(current->extension()));
11578 isolate->factory()->NewCatchContext(
function,
11584 Handle<JSObject> block_scope_object =
11585 MaterializeBlockScope(isolate, current);
11586 CHECK(!block_scope_object.is_null());
11589 Handle<Context> new_context =
11592 new_context->set_extension(*block_scope_object);
11593 new_context->set_previous(*context);
11594 context = new_context;
11597 ASSERT(current->IsWithContext());
11598 Handle<JSObject> extension(
JSObject::cast(current->extension()));
11600 isolate->factory()->NewWithContext(
function, context, extension);
11604 return scope.CloseAndEscape(context);
11610 static Handle<Object> GetArgumentsObject(Isolate* isolate,
11611 JavaScriptFrame* frame,
11612 FrameInspector* frame_inspector,
11613 Handle<ScopeInfo> scope_info,
11614 Handle<Context> function_context) {
11619 if (scope_info->StackLocalCount() > 0) {
11620 index = scope_info->StackSlotIndex(isolate->heap()->arguments_symbol());
11622 return Handle<Object>(frame->GetExpression(index), isolate);
11626 if (scope_info->HasHeapAllocatedLocals()) {
11629 index = scope_info->ContextSlotIndex(
11630 isolate->heap()->arguments_symbol(), &mode, &init_flag);
11632 return Handle<Object>(function_context->get(index), isolate);
11636 Handle<JSFunction>
function(
JSFunction::cast(frame_inspector->GetFunction()));
11637 int length = frame_inspector->GetParametersCount();
11638 Handle<JSObject> arguments =
11639 isolate->factory()->NewArgumentsObject(
function, length);
11640 Handle<FixedArray> array = isolate->factory()->NewFixedArray(length);
11642 AssertNoAllocation no_gc;
11644 for (
int i = 0; i < length; i++) {
11645 array->set(i, frame_inspector->GetParameter(i), mode);
11647 arguments->set_elements(*array);
11652 static const char kSourceStr[] =
11653 "(function(arguments,__source__){return eval(__source__);})";
11668 HandleScope scope(isolate);
11672 ASSERT(args.length() == 6);
11674 { MaybeObject* maybe_check_result = Runtime_CheckExecutionState(
11676 if (!maybe_check_result->ToObject(&check_result)) {
11677 return maybe_check_result;
11684 Handle<Object> additional_context(args[5]);
11687 DisableBreak disable_break_save(disable_break);
11690 StackFrame::Id
id = UnwrapFrameId(wrapped_id);
11692 JavaScriptFrame* frame = it.frame();
11693 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate);
11694 Handle<JSFunction>
function(
JSFunction::cast(frame_inspector.GetFunction()));
11695 Handle<ScopeInfo> scope_info(function->shared()->scope_info());
11699 SaveContext* save = FindSavedContextForFrame(isolate, frame);
11701 SaveContext savex(isolate);
11702 isolate->set_context(*(save->context()));
11710 Handle<JSFunction> go_between =
11711 isolate->factory()->NewFunction(isolate->factory()->empty_string(),
11712 isolate->factory()->undefined_value());
11713 go_between->set_context(function->context());
11715 Handle<ScopeInfo> go_between_scope_info(go_between->shared()->scope_info());
11716 ASSERT(go_between_scope_info->ParameterCount() == 0);
11717 ASSERT(go_between_scope_info->ContextLocalCount() == 0);
11721 Handle<JSObject> local_scope = MaterializeLocalScopeWithFrameInspector(
11722 isolate, frame, &frame_inspector);
11727 Handle<Context> context =
11733 isolate->factory()->NewWithContext(go_between, context, local_scope);
11736 Handle<Context> frame_context(
Context::cast(frame->context()));
11737 Handle<Context> function_context;
11739 if (scope_info->HasContext()) {
11740 function_context = Handle<Context>(frame_context->declaration_context());
11742 context = CopyNestedScopeContextChain(isolate,
11746 inlined_jsframe_index);
11747 if (context.is_null()) {
11748 ASSERT(isolate->has_pending_exception());
11749 MaybeObject* exception = isolate->pending_exception();
11750 isolate->clear_pending_exception();
11754 if (additional_context->IsJSObject()) {
11757 isolate->factory()->NewWithContext(go_between, context, extension);
11766 Handle<String> function_source =
11767 isolate->factory()->NewStringFromAscii(
11768 Vector<const char>(kSourceStr,
sizeof(kSourceStr) - 1));
11772 Handle<SharedFunctionInfo> shared =
11775 context->IsNativeContext(),
11777 RelocInfo::kNoPosition);
11779 Handle<JSFunction> compiled_function =
11780 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context);
11783 bool has_pending_exception;
11784 Handle<Object> receiver(frame->receiver(), isolate);
11785 Handle<Object> evaluation_function =
11787 &has_pending_exception);
11790 Handle<Object> arguments = GetArgumentsObject(isolate,
11798 Handle<Context> native_context = Handle<Context>(context->native_context());
11799 bool eval_disabled =
11800 native_context->allow_code_gen_from_strings()->IsFalse();
11801 if (eval_disabled) {
11802 native_context->set_allow_code_gen_from_strings(
11803 isolate->heap()->true_value());
11806 Handle<Object> argv[] = { arguments, source };
11807 Handle<Object> result =
11812 &has_pending_exception);
11813 if (eval_disabled) {
11814 native_context->set_allow_code_gen_from_strings(
11815 isolate->heap()->false_value());
11821 if (result->IsJSGlobalProxy()) {
11822 result = Handle<JSObject>(
JSObject::cast(result->GetPrototype()));
11830 HandleScope scope(isolate);
11834 ASSERT(args.length() == 4);
11836 { MaybeObject* maybe_check_result = Runtime_CheckExecutionState(
11838 if (!maybe_check_result->ToObject(&check_result)) {
11839 return maybe_check_result;
11844 Handle<Object> additional_context(args[3]);
11847 DisableBreak disable_break_save(disable_break);
11850 SaveContext save(isolate);
11851 SaveContext* top = &save;
11852 while (top !=
NULL && *top->context() == *isolate->debug()->debug_context()) {
11856 isolate->set_context(*top->context());
11861 Handle<Context> context = isolate->native_context();
11863 bool is_global =
true;
11865 if (additional_context->IsJSObject()) {
11868 context = isolate->factory()->NewWithContext(
11869 Handle<JSFunction>(context->closure()),
11871 Handle<JSObject>::cast(additional_context));
11878 Handle<SharedFunctionInfo> shared =
11883 RelocInfo::kNoPosition);
11885 Handle<JSFunction> compiled_function =
11886 Handle<JSFunction>(
11887 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared,
11891 bool has_pending_exception;
11892 Handle<Object> receiver = isolate->global_object();
11893 Handle<Object> result =
11895 &has_pending_exception);
11897 isolate->debug()->ClearStepping();
11904 HandleScope scope(isolate);
11905 ASSERT(args.length() == 0);
11908 Handle<FixedArray> instances = isolate->debug()->GetLoadedScripts();
11911 for (
int i = 0; i < instances->length(); i++) {
11912 Handle<Script> script = Handle<Script>(
Script::cast(instances->get(i)));
11919 instances->set(i, *wrapper);
11923 Handle<JSObject> result =
11924 isolate->factory()->NewJSObject(isolate->array_function());
11925 isolate->factory()->SetContent(Handle<JSArray>::cast(result), instances);
11931 static int DebugReferencedBy(HeapIterator* iterator,
11933 Object* instance_filter,
int max_references,
11934 FixedArray* instances,
int instances_size,
11935 JSFunction* arguments_function) {
11936 NoHandleAllocation ha;
11937 AssertNoAllocation no_alloc;
11941 JSObject* last =
NULL;
11942 HeapObject* heap_obj =
NULL;
11943 while (((heap_obj = iterator->next()) !=
NULL) &&
11944 (max_references == 0 || count < max_references)) {
11946 if (heap_obj->IsJSObject()) {
11950 if (obj->IsJSContextExtensionObject() ||
11951 obj->map()->constructor() == arguments_function) {
11956 if (obj->ReferencesObject(target)) {
11959 if (!instance_filter->IsUndefined()) {
11963 if (prototype->IsNull()) {
11966 if (instance_filter == prototype) {
11977 if (instances !=
NULL && count < instances_size) {
11978 instances->set(count, obj);
11991 if (count == 1 && last == target) {
12005 ASSERT(args.length() == 3);
12009 "%DebugReferencedBy");
12017 Object* instance_filter = args[1];
12019 instance_filter->IsJSObject());
12025 JSObject* arguments_boilerplate =
12026 isolate->context()->native_context()->arguments_boilerplate();
12027 JSFunction* arguments_function =
12032 HeapIterator heap_iterator;
12033 count = DebugReferencedBy(&heap_iterator,
12034 target, instance_filter, max_references,
12035 NULL, 0, arguments_function);
12039 { MaybeObject* maybe_object = isolate->heap()->AllocateFixedArray(count);
12040 if (!maybe_object->ToObject(&
object))
return maybe_object;
12047 HeapIterator heap_iterator2;
12048 count = DebugReferencedBy(&heap_iterator2,
12049 target, instance_filter, max_references,
12050 instances, count, arguments_function);
12054 MaybeObject* maybe_result = isolate->heap()->AllocateJSObject(
12055 isolate->context()->native_context()->array_function());
12056 if (!maybe_result->ToObject(&result))
return maybe_result;
12062 static int DebugConstructedBy(HeapIterator* iterator,
12063 JSFunction* constructor,
12064 int max_references,
12065 FixedArray* instances,
12066 int instances_size) {
12067 AssertNoAllocation no_alloc;
12071 HeapObject* heap_obj =
NULL;
12072 while (((heap_obj = iterator->next()) !=
NULL) &&
12073 (max_references == 0 || count < max_references)) {
12075 if (heap_obj->IsJSObject()) {
12077 if (obj->map()->constructor() == constructor) {
12080 if (instances !=
NULL && count < instances_size) {
12081 instances->set(count, obj);
12097 ASSERT(args.length() == 2);
12101 "%DebugConstructedBy");
12110 HeapIterator heap_iterator;
12111 count = DebugConstructedBy(&heap_iterator,
12119 { MaybeObject* maybe_object = isolate->heap()->AllocateFixedArray(count);
12120 if (!maybe_object->ToObject(&
object))
return maybe_object;
12126 HeapIterator heap_iterator2;
12127 count = DebugConstructedBy(&heap_iterator2,
12135 { MaybeObject* maybe_result = isolate->heap()->AllocateJSObject(
12136 isolate->context()->native_context()->array_function());
12137 if (!maybe_result->ToObject(&result))
return maybe_result;
12146 ASSERT(args.length() == 1);
12151 return Accessors::ObjectPrototype.getter(obj,
NULL);
12157 HandleScope scope(isolate);
12158 ASSERT(args.length() == 2);
12164 Handle<Script> script(
Script::cast(script_wrapper->value()));
12166 int compilation_state =
Smi::cast(script->compilation_state())->value();
12168 script->set_source(*source);
12170 return isolate->heap()->undefined_value();
12175 ASSERT(args.length() == 0);
12177 return isolate->heap()->undefined_value();
12183 HandleScope scope(isolate);
12184 ASSERT(args.length() == 1);
12190 func->code()->PrintLn();
12192 return isolate->heap()->undefined_value();
12198 HandleScope scope(isolate);
12199 ASSERT(args.length() == 1);
12205 func->shared()->construct_stub()->PrintLn();
12207 return isolate->heap()->undefined_value();
12212 NoHandleAllocation ha;
12213 ASSERT(args.length() == 1);
12216 return f->shared()->inferred_name();
12220 static int FindSharedFunctionInfosForScript(HeapIterator* iterator,
12222 FixedArray* buffer) {
12223 AssertNoAllocation no_allocations;
12225 int buffer_size = buffer->length();
12226 for (HeapObject* obj = iterator->next();
12228 obj = iterator->next()) {
12230 if (!obj->IsSharedFunctionInfo()) {
12234 if (shared->script() != script) {
12237 if (counter < buffer_size) {
12238 buffer->set(counter, shared);
12249 Runtime_LiveEditFindSharedFunctionInfosForScript) {
12250 CHECK(isolate->debugger()->live_edit_enabled());
12251 ASSERT(args.length() == 1);
12252 HandleScope scope(isolate);
12256 Handle<Script> script = Handle<Script>(
Script::cast(script_value->value()));
12258 const int kBufferSize = 32;
12260 Handle<FixedArray> array;
12261 array = isolate->factory()->NewFixedArray(kBufferSize);
12264 isolate->heap()->EnsureHeapIsIterable();
12265 AssertNoAllocation no_allocations;
12266 HeapIterator heap_iterator;
12267 Script* scr = *script;
12268 FixedArray* arr = *array;
12269 number = FindSharedFunctionInfosForScript(&heap_iterator, scr, arr);
12271 if (number > kBufferSize) {
12272 array = isolate->factory()->NewFixedArray(number);
12273 isolate->heap()->EnsureHeapIsIterable();
12274 AssertNoAllocation no_allocations;
12275 HeapIterator heap_iterator;
12276 Script* scr = *script;
12277 FixedArray* arr = *array;
12278 FindSharedFunctionInfosForScript(&heap_iterator, scr, arr);
12281 Handle<JSArray> result = isolate->factory()->NewJSArrayWithElements(array);
12284 LiveEdit::WrapSharedFunctionInfos(result);
12297 CHECK(isolate->debugger()->live_edit_enabled());
12298 ASSERT(args.length() == 2);
12299 HandleScope scope(isolate);
12304 Handle<Script> script_handle = Handle<Script>(
Script::cast(script->value()));
12306 JSArray* result = LiveEdit::GatherCompileInfo(script_handle, source);
12308 if (isolate->has_pending_exception()) {
12319 CHECK(isolate->debugger()->live_edit_enabled());
12320 ASSERT(args.length() == 3);
12321 HandleScope scope(isolate);
12324 Handle<Object> old_script_name(args[2], isolate);
12327 Handle<Script> original_script(
Script::cast(original_script_value->value()));
12329 Object* old_script = LiveEdit::ChangeScriptSource(original_script,
12333 if (old_script->IsScript()) {
12334 Handle<Script> script_handle(
Script::cast(old_script));
12337 return isolate->heap()->null_value();
12343 CHECK(isolate->debugger()->live_edit_enabled());
12344 ASSERT(args.length() == 1);
12345 HandleScope scope(isolate);
12347 return LiveEdit::FunctionSourceUpdated(shared_info);
12353 CHECK(isolate->debugger()->live_edit_enabled());
12354 ASSERT(args.length() == 2);
12355 HandleScope scope(isolate);
12359 return LiveEdit::ReplaceFunctionCode(new_compile_info, shared_info);
12364 CHECK(isolate->debugger()->live_edit_enabled());
12365 ASSERT(args.length() == 2);
12366 HandleScope scope(isolate);
12367 Handle<Object> function_object(args[0], isolate);
12368 Handle<Object> script_object(args[1], isolate);
12370 if (function_object->IsJSValue()) {
12372 if (script_object->IsJSValue()) {
12375 script_object = Handle<Object>(script, isolate);
12378 LiveEdit::SetFunctionScript(function_wrapper, script_object);
12384 return isolate->heap()->undefined_value();
12390 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditReplaceRefToNestedFunction) {
12391 CHECK(isolate->debugger()->live_edit_enabled());
12392 ASSERT(args.length() == 3);
12393 HandleScope scope(isolate);
12399 LiveEdit::ReplaceRefToNestedFunction(parent_wrapper, orig_wrapper,
12402 return isolate->heap()->undefined_value();
12412 CHECK(isolate->debugger()->live_edit_enabled());
12413 ASSERT(args.length() == 2);
12414 HandleScope scope(isolate);
12418 return LiveEdit::PatchFunctionPositions(shared_array, position_change_array);
12427 CHECK(isolate->debugger()->live_edit_enabled());
12428 ASSERT(args.length() == 2);
12429 HandleScope scope(isolate);
12433 return *LiveEdit::CheckAndDropActivations(shared_array, do_drop,
12434 isolate->runtime_zone());
12441 CHECK(isolate->debugger()->live_edit_enabled());
12442 ASSERT(args.length() == 2);
12443 HandleScope scope(isolate);
12447 return *LiveEdit::CompareStrings(
s1,
s2);
12454 CHECK(isolate->debugger()->live_edit_enabled());
12455 HandleScope scope(isolate);
12456 ASSERT(args.length() == 2);
12460 { MaybeObject* maybe_check = Runtime_CheckExecutionState(
12462 if (!maybe_check->ToObject(&check))
return maybe_check;
12465 Heap* heap = isolate->heap();
12468 StackFrame::Id
id = isolate->debug()->break_frame_id();
12469 if (
id == StackFrame::NO_ID) {
12471 return heap->undefined_value();
12476 for (; !it.done(); it.Advance()) {
12477 if (index < count + it.frame()->GetInlineCount())
break;
12478 count += it.frame()->GetInlineCount();
12480 if (it.done())
return heap->undefined_value();
12482 const char* error_message =
12483 LiveEdit::RestartFrame(it.frame(), isolate->runtime_zone());
12484 if (error_message) {
12485 return *(isolate->factory()->LookupAsciiSymbol(error_message));
12487 return heap->true_value();
12493 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFunctionCodePositionFromSource) {
12494 CHECK(isolate->debugger()->live_edit_enabled());
12495 ASSERT(args.length() == 2);
12496 HandleScope scope(isolate);
12500 Handle<Code>
code(function->code(), isolate);
12502 if (code->kind() != Code::FUNCTION &&
12503 code->kind() != Code::OPTIMIZED_FUNCTION) {
12504 return isolate->heap()->undefined_value();
12507 RelocIterator it(*code, RelocInfo::ModeMask(RelocInfo::STATEMENT_POSITION));
12508 int closest_pc = 0;
12510 while (!it.done()) {
12511 int statement_position =
static_cast<int>(it.rinfo()->data());
12513 if (source_position <= statement_position &&
12514 statement_position - source_position < distance) {
12516 static_cast<int>(it.rinfo()->pc() - code->instruction_start());
12517 distance = statement_position - source_position;
12519 if (distance == 0)
break;
12532 ASSERT(args.length() == 2);
12533 HandleScope scope(isolate);
12537 Handle<Object> result;
12538 bool pending_exception;
12540 if (without_debugger) {
12542 &pending_exception);
12544 EnterDebugger enter_debugger;
12546 &pending_exception);
12549 if (!pending_exception) {
12560 SmartArrayPointer<char> flags =
12563 return isolate->heap()->undefined_value();
12571 return isolate->heap()->undefined_value();
12577 int usage =
static_cast<int>(isolate->heap()->SizeOfObjects());
12579 return *isolate->factory()->NewNumberFromInt(usage);
12587 #ifdef LIVE_OBJECT_LIST
12588 return isolate->heap()->true_value();
12590 return isolate->heap()->false_value();
12597 #ifdef LIVE_OBJECT_LIST
12600 return isolate->heap()->undefined_value();
12607 #ifdef LIVE_OBJECT_LIST
12610 return isolate->heap()->ToBoolean(success);
12612 return isolate->heap()->undefined_value();
12623 #ifdef LIVE_OBJECT_LIST
12630 EnterDebugger enter_debugger;
12633 return isolate->heap()->undefined_value();
12641 #ifdef LIVE_OBJECT_LIST
12646 return isolate->heap()->undefined_value();
12654 #ifdef LIVE_OBJECT_LIST
12660 return isolate->heap()->undefined_value();
12667 #ifdef LIVE_OBJECT_LIST
12670 RUNTIME_ASSERT(args[1]->IsUndefined() || args[1]->IsJSObject());
12676 Handle<JSObject> instance_filter;
12677 if (args[1]->IsJSObject()) {
12678 instance_filter = args.at<JSObject>(1);
12680 bool verbose =
false;
12681 if (args[2]->IsBoolean()) {
12682 verbose = args[2]->IsTrue();
12685 if (args[3]->IsSmi()) {
12686 start = args.smi_at(3);
12689 if (args[4]->IsSmi()) {
12690 limit = args.smi_at(4);
12700 return isolate->heap()->undefined_value();
12707 #ifdef LIVE_OBJECT_LIST
12711 RUNTIME_ASSERT(args[2]->IsUndefined() || args[2]->IsJSObject());
12713 Handle<JSObject> instance_filter;
12714 if (args[2]->IsJSObject()) {
12715 instance_filter = args.at<JSObject>(2);
12722 return isolate->heap()->undefined_value();
12730 #ifdef LIVE_OBJECT_LIST
12735 return isolate->heap()->undefined_value();
12743 #ifdef LIVE_OBJECT_LIST
12749 return isolate->heap()->undefined_value();
12756 #ifdef LIVE_OBJECT_LIST
12758 return isolate->heap()->undefined_value();
12760 return isolate->heap()->undefined_value();
12771 #ifdef LIVE_OBJECT_LIST
12777 EnterDebugger enter_debugger;
12780 return isolate->heap()->undefined_value();
12784 #endif // ENABLE_DEBUGGER_SUPPORT
12788 NoHandleAllocation ha;
12790 return isolate->heap()->undefined_value();
12795 NoHandleAllocation ha;
12797 return isolate->heap()->undefined_value();
12813 AssertNoAllocation no_allocation_during_heap_iteration;
12814 HeapIterator iterator;
12815 HeapObject* obj =
NULL;
12816 while (script.is_null() && ((obj = iterator.next()) !=
NULL)) {
12818 if (obj->IsScript()) {
12828 if (script.is_null())
return FACTORY->undefined_value();
12841 ASSERT(args.length() == 1);
12858 static bool ShowFrameInStackTrace(
StackFrame* raw_frame,
12860 bool* seen_caller) {
12862 if (!raw_frame->is_java_script()) {
12866 Object* raw_fun = frame->function();
12868 if (!raw_fun->IsJSFunction()) {
12871 if ((raw_fun == caller) && !(*seen_caller)) {
12872 *seen_caller =
true;
12876 if (!(*seen_caller))
return false;
12882 if (!FLAG_builtins_in_stack_traces) {
12884 if (frame->receiver()->IsJSBuiltinsObject() ||
12885 (fun->IsBuiltin() && !fun->shared()->native())) {
12903 Factory* factory = isolate->factory();
12905 limit =
Max(limit, 0);
12906 int initial_size =
Min(limit, 10);
12910 StackFrameIterator iter(isolate);
12913 bool seen_caller = !caller->IsJSFunction();
12915 int frames_seen = 0;
12916 while (!iter.done() && frames_seen < limit) {
12918 if (ShowFrameInStackTrace(raw_frame, *caller, &seen_caller)) {
12925 for (
int i = frames.length() - 1; i >= 0; i--) {
12926 if (cursor + 4 > elements->length()) {
12930 for (
int i = 0; i < cursor; i++) {
12931 new_elements->set(i, elements->get(i));
12933 elements = new_elements;
12935 ASSERT(cursor + 4 <= elements->length());
12941 elements->set(cursor++, *recv);
12942 elements->set(cursor++, *fun);
12943 elements->set(cursor++, *code);
12944 elements->set(cursor++, *offset);
12951 isolate->CaptureAndSetCurrentStackTraceFor(error_object);
12961 NoHandleAllocation ha;
12965 return isolate->heap()->AllocateStringFromAscii(
CStrVector(version_string),
12971 ASSERT(args.length() == 2);
12973 reinterpret_cast<char*>(args[0]) + args.smi_at(1));
12974 isolate->PrintStack();
12986 int finger_index = cache->finger_index();
12987 Object* o = cache->get(finger_index);
12990 return cache->get(finger_index + 1);
12993 for (
int i = finger_index - 2;
12998 cache->set_finger_index(i);
12999 return cache->get(i + 1);
13003 int size = cache->size();
13004 ASSERT(size <= cache->length());
13006 for (
int i = size - 2; i > finger_index; i -= 2) {
13009 cache->set_finger_index(i);
13010 return cache->get(i + 1);
13024 Handle<Object> receiver(isolate->native_context()->global_object());
13027 bool pending_exception;
13032 &pending_exception);
13037 if (FLAG_verify_heap) {
13038 cache_handle->JSFunctionResultCacheVerify();
13043 finger_index = cache_handle->finger_index();
13044 size = cache_handle->size();
13049 if (size < cache_handle->length()) {
13054 if (index == cache_handle->length()) {
13061 ASSERT(index < cache_handle->length());
13063 cache_handle->set(index, *key_handle);
13064 cache_handle->set(index + 1, *value);
13065 cache_handle->set_finger_index(index);
13068 if (FLAG_verify_heap) {
13069 cache_handle->JSFunctionResultCacheVerify();
13081 return *isolate->factory()->NewJSMessageObject(
13086 isolate->factory()->undefined_value(),
13087 isolate->factory()->undefined_value(),
13088 isolate->factory()->undefined_value());
13120 ASSERT(args.length() == 0);
13122 #define COUNT_ENTRY(Name, argc, ressize) + 1
13123 int entry_count = 0
13128 Factory* factory = isolate->factory();
13131 bool inline_runtime_functions =
false;
13132 #define ADD_ENTRY(Name, argc, ressize) \
13134 HandleScope inner; \
13135 Handle<String> name; \
13137 if (inline_runtime_functions) { \
13138 name = factory->NewStringFromAscii( \
13139 Vector<const char>("_" #Name, StrLength("_" #Name))); \
13141 name = factory->NewStringFromAscii( \
13142 Vector<const char>(#Name, StrLength(#Name))); \
13144 Handle<FixedArray> pair_elements = factory->NewFixedArray(2); \
13145 pair_elements->set(0, *name); \
13146 pair_elements->set(1, Smi::FromInt(argc)); \
13147 Handle<JSArray> pair = factory->NewJSArrayWithElements(pair_elements); \
13148 elements->set(index++, *pair); \
13150 inline_runtime_functions =
false;
13152 inline_runtime_functions =
true;
13164 ASSERT(args.length() == 2);
13170 LOGGER->LogRuntime(chars, elms);
13171 return isolate->heap()->undefined_value();
13181 #define ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(Name) \
13182 RUNTIME_FUNCTION(MaybeObject*, Runtime_Has##Name) { \
13183 CONVERT_ARG_CHECKED(JSObject, obj, 0); \
13184 return isolate->heap()->ToBoolean(obj->Has##Name()); \
13206 #undef ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION
13210 ASSERT(args.length() == 2);
13213 return isolate->heap()->ToBoolean(obj1->map() == obj2->map());
13219 #define F(name, number_of_args, result_size) \
13220 { Runtime::k##name, Runtime::RUNTIME, #name, \
13221 FUNCTION_ADDR(Runtime_##name), number_of_args, result_size },
13224 #define I(name, number_of_args, result_size) \
13225 { Runtime::kInline##name, Runtime::INLINE, \
13226 "_" #name, NULL, number_of_args, result_size },
13228 static const Runtime::Function kIntrinsicFunctions[] = {
13237 ASSERT(Isolate::Current()->heap() == heap);
13242 { MaybeObject* maybe_name_symbol =
13244 if (!maybe_name_symbol->ToObject(&name_symbol))
return maybe_name_symbol;
13247 { MaybeObject* maybe_dictionary = string_dictionary->
Add(
13251 if (!maybe_dictionary->ToObject(&dictionary)) {
13254 return maybe_dictionary;
13263 Heap* heap = name->GetHeap();
13264 int entry = heap->intrinsic_function_names()->FindEntry(*name);
13266 Object* smi_index = heap->intrinsic_function_names()->ValueAt(entry);
13268 return &(kIntrinsicFunctions[function_index]);
13275 return &(kIntrinsicFunctions[
static_cast<int>(id)]);
13280 Isolate* isolate = Isolate::Current();
13282 if (failure->IsRetryAfterGC()) {
13290 "Runtime::PerformGC");
13294 isolate->
counters()->gc_last_resort_from_js()->Increment();
13296 "Runtime::PerformGC");
static bool IsBlack(MarkBit mark_bit)
MaybeObject * AllocateRawString< SeqAsciiString >(Isolate *isolate, int length)
#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)
Object * LookupAccessor(String *name, AccessorComponent component)
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)
static String * cast(Object *obj)
MUST_USE_RESULT MaybeObject * Add(Key key, Object *value, PropertyDetails details)
int64_t ToUTC(int64_t time_ms)
MaybeObject * TryFlatten(PretenureFlag pretenure=NOT_TENURED)
static bool UseCrankshaft()
uint32_t NumberToUint32(Object *number)
Object * ToBoolean(bool condition)
bool Compile(Handle< String > replacement, int capture_count, int subject_length)
double DoubleToInteger(double x)
static void PerformGC(Object *result)
void set_length(Smi *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)
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)
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 Handle< Object > GetConstructorDelegate(Handle< Object > object)
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)
static Handle< Object > TransitionElementsKind(Handle< JSObject > object, ElementsKind to_kind)
BitField< int, 0, kStringBuilderConcatHelperLengthBits > StringBuilderSubstringLength
static bool CompileOptimized(Handle< JSFunction > function, BailoutId osr_ast_id, ClearExceptionFlag flag)
#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()
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)
void MaterializeHeapObjects(JavaScriptFrameIterator *it)
Object * DataAt(int index)
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)
MUST_USE_RESULT MaybeObject * Copy()
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)
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 void RecompileParallel(Handle< JSFunction > function)
static Smi * cast(Object *object)
Handle< String > FlattenGetString(Handle< String > string)
static bool Parse(CompilationInfo *info, int flags)
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)
void set_closure(JSFunction *closure)
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)
GlobalObject * global_object()
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 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 const int kLiteralNativeContextIndex
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)
void set_global_object(GlobalObject *object)
Handle< SeqTwoByteString > NewRawTwoByteString(int length, PretenureFlag pretenure=NOT_TENURED)
static SeededNumberDictionary * cast(Object *obj)
Handle< Object > LookupSingleCharacterStringFromCode(uint32_t index)
static const int kFactoryIndex
void Apply(ReplacementStringBuilder *builder, int match_from, int match_to, int32_t *match)
MUST_USE_RESULT MaybeObject * SetContent(FixedArrayBase *storage)
static const int kInputIndex
void SetExpectedNofProperties(Handle< JSFunction > func, int nof)
#define CONVERT_BOOLEAN_ARG_CHECKED(name, index)
static ExternalIntArray * cast(Object *obj)
static ThreadId Current()
Context * native_context()
int FastD2IChecked(double x)
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)
Handle< String > StringReplaceOneCharWithString(Isolate *isolate, Handle< String > subject, Handle< String > search, Handle< String > replace, bool *found, int recursion_limit)
static const int kMaxWidth
Handle< Object > SetProperty(Handle< Object > object, Handle< Object > key, Handle< Object > value, PropertyAttributes attributes, StrictModeFlag strict_mode)
static void ResumeProfiler()
static Handle< JSArray > SetLastMatchInfo(Handle< JSArray > last_match_info, Handle< String > subject, int capture_count, int32_t *match)
const char * DoubleToCString(double v, Vector< char > buffer)
int32_t * LastSuccessfulMatch()
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)
void set_hash_field(uint32_t value)
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 Handle< Object > Compile(Handle< JSRegExp > re, Handle< String > pattern, Handle< String > flags, Zone *zone)
static void Enter(Heap *heap, String *key_string, Object *key_pattern, FixedArray *value_array, ResultsCacheType type)
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)
static Handle< Object > Exec(Handle< JSRegExp > regexp, Handle< String > subject, int index, Handle< JSArray > lastMatchInfo)
Vector< const uc16 > ToUC16Vector()
double modulo(double x, double y)
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)
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 ScopeInfo * Empty()
unibrow::Mapping< unibrow::ToUppercase, 128 > * to_upper_mapping()
static uint32_t MakeArrayIndexHash(uint32_t value, int length)
static Object * Lookup(Heap *heap, String *key_string, Object *key_pattern, ResultsCacheType type)
void Lookup(String *name, LookupResult *result)
activate correct semantics for inheriting readonliness false
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)
#define ASSERT_LT(v1, v2)
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)
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)
static const int kAtomPatternIndex
static int SetFlagsFromString(const char *str, int len)
void AddSubjectSlice(int from, int to)
static JSGlobalPropertyCell * cast(Object *obj)
static bool EnsureCompiled(Handle< JSFunction > function, ClearExceptionFlag flag)
static Deoptimizer * Grab(Isolate *isolate)
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)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction pairs(ARM only)") DEFINE_bool(enable_unaligned_accesses
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)
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 use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of MIPS FPU instructions if expose natives in global object expose gc extension number of stack frames to capture disable builtin natives files print a stack trace if an assertion failure occurs use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations prepare for turning on always opt minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions automatically set the debug break flag when debugger commands are in the queue always cause a debug break before aborting maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print more details following each garbage collection print amount of external allocated memory after each time it is adjusted flush code that we expect not to use again before full gc do incremental marking steps track object counts and memory usage use caching Perform compaction on every full GC Never perform compaction on full GC testing only Compact code space on full incremental collections Default seed for initializing random allows verbose printing trace parsing and preparsing Check icache flushes in ARM and MIPS simulator Stack alingment in bytes in print stack trace when throwing exceptions randomize hashes to avoid predictable hash Fixed seed to use to hash property keys(0 means random)" "(with snapshots this option cannot override the baked-in seed)") DEFINE_bool(preemption
static const int kIndexIndex
bool HasFastObjectElements()
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)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of MIPS FPU instructions if expose natives in global object expose gc extension number of stack frames to capture disable builtin natives files print a stack trace if an assertion failure occurs use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations prepare for turning on always opt minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions automatically set the debug break flag when debugger commands are in the queue always cause a debug break before aborting maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print more details following each garbage collection print amount of external allocated memory after each time it is adjusted flush code that we expect not to use again before full gc do incremental marking steps track object counts and memory usage use caching Perform compaction on every full GC Never perform compaction on full GC testing only Compact code space on full incremental collections Default seed for initializing random allows verbose printing trace parsing and preparsing Check icache flushes in ARM and MIPS simulator Stack alingment in bytes in print stack trace when throwing exceptions randomize hashes to avoid predictable hash Fixed seed to use to hash property activate a timer that switches between V8 threads testing_bool_flag float flag Seed used for threading test randomness A filename with extra code to be included in the Print usage message
static Object * GetPath(int obj_id1, int obj_id2, Handle< JSObject > instance_filter)
#define ASSERT_NE(v1, v2)
static AccessorInfo * cast(Object *obj)
static FixedArray * cast(Object *obj)
static const int kHeaderSize
Handle< FixedDoubleArray > CopyFixedDoubleArray(Handle< FixedDoubleArray > array)
void set_previous(Context *context)
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)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of MIPS FPU instructions if NULL
int FindEntry(String *key)
static Handle< Object > ToString(Handle< Object > obj, bool *exc)
Handle< Object > ErrorMessageForCodeGenerationFromStrings()
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)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra code(assertions) for debugging") DEFINE_bool(code_comments
BitField< int, kStringBuilderConcatHelperLengthBits, kStringBuilderConcatHelperPositionBits > StringBuilderSubstringPosition
static Object * GetObj(int obj_id)
static const int kMaxLength
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)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of MIPS FPU instructions if expose natives in global object expose gc extension number of stack frames to capture disable builtin natives files print a stack trace if an assertion failure occurs use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations prepare for turning on always opt minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions automatically set the debug break flag when debugger commands are in the queue always cause a debug break before aborting maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print more details following each garbage collection print amount of external allocated memory after each time it is adjusted flush code that we expect not to use again before full gc do incremental marking steps track object counts and memory usage use caching Perform compaction on every full GC Never perform compaction on full GC testing only Compact code space on full incremental collections Default seed for initializing random allows verbose printing trace parsing and preparsing Check icache flushes in ARM and MIPS simulator Stack alingment in bytes in print stack trace when throwing exceptions randomize hashes to avoid predictable hash Fixed seed to use to hash property activate a timer that switches between V8 threads testing_bool_flag float flag Seed used for threading test randomness A filename with extra code to be included in the Print usage including flags
static int NewElementsCapacity(int old_capacity)
static FixedArrayBase * cast(Object *object)
#define CONVERT_NUMBER_CHECKED(type, name, Type, obj)
static Context * NativeContextFromLiterals(FixedArray *literals)
#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)
MUST_USE_RESULT MaybeObject * CopyReplaceDescriptor(DescriptorArray *descriptors, Descriptor *descriptor, int index, TransitionFlag flag)
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)
Handle< SeededNumberDictionary > NewSeededNumberDictionary(int at_least_space_for)
FixedArrayBuilder(Isolate *isolate, int initial_capacity)
kPropertyAccessorsOffset kNamedPropertyHandlerOffset kInstanceTemplateOffset kAccessCheckInfoOffset kEvalFrominstructionsOffsetOffset kInstanceClassNameOffset flag
static JSGlobalObject * cast(Object *obj)
static JSFunction * cast(Object *obj)