70 #ifdef V8_I18N_SUPPORT
72 #include "unicode/brkiter.h"
73 #include "unicode/calendar.h"
74 #include "unicode/coll.h"
75 #include "unicode/curramt.h"
76 #include "unicode/datefmt.h"
77 #include "unicode/dcfmtsym.h"
78 #include "unicode/decimfmt.h"
79 #include "unicode/dtfmtsym.h"
80 #include "unicode/dtptngen.h"
81 #include "unicode/locid.h"
82 #include "unicode/numfmt.h"
83 #include "unicode/numsys.h"
84 #include "unicode/rbbi.h"
85 #include "unicode/smpdtfmt.h"
86 #include "unicode/timezone.h"
87 #include "unicode/uchar.h"
88 #include "unicode/ucol.h"
89 #include "unicode/ucurr.h"
90 #include "unicode/uloc.h"
91 #include "unicode/unum.h"
92 #include "unicode/uversion.h"
95 #ifndef _STLP_VENDOR_CSTD
105 #define RUNTIME_ASSERT(value) \
106 if (!(value)) return isolate->ThrowIllegalOperation();
111 #define CONVERT_ARG_CHECKED(Type, name, index) \
112 RUNTIME_ASSERT(args[index]->Is##Type()); \
113 Type* name = Type::cast(args[index]);
115 #define CONVERT_ARG_HANDLE_CHECKED(Type, name, index) \
116 RUNTIME_ASSERT(args[index]->Is##Type()); \
117 Handle<Type> name = args.at<Type>(index);
122 #define CONVERT_BOOLEAN_ARG_CHECKED(name, index) \
123 RUNTIME_ASSERT(args[index]->IsBoolean()); \
124 bool name = args[index]->IsTrue();
129 #define CONVERT_SMI_ARG_CHECKED(name, index) \
130 RUNTIME_ASSERT(args[index]->IsSmi()); \
131 int name = args.smi_at(index);
136 #define CONVERT_DOUBLE_ARG_CHECKED(name, index) \
137 RUNTIME_ASSERT(args[index]->IsNumber()); \
138 double name = args.number_at(index);
143 #define CONVERT_NUMBER_CHECKED(type, name, Type, obj) \
144 RUNTIME_ASSERT(obj->IsNumber()); \
145 type name = NumberTo##Type(obj);
151 #define CONVERT_PROPERTY_DETAILS_CHECKED(name, index) \
152 RUNTIME_ASSERT(args[index]->IsSmi()); \
153 PropertyDetails name = PropertyDetails(Smi::cast(args[index]));
158 #define CONVERT_STRICT_MODE_ARG_CHECKED(name, index) \
159 RUNTIME_ASSERT(args[index]->IsSmi()); \
160 RUNTIME_ASSERT(args.smi_at(index) == STRICT || \
161 args.smi_at(index) == SLOPPY); \
162 StrictMode name = static_cast<StrictMode>(args.smi_at(index));
165 static Handle<Map> ComputeObjectLiteralMap(
166 Handle<Context> context,
167 Handle<FixedArray> constant_properties,
168 bool* is_result_from_cache) {
169 Isolate* isolate = context->GetIsolate();
170 int properties_length = constant_properties->length();
171 int number_of_properties = properties_length / 2;
173 int number_of_string_keys = 0;
174 for (
int p = 0; p != properties_length; p += 2) {
175 Object* key = constant_properties->get(p);
176 uint32_t element_index = 0;
177 if (key->IsInternalizedString()) {
178 number_of_string_keys++;
179 }
else if (key->ToArrayIndex(&element_index)) {
181 number_of_properties--;
186 ASSERT(number_of_string_keys != number_of_properties);
192 const int kMaxKeys = 10;
193 if ((number_of_string_keys == number_of_properties) &&
194 (number_of_string_keys < kMaxKeys)) {
196 Handle<FixedArray>
keys =
197 isolate->factory()->NewFixedArray(number_of_string_keys);
198 if (number_of_string_keys > 0) {
200 for (
int p = 0; p < properties_length; p += 2) {
201 Object* key = constant_properties->get(p);
202 if (key->IsInternalizedString()) {
203 keys->set(index++, key);
206 ASSERT(index == number_of_string_keys);
208 *is_result_from_cache =
true;
209 return isolate->factory()->ObjectLiteralMapFromCache(context, keys);
211 *is_result_from_cache =
false;
212 return isolate->factory()->CopyMap(
213 Handle<Map>(context->object_function()->initial_map()),
214 number_of_properties);
218 static Handle<Object> CreateLiteralBoilerplate(
221 Handle<FixedArray> constant_properties);
224 static Handle<Object> CreateObjectLiteralBoilerplate(
227 Handle<FixedArray> constant_properties,
228 bool should_have_fast_elements,
229 bool has_function_literal) {
236 Handle<Context> context =
243 bool is_result_from_cache =
false;
244 Handle<Map>
map = has_function_literal
245 ? Handle<Map>(context->object_function()->initial_map())
246 : ComputeObjectLiteralMap(context,
248 &is_result_from_cache);
253 Handle<JSObject> boilerplate =
254 isolate->factory()->NewJSObjectFromMap(map, pretenure_flag);
260 int length = constant_properties->length();
261 bool should_transform =
262 !is_result_from_cache && boilerplate->HasFastProperties();
263 if (should_transform || has_function_literal) {
272 for (
int index = 0; index < length; index +=2) {
273 Handle<Object> key(constant_properties->get(index+0), isolate);
274 Handle<Object> value(constant_properties->get(index+1), isolate);
275 if (value->IsFixedArray()) {
279 value = CreateLiteralBoilerplate(isolate, literals, array);
280 if (value.is_null())
return value;
282 Handle<Object> result;
283 uint32_t element_index = 0;
285 if (key->IsInternalizedString()) {
289 boilerplate, element_index, value,
SLOPPY);
297 }
else if (key->ToArrayIndex(&element_index)) {
300 boilerplate, element_index, value,
SLOPPY);
304 double num = key->Number();
308 Handle<String>
name =
309 isolate->factory()->NewStringFromAscii(
CStrVector(str));
311 boilerplate, name, value,
NONE,
318 if (result.is_null())
return result;
325 if (should_transform && !has_function_literal) {
327 boilerplate, boilerplate->map()->unused_property_fields());
349 static const int kSmiLiteralMinimumLength = 1024;
373 Object* maybe_maps_array = native_context->js_array_maps();
374 ASSERT(!maybe_maps_array->IsUndefined());
376 constant_elements_kind);
377 ASSERT(maybe_map->IsMap());
382 ASSERT(FLAG_smi_only_arrays);
388 (constant_elements_values->map() ==
389 isolate->
heap()->fixed_cow_array_map());
391 copied_elements_values = constant_elements_values;
395 for (
int i = 0; i < fixed_array_values->length(); i++) {
396 ASSERT(!fixed_array_values->get(i)->IsFixedArray());
404 copied_elements_values = fixed_array_values_copy;
405 for (
int i = 0; i < fixed_array_values->length(); i++) {
406 Object* current = fixed_array_values->get(i);
407 if (current->IsFixedArray()) {
412 CreateLiteralBoilerplate(isolate, literals, fa);
413 if (result.is_null())
return result;
414 fixed_array_values_copy->set(i, *result);
419 object->set_elements(*copied_elements_values);
420 object->set_length(
Smi::FromInt(copied_elements_values->length()));
424 if (!FLAG_smi_only_arrays &&
425 constant_elements_values->length() < kSmiLiteralMinimumLength) {
430 isolate)->IsFailure());
437 object->ValidateElements();
447 const bool kHasNoFunctionLiteral =
false;
450 return CreateObjectLiteralBoilerplate(isolate,
454 kHasNoFunctionLiteral);
456 return CreateObjectLiteralBoilerplate(isolate,
460 kHasNoFunctionLiteral);
463 isolate, literals, elements);
473 ASSERT(args.length() == 4);
478 bool should_have_fast_elements = (
flags & ObjectLiteral::kFastElements) != 0;
479 bool has_function_literal = (
flags & ObjectLiteral::kHasFunction) != 0;
482 Handle<Object> literal_site(literals->get(literals_index), isolate);
485 if (*literal_site == isolate->
heap()->undefined_value()) {
490 should_have_fast_elements,
491 has_function_literal);
499 creation_context.
ExitScope(site, boilerplate);
502 literals->set(literals_index, *site);
512 usage_context.
ExitScope(site, boilerplate);
526 if (*literal_site == isolate->heap()->undefined_value()) {
527 ASSERT(*elements != isolate->heap()->empty_fixed_array());
532 AllocationSiteCreationContext creation_context(isolate);
533 site = creation_context.EnterNewScope();
535 &creation_context).is_null()) {
538 creation_context.ExitScope(site, Handle<JSObject>::cast(boilerplate));
540 literals->
set(literals_index, *site);
549 static MaybeObject* CreateArrayLiteralImpl(Isolate* isolate,
550 Handle<FixedArray> literals,
552 Handle<FixedArray> elements,
554 Handle<AllocationSite> site = GetLiteralAllocationSite(isolate, literals,
555 literals_index, elements);
558 bool enable_mementos = (flags & ArrayLiteral::kDisableMementos) == 0;
559 Handle<JSObject> boilerplate(
JSObject::cast(site->transition_info()));
560 AllocationSiteUsageContext usage_context(isolate, site, enable_mementos);
561 usage_context.EnterNewScope();
567 usage_context.ExitScope(site, boilerplate);
575 ASSERT(args.length() == 4);
581 return CreateArrayLiteralImpl(isolate, literals, literals_index, elements,
588 ASSERT(args.length() == 3);
593 return CreateArrayLiteralImpl(isolate, literals, literals_index, elements,
594 ArrayLiteral::kShallowElements);
600 ASSERT(args.length() == 1);
604 MaybeObject* maybe = isolate->heap()->AllocateSymbol();
605 if (!maybe->To(&symbol))
return maybe;
606 if (name->IsString()) symbol->set_name(*name);
613 ASSERT(args.length() == 1);
617 MaybeObject* maybe = isolate->heap()->AllocatePrivateSymbol();
618 if (!maybe->To(&symbol))
return maybe;
619 if (name->IsString()) symbol->set_name(*name);
626 ASSERT(args.length() == 1);
629 Handle<String> part = isolate->factory()->private_intern_string();
633 if (!symbol->IsSymbol()) {
634 ASSERT(symbol->IsUndefined());
635 symbol = isolate->factory()->NewPrivateSymbol();
644 ASSERT(args.length() == 1);
646 return symbol->ToObject(isolate);
651 SealHandleScope shs(isolate);
652 ASSERT(args.length() == 1);
654 return symbol->name();
660 ASSERT(args.length() == 0);
661 return *isolate->GetSymbolRegistry();
666 SealHandleScope shs(isolate);
667 ASSERT(args.length() == 1);
669 return isolate->heap()->ToBoolean(symbol->is_private());
674 SealHandleScope shs(isolate);
675 ASSERT(args.length() == 2);
677 Object* prototype = args[1];
679 prototype->IsJSReceiver() ? prototype : isolate->heap()->null_value();
680 return isolate->heap()->AllocateJSProxy(handler, used_prototype);
685 SealHandleScope shs(isolate);
686 ASSERT(args.length() == 4);
688 Object* call_trap = args[1];
689 RUNTIME_ASSERT(call_trap->IsJSFunction() || call_trap->IsJSFunctionProxy());
691 Object* prototype = args[3];
693 prototype->IsJSReceiver() ? prototype : isolate->heap()->null_value();
694 return isolate->heap()->AllocateJSFunctionProxy(
695 handler, call_trap, construct_trap, used_prototype);
700 SealHandleScope shs(isolate);
701 ASSERT(args.length() == 1);
703 return isolate->heap()->ToBoolean(obj->IsJSProxy());
708 SealHandleScope shs(isolate);
709 ASSERT(args.length() == 1);
711 return isolate->heap()->ToBoolean(obj->IsJSFunctionProxy());
716 SealHandleScope shs(isolate);
717 ASSERT(args.length() == 1);
719 return proxy->handler();
724 SealHandleScope shs(isolate);
725 ASSERT(args.length() == 1);
727 return proxy->call_trap();
732 SealHandleScope shs(isolate);
733 ASSERT(args.length() == 1);
735 return proxy->construct_trap();
741 ASSERT(args.length() == 1);
744 return isolate->heap()->undefined_value();
752 free(phantom_array_buffer->backing_store());
757 isolate, phantom_array_buffer->byte_length());
760 -static_cast<int64_t>(allocated_length));
763 phantom_array_buffer->backing_store(),
772 size_t allocated_length) {
773 ASSERT(array_buffer->GetInternalFieldCount() ==
778 array_buffer->set_backing_store(data);
780 array_buffer->set_is_external(is_external);
784 CHECK(byte_length->IsSmi() || byte_length->IsHeapNumber());
785 array_buffer->set_byte_length(*byte_length);
789 array_buffer->set_weak_first_view(isolate->
heap()->undefined_value());
796 size_t allocated_length,
800 if (allocated_length != 0) {
807 if (data ==
NULL)
return false;
821 Isolate* isolate = array_buffer->GetIsolate();
822 for (
Handle<Object> view_obj(array_buffer->weak_first_view(), isolate);
825 if (view->IsJSTypedArray()) {
827 }
else if (view->IsJSDataView()) {
832 view_obj =
handle(view->weak_next(), isolate);
834 array_buffer->Neuter();
840 ASSERT(args.length() == 2);
843 size_t allocated_length;
844 if (byteLength->IsSmi()) {
847 ASSERT(byteLength->IsHeapNumber());
852 if (value > std::numeric_limits<size_t>::max()) {
853 return isolate->Throw(
854 *isolate->factory()->NewRangeError(
"invalid_array_buffer_length",
855 HandleVector<Object>(
NULL, 0)));
858 allocated_length =
static_cast<size_t>(value);
862 holder, allocated_length)) {
863 return isolate->Throw(*isolate->factory()->
864 NewRangeError(
"invalid_array_buffer_length",
865 HandleVector<Object>(
NULL, 0)));
873 SealHandleScope shs(isolate);
874 ASSERT(args.length() == 1);
876 return holder->byte_length();
882 ASSERT(args.length() == 3);
886 size_t start =
static_cast<size_t>(first);
887 size_t target_length =
NumberToSize(isolate, target->byte_length());
889 if (target_length == 0)
return isolate->heap()->undefined_value();
891 size_t source_byte_length =
NumberToSize(isolate, source->byte_length());
892 CHECK(start <= source_byte_length);
893 CHECK(source_byte_length - start >= target_length);
894 uint8_t* source_data =
reinterpret_cast<uint8_t*
>(source->backing_store());
895 uint8_t* target_data =
reinterpret_cast<uint8_t*
>(target->backing_store());
896 CopyBytes(target_data, source_data + start, target_length);
897 return isolate->heap()->undefined_value();
903 ASSERT(args.length() == 1);
905 return object->IsJSArrayBufferView()
906 ? isolate->heap()->true_value()
907 : isolate->heap()->false_value();
914 if (array_buffer->backing_store() ==
NULL) {
916 return isolate->heap()->undefined_value();
918 ASSERT(!array_buffer->is_external());
919 void* backing_store = array_buffer->backing_store();
920 size_t byte_length =
NumberToSize(isolate, array_buffer->byte_length());
921 array_buffer->set_is_external(
true);
924 return isolate->heap()->undefined_value();
933 size_t* element_size) {
935 #define ARRAY_ID_CASE(Type, type, TYPE, ctype, size) \
936 case ARRAY_ID_##TYPE: \
937 *array_type = kExternal##Type##Array; \
938 *external_elements_kind = EXTERNAL_##TYPE##_ELEMENTS; \
939 *fixed_elements_kind = TYPE##_ELEMENTS; \
940 *element_size = size; \
954 ASSERT(args.length() == 5);
961 ASSERT(holder->GetInternalFieldCount() ==
968 size_t element_size = 1;
974 &external_elements_kind,
975 &fixed_elements_kind,
978 holder->set_byte_offset(*byte_offset_object);
979 holder->set_byte_length(*byte_length_object);
981 size_t byte_offset =
NumberToSize(isolate, *byte_offset_object);
982 size_t byte_length =
NumberToSize(isolate, *byte_length_object);
984 CHECK_EQ(0, static_cast<int>(byte_length % element_size));
985 size_t length = byte_length / element_size;
988 return isolate->Throw(*isolate->factory()->
989 NewRangeError(
"invalid_typed_array_length",
990 HandleVector<Object>(
NULL, 0)));
993 Handle<Object> length_obj = isolate->factory()->NewNumberFromSize(length);
994 holder->set_length(*length_obj);
995 if (!maybe_buffer->IsNull()) {
998 size_t array_buffer_byte_length =
1000 CHECK(byte_offset <= array_buffer_byte_length);
1001 CHECK(array_buffer_byte_length - byte_offset >= byte_length);
1003 holder->set_buffer(*buffer);
1004 holder->set_weak_next(buffer->weak_first_view());
1005 buffer->set_weak_first_view(*holder);
1008 isolate->factory()->NewExternalArray(
1009 static_cast<int>(length), array_type,
1010 static_cast<uint8_t*>(buffer->backing_store()) + byte_offset);
1013 holder->set_map_and_elements(*map, *elements);
1017 holder->set_weak_next(isolate->heap()->undefined_value());
1019 isolate->factory()->NewFixedTypedArray(
1020 static_cast<int>(length), array_type);
1021 holder->set_elements(*elements);
1023 return isolate->heap()->undefined_value();
1034 ASSERT(args.length() == 4);
1040 ASSERT(holder->GetInternalFieldCount() ==
1047 size_t element_size = 1;
1053 &external_elements_kind,
1054 &fixed_elements_kind,
1058 if (source->IsJSTypedArray() &&
1065 (length > (
kMaxInt / element_size))) {
1066 return isolate->Throw(*isolate->factory()->
1067 NewRangeError(
"invalid_typed_array_length",
1068 HandleVector<Object>(
NULL, 0)));
1070 size_t byte_length = length * element_size;
1089 isolate, buffer, byte_length,
false)) {
1090 return isolate->Throw(*isolate->factory()->
1091 NewRangeError(
"invalid_array_buffer_length",
1092 HandleVector<Object>(
NULL, 0)));
1095 holder->set_buffer(*buffer);
1098 isolate->factory()->NewNumberFromSize(byte_length));
1099 holder->set_byte_length(*byte_length_obj);
1100 holder->set_length(*length_obj);
1101 holder->set_weak_next(buffer->weak_first_view());
1102 buffer->set_weak_first_view(*holder);
1105 isolate->factory()->NewExternalArray(
1106 static_cast<int>(length), array_type,
1107 static_cast<uint8_t*>(buffer->backing_store()));
1109 holder, external_elements_kind);
1110 holder->set_map_and_elements(*map, *elements);
1112 if (source->IsJSTypedArray()) {
1115 if (typed_array->type() == holder->type()) {
1116 uint8_t* backing_store =
1117 static_cast<uint8_t*
>(
1118 typed_array->GetBuffer()->backing_store());
1119 size_t source_byte_offset =
1122 buffer->backing_store(),
1123 backing_store + source_byte_offset,
1125 return *isolate->factory()->true_value();
1127 return *isolate->factory()->false_value();
1131 return *isolate->factory()->false_value();
1135 #define TYPED_ARRAY_GETTER(getter, accessor) \
1136 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayGet##getter) { \
1137 HandleScope scope(isolate); \
1138 ASSERT(args.length() == 1); \
1139 CONVERT_ARG_HANDLE_CHECKED(Object, holder, 0); \
1140 if (!holder->IsJSTypedArray()) \
1141 return isolate->Throw(*isolate->factory()->NewTypeError( \
1142 "not_typed_array", HandleVector<Object>(NULL, 0))); \
1143 Handle<JSTypedArray> typed_array(JSTypedArray::cast(*holder)); \
1144 return typed_array->accessor(); \
1151 #undef TYPED_ARRAY_GETTER
1155 ASSERT(args.length() == 1);
1157 if (!holder->IsJSTypedArray())
1158 return isolate->Throw(*isolate->factory()->NewTypeError(
1159 "not_typed_array", HandleVector<Object>(
NULL, 0)));
1161 return *typed_array->GetBuffer();
1186 if (!target_obj->IsJSTypedArray())
1187 return isolate->Throw(*isolate->factory()->NewTypeError(
1188 "not_typed_array", HandleVector<Object>(
NULL, 0)));
1190 if (!source_obj->IsJSTypedArray())
1196 size_t target_length =
NumberToSize(isolate, target->length());
1197 size_t source_length =
NumberToSize(isolate, source->length());
1198 size_t target_byte_length =
NumberToSize(isolate, target->byte_length());
1199 size_t source_byte_length =
NumberToSize(isolate, source->byte_length());
1200 if (offset > target_length ||
1201 offset + source_length > target_length ||
1202 offset + source_length < offset)
1203 return isolate->Throw(*isolate->factory()->NewRangeError(
1204 "typed_array_set_source_too_large", HandleVector<Object>(
NULL, 0)));
1206 size_t target_offset =
NumberToSize(isolate, target->byte_offset());
1207 size_t source_offset =
NumberToSize(isolate, source->byte_offset());
1208 uint8_t* target_base =
1209 static_cast<uint8_t*
>(
1210 target->GetBuffer()->backing_store()) + target_offset;
1211 uint8_t* source_base =
1212 static_cast<uint8_t*
>(
1213 source->GetBuffer()->backing_store()) + source_offset;
1216 if (target->type() == source->type()) {
1217 memmove(target_base + offset * target->element_size(),
1218 source_base, source_byte_length);
1223 if ((source_base <= target_base &&
1224 source_base + source_byte_length > target_base) ||
1225 (target_base <= source_base &&
1226 target_base + target_byte_length > source_base)) {
1229 target->GetBuffer()->backing_store() ==
1230 source->GetBuffer()->backing_store());
1240 return Smi::FromInt(FLAG_typed_array_max_size_in_heap);
1246 ASSERT(args.length() == 4);
1252 ASSERT(holder->GetInternalFieldCount() ==
1258 holder->set_buffer(*buffer);
1259 ASSERT(byte_offset->IsNumber());
1264 holder->set_byte_offset(*byte_offset);
1265 ASSERT(byte_length->IsNumber());
1266 holder->set_byte_length(*byte_length);
1268 holder->set_weak_next(buffer->weak_first_view());
1269 buffer->set_weak_first_view(*holder);
1271 return isolate->heap()->undefined_value();
1277 ASSERT(args.length() == 1);
1279 return data_view->buffer();
1285 ASSERT(args.length() == 1);
1287 return data_view->byte_offset();
1293 ASSERT(args.length() == 1);
1295 return data_view->byte_length();
1299 inline static bool NeedToFlipBytes(
bool is_little_endian) {
1300 #ifdef V8_TARGET_LITTLE_ENDIAN
1301 return !is_little_endian;
1303 return is_little_endian;
1310 for (
int i = 0; i < n; i++) {
1311 *(target++) = *(source++);
1318 source = source + (n-1);
1319 for (
int i = 0; i < n; i++) {
1320 *(target++) = *(source--);
1325 template<
typename T>
1326 inline static bool DataViewGetValue(
1330 bool is_little_endian,
1332 size_t byte_offset = 0;
1338 size_t data_view_byte_offset =
1340 size_t data_view_byte_length =
1342 if (byte_offset +
sizeof(
T) > data_view_byte_length ||
1343 byte_offset +
sizeof(
T) < byte_offset) {
1349 uint8_t bytes[
sizeof(
T)];
1353 size_t buffer_offset = data_view_byte_offset + byte_offset;
1356 >= buffer_offset +
sizeof(
T));
1358 static_cast<uint8_t*
>(buffer->backing_store()) + buffer_offset;
1359 if (NeedToFlipBytes(is_little_endian)) {
1360 FlipBytes<sizeof(T)>(value.bytes, source);
1362 CopyBytes<sizeof(T)>(value.bytes, source);
1364 *result = value.data;
1369 template<
typename T>
1370 static bool DataViewSetValue(
1372 Handle<JSDataView> data_view,
1373 Handle<Object> byte_offset_obj,
1374 bool is_little_endian,
1376 size_t byte_offset = 0;
1382 size_t data_view_byte_offset =
1384 size_t data_view_byte_length =
1386 if (byte_offset +
sizeof(
T) > data_view_byte_length ||
1387 byte_offset +
sizeof(
T) < byte_offset) {
1393 uint8_t bytes[
sizeof(
T)];
1398 size_t buffer_offset = data_view_byte_offset + byte_offset;
1401 >= buffer_offset +
sizeof(
T));
1403 static_cast<uint8_t*
>(buffer->backing_store()) + buffer_offset;
1404 if (NeedToFlipBytes(is_little_endian)) {
1405 FlipBytes<sizeof(T)>(target, value.bytes);
1407 CopyBytes<sizeof(T)>(target, value.bytes);
1413 #define DATA_VIEW_GETTER(TypeName, Type, Converter) \
1414 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewGet##TypeName) { \
1415 HandleScope scope(isolate); \
1416 ASSERT(args.length() == 3); \
1417 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); \
1418 CONVERT_ARG_HANDLE_CHECKED(Object, offset, 1); \
1419 CONVERT_BOOLEAN_ARG_CHECKED(is_little_endian, 2); \
1421 if (DataViewGetValue( \
1422 isolate, holder, offset, is_little_endian, &result)) { \
1423 return isolate->heap()->Converter(result); \
1425 return isolate->Throw(*isolate->factory()->NewRangeError( \
1426 "invalid_data_view_accessor_offset", \
1427 HandleVector<Object>(NULL, 0))); \
1440 #undef DATA_VIEW_GETTER
1443 template <
typename T>
1444 static T DataViewConvertValue(
double value);
1485 return static_cast<float>(value);
1495 #define DATA_VIEW_SETTER(TypeName, Type) \
1496 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewSet##TypeName) { \
1497 HandleScope scope(isolate); \
1498 ASSERT(args.length() == 4); \
1499 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); \
1500 CONVERT_ARG_HANDLE_CHECKED(Object, offset, 1); \
1501 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); \
1502 CONVERT_BOOLEAN_ARG_CHECKED(is_little_endian, 3); \
1503 Type v = DataViewConvertValue<Type>(value->Number()); \
1504 if (DataViewSetValue( \
1505 isolate, holder, offset, is_little_endian, v)) { \
1506 return isolate->heap()->undefined_value(); \
1508 return isolate->Throw(*isolate->factory()->NewRangeError( \
1509 "invalid_data_view_accessor_offset", \
1510 HandleVector<Object>(NULL, 0))); \
1523 #undef DATA_VIEW_SETTER
1528 ASSERT(args.length() == 1);
1531 holder->set_table(*table);
1538 ASSERT(args.length() == 2);
1543 holder->set_table(*table);
1544 return isolate->heap()->undefined_value();
1550 ASSERT(args.length() == 2);
1554 return isolate->heap()->ToBoolean(table->Contains(*key));
1560 ASSERT(args.length() == 2);
1565 holder->set_table(*table);
1566 return isolate->heap()->undefined_value();
1572 ASSERT(args.length() == 1);
1581 ASSERT(args.length() == 1);
1584 holder->set_table(*table);
1591 ASSERT(args.length() == 2);
1596 return lookup->IsTheHole() ? isolate->heap()->undefined_value() : *lookup;
1602 ASSERT(args.length() == 2);
1607 return isolate->heap()->ToBoolean(!lookup->IsTheHole());
1613 ASSERT(args.length() == 2);
1620 holder->set_table(*new_table);
1621 return isolate->heap()->ToBoolean(!lookup->IsTheHole());
1627 ASSERT(args.length() == 3);
1633 holder->set_table(*new_table);
1634 return isolate->heap()->undefined_value();
1640 ASSERT(args.length() == 1);
1647 static JSWeakCollection* WeakCollectionInitialize(
Isolate* isolate,
1651 weak_collection->set_table(*table);
1653 return *weak_collection;
1659 ASSERT(args.length() == 1);
1661 return WeakCollectionInitialize(isolate, weak_collection);
1667 ASSERT(args.length() == 2);
1673 return lookup->IsTheHole() ? isolate->heap()->undefined_value() : *lookup;
1679 ASSERT(args.length() == 2);
1685 return isolate->heap()->ToBoolean(!lookup->IsTheHole());
1691 ASSERT(args.length() == 2);
1695 weak_collection->table()));
1699 weak_collection->set_table(*new_table);
1700 return isolate->heap()->ToBoolean(!lookup->IsTheHole());
1706 ASSERT(args.length() == 3);
1713 weak_collection->set_table(*new_table);
1714 return isolate->heap()->undefined_value();
1719 SealHandleScope shs(isolate);
1720 ASSERT(args.length() == 1);
1722 if (!obj->IsJSObject())
return isolate->heap()->null_value();
1729 ASSERT(args.length() == 1);
1732 ASSERT(!
obj->IsAccessCheckNeeded() ||
obj->IsJSObject());
1734 if (
obj->IsAccessCheckNeeded() &&
1736 isolate->factory()->proto_string(),
1741 return isolate->heap()->undefined_value();
1744 }
while (
obj->IsJSObject() &&
1750 static inline Object* GetPrototypeSkipHiddenPrototypes(
Isolate* isolate,
1753 while (current->IsJSObject() &&
1763 ASSERT(args.length() == 2);
1766 if (
obj->IsAccessCheckNeeded() &&
1767 !isolate->MayNamedAccessWrapper(
obj,
1768 isolate->factory()->proto_string(),
1772 return isolate->heap()->undefined_value();
1776 GetPrototypeSkipHiddenPrototypes(isolate, *
obj), isolate);
1782 GetPrototypeSkipHiddenPrototypes(isolate, *
obj), isolate);
1783 if (!new_value->
SameValue(*old_value)) {
1785 isolate->factory()->proto_string(),
1797 SealHandleScope shs(isolate);
1798 ASSERT(args.length() == 2);
1804 if (prototype->IsNull())
return isolate->heap()->false_value();
1805 if (O == prototype)
return isolate->heap()->true_value();
1811 static bool CheckAccessException(
Object* callback,
1814 if (callback->IsAccessorInfo()) {
1818 (info->all_can_read() || info->all_can_write())) ||
1822 if (callback->IsAccessorPair()) {
1826 (info->all_can_read() || info->all_can_write())) ||
1835 static bool CheckGenericAccess(
1836 Handle<JSObject> receiver,
1837 Handle<JSObject> holder,
1840 bool (Isolate::*mayAccess)(Handle<JSObject>, Key,
v8::AccessType)) {
1841 Isolate* isolate = receiver->GetIsolate();
1842 for (Handle<JSObject> current = receiver;
1845 if (current->IsAccessCheckNeeded() &&
1846 !(isolate->*mayAccess)(current, key, access_type)) {
1849 if (current.is_identical_to(holder))
break;
1868 if (CheckGenericAccess(
1878 LookupResult lookup(isolate);
1882 Handle<JSObject> holder(lookup.holder(), isolate);
1883 if (CheckGenericAccess<Handle<Object> >(
1892 switch (lookup.type()) {
1894 if (CheckAccessException(lookup.GetCallbackObject(), access_type)) {
1901 holder->LookupRealNamedProperty(*name, &lookup);
1902 if (lookup.IsProperty() && lookup.IsPropertyCallbacks()) {
1903 if (CheckAccessException(lookup.GetCallbackObject(), access_type)) {
1912 isolate->ReportFailedAccessCheckWrapper(obj, access_type);
1933 Heap* heap = isolate->heap();
1934 Factory* factory = isolate->factory();
1940 switch (access_check_result) {
1949 return factory->undefined_value();
1951 ASSERT(!isolate->has_scheduled_exception());
1953 Handle<AccessorPair> accessors(raw_accessors, isolate);
1954 Handle<FixedArray> elms = isolate->factory()->NewFixedArray(
DESCRIPTOR_SIZE);
1959 if (raw_accessors ==
NULL) {
1962 Handle<Object> value =
GetProperty(isolate, obj, name);
1968 Handle<Object> getter(accessors->GetComponent(
ACCESSOR_GETTER), isolate);
1969 Handle<Object> setter(accessors->GetComponent(
ACCESSOR_SETTER), isolate);
1971 if (!getter->IsMap() && CheckPropertyAccess(obj, name,
v8::ACCESS_GET)) {
1972 ASSERT(!isolate->has_scheduled_exception());
1978 if (!setter->IsMap() && CheckPropertyAccess(obj, name,
v8::ACCESS_SET)) {
1979 ASSERT(!isolate->has_scheduled_exception());
1986 return isolate->factory()->NewJSArrayWithElements(elms);
1999 ASSERT(args.length() == 2);
2010 ASSERT(args.length() == 1);
2019 SealHandleScope shs(isolate);
2020 ASSERT(args.length() == 1);
2022 if (obj->IsJSGlobalProxy()) {
2024 if (proto->IsNull())
return isolate->heap()->false_value();
2025 ASSERT(proto->IsJSGlobalObject());
2034 ASSERT(args.length() == 3);
2046 ASSERT(args.length() == 1);
2048 return *isolate->factory()->CreateApiFunction(data);
2053 SealHandleScope shs(isolate);
2054 ASSERT(args.length() == 1);
2056 bool result = arg->IsObjectTemplateInfo() || arg->IsFunctionTemplateInfo();
2057 return isolate->heap()->ToBoolean(result);
2062 SealHandleScope shs(isolate);
2063 ASSERT(args.length() == 2);
2081 SealHandleScope shs(isolate);
2082 ASSERT(args.length() == 1);
2084 Map* old_map =
object->
map();
2086 if (needs_access_checks) {
2089 MaybeObject* maybe_new_map = old_map->
Copy();
2090 if (!maybe_new_map->To(&new_map))
return maybe_new_map;
2093 object->set_map(new_map);
2095 return isolate->heap()->ToBoolean(needs_access_checks);
2100 SealHandleScope shs(isolate);
2101 ASSERT(args.length() == 1);
2103 Map* old_map =
object->
map();
2107 MaybeObject* maybe_new_map = old_map->
Copy();
2108 if (!maybe_new_map->To(&new_map))
return maybe_new_map;
2111 object->set_map(new_map);
2113 return isolate->heap()->undefined_value();
2120 if (component->IsUndefined())
return isolate->factory()->null_value();
2129 ASSERT(args.length() == 6);
2136 RUNTIME_ASSERT(getter->IsUndefined() || getter->IsFunctionTemplateInfo());
2137 RUNTIME_ASSERT(setter->IsUndefined() || setter->IsFunctionTemplateInfo());
2140 InstantiateAccessorComponent(isolate, getter),
2141 InstantiateAccessorComponent(isolate, setter),
2142 static_cast<PropertyAttributes>(attribute),
2143 static_cast<v8::AccessControl>(access_control));
2144 return isolate->heap()->undefined_value();
2148 static Failure* ThrowRedeclarationError(
Isolate* isolate,
2153 isolate->factory()->NewStringFromAscii(
CStrVector(type));
2155 Handle<Object> error =
2156 isolate->factory()->NewTypeError(
"redeclaration",
HandleVector(args, 2));
2157 return isolate->Throw(*error);
2163 ASSERT(args.length() == 3);
2165 isolate->context()->global_object());
2172 int length =
pairs->length();
2173 for (
int i = 0; i < length; i += 2) {
2181 bool is_var = value->IsUndefined();
2182 bool is_const = value->IsTheHole();
2183 bool is_function = value->IsSharedFunctionInfo();
2184 ASSERT(is_var + is_const + is_function == 1);
2186 if (is_var || is_const) {
2190 LookupResult lookup(isolate);
2191 global->LocalLookup(*name, &lookup,
true);
2192 if (lookup.IsFound()) {
2195 if (!lookup.IsInterceptor())
continue;
2200 }
else if (is_function) {
2205 isolate->factory()->NewFunctionFromSharedFunctionInfo(
2210 LookupResult lookup(isolate);
2211 global->LocalLookup(*name, &lookup,
true);
2221 if (is_const || (is_native && is_function)) {
2227 if (!lookup.IsFound() || is_function) {
2230 if (lookup.IsFound() && lookup.IsDontDelete()) {
2231 if (lookup.IsReadOnly() || lookup.IsDontEnum() ||
2232 lookup.IsPropertyCallbacks()) {
2233 return ThrowRedeclarationError(isolate,
"function", name);
2236 attr = lookup.GetAttributes();
2241 global, name, value, static_cast<PropertyAttributes>(attr)));
2246 global, name, value, static_cast<PropertyAttributes>(attr),
2251 ASSERT(!isolate->has_pending_exception());
2252 return isolate->heap()->undefined_value();
2258 ASSERT(args.length() == 4);
2276 context->
Lookup(name, flags, &index, &attributes, &binding_flags);
2278 if (attributes !=
ABSENT) {
2282 if (((attributes & READ_ONLY) != 0) || (mode == READ_ONLY)) {
2284 ASSERT(mode != READ_ONLY || initial_value->IsTheHole());
2285 const char* type = ((attributes &
READ_ONLY) != 0) ?
"const" :
"var";
2286 return ThrowRedeclarationError(isolate, type, name);
2290 if (*initial_value !=
NULL) {
2292 ASSERT(holder.is_identical_to(context));
2293 if (((attributes & READ_ONLY) == 0) ||
2294 context->
get(index)->IsTheHole()) {
2295 context->
set(index, *initial_value);
2317 object = isolate->factory()->NewJSObject(
2318 isolate->context_extension_function());
2327 Handle<Object> value(isolate->heap()->undefined_value(), isolate);
2328 if (*initial_value !=
NULL) value = initial_value;
2335 if (initial_value->IsTheHole() &&
2336 !
object->IsJSContextExtensionObject()) {
2337 LookupResult lookup(isolate);
2338 object->Lookup(*name, &lookup);
2339 if (lookup.IsPropertyCallbacks()) {
2340 return ThrowRedeclarationError(isolate,
"const", name);
2343 if (object->IsJSGlobalObject()) {
2353 return isolate->heap()->undefined_value();
2366 bool assign = args.length() == 3;
2383 LookupResult lookup(isolate);
2384 isolate->context()->global_object()->LocalLookup(*name, &lookup,
true);
2385 if (lookup.IsInterceptor()) {
2389 if (intercepted !=
ABSENT && (intercepted & READ_ONLY) == 0) {
2394 holder, &lookup, name, value, attributes, strict_mode);
2398 return isolate->heap()->undefined_value();
2407 global, name, value, attributes, strict_mode);
2411 return isolate->heap()->undefined_value();
2416 SealHandleScope shs(isolate);
2425 GlobalObject* global = isolate->context()->global_object();
2437 LookupResult lookup(isolate);
2438 global->LocalLookup(*name, &lookup);
2439 if (!lookup.IsFound()) {
2449 if (!lookup.IsReadOnly()) {
2469 if (lookup.IsField()) {
2470 FixedArray* properties = global->properties();
2471 int index = lookup.GetFieldIndex().field_index();
2472 if (properties->
get(index)->IsTheHole() || !lookup.IsReadOnly()) {
2473 properties->
set(index, *value);
2475 }
else if (lookup.IsNormal()) {
2476 if (global->GetNormalizedProperty(&lookup)->IsTheHole() ||
2477 !lookup.IsReadOnly()) {
2484 ASSERT(lookup.IsReadOnly() && lookup.IsConstant());
2494 ASSERT(args.length() == 3);
2497 ASSERT(!value->IsTheHole());
2510 context->
Lookup(name, flags, &index, &attributes, &binding_flags);
2513 ASSERT(holder->IsContext());
2517 if ((attributes & READ_ONLY) == 0 || context->get(index)->IsTheHole()) {
2518 context->set(index, *value);
2525 if (attributes ==
ABSENT) {
2527 isolate->context()->global_object());
2555 LookupResult lookup(isolate);
2556 object->LocalLookupRealNamedProperty(*name, &lookup);
2557 ASSERT(lookup.IsFound());
2558 ASSERT(lookup.IsReadOnly());
2560 if (lookup.IsField()) {
2561 FixedArray* properties =
object->properties();
2562 int index = lookup.GetFieldIndex().field_index();
2563 if (properties->
get(index)->IsTheHole()) {
2564 properties->
set(index, *value);
2566 }
else if (lookup.IsNormal()) {
2567 if (object->GetNormalizedProperty(&lookup)->IsTheHole()) {
2578 if ((attributes & READ_ONLY) == 0) {
2591 Runtime_OptimizeObjectForAddingMultipleProperties) {
2593 ASSERT(args.length() == 2);
2596 if (object->HasFastProperties() && !
object->IsJSGlobalProxy()) {
2605 ASSERT(args.length() == 4);
2614 isolate->counters()->regexp_entry_runtime()->Increment();
2625 SealHandleScope shs(isolate);
2626 ASSERT(args.length() == 3);
2628 if (elements_count < 0 ||
2631 return isolate->ThrowIllegalOperation();
2634 { MaybeObject* maybe_new_object =
2635 isolate->heap()->AllocateFixedArray(elements_count);
2636 if (!maybe_new_object->ToObject(&new_object))
return maybe_new_object;
2639 { MaybeObject* maybe_new_object = isolate->heap()->AllocateRaw(
2641 if (!maybe_new_object->ToObject(&new_object))
return maybe_new_object;
2647 set_map(isolate->native_context()->regexp_result_map());
2650 array->set_properties(isolate->heap()->empty_fixed_array());
2651 array->set_elements(elements);
2662 ASSERT(args.length() == 5);
2667 if (source->length() == 0) source = isolate->factory()->query_colon_string();
2670 if (!global->IsTrue()) global = isolate->factory()->false_value();
2673 if (!ignoreCase->IsTrue()) ignoreCase = isolate->factory()->false_value();
2676 if (!multiline->IsTrue()) multiline = isolate->factory()->false_value();
2678 Map* map = regexp->
map();
2679 Object* constructor = map->constructor();
2680 if (constructor->IsJSFunction() &&
2686 regexp->InObjectPropertyAtPut(
2688 regexp->InObjectPropertyAtPut(
2690 regexp->InObjectPropertyAtPut(
2692 regexp->InObjectPropertyAtPut(
2703 Factory* factory = isolate->factory();
2705 regexp, factory->source_string(), source,
final));
2707 regexp, factory->global_string(), global,
final));
2709 regexp, factory->ignore_case_string(), ignoreCase,
final));
2711 regexp, factory->multiline_string(), multiline,
final));
2713 regexp, factory->last_index_string(),
zero, writable));
2720 ASSERT(args.length() == 1);
2724 prototype->set_elements(isolate->heap()->empty_fixed_array());
2733 Handle<String> key = isolate->factory()->InternalizeUtf8String(name);
2736 isolate->factory()->NewFunction(key,
2741 optimized->shared()->DontAdaptArguments();
2749 ASSERT(args.length() == 1);
2752 InstallBuiltin(isolate, holder,
"pop", Builtins::kArrayPop);
2753 InstallBuiltin(isolate, holder,
"push", Builtins::kArrayPush);
2754 InstallBuiltin(isolate, holder,
"shift", Builtins::kArrayShift);
2755 InstallBuiltin(isolate, holder,
"unshift", Builtins::kArrayUnshift);
2756 InstallBuiltin(isolate, holder,
"slice", Builtins::kArraySlice);
2757 InstallBuiltin(isolate, holder,
"splice", Builtins::kArraySplice);
2758 InstallBuiltin(isolate, holder,
"concat", Builtins::kArrayConcat);
2765 SealHandleScope shs(isolate);
2766 ASSERT(args.length() == 1);
2768 if (!callable->IsJSFunction()) {
2783 SealHandleScope shs(isolate);
2784 ASSERT(args.length() == 1);
2787 if (!callable->IsJSFunction()) {
2799 return isolate->heap()->undefined_value();
2812 ASSERT(args.length() == 4);
2814 int index = args.smi_at(1);
2827 bool has_pending_exception;
2830 &has_pending_exception);
2831 if (has_pending_exception) {
2832 ASSERT(isolate->has_pending_exception());
2835 literals->set(index, *regexp);
2841 SealHandleScope shs(isolate);
2842 ASSERT(args.length() == 1);
2845 return f->shared()->name();
2850 SealHandleScope shs(isolate);
2851 ASSERT(args.length() == 2);
2855 f->shared()->set_name(name);
2856 return isolate->heap()->undefined_value();
2861 SealHandleScope shs(isolate);
2862 ASSERT(args.length() == 1);
2864 return isolate->heap()->ToBoolean(
2865 f->shared()->name_should_print_as_anonymous());
2870 SealHandleScope shs(isolate);
2871 ASSERT(args.length() == 1);
2873 f->shared()->set_name_should_print_as_anonymous(
true);
2874 return isolate->heap()->undefined_value();
2879 SealHandleScope shs(isolate);
2880 ASSERT(args.length() == 1);
2882 return isolate->heap()->ToBoolean(f->shared()->is_generator());
2887 SealHandleScope shs(isolate);
2888 ASSERT(args.length() == 1);
2891 f->RemovePrototype();
2893 return isolate->heap()->undefined_value();
2899 ASSERT(args.length() == 1);
2903 if (!script->IsScript())
return isolate->heap()->undefined_value();
2911 ASSERT(args.length() == 1);
2915 return *shared->GetSourceCode();
2920 SealHandleScope shs(isolate);
2921 ASSERT(args.length() == 1);
2924 int pos = fun->shared()->start_position();
2930 SealHandleScope shs(isolate);
2931 ASSERT(args.length() == 2);
2944 SealHandleScope shs(isolate);
2945 ASSERT(args.length() == 2);
2949 fun->SetInstanceClassName(name);
2950 return isolate->heap()->undefined_value();
2955 SealHandleScope shs(isolate);
2956 ASSERT(args.length() == 2);
2960 fun->shared()->set_length(length);
2961 return isolate->heap()->undefined_value();
2967 ASSERT(args.length() == 2);
2971 ASSERT(fun->should_have_prototype());
2978 SealHandleScope shs(isolate);
2982 String* name = isolate->heap()->prototype_string();
2984 if (function->HasFastProperties()) {
2988 int index = instance_desc->SearchWithCache(name, function->
map());
2990 PropertyDetails details = instance_desc->
GetDetails(index);
2998 MaybeObject* maybe_map =
3001 if (!maybe_map->To(&new_map))
return maybe_map;
3003 function->set_map(new_map);
3006 int entry =
function->property_dictionary()->FindEntry(name);
3008 PropertyDetails details =
function->property_dictionary()->DetailsAt(entry);
3009 PropertyDetails new_details(
3010 static_cast<PropertyAttributes>(details.attributes() |
READ_ONLY),
3012 details.dictionary_index());
3013 function->property_dictionary()->DetailsAtPut(entry, new_details);
3020 SealHandleScope shs(isolate);
3021 ASSERT(args.length() == 1);
3024 return isolate->heap()->ToBoolean(f->shared()->IsApiFunction());
3029 SealHandleScope shs(isolate);
3030 ASSERT(args.length() == 1);
3033 return isolate->heap()->ToBoolean(f->IsBuiltin());
3039 ASSERT(args.length() == 2);
3044 if (code->IsNull())
return *target;
3056 ASSERT(target_shared->code()->gc_metadata() ==
NULL);
3057 ASSERT(source_shared->code()->gc_metadata() ==
NULL);
3058 target_shared->set_dont_flush(
true);
3059 source_shared->set_dont_flush(
true);
3063 target_shared->ReplaceCode(source_shared->code());
3064 target_shared->set_scope_info(source_shared->scope_info());
3065 target_shared->set_length(source_shared->length());
3066 target_shared->set_formal_parameter_count(
3067 source_shared->formal_parameter_count());
3068 target_shared->set_script(source_shared->script());
3069 target_shared->set_start_position_and_type(
3070 source_shared->start_position_and_type());
3071 target_shared->set_end_position(source_shared->end_position());
3072 bool was_native = target_shared->native();
3073 target_shared->set_compiler_hints(source_shared->compiler_hints());
3074 target_shared->set_native(was_native);
3077 target->ReplaceCode(source_shared->code());
3078 ASSERT(target->next_function_link()->IsUndefined());
3083 int number_of_literals = source->NumberOfLiterals();
3085 isolate->factory()->NewFixedArray(number_of_literals,
TENURED);
3086 if (number_of_literals > 0) {
3088 context->native_context());
3090 target->set_context(*context);
3091 target->set_literals(*literals);
3093 if (isolate->logger()->is_logging_code_events() ||
3094 isolate->cpu_profiler()->is_profiling()) {
3095 isolate->logger()->LogExistingFunction(
3105 ASSERT(args.length() == 2);
3114 if (!func->shared()->live_objects_may_exist()) {
3115 func->shared()->set_expected_nof_properties(num);
3116 if (func->has_initial_map()) {
3118 func->GetIsolate()->factory()->CopyMap(
3120 new_initial_map->set_unused_property_fields(num);
3121 func->set_initial_map(*new_initial_map);
3124 return isolate->heap()->undefined_value();
3130 ASSERT(args.length() == 0);
3132 JavaScriptFrameIterator it(isolate);
3141 generator = isolate->factory()->NewJSGeneratorObject(
function);
3143 generator->set_function(*
function);
3145 generator->set_receiver(frame->
receiver());
3146 generator->set_continuation(0);
3147 generator->set_operand_stack(isolate->heap()->empty_fixed_array());
3148 generator->set_stack_handler_index(-1);
3155 SealHandleScope shs(isolate);
3156 ASSERT(args.length() == 1);
3159 JavaScriptFrameIterator stack_iterator(isolate);
3166 ASSERT_LT(0, generator_object->continuation());
3173 operands_count -= 2;
3175 if (operands_count == 0) {
3178 ASSERT_EQ(generator_object->operand_stack(),
3179 isolate->heap()->empty_fixed_array());
3180 ASSERT_EQ(generator_object->stack_handler_index(), -1);
3183 ASSERT(!frame->HasHandler());
3185 int stack_handler_index = -1;
3186 MaybeObject* alloc = isolate->heap()->AllocateFixedArray(operands_count);
3188 if (!alloc->To(&operand_stack))
return alloc;
3190 generator_object->set_operand_stack(operand_stack);
3191 generator_object->set_stack_handler_index(stack_handler_index);
3194 return isolate->heap()->undefined_value();
3206 SealHandleScope shs(isolate);
3207 ASSERT(args.length() == 3);
3211 JavaScriptFrameIterator stack_iterator(isolate);
3220 Address pc = generator_object->function()->
code()->instruction_start();
3221 int offset = generator_object->continuation();
3223 frame->set_pc(pc + offset);
3224 if (FLAG_enable_ool_constant_pool) {
3225 frame->set_constant_pool(
3226 generator_object->function()->code()->constant_pool());
3230 FixedArray* operand_stack = generator_object->operand_stack();
3231 int operands_count = operand_stack->
length();
3232 if (operands_count != 0) {
3234 generator_object->stack_handler_index());
3235 generator_object->set_operand_stack(isolate->heap()->empty_fixed_array());
3236 generator_object->set_stack_handler_index(-1);
3241 switch (resume_mode) {
3245 return isolate->Throw(value);
3249 return isolate->ThrowIllegalOperation();
3255 ASSERT(args.length() == 1);
3257 int continuation = generator->continuation();
3259 "generator_finished" :
"generator_running";
3261 Handle<Object> error = isolate->factory()->NewError(message, argv);
3262 return isolate->Throw(*error);
3268 ASSERT(args.length() == 1);
3279 return isolate->heap()->LookupSingleCharacterStringFromCode(
3282 return isolate->heap()->empty_string();
3287 SealHandleScope shs(isolate);
3288 ASSERT(args.length() == 2);
3297 { MaybeObject* maybe_flat = subject->TryFlatten();
3298 if (!maybe_flat->ToObject(&flat))
return maybe_flat;
3302 if (i >= static_cast<uint32_t>(subject->length())) {
3303 return isolate->heap()->nan_value();
3311 SealHandleScope shs(isolate);
3312 ASSERT(args.length() == 1);
3313 return CharFromCode(isolate, args[0]);
3320 : array_(isolate->factory()->NewFixedArrayWithHoles(initial_capacity)),
3322 has_non_smi_elements_(
false) {
3325 ASSERT(initial_capacity > 0);
3329 : array_(backing_store),
3331 has_non_smi_elements_(
false) {
3334 ASSERT(backing_store->length() > 0);
3338 int length = array_->length();
3339 int required_length = length_ + elements;
3340 return (length >= required_length);
3344 int length = array_->length();
3345 int required_length = length_ + elements;
3346 if (length < required_length) {
3350 }
while (new_length < required_length);
3352 array_->GetIsolate()->factory()->NewFixedArrayWithHoles(new_length);
3353 array_->CopyTo(0, *extended_array, 0, length_);
3354 array_ = extended_array;
3361 array_->set(length_, value);
3363 has_non_smi_elements_ =
true;
3369 array_->set(length_, value);
3382 return array_->length();
3388 return target_array;
3395 bool has_non_smi_elements_;
3403 template <
typename s
char>
3404 static inline void StringBuilderConcatHelper(
String*,
3421 int estimated_part_count)
3423 array_builder_(heap->isolate(), estimated_part_count),
3425 character_count_(0),
3426 is_ascii_(subject->IsOneByteRepresentation()) {
3429 ASSERT(estimated_part_count > 0);
3436 int length = to - from;
3463 int length =
string->length();
3465 AddElement(*
string);
3466 if (!string->IsOneByteRepresentation()) {
3474 if (array_builder_.
length() == 0) {
3483 uint8_t* char_buffer = seq->GetChars();
3484 StringBuilderConcatHelper(*subject_,
3486 *array_builder_.
array(),
3487 array_builder_.
length());
3494 uc16* char_buffer = seq->GetChars();
3495 StringBuilderConcatHelper(*subject_,
3497 *array_builder_.
array(),
3498 array_builder_.
length());
3501 return joined_string;
3510 character_count_ += by;
3525 void AddElement(
Object* element) {
3526 ASSERT(element->IsSmi() || element->IsString());
3528 array_builder_.
Add(element);
3532 FixedArrayBuilder array_builder_;
3533 Handle<String> subject_;
3534 int character_count_;
3542 : parts_(1, zone), replacement_substrings_(0, zone), zone_(zone) {}
3547 int subject_length);
3557 return parts_.length();
3567 REPLACEMENT_SUBSTRING,
3570 NUMBER_OF_PART_TYPES
3573 struct ReplacementPart {
3574 static inline ReplacementPart SubjectMatch() {
3575 return ReplacementPart(SUBJECT_CAPTURE, 0);
3577 static inline ReplacementPart SubjectCapture(
int capture_index) {
3578 return ReplacementPart(SUBJECT_CAPTURE, capture_index);
3580 static inline ReplacementPart SubjectPrefix() {
3581 return ReplacementPart(SUBJECT_PREFIX, 0);
3583 static inline ReplacementPart SubjectSuffix(
int subject_length) {
3584 return ReplacementPart(SUBJECT_SUFFIX, subject_length);
3586 static inline ReplacementPart ReplacementString() {
3587 return ReplacementPart(REPLACEMENT_STRING, 0);
3589 static inline ReplacementPart ReplacementSubString(
int from,
int to) {
3592 return ReplacementPart(-from, to);
3597 ReplacementPart(
int tag,
int data)
3598 : tag(tag), data(data) {
3600 ASSERT(tag < NUMBER_OF_PART_TYPES);
3619 template<
typename Char>
3620 bool ParseReplacementPattern(ZoneList<ReplacementPart>*
parts,
3621 Vector<Char> characters,
3625 int length = characters.length();
3627 for (
int i = 0; i < length; i++) {
3628 Char c = characters[i];
3630 int next_index = i + 1;
3631 if (next_index == length) {
3634 Char c2 = characters[next_index];
3639 parts->Add(ReplacementPart::ReplacementSubString(last, next_index),
3641 last = next_index + 1;
3650 parts->Add(ReplacementPart::ReplacementSubString(last, i), zone);
3652 parts->Add(ReplacementPart::SubjectPrefix(), zone);
3658 parts->Add(ReplacementPart::ReplacementSubString(last, i), zone);
3660 parts->Add(ReplacementPart::SubjectSuffix(subject_length), zone);
3666 parts->Add(ReplacementPart::ReplacementSubString(last, i), zone);
3668 parts->Add(ReplacementPart::SubjectMatch(), zone);
3682 int capture_ref = c2 -
'0';
3683 if (capture_ref > capture_count) {
3687 int second_digit_index = next_index + 1;
3688 if (second_digit_index < length) {
3690 Char c3 = characters[second_digit_index];
3691 if (
'0' <= c3 && c3 <=
'9') {
3692 int double_digit_ref = capture_ref * 10 + c3 -
'0';
3693 if (double_digit_ref <= capture_count) {
3694 next_index = second_digit_index;
3695 capture_ref = double_digit_ref;
3699 if (capture_ref > 0) {
3701 parts->Add(ReplacementPart::ReplacementSubString(last, i), zone);
3703 ASSERT(capture_ref <= capture_count);
3704 parts->Add(ReplacementPart::SubjectCapture(capture_ref), zone);
3705 last = next_index + 1;
3716 if (length > last) {
3721 parts->Add(ReplacementPart::ReplacementSubString(last, length), zone);
3727 ZoneList<ReplacementPart> parts_;
3728 ZoneList<Handle<String> > replacement_substrings_;
3735 int subject_length) {
3740 bool simple =
false;
3742 simple = ParseReplacementPattern(&parts_,
3749 simple = ParseReplacementPattern(&parts_,
3755 if (simple)
return true;
3758 Isolate* isolate = replacement->GetIsolate();
3760 int substring_index = 0;
3761 for (
int i = 0, n = parts_.length(); i < n; i++) {
3762 int tag = parts_[i].tag;
3765 int to = parts_[i].data;
3766 replacement_substrings_.Add(
3768 parts_[i].tag = REPLACEMENT_SUBSTRING;
3769 parts_[i].data = substring_index;
3771 }
else if (tag == REPLACEMENT_STRING) {
3772 replacement_substrings_.Add(replacement,
zone());
3773 parts_[i].data = substring_index;
3786 for (
int i = 0, n = parts_.length(); i < n; i++) {
3787 ReplacementPart part = parts_[i];
3789 case SUBJECT_PREFIX:
3792 case SUBJECT_SUFFIX: {
3793 int subject_length = part.data;
3794 if (match_to < subject_length) {
3799 case SUBJECT_CAPTURE: {
3800 int capture = part.data;
3801 int from = match[capture * 2];
3802 int to = match[capture * 2 + 1];
3803 if (from >= 0 && to > from) {
3808 case REPLACEMENT_SUBSTRING:
3809 case REPLACEMENT_STRING:
3810 builder->
AddString(replacement_substrings_[part.data]);
3827 const uint8_t* subject_start = subject.
start();
3828 const uint8_t* subject_end = subject_start + subject.
length();
3829 const uint8_t* pos = subject_start;
3831 pos =
reinterpret_cast<const uint8_t*
>(
3832 memchr(pos, pattern, subject_end - pos));
3833 if (pos ==
NULL)
return;
3834 indices->
Add(static_cast<int>(pos - subject_start), zone);
3847 const uc16* subject_start = subject.
start();
3848 const uc16* subject_end = subject_start + subject.
length();
3849 for (
const uc16* pos = subject_start; pos < subject_end && limit > 0; pos++) {
3850 if (*pos == pattern) {
3851 indices->
Add(static_cast<int>(pos - subject_start), zone);
3858 template <
typename SubjectChar,
typename PatternChar>
3868 int pattern_length = pattern.
length();
3872 index = search.
Search(subject, index);
3873 if (index < 0)
return;
3874 indices->
Add(index, zone);
3875 index += pattern_length;
3893 if (subject_content.
IsAscii()) {
3895 if (pattern_content.
IsAscii()) {
3898 if (pattern_vector.
length() == 1) {
3922 if (pattern_content.
IsAscii()) {
3925 if (pattern_vector.
length() == 1) {
3941 if (pattern_vector.
length() == 1) {
3961 template<
typename ResultSeqString>
3962 MUST_USE_RESULT static MaybeObject* StringReplaceGlobalAtomRegExpWithString(
3971 ZoneScope zone_scope(isolate->runtime_zone());
3972 ZoneList<int> indices(8, zone_scope.zone());
3976 int subject_len = subject->
length();
3977 int pattern_len = pattern->length();
3978 int replacement_len = replacement->
length();
3981 isolate, *subject, pattern, &indices, 0xffffffff, zone_scope.zone());
3983 int matches = indices.length();
3984 if (matches == 0)
return *subject;
3987 int64_t result_len_64 =
3988 (
static_cast<int64_t
>(replacement_len) -
3989 static_cast<int64_t>(pattern_len)) *
3990 static_cast<int64_t>(matches) +
3991 static_cast<int64_t
>(subject_len);
3997 result_len =
static_cast<int>(result_len_64);
4000 int subject_pos = 0;
4003 Handle<String> result_seq;
4004 if (ResultSeqString::kHasAsciiEncoding) {
4005 result_seq = isolate->factory()->NewRawOneByteString(result_len);
4007 result_seq = isolate->factory()->NewRawTwoByteString(result_len);
4012 for (
int i = 0; i < matches; i++) {
4014 if (subject_pos < indices.at(i)) {
4016 result->GetChars() + result_pos,
4019 result_pos += indices.at(i) - subject_pos;
4023 if (replacement_len > 0) {
4025 result->GetChars() + result_pos,
4028 result_pos += replacement_len;
4031 subject_pos = indices.at(i) + pattern_len;
4034 if (subject_pos < subject_len) {
4036 result->GetChars() + result_pos,
4041 int32_t match_indices[] = { indices.at(matches - 1),
4042 indices.at(matches - 1) + pattern_len };
4049 MUST_USE_RESULT static MaybeObject* StringReplaceGlobalRegExpWithString(
4051 Handle<String> subject,
4052 Handle<JSRegExp> regexp,
4053 Handle<String> replacement,
4054 Handle<JSArray> last_match_info) {
4055 ASSERT(subject->IsFlat());
4056 ASSERT(replacement->IsFlat());
4058 int capture_count = regexp->CaptureCount();
4059 int subject_length = subject->length();
4062 ZoneScope zone_scope(isolate->runtime_zone());
4063 CompiledReplacement compiled_replacement(zone_scope.zone());
4064 bool simple_replace = compiled_replacement.Compile(replacement,
4070 if (subject->HasOnlyOneByteChars() &&
4071 replacement->HasOnlyOneByteChars()) {
4072 return StringReplaceGlobalAtomRegExpWithString<SeqOneByteString>(
4073 isolate, subject, regexp, replacement, last_match_info);
4075 return StringReplaceGlobalAtomRegExpWithString<SeqTwoByteString>(
4076 isolate, subject, regexp, replacement, last_match_info);
4080 RegExpImpl::GlobalCache global_cache(regexp, subject,
true, isolate);
4083 int32_t* current_match = global_cache.FetchNext();
4084 if (current_match ==
NULL) {
4092 int expected_parts = (compiled_replacement.parts() + 1) * 4 + 1;
4093 ReplacementStringBuilder builder(isolate->heap(),
4100 const int parts_added_per_loop = 2 * (compiled_replacement.parts() + 2);
4105 builder.EnsureCapacity(parts_added_per_loop);
4107 int start = current_match[0];
4108 int end = current_match[1];
4111 builder.AddSubjectSlice(prev, start);
4114 if (simple_replace) {
4115 builder.AddString(replacement);
4117 compiled_replacement.Apply(&builder,
4124 current_match = global_cache.FetchNext();
4125 }
while (current_match !=
NULL);
4129 if (prev < subject_length) {
4130 builder.EnsureCapacity(2);
4131 builder.AddSubjectSlice(prev, subject_length);
4137 global_cache.LastSuccessfulMatch());
4139 Handle<String> result = builder.ToString();
4145 template <
typename ResultSeqString>
4146 MUST_USE_RESULT static MaybeObject* StringReplaceGlobalRegExpWithEmptyString(
4148 Handle<String> subject,
4149 Handle<JSRegExp> regexp,
4150 Handle<JSArray> last_match_info) {
4151 ASSERT(subject->IsFlat());
4155 Handle<String> empty_string = isolate->factory()->empty_string();
4156 if (subject->IsOneByteRepresentation()) {
4157 return StringReplaceGlobalAtomRegExpWithString<SeqOneByteString>(
4158 isolate, subject, regexp, empty_string, last_match_info);
4160 return StringReplaceGlobalAtomRegExpWithString<SeqTwoByteString>(
4161 isolate, subject, regexp, empty_string, last_match_info);
4165 RegExpImpl::GlobalCache global_cache(regexp, subject,
true, isolate);
4168 int32_t* current_match = global_cache.FetchNext();
4169 if (current_match ==
NULL) {
4174 int start = current_match[0];
4175 int end = current_match[1];
4176 int capture_count = regexp->CaptureCount();
4177 int subject_length = subject->length();
4179 int new_length = subject_length - (end - start);
4180 if (new_length == 0)
return isolate->heap()->empty_string();
4182 Handle<ResultSeqString> answer;
4183 if (ResultSeqString::kHasAsciiEncoding) {
4185 isolate->factory()->NewRawOneByteString(new_length));
4188 isolate->factory()->NewRawTwoByteString(new_length));
4190 ASSERT(!answer.is_null());
4196 start = current_match[0];
4197 end = current_match[1];
4201 position += start - prev;
4205 current_match = global_cache.FetchNext();
4206 }
while (current_match !=
NULL);
4213 global_cache.LastSuccessfulMatch());
4215 if (prev < subject_length) {
4218 *subject, answer->GetChars() + position, prev, subject_length);
4219 position += subject_length - prev;
4222 if (position == 0)
return isolate->heap()->empty_string();
4225 int string_size = ResultSeqString::SizeFor(position);
4226 int allocated_string_size = ResultSeqString::SizeFor(new_length);
4227 int delta = allocated_string_size - string_size;
4229 answer->set_length(position);
4230 if (delta == 0)
return *answer;
4232 Address end_of_string = answer->address() + string_size;
4233 Heap* heap = isolate->heap();
4234 heap->CreateFillerObjectAt(end_of_string, delta);
4242 ASSERT(args.length() == 4);
4249 ASSERT(regexp->GetFlags().is_global());
4253 if (replacement->length() == 0) {
4254 if (subject->HasOnlyOneByteChars()) {
4255 return StringReplaceGlobalRegExpWithEmptyString<SeqOneByteString>(
4256 isolate, subject, regexp, last_match_info);
4258 return StringReplaceGlobalRegExpWithEmptyString<SeqTwoByteString>(
4259 isolate, subject, regexp, last_match_info);
4265 return StringReplaceGlobalRegExpWithString(
4266 isolate, subject, regexp, replacement, last_match_info);
4275 int recursion_limit) {
4277 if (subject->IsConsString()) {
4287 recursion_limit - 1);
4288 if (new_first.
is_null())
return new_first;
4297 recursion_limit - 1);
4298 if (new_second.
is_null())
return new_second;
4304 if (index == -1)
return subject;
4318 ASSERT(args.length() == 3);
4325 const int kRecursionLimit = 0x1000;
4333 if (!result.
is_null())
return *result;
4351 ASSERT(0 <= start_index);
4352 ASSERT(start_index <= sub->length());
4354 int pattern_length = pat->length();
4355 if (pattern_length == 0)
return start_index;
4357 int subject_length = sub->length();
4358 if (start_index + pattern_length > subject_length)
return -1;
4398 ASSERT(args.length() == 3);
4404 uint32_t start_index;
4407 RUNTIME_ASSERT(start_index <= static_cast<uint32_t>(sub->length()));
4414 template <
typename s
char,
typename p
char>
4415 static int StringMatchBackwards(Vector<const schar> subject,
4416 Vector<const pchar> pattern,
4418 int pattern_length = pattern.length();
4419 ASSERT(pattern_length >= 1);
4420 ASSERT(idx + pattern_length <= subject.length());
4422 if (
sizeof(schar) == 1 &&
sizeof(pchar) > 1) {
4423 for (
int i = 0; i < pattern_length; i++) {
4424 uc16 c = pattern[i];
4431 pchar pattern_first_char = pattern[0];
4432 for (
int i = idx; i >= 0; i--) {
4433 if (subject[i] != pattern_first_char)
continue;
4435 while (j < pattern_length) {
4436 if (pattern[j] != subject[i+j]) {
4441 if (j == pattern_length) {
4451 ASSERT(args.length() == 3);
4457 uint32_t start_index;
4460 uint32_t pat_length = pat->length();
4461 uint32_t sub_length = sub->length();
4463 if (start_index + pat_length > sub_length) {
4464 start_index = sub_length - pat_length;
4467 if (pat_length == 0) {
4487 position = StringMatchBackwards(sub_content.
ToUC16Vector(),
4498 position = StringMatchBackwards(sub_content.
ToUC16Vector(),
4509 SealHandleScope shs(isolate);
4510 ASSERT(args.length() == 2);
4516 int str1_length = str1->length();
4517 int str2_length = str2->length();
4520 if (str1_length == 0) {
4524 if (str2_length == 0)
return Smi::FromInt(str1_length);
4527 int end = str1_length < str2_length ? str1_length : str2_length;
4532 int d = str1->Get(0) - str2->Get(0);
4539 isolate->runtime_state()->string_locale_compare_it1();
4541 isolate->runtime_state()->string_locale_compare_it2();
4546 for (
int i = 0; i < end; i++) {
4547 uint16_t char1 = stream1.
GetNext();
4548 uint16_t char2 = stream2.
GetNext();
4549 if (char1 != char2)
return Smi::FromInt(char1 - char2);
4558 ASSERT(args.length() == 3);
4564 if (args[1]->IsSmi() && args[2]->IsSmi()) {
4567 start = from_number;
4578 isolate->counters()->sub_string_runtime()->Increment();
4580 return *isolate->factory()->NewSubString(
string, start, end);
4595 int capture_count = regexp->CaptureCount();
4597 ZoneScope zone_scope(isolate->runtime_zone());
4601 int32_t* match = global_cache.FetchNext();
4602 if (match ==
NULL)
break;
4603 offsets.Add(match[0], zone_scope.zone());
4604 offsets.Add(match[1], zone_scope.zone());
4609 if (offsets.length() == 0) {
4611 return isolate->heap()->null_value();
4617 global_cache.LastSuccessfulMatch());
4619 int matches = offsets.length() / 2;
4622 isolate->factory()->NewSubString(subject, offsets.at(0), offsets.at(1));
4623 elements->set(0, *substring);
4624 for (
int i = 1; i < matches; i++) {
4626 int from = offsets.at(i * 2);
4627 int to = offsets.at(i * 2 + 1);
4629 isolate->factory()->NewProperSubString(subject, from, to);
4630 elements->set(i, *substring);
4632 Handle<JSArray> result = isolate->factory()->NewJSArrayWithElements(elements);
4640 template<
bool has_capture>
4641 static MaybeObject* SearchRegExpMultiple(
4651 int subject_length = subject->
length();
4653 static const int kMinLengthToCache = 0x1000;
4655 if (subject_length > kMinLengthToCache) {
4668 Object* cached_fixed_array_last_element =
4669 cached_fixed_array->
get(cached_fixed_array->
length() - 1);
4670 Smi* js_array_length =
Smi::cast(cached_fixed_array_last_element);
4673 last_match_array, subject, capture_count,
NULL);
4674 return *result_array;
4678 RegExpImpl::GlobalCache global_cache(regexp, subject,
true, isolate);
4681 Handle<FixedArray> result_elements;
4686 if (result_elements.is_null() || result_elements->length() < 16) {
4687 result_elements = isolate->factory()->NewFixedArrayWithHoles(16);
4690 FixedArrayBuilder builder(result_elements);
4693 int match_start = -1;
4698 static const int kMaxBuilderEntriesPerRegExpMatch = 5;
4701 int32_t* current_match = global_cache.FetchNext();
4702 if (current_match ==
NULL)
break;
4703 match_start = current_match[0];
4704 builder.EnsureCapacity(kMaxBuilderEntriesPerRegExpMatch);
4705 if (match_end < match_start) {
4710 match_end = current_match[1];
4713 HandleScope temp_scope(isolate);
4714 Handle<String> match;
4716 match = isolate->factory()->NewProperSubString(subject,
4720 match = isolate->factory()->NewSubString(subject,
4729 Handle<FixedArray> elements =
4730 isolate->factory()->NewFixedArray(3 + capture_count);
4732 elements->set(0, *match);
4733 for (
int i = 1; i <= capture_count; i++) {
4734 int start = current_match[i * 2];
4736 int end = current_match[i * 2 + 1];
4738 Handle<String> substring =
4739 isolate->factory()->NewSubString(subject, start, end);
4740 elements->set(i, *substring);
4742 ASSERT(current_match[i * 2 + 1] < 0);
4743 elements->set(i, isolate->heap()->undefined_value());
4746 elements->set(capture_count + 1,
Smi::FromInt(match_start));
4747 elements->set(capture_count + 2, *subject);
4748 builder.Add(*isolate->factory()->NewJSArrayWithElements(elements));
4750 builder.Add(*match);
4757 if (match_start >= 0) {
4759 if (match_end < subject_length) {
4766 last_match_array, subject, capture_count,
NULL);
4768 if (subject_length > kMinLengthToCache) {
4771 builder.EnsureCapacity(1);
4772 Handle<FixedArray> fixed_array = builder.array();
4773 fixed_array->set(fixed_array->length() - 1,
4782 return *builder.ToJSArray(result_array);
4784 return isolate->heap()->null_value();
4794 ASSERT(args.length() == 4);
4805 return SearchRegExpMultiple<false>(
4806 isolate, subject, regexp, last_match_info, result_array);
4808 return SearchRegExpMultiple<true>(
4809 isolate, subject, regexp, last_match_info, result_array);
4815 SealHandleScope shs(isolate);
4816 ASSERT(args.length() == 2);
4821 if (args[0]->IsSmi()) {
4822 int value = args.smi_at(0);
4823 if (value >= 0 && value < radix) {
4825 static const char kCharTable[] =
"0123456789abcdefghijklmnopqrstuvwxyz";
4826 return isolate->heap()->
4834 return *isolate->factory()->nan_string();
4838 return *isolate->factory()->minus_infinity_string();
4840 return *isolate->factory()->infinity_string();
4843 MaybeObject* result =
4844 isolate->heap()->AllocateStringFromOneByte(
CStrVector(str));
4851 SealHandleScope shs(isolate);
4852 ASSERT(args.length() == 2);
4860 isolate->heap()->AllocateStringFromOneByte(
CStrVector(str));
4867 SealHandleScope shs(isolate);
4868 ASSERT(args.length() == 2);
4876 isolate->heap()->AllocateStringFromOneByte(
CStrVector(str));
4883 SealHandleScope shs(isolate);
4884 ASSERT(args.length() == 2);
4892 isolate->heap()->AllocateStringFromOneByte(
CStrVector(str));
4900 ASSERT(args.length() == 1);
4904 return isolate->heap()->true_value();
4906 return isolate->heap()->false_value();
4914 if (index < static_cast<uint32_t>(string->
length())) {
4915 string->TryFlatten();
4918 string->Get(index));
4934 if (object->IsStringObjectWithCharacterAt(index)) {
4942 if (object->
IsString() ||
object->IsNumber() ||
object->IsBoolean()) {
4952 if (key->IsName()) {
4955 bool has_pending_exception =
false;
5000 return isolate->
Throw(*error);
5017 if (name->AsArrayIndex(&index)) {
5022 return object->GetProperty(*name);
5028 SealHandleScope shs(isolate);
5029 ASSERT(args.length() == 2);
5040 SealHandleScope shs(isolate);
5041 ASSERT(args.length() == 2);
5054 if (args[0]->IsJSObject()) {
5055 if (!args[0]->IsJSGlobalProxy() &&
5056 !args[0]->IsAccessCheckNeeded() &&
5057 args[1]->IsName()) {
5062 Map* receiver_map = receiver->
map();
5064 int offset = keyed_lookup_cache->
Lookup(receiver_map, key);
5068 return value->IsTheHole()
5069 ? isolate->
heap()->undefined_value()
5074 LookupResult result(isolate);
5076 if (result.IsField()) {
5077 int offset = result.GetFieldIndex().field_index();
5080 if (!result.representation().IsDouble()) {
5081 keyed_lookup_cache->
Update(receiver_map, key, offset);
5083 return receiver->
FastPropertyAt(result.representation(), offset);
5092 if (!receiver->IsGlobalObject())
return value;
5094 if (!value->IsTheHole())
return value;
5098 }
else if (FLAG_smi_only_arrays && args.at<
Object>(1)->IsSmi()) {
5106 ElementsKind elements_kind = js_object->GetElementsKind();
5118 if (maybe_object->IsFailure())
return maybe_object;
5125 }
else if (args[0]->IsString() && args[1]->IsSmi()) {
5129 int index = args.smi_at(1);
5130 if (index >= 0 && index < str->length()) {
5144 return obj->IsUndefined() || obj->IsSpecFunction() || obj->IsNull();
5156 ASSERT(args.length() == 5);
5165 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0);
5168 bool fast = obj->HasFastProperties();
5172 return isolate->
heap()->undefined_value();
5184 ASSERT(args.length() == 4);
5189 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0);
5192 LookupResult lookup(isolate);
5193 js_object->LocalLookupRealNamedProperty(*name, &lookup);
5196 if (lookup.IsPropertyCallbacks()) {
5201 if (callback->IsAccessorInfo()) {
5202 return isolate->
heap()->undefined_value();
5208 if (callback->IsForeign() && lookup.GetAttributes() == attr) {
5217 return *result_object;
5227 if (lookup.IsFound() &&
5228 (attr != lookup.GetAttributes() || lookup.IsPropertyCallbacks())) {
5230 if (js_object->IsJSGlobalProxy()) {
5239 js_object, name, obj_value, attr);
5255 SealHandleScope shs(isolate);
5256 ASSERT(args.length() == 2);
5259 LookupResult lookup(isolate);
5260 object->LookupRealNamedProperty(*key, &lookup);
5261 if (!lookup.IsFound())
return isolate->
heap()->undefined_value();
5262 switch (lookup.type()) {
5264 return lookup.holder()->GetNormalizedProperty(&lookup);
5266 return lookup.holder()->FastPropertyAt(
5267 lookup.representation(),
5268 lookup.GetFieldIndex().field_index());
5270 return lookup.GetConstant();
5275 return isolate->
heap()->undefined_value();
5279 return isolate->
heap()->undefined_value();
5296 isolate->
Throw(*error);
5300 if (object->IsJSProxy()) {
5301 bool has_pending_exception =
false;
5312 if (!object->IsJSObject())
return value;
5326 if (js_object->IsStringObjectWithCharacterAt(index)) {
5330 js_object->ValidateElements();
5331 if (js_object->HasExternalArrayElements() ||
5332 js_object->HasFixedTypedArrayElements()) {
5345 js_object->ValidateElements();
5346 return result.is_null() ? result : value;
5349 if (key->IsName()) {
5351 if (name->AsArrayIndex(&index)) {
5352 if (js_object->HasExternalArrayElements()) {
5371 bool has_pending_exception =
false;
5377 if (name->AsArrayIndex(&index)) {
5402 if (js_object->IsStringObjectWithCharacterAt(index)) {
5411 if (key->IsName()) {
5413 if (name->AsArrayIndex(&index)) {
5425 bool has_pending_exception =
false;
5431 if (name->AsArrayIndex(&index)) {
5457 if (receiver->IsStringObjectWithCharacterAt(index)) {
5458 return isolate->
heap()->true_value();
5467 if (key->IsName()) {
5471 bool has_pending_exception =
false;
5473 isolate, key, &has_pending_exception);
5505 (unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0);
5511 if (args.length() == 5) {
5513 strict_mode = strict_mode_arg;
5539 SealHandleScope shs(isolate);
5544 if (object->IsJSFunction()) {
5546 func->shared()->set_native(
true);
5548 return isolate->
heap()->undefined_value();
5553 SealHandleScope shs(isolate);
5558 if (object->IsJSFunction()) {
5560 func->shared()->set_inline_builtin(
true);
5562 return isolate->
heap()->undefined_value();
5575 Object* raw_literal_cell = literals->get(literal_index);
5577 if (raw_literal_cell->IsAllocationSite()) {
5584 ElementsKind elements_kind =
object->GetElementsKind();
5589 if (value->IsNumber()) {
5595 boilerplate_object->GetElementsKind(),
5596 transitioned_kind)) {
5603 double_array->
set(store_index, number->Number());
5612 boilerplate_object->GetElementsKind(),
5613 transitioned_kind)) {
5617 object_array->
set(store_index, *value);
5626 SealHandleScope shs(isolate);
5627 #ifdef ENABLE_DEBUGGER_SUPPORT
5629 return isolate->
heap()->false_value();
5634 return isolate->
heap()->false_value();
5636 return isolate->
heap()->true_value();
5638 return isolate->
heap()->false_value();
5639 #endif // ENABLE_DEBUGGER_SUPPORT
5646 SealHandleScope shs(isolate);
5647 #ifdef ENABLE_DEBUGGER_SUPPORT
5648 Debug* debug = isolate->debug();
5649 if (!debug->IsStepping())
return isolate->
heap()->undefined_value();
5655 debug->ClearStepOut();
5656 debug->FloodWithOneShot(callback);
5657 #endif // ENABLE_DEBUGGER_SUPPORT
5658 return isolate->
heap()->undefined_value();
5672 if (args.length() == 4) {
5676 (unchecked_value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0);
5680 object, name, value, attributes);
5688 ASSERT(args.length() == 3);
5700 static MaybeObject* HasLocalPropertyImplementation(
Isolate* isolate,
5704 return isolate->heap()->true_value();
5710 if (proto->IsJSObject() &&
5712 return HasLocalPropertyImplementation(isolate,
5713 Handle<JSObject>::cast(proto),
5717 return isolate->heap()->false_value();
5723 ASSERT(args.length() == 2);
5728 const bool key_is_array_index = key->
AsArrayIndex(&index);
5731 if (object->IsJSObject()) {
5737 ASSERT(!isolate->has_scheduled_exception());
5738 return isolate->heap()->true_value();
5742 Map* map = js_obj->map();
5743 if (!key_is_array_index &&
5746 return isolate->heap()->false_value();
5749 return HasLocalPropertyImplementation(isolate,
5752 }
else if (object->IsString() && key_is_array_index) {
5755 if (index < static_cast<uint32_t>(string->length())) {
5756 return isolate->heap()->true_value();
5759 return isolate->heap()->false_value();
5765 ASSERT(args.length() == 2);
5772 return isolate->heap()->ToBoolean(result);
5778 ASSERT(args.length() == 2);
5785 return isolate->heap()->ToBoolean(result);
5791 ASSERT(args.length() == 2);
5797 if (att ==
ABSENT || (att & DONT_ENUM) != 0) {
5799 return isolate->heap()->false_value();
5801 ASSERT(!isolate->has_scheduled_exception());
5802 return isolate->heap()->true_value();
5808 ASSERT(args.length() == 1);
5823 SealHandleScope shs(isolate);
5824 ASSERT(args.length() == 1);
5828 if (raw_object->IsSimpleEnum())
return raw_object->map();
5838 if (object->IsSimpleEnum())
return object->map();
5847 static int LocalPrototypeChainLength(JSObject* obj) {
5850 while (proto->IsJSObject() &&
5864 ASSERT(args.length() == 2);
5865 if (!args[0]->IsJSObject()) {
5866 return isolate->heap()->undefined_value();
5874 if (obj->IsJSGlobalProxy()) {
5876 if (obj->IsAccessCheckNeeded() &&
5877 !isolate->MayNamedAccessWrapper(obj,
5878 isolate->factory()->undefined_value(),
5882 return *isolate->factory()->NewJSArray(0);
5888 int length = LocalPrototypeChainLength(*obj);
5892 int total_property_count = 0;
5894 for (
int i = 0; i < length; i++) {
5896 if (jsproto->IsAccessCheckNeeded() &&
5897 !isolate->MayNamedAccessWrapper(jsproto,
5898 isolate->factory()->undefined_value(),
5902 return *isolate->factory()->NewJSArray(0);
5905 n = jsproto->NumberOfLocalProperties(filter);
5906 local_property_count[i] = n;
5907 total_property_count += n;
5908 if (i < length - 1) {
5915 isolate->factory()->NewFixedArray(total_property_count);
5919 int next_copy_index = 0;
5920 int hidden_strings = 0;
5921 for (
int i = 0; i < length; i++) {
5922 jsproto->GetLocalPropertyNames(*names, next_copy_index, filter);
5927 for (
int j = next_copy_index;
5928 j < next_copy_index + local_property_count[i];
5930 Object* name_from_hidden_proto = names->get(j);
5931 for (
int k = 0; k < next_copy_index; k++) {
5932 if (names->get(k) != isolate->heap()->hidden_string()) {
5933 Object* name = names->get(k);
5934 if (name_from_hidden_proto == name) {
5935 names->set(j, isolate->heap()->hidden_string());
5943 next_copy_index += local_property_count[i];
5949 if (i < length - 1) {
5956 if (hidden_strings > 0) {
5958 names = isolate->factory()->NewFixedArray(
5959 names->length() - hidden_strings);
5961 for (
int i = 0; i < total_property_count; i++) {
5962 Object* name = old_names->get(i);
5963 if (name == isolate->heap()->hidden_string()) {
5967 names->set(dest_pos++, name);
5972 return *isolate->factory()->NewJSArrayWithElements(names);
5980 ASSERT(args.length() == 1);
5981 if (!args[0]->IsJSObject()) {
5982 return isolate->heap()->undefined_value();
5986 int n = obj->NumberOfLocalElements(static_cast<PropertyAttributes>(
NONE));
5988 obj->GetLocalElementKeys(*names, static_cast<PropertyAttributes>(
NONE));
5989 return *isolate->factory()->NewJSArrayWithElements(names);
5997 ASSERT(args.length() == 1);
5998 if (!args[0]->IsJSObject()) {
6004 if (obj->HasNamedInterceptor()) result |= 2;
6005 if (obj->HasIndexedInterceptor()) result |= 1;
6015 ASSERT(args.length() == 1);
6018 if (obj->HasNamedInterceptor()) {
6022 return isolate->heap()->undefined_value();
6030 ASSERT(args.length() == 1);
6033 if (obj->HasIndexedInterceptor()) {
6037 return isolate->heap()->undefined_value();
6047 if (object->IsJSGlobalProxy()) {
6049 if (object->IsAccessCheckNeeded() &&
6050 !isolate->MayNamedAccessWrapper(
object,
6051 isolate->factory()->undefined_value(),
6055 return *isolate->factory()->NewJSArray(0);
6060 if (proto->
IsNull())
return *isolate->factory()->NewJSArray(0);
6072 int length = contents->length();
6074 for (
int i = 0; i < length; i++) {
6075 Object* entry = contents->get(i);
6076 if (entry->IsString()) {
6077 copy->set(i, entry);
6079 ASSERT(entry->IsNumber());
6083 isolate->factory()->NumberToString(entry_handle);
6084 copy->set(i, *entry_str);
6087 return *isolate->factory()->NewJSArrayWithElements(copy);
6092 SealHandleScope shs(isolate);
6093 ASSERT(args.length() == 1);
6096 JavaScriptFrameIterator it(isolate);
6097 it.AdvanceToArgumentsFrame();
6106 if (args[0]->ToArrayIndex(&index) && index < n) {
6110 if (args[0]->IsSymbol()) {
6112 return isolate->initial_object_prototype()->GetProperty(
6118 bool exception =
false;
6125 if (key->AsArrayIndex(&index)) {
6129 Handle<Object> initial_prototype(isolate->initial_object_prototype());
6138 if (key->Equals(isolate->heap()->length_string()))
return Smi::FromInt(n);
6139 if (key->Equals(isolate->heap()->callee_string())) {
6141 if (function->shared()->strict_mode() ==
STRICT) {
6142 return isolate->Throw(*isolate->factory()->NewTypeError(
6143 "strict_arguments_callee", HandleVector<Object>(
NULL, 0)));
6149 return isolate->initial_object_prototype()->GetProperty(*key);
6155 ASSERT(args.length() == 1);
6157 if (object->IsJSObject() && !
object->IsGlobalObject()) {
6165 SealHandleScope shs(isolate);
6166 ASSERT(args.length() == 1);
6168 return isolate->heap()->ToBoolean(args[0]->BooleanValue());
6175 SealHandleScope shs(isolate);
6178 if (obj->IsNumber())
return isolate->heap()->number_string();
6183 return isolate->heap()->undefined_string();
6188 return isolate->heap()->string_string();
6191 switch (instance_type) {
6193 if (heap_obj->IsTrue() || heap_obj->IsFalse()) {
6194 return isolate->heap()->boolean_string();
6196 if (heap_obj->IsNull()) {
6197 return FLAG_harmony_typeof
6198 ? isolate->heap()->null_string()
6199 : isolate->heap()->object_string();
6201 ASSERT(heap_obj->IsUndefined());
6202 return isolate->heap()->undefined_string();
6204 return isolate->heap()->symbol_string();
6207 return isolate->heap()->function_string();
6211 return isolate->heap()->object_string();
6216 static bool AreDigits(
const uint8_t*s,
int from,
int to) {
6217 for (
int i = from; i < to; i++) {
6218 if (s[i] <
'0' || s[i] >
'9')
return false;
6225 static int ParseDecimalInteger(
const uint8_t*s,
int from,
int to) {
6228 int d = s[from] -
'0';
6230 for (
int i = from + 1; i < to; i++) {
6231 d = 10 * d + (s[i] -
'0');
6239 SealHandleScope shs(isolate);
6240 ASSERT(args.length() == 1);
6245 int len = subject->
length();
6246 if (subject->IsSeqOneByteString()) {
6250 bool minus = (data[0] ==
'-');
6251 int start_pos = (minus ? 1 : 0);
6253 if (start_pos == len) {
6254 return isolate->heap()->nan_value();
6255 }
else if (data[start_pos] >
'9') {
6260 if (data[start_pos] !=
'I' && data[start_pos] != 0xa0) {
6261 return isolate->heap()->nan_value();
6263 }
else if (len - start_pos < 10 && AreDigits(data, start_pos, len)) {
6266 int d = ParseDecimalInteger(data, start_pos, len);
6268 if (d == 0)
return isolate->heap()->minus_zero_value();
6272 (len == 1 || data[0] !=
'0')) {
6279 static_cast<int>(hash));
6289 if (FLAG_harmony_numeric_literals) {
6294 return isolate->heap()->NumberFromDouble(
6300 SealHandleScope shs(isolate);
6303 if (length == 0)
return isolate->heap()->empty_string();
6305 return isolate->heap()->AllocateRawOneByteString(length);
6307 return isolate->heap()->AllocateRawTwoByteString(length);
6322 ASSERT(args.length() == 1);
6325 ASSERT(string->IsFlat());
6326 Handle<String> result =
string->IsOneByteRepresentationUnderneath()
6327 ? URIEscape::Escape<uint8_t>(isolate, source)
6328 : URIEscape::Escape<uc16>(isolate, source);
6336 ASSERT(args.length() == 1);
6339 ASSERT(string->IsFlat());
6340 return string->IsOneByteRepresentationUnderneath()
6341 ? *URIUnescape::Unescape<uint8_t>(isolate, source)
6342 : *URIUnescape::Unescape<uc16>(isolate, source);
6349 ASSERT(args.length() == 1);
6350 return BasicJsonStringifier::StringifyString(isolate,
string);
6356 ASSERT(args.length() == 1);
6357 BasicJsonStringifier stringifier(isolate);
6363 SealHandleScope shs(isolate);
6371 double value =
StringToInt(isolate->unicode_cache(), s, radix);
6372 return isolate->heap()->NumberFromDouble(value);
6377 SealHandleScope shs(isolate);
6385 return isolate->heap()->NumberFromDouble(value);
6389 static inline bool ToUpperOverflows(
uc32 character) {
6392 static const uc32 yuml_code = 0xff;
6393 static const uc32 micro_code = 0xb5;
6394 return (character == yuml_code || character == micro_code);
6398 template <
class Converter>
6415 bool has_changed_character =
false;
6419 Access<ConsStringIteratorOp> op(
6420 isolate->runtime_state()->string_iterator());
6421 StringCharacterStream stream(
string, op.value());
6424 uc32 current = stream.GetNext();
6425 bool ignore_overflow = Converter::kIsToLower || result->IsSeqTwoByteString();
6426 for (
int i = 0; i < result_length;) {
6427 bool has_next = stream.HasMore();
6428 uc32 next = has_next ? stream.GetNext() : 0;
6429 int char_length = mapping->
get(current, next, chars);
6430 if (char_length == 0) {
6432 result->Set(i, current);
6434 }
else if (char_length == 1 &&
6435 (ignore_overflow || !ToUpperOverflows(current))) {
6437 ASSERT(static_cast<uc32>(chars[0]) != current);
6438 result->Set(i, chars[0]);
6439 has_changed_character =
true;
6441 }
else if (result_length == string->length()) {
6442 bool overflows = ToUpperOverflows(current);
6454 int next_length = 0;
6456 next_length = mapping->
get(next, 0, chars);
6457 if (next_length == 0) next_length = 1;
6459 int current_length = i + char_length + next_length;
6460 while (stream.HasMore()) {
6461 current = stream.GetNext();
6462 overflows |= ToUpperOverflows(current);
6467 int char_length = mapping->
get(current, 0, chars);
6468 if (char_length == 0) char_length = 1;
6469 current_length += char_length;
6472 return isolate->ThrowInvalidStringLength();
6477 return (overflows && !ignore_overflow) ?
Smi::FromInt(-current_length)
6478 : Smi::FromInt(current_length);
6480 for (
int j = 0; j < char_length; j++) {
6481 result->Set(i, chars[j]);
6484 has_changed_character =
true;
6488 if (has_changed_character) {
6503 static const uintptr_t kAsciiMask = kOneInEveryByte << 7;
6512 static inline uintptr_t AsciiRangeMask(uintptr_t w,
char m,
char n) {
6517 uintptr_t tmp1 = kOneInEveryByte * (0x7F + n) - w;
6519 uintptr_t tmp2 = w + kOneInEveryByte * (0x7F - m);
6520 return (tmp1 & tmp2 & (kOneInEveryByte * 0x80));
6525 static bool CheckFastAsciiConvert(
char* dst,
6530 bool expected_changed =
false;
6531 for (
int i = 0; i < length; i++) {
6532 if (dst[i] == src[i])
continue;
6533 expected_changed =
true;
6535 ASSERT(
'A' <= src[i] && src[i] <=
'Z');
6536 ASSERT(dst[i] == src[i] + (
'a' -
'A'));
6538 ASSERT(
'a' <= src[i] && src[i] <=
'z');
6539 ASSERT(dst[i] == src[i] - (
'a' -
'A'));
6542 return (expected_changed == changed);
6547 template<
class Converter>
6548 static bool FastAsciiConvert(
char* dst,
6551 bool* changed_out) {
6553 char* saved_dst = dst;
6554 const char* saved_src = src;
6559 ASSERT(
'a' -
'A' == (1 << 5));
6561 static const char lo = Converter::kIsToLower ?
'A' - 1 :
'a' - 1;
6562 static const char hi = Converter::kIsToLower ?
'Z' + 1 :
'z' + 1;
6563 bool changed =
false;
6564 uintptr_t or_acc = 0;
6565 const char*
const limit = src + length;
6566 #ifdef V8_HOST_CAN_READ_UNALIGNED
6569 while (src <= limit -
sizeof(uintptr_t)) {
6570 const uintptr_t w = *
reinterpret_cast<const uintptr_t*
>(src);
6572 if (AsciiRangeMask(w, lo, hi) != 0) {
6576 *
reinterpret_cast<uintptr_t*
>(dst) = w;
6577 src +=
sizeof(uintptr_t);
6578 dst +=
sizeof(uintptr_t);
6582 while (src <= limit -
sizeof(uintptr_t)) {
6583 const uintptr_t w = *
reinterpret_cast<const uintptr_t*
>(src);
6585 uintptr_t m = AsciiRangeMask(w, lo, hi);
6589 *
reinterpret_cast<uintptr_t*
>(dst) = w ^ (m >> 2);
6590 src +=
sizeof(uintptr_t);
6591 dst +=
sizeof(uintptr_t);
6596 while (src < limit) {
6599 if (lo < c && c < hi) {
6607 if ((or_acc & kAsciiMask) != 0) {
6611 ASSERT(CheckFastAsciiConvert(
6612 saved_dst, saved_src, length, changed, Converter::kIsToLower));
6614 *changed_out = changed;
6621 template <
class Converter>
6626 HandleScope handle_scope(isolate);
6629 int length = s->length();
6631 if (length == 0)
return *s;
6639 if (s->IsOneByteRepresentationUnderneath()) {
6640 Handle<SeqOneByteString> result =
6641 isolate->factory()->NewRawOneByteString(length);
6642 ASSERT(!result.is_null());
6644 String::FlatContent flat_content = s->GetFlatContent();
6645 ASSERT(flat_content.IsFlat());
6646 bool has_changed_character =
false;
6647 bool is_ascii = FastAsciiConvert<Converter>(
6648 reinterpret_cast<char*
>(result->GetChars()),
6649 reinterpret_cast<const char*>(flat_content.ToOneByteVector().start()),
6651 &has_changed_character);
6653 if (is_ascii)
return has_changed_character ? *result : *s;
6656 Handle<SeqString> result;
6657 if (s->IsOneByteRepresentation()) {
6658 result = isolate->factory()->NewRawOneByteString(length);
6660 result = isolate->factory()->NewRawTwoByteString(length);
6662 ASSERT(!result.is_null());
6664 MaybeObject* maybe = ConvertCaseHelper(isolate, *s, *result, length, mapping);
6666 if (!maybe->ToObject(&answer))
return maybe;
6667 if (answer->IsString())
return answer;
6671 if (s->IsOneByteRepresentation() && length > 0) {
6672 result = isolate->factory()->NewRawOneByteString(length);
6674 if (length < 0) length = -length;
6675 result = isolate->factory()->NewRawTwoByteString(length);
6678 return ConvertCaseHelper(isolate, *s, *result, length, mapping);
6684 args, isolate, isolate->runtime_state()->to_lower_mapping());
6690 args, isolate, isolate->runtime_state()->to_upper_mapping());
6696 ASSERT(args.length() == 3);
6703 int length =
string->length();
6706 UnicodeCache* unicode_cache = isolate->unicode_cache();
6708 while (left < length &&
6716 while (right > left &&
6718 string->Get(right - 1))) {
6723 return *isolate->factory()->NewSubString(
string, left, right);
6729 ASSERT(args.length() == 3);
6734 int subject_length = subject->
length();
6735 int pattern_length = pattern->length();
6738 if (limit == 0xffffffffu) {
6748 isolate->factory()->NewJSArrayWithElements(
6760 static const int kMaxInitialListCapacity = 16;
6762 ZoneScope zone_scope(isolate->runtime_zone());
6765 int initial_capacity = Min<uint32_t>(kMaxInitialListCapacity, limit);
6770 &indices, limit, zone_scope.zone());
6772 if (static_cast<uint32_t>(indices.length()) < limit) {
6773 indices.Add(subject_length, zone_scope.zone());
6779 int part_count = indices.length();
6785 ASSERT(result->HasFastObjectElements());
6787 if (part_count == 1 && indices.at(0) == subject_length) {
6794 for (
int i = 0; i < part_count; i++) {
6796 int part_end = indices.at(i);
6798 isolate->factory()->NewProperSubString(subject, part_start, part_end);
6799 elements->set(i, *substring);
6800 part_start = part_end + pattern_length;
6803 if (limit == 0xffffffffu) {
6804 if (result->HasFastObjectElements()) {
6821 static int CopyCachedAsciiCharsToArray(Heap* heap,
6822 const uint8_t* chars,
6823 FixedArray* elements,
6826 FixedArray* ascii_cache = heap->single_character_string_cache();
6827 Object* undefined = heap->undefined_value();
6830 for (i = 0; i < length; ++i) {
6831 Object* value = ascii_cache->get(chars[i]);
6832 if (value == undefined)
break;
6833 elements->set(i, value, mode);
6837 memset(elements->data_start() + i, 0,
kPointerSize * (length - i));
6840 for (
int j = 0; j < length; ++j) {
6841 Object* element = elements->get(j);
6854 ASSERT(args.length() == 2);
6859 const int length =
static_cast<int>(Min<uint32_t>(s->length(), limit));
6863 if (s->IsFlat() && s->IsOneByteRepresentation()) {
6866 { MaybeObject* maybe_obj =
6867 isolate->heap()->AllocateUninitializedFixedArray(length);
6868 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
6877 position = CopyCachedAsciiCharsToArray(isolate->heap(),
6883 isolate->heap()->undefined_value(),
6887 elements = isolate->factory()->NewFixedArray(length);
6889 for (
int i = position; i < length; ++i) {
6892 elements->set(i, *str);
6896 for (
int i = 0; i < length; ++i) {
6901 return *isolate->factory()->NewJSArrayWithElements(elements);
6906 SealHandleScope shs(isolate);
6907 ASSERT(args.length() == 1);
6916 return char_length == 0;
6921 SealHandleScope shs(isolate);
6922 ASSERT(args.length() == 1);
6924 Object* number = args[0];
6927 return isolate->heap()->NumberToString(number);
6932 SealHandleScope shs(isolate);
6933 ASSERT(args.length() == 1);
6935 Object* number = args[0];
6938 return isolate->heap()->NumberToString(number,
false);
6943 SealHandleScope shs(isolate);
6944 ASSERT(args.length() == 1);
6957 SealHandleScope shs(isolate);
6958 ASSERT(args.length() == 1);
6969 if (double_value == 0) double_value = 0;
6971 return isolate->heap()->NumberFromDouble(double_value);
6976 SealHandleScope shs(isolate);
6977 ASSERT(args.length() == 1);
6980 return isolate->heap()->NumberFromUint32(number);
6985 SealHandleScope shs(isolate);
6986 ASSERT(args.length() == 1);
6994 return isolate->heap()->NumberFromInt32(
DoubleToInt32(number));
7001 SealHandleScope shs(isolate);
7002 ASSERT(args.length() == 1);
7008 if (obj->IsHeapNumber()) {
7010 int int_value =
FastD2I(value);
7015 return isolate->heap()->nan_value();
7020 SealHandleScope shs(isolate);
7021 ASSERT(args.length() == 0);
7022 return isolate->heap()->AllocateHeapNumber(0);
7027 SealHandleScope shs(isolate);
7028 ASSERT(args.length() == 2);
7032 return isolate->heap()->NumberFromDouble(x + y);
7037 SealHandleScope shs(isolate);
7038 ASSERT(args.length() == 2);
7042 return isolate->heap()->NumberFromDouble(x - y);
7047 SealHandleScope shs(isolate);
7048 ASSERT(args.length() == 2);
7052 return isolate->heap()->NumberFromDouble(x * y);
7057 SealHandleScope shs(isolate);
7058 ASSERT(args.length() == 1);
7061 return isolate->heap()->NumberFromDouble(-x);
7066 SealHandleScope shs(isolate);
7067 ASSERT(args.length() == 0);
7069 return isolate->heap()->NumberFromDouble(9876543210.0);
7074 SealHandleScope shs(isolate);
7075 ASSERT(args.length() == 2);
7079 return isolate->heap()->NumberFromDouble(x / y);
7084 SealHandleScope shs(isolate);
7085 ASSERT(args.length() == 2);
7092 return isolate->heap()->NumberFromDouble(x);
7097 SealHandleScope shs(isolate);
7098 ASSERT(args.length() == 2);
7102 return isolate->heap()->NumberFromInt32(x * y);
7108 ASSERT(args.length() == 2);
7111 isolate->counters()->string_add_runtime()->Increment();
7112 Handle<String> result = isolate->factory()->NewConsString(str1, str2);
7118 template <
typename sink
char>
7119 static inline void StringBuilderConcatHelper(
String* special,
7121 FixedArray* fixed_array,
7124 for (
int i = 0; i < array_length; i++) {
7125 Object* element = fixed_array->get(i);
7126 if (element->IsSmi()) {
7131 if (encoded_slice > 0) {
7137 Object* obj = fixed_array->get(++i);
7140 len = -encoded_slice;
7149 int element_length =
string->length();
7151 position += element_length;
7159 ASSERT(args.length() == 3);
7161 if (!args[1]->IsSmi())
return isolate->ThrowInvalidStringLength();
7162 int array_length = args.smi_at(1);
7170 int special_length = special->length();
7171 if (!array->HasFastObjectElements()) {
7172 return isolate->Throw(isolate->heap()->illegal_argument_string());
7175 if (fixed_array->
length() < array_length) {
7176 array_length = fixed_array->
length();
7179 if (array_length == 0) {
7180 return isolate->heap()->empty_string();
7181 }
else if (array_length == 1) {
7183 if (first->IsString())
return first;
7186 bool one_byte = special->HasOnlyOneByteChars();
7188 for (
int i = 0; i < array_length; i++) {
7196 if (smi_value > 0) {
7205 if (i >= array_length) {
7206 return isolate->Throw(isolate->heap()->illegal_argument_string());
7209 if (!next_smi->IsSmi()) {
7210 return isolate->Throw(isolate->heap()->illegal_argument_string());
7214 return isolate->Throw(isolate->heap()->illegal_argument_string());
7219 if (pos > special_length || len > special_length - pos) {
7220 return isolate->Throw(isolate->heap()->illegal_argument_string());
7223 }
else if (elt->IsString()) {
7225 int element_length = element->
length();
7226 increment = element_length;
7231 ASSERT(!elt->IsTheHole());
7232 return isolate->Throw(isolate->heap()->illegal_argument_string());
7235 return isolate->ThrowInvalidStringLength();
7237 position += increment;
7240 int length = position;
7244 { MaybeObject* maybe_object =
7245 isolate->heap()->AllocateRawOneByteString(length);
7246 if (!maybe_object->ToObject(&
object))
return maybe_object;
7249 StringBuilderConcatHelper(*special,
7255 { MaybeObject* maybe_object =
7256 isolate->heap()->AllocateRawTwoByteString(length);
7257 if (!maybe_object->ToObject(&
object))
return maybe_object;
7260 StringBuilderConcatHelper(*special,
7271 ASSERT(args.length() == 3);
7273 if (!args[1]->IsSmi())
return isolate->ThrowInvalidStringLength();
7274 int array_length = args.smi_at(1);
7279 if (fixed_array->length() < array_length) {
7280 array_length = fixed_array->length();
7283 if (array_length == 0) {
7284 return isolate->heap()->empty_string();
7285 }
else if (array_length == 1) {
7286 Object* first = fixed_array->get(0);
7291 int separator_length = separator->length();
7292 int max_nof_separators =
7294 if (max_nof_separators < (array_length - 1)) {
7295 return isolate->ThrowInvalidStringLength();
7297 int length = (array_length - 1) * separator_length;
7298 for (
int i = 0; i < array_length; i++) {
7299 Object* element_obj = fixed_array->get(i);
7302 int increment = element->length();
7308 length += increment;
7312 isolate->factory()->NewRawTwoByteString(length);
7317 uc16* sink = answer->GetChars();
7319 uc16* end = sink + length;
7323 String* seperator_raw = *separator;
7324 int first_length = first->
length();
7326 sink += first_length;
7328 for (
int i = 1; i < array_length; i++) {
7329 ASSERT(sink + separator_length <= end);
7331 sink += separator_length;
7334 int element_length = element->
length();
7335 ASSERT(sink + element_length <= end);
7337 sink += element_length;
7342 ASSERT(!answer->IsOneByteRepresentation());
7346 template <
typename Char>
7347 static void JoinSparseArrayWithSeparator(FixedArray* elements,
7348 int elements_length,
7349 uint32_t array_length,
7351 Vector<Char> buffer) {
7352 int previous_separator_position = 0;
7353 int separator_length = separator->length();
7355 for (
int i = 0; i < elements_length; i += 2) {
7358 int string_length =
string->
length();
7359 if (string->length() > 0) {
7360 while (previous_separator_position < position) {
7361 String::WriteToFlat<Char>(separator, &buffer[cursor],
7362 0, separator_length);
7363 cursor += separator_length;
7364 previous_separator_position++;
7366 String::WriteToFlat<Char>(string, &buffer[cursor],
7368 cursor +=
string->length();
7371 if (separator_length > 0) {
7374 ASSERT(array_length <= 0x7fffffff);
7375 int last_array_index =
static_cast<int>(array_length - 1);
7376 while (previous_separator_position < last_array_index) {
7377 String::WriteToFlat<Char>(separator, &buffer[cursor],
7378 0, separator_length);
7379 cursor += separator_length;
7380 previous_separator_position++;
7383 ASSERT(cursor <= buffer.length());
7389 ASSERT(args.length() == 3);
7400 int string_length = 0;
7401 bool is_ascii = separator->IsOneByteRepresentation();
7404 Int32, elements_array->length());
7407 for (
int i = 0; i < elements_length; i += 2) {
7411 int length =
string->
length();
7412 if (is_ascii && !string->IsOneByteRepresentation()) {
7420 string_length += length;
7422 int separator_length = separator->length();
7423 if (!overflow && separator_length > 0) {
7424 if (array_length <= 0x7fffffffu) {
7425 int separator_count =
static_cast<int>(array_length) - 1;
7427 if ((remaining_length / separator_length) >= separator_count) {
7428 string_length += separator_length * (array_length - 1);
7444 return isolate->ThrowInvalidStringLength();
7448 MaybeObject* result_allocation =
7449 isolate->heap()->AllocateRawOneByteString(string_length);
7450 if (result_allocation->IsFailure())
return result_allocation;
7453 JoinSparseArrayWithSeparator<uint8_t>(elements,
7460 return result_string;
7462 MaybeObject* result_allocation =
7463 isolate->heap()->AllocateRawTwoByteString(string_length);
7464 if (result_allocation->IsFailure())
return result_allocation;
7467 JoinSparseArrayWithSeparator<uc16>(elements,
7473 return result_string;
7479 SealHandleScope shs(isolate);
7480 ASSERT(args.length() == 2);
7484 return isolate->heap()->NumberFromInt32(x | y);
7489 SealHandleScope shs(isolate);
7490 ASSERT(args.length() == 2);
7494 return isolate->heap()->NumberFromInt32(x & y);
7499 SealHandleScope shs(isolate);
7500 ASSERT(args.length() == 2);
7504 return isolate->heap()->NumberFromInt32(x ^ y);
7509 SealHandleScope shs(isolate);
7510 ASSERT(args.length() == 2);
7514 return isolate->heap()->NumberFromInt32(x << (y & 0x1f));
7519 SealHandleScope shs(isolate);
7520 ASSERT(args.length() == 2);
7524 return isolate->heap()->NumberFromUint32(x >> (y & 0x1f));
7529 SealHandleScope shs(isolate);
7530 ASSERT(args.length() == 2);
7539 SealHandleScope shs(isolate);
7540 ASSERT(args.length() == 2);
7558 SealHandleScope shs(isolate);
7559 ASSERT(args.length() == 2);
7568 ASSERT(not_equal == 0 || not_equal == 1);
7576 SealHandleScope shs(isolate);
7577 ASSERT(args.length() == 3);
7591 SealHandleScope shs(isolate);
7592 ASSERT(args.length() == 2);
7601 if (x_value == 0 || y_value == 0)
7610 uint32_t x_scaled = x_value;
7611 uint32_t y_scaled = y_value;
7612 if (x_value < 0 || y_value < 0) {
7615 x_scaled = -x_value;
7616 y_scaled = -y_value;
7619 static const uint32_t kPowersOf10[] = {
7620 1, 10, 100, 1000, 10*1000, 100*1000,
7621 1000*1000, 10*1000*1000, 100*1000*1000,
7634 int x_log10 = ((x_log2 + 1) * 1233) >> 12;
7635 x_log10 -= x_scaled < kPowersOf10[x_log10];
7638 int y_log10 = ((y_log2 + 1) * 1233) >> 12;
7639 y_log10 -= y_scaled < kPowersOf10[y_log10];
7643 if (x_log10 < y_log10) {
7650 x_scaled *= kPowersOf10[y_log10 - x_log10 - 1];
7653 }
else if (y_log10 < x_log10) {
7654 y_scaled *= kPowersOf10[x_log10 - y_log10 - 1];
7665 static Object* StringCharacterStreamCompare(RuntimeState* state,
7668 StringCharacterStream stream_x(x, state->string_iterator_compare_x());
7669 StringCharacterStream stream_y(y, state->string_iterator_compare_y());
7670 while (stream_x.HasMore() && stream_y.HasMore()) {
7671 int d = stream_x.GetNext() - stream_y.GetNext();
7683 static Object* FlatStringCompare(String* x, String* y) {
7687 int prefix_length = x->length();
7688 if (y->length() < prefix_length) {
7689 prefix_length = y->length();
7691 }
else if (y->length() > prefix_length) {
7696 String::FlatContent x_content = x->GetFlatContent();
7697 String::FlatContent y_content = y->GetFlatContent();
7698 if (x_content.IsAscii()) {
7699 Vector<const uint8_t> x_chars = x_content.ToOneByteVector();
7700 if (y_content.IsAscii()) {
7701 Vector<const uint8_t> y_chars = y_content.ToOneByteVector();
7702 r =
CompareChars(x_chars.start(), y_chars.start(), prefix_length);
7704 Vector<const uc16> y_chars = y_content.ToUC16Vector();
7705 r =
CompareChars(x_chars.start(), y_chars.start(), prefix_length);
7708 Vector<const uc16> x_chars = x_content.ToUC16Vector();
7709 if (y_content.IsAscii()) {
7710 Vector<const uint8_t> y_chars = y_content.ToOneByteVector();
7711 r =
CompareChars(x_chars.start(), y_chars.start(), prefix_length);
7713 Vector<const uc16> y_chars = y_content.ToUC16Vector();
7714 r =
CompareChars(x_chars.start(), y_chars.start(), prefix_length);
7719 result = equal_prefix_result;
7724 StringCharacterStreamCompare(x->GetIsolate()->runtime_state(), x, y));
7730 SealHandleScope shs(isolate);
7731 ASSERT(args.length() == 2);
7736 isolate->counters()->string_compare_runtime()->Increment();
7740 if (y->length() == 0) {
7743 }
else if (x->length() == 0) {
7747 int d = x->Get(0) - y->Get(0);
7752 { MaybeObject* maybe_obj = isolate->heap()->PrepareForCompare(x);
7753 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
7755 { MaybeObject* maybe_obj = isolate->heap()->PrepareForCompare(y);
7756 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
7759 return (x->IsFlat() && y->IsFlat()) ? FlatStringCompare(x, y)
7760 : StringCharacterStreamCompare(isolate->runtime_state(), x, y);
7764 #define RUNTIME_UNARY_MATH(NAME) \
7765 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_##NAME) { \
7766 SealHandleScope shs(isolate); \
7767 ASSERT(args.length() == 1); \
7768 isolate->counters()->math_##NAME()->Increment(); \
7769 CONVERT_DOUBLE_ARG_CHECKED(x, 0); \
7770 return isolate->heap()->AllocateHeapNumber(std::NAME(x)); \
7777 #undef RUNTIME_UNARY_MATH
7781 SealHandleScope shs(isolate);
7782 ASSERT(args.length() == 1);
7785 integer = (integer >> 32) & 0xFFFFFFFFu;
7786 return isolate->heap()->NumberFromDouble(static_cast<int32_t>(integer));
7791 SealHandleScope shs(isolate);
7792 ASSERT(args.length() == 1);
7794 return isolate->heap()->NumberFromDouble(
7800 SealHandleScope shs(isolate);
7801 ASSERT(args.length() == 2);
7804 uint64_t result = (
static_cast<uint64_t
>(
hi) << 32) |
lo;
7809 static const double kPiDividedBy4 = 0.78539816339744830962;
7813 SealHandleScope shs(isolate);
7814 ASSERT(args.length() == 2);
7815 isolate->counters()->math_atan2()->Increment();
7825 int multiplier = (x < 0) ? -1 : 1;
7826 if (y < 0) multiplier *= 3;
7827 result = multiplier * kPiDividedBy4;
7829 result = std::atan2(x, y);
7831 return isolate->heap()->AllocateHeapNumber(result);
7836 SealHandleScope shs(isolate);
7837 ASSERT(args.length() == 1);
7838 isolate->counters()->math_exp()->Increment();
7842 return isolate->heap()->NumberFromDouble(
fast_exp(x));
7847 SealHandleScope shs(isolate);
7848 ASSERT(args.length() == 1);
7849 isolate->counters()->math_floor()->Increment();
7852 return isolate->heap()->NumberFromDouble(std::floor(x));
7859 SealHandleScope shs(isolate);
7860 ASSERT(args.length() == 2);
7861 isolate->counters()->math_pow()->Increment();
7867 if (args[1]->IsSmi()) {
7868 int y = args.smi_at(1);
7874 if (
std::isnan(result))
return isolate->heap()->nan_value();
7875 return isolate->heap()->AllocateHeapNumber(result);
7882 SealHandleScope shs(isolate);
7883 ASSERT(args.length() == 2);
7884 isolate->counters()->math_pow()->Increment();
7892 if (
std::isnan(result))
return isolate->heap()->nan_value();
7893 return isolate->heap()->AllocateHeapNumber(result);
7899 SealHandleScope shs(isolate);
7900 ASSERT(args.length() == 1);
7901 isolate->counters()->math_round()->Increment();
7903 if (!args[0]->IsHeapNumber()) {
7911 double value = number->
value();
7915 if (exponent < -1) {
7917 if (sign)
return isolate->heap()->minus_zero_value();
7930 if (exponent >= 52) {
7934 if (sign && value >= -0.5)
return isolate->heap()->minus_zero_value();
7937 return isolate->heap()->AllocateHeapNumber(std::floor(value + 0.5));
7942 SealHandleScope shs(isolate);
7943 ASSERT(args.length() == 1);
7944 isolate->counters()->math_sqrt()->Increment();
7947 return isolate->heap()->AllocateHeapNumber(
fast_sqrt(x));
7952 SealHandleScope shs(isolate);
7953 ASSERT(args.length() == 1);
7956 float xf =
static_cast<float>(x);
7957 return isolate->heap()->AllocateHeapNumber(xf);
7962 SealHandleScope shs(isolate);
7963 ASSERT(args.length() == 2);
7968 return Smi::FromInt(isolate->date_cache()->DaysFromYearMonth(year, month));
7974 ASSERT(args.length() == 3);
7980 DateCache* date_cache = isolate->date_cache();
7983 bool is_value_nan =
false;
7985 value = isolate->heap()->nan_value();
7986 is_value_nan =
true;
7987 }
else if (!is_utc &&
7990 value = isolate->heap()->nan_value();
7991 is_value_nan =
true;
7993 time = is_utc ? time : date_cache->
ToUTC(static_cast<int64_t>(time));
7996 value = isolate->heap()->nan_value();
7997 is_value_nan =
true;
7999 MaybeObject* maybe_result =
8001 if (!maybe_result->ToObject(&value))
return maybe_result;
8004 date->SetValue(value, is_value_nan);
8011 ASSERT(args.length() == 3);
8014 Object** parameters =
reinterpret_cast<Object**
>(args[1]);
8018 isolate->factory()->NewArgumentsObject(callee, argument_count);
8020 int parameter_count = callee->shared()->formal_parameter_count();
8021 if (argument_count > 0) {
8022 if (parameter_count > 0) {
8023 int mapped_count =
Min(argument_count, parameter_count);
8025 isolate->factory()->NewFixedArray(mapped_count + 2,
NOT_TENURED);
8026 parameter_map->set_map(
8027 isolate->heap()->sloppy_arguments_elements_map());
8030 Handle<Map> new_map = isolate->factory()->CopyMap(old_map);
8033 result->set_map(*new_map);
8034 result->set_elements(*parameter_map);
8040 isolate->factory()->NewFixedArray(argument_count,
NOT_TENURED);
8041 parameter_map->set(0, *context);
8042 parameter_map->set(1, *arguments);
8045 int index = argument_count - 1;
8046 while (index >= mapped_count) {
8049 arguments->set(index, *(parameters - index - 1));
8054 while (index >= 0) {
8057 int context_local_count = scope_info->ContextLocalCount();
8058 bool duplicate =
false;
8059 for (
int j = index + 1; j < parameter_count; ++j) {
8060 if (scope_info->ParameterName(j) == *
name) {
8069 arguments->set(index, *(parameters - index - 1));
8070 parameter_map->set_the_hole(index + 2);
8074 int context_index = -1;
8075 for (
int j = 0; j < context_local_count; ++j) {
8076 if (scope_info->ContextLocalName(j) == *
name) {
8081 ASSERT(context_index >= 0);
8082 arguments->set_the_hole(index);
8093 isolate->factory()->NewFixedArray(argument_count,
NOT_TENURED);
8094 result->set_elements(*elements);
8095 for (
int i = 0; i < argument_count; ++i) {
8096 elements->set(i, *(parameters - i - 1));
8105 SealHandleScope shs(isolate);
8106 ASSERT(args.length() == 3);
8109 Object** parameters =
reinterpret_cast<Object**
>(args[1]);
8110 const int length = args.smi_at(2);
8113 { MaybeObject* maybe_result =
8114 isolate->heap()->AllocateArgumentsObject(callee, length);
8115 if (!maybe_result->ToObject(&result))
return maybe_result;
8121 { MaybeObject* maybe_obj =
8122 isolate->heap()->AllocateUninitializedFixedArray(length);
8123 if (!maybe_obj->To(&array))
return maybe_obj;
8128 for (
int i = 0; i < length; i++) {
8129 array->
set(i, *--parameters, mode);
8139 ASSERT(args.length() == 1);
8144 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared,
8153 ASSERT(args.length() == 3);
8162 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared,
8172 static SmartArrayPointer<Handle<Object> > GetCallerArguments(
8177 JavaScriptFrameIterator it(isolate);
8178 JavaScriptFrame* frame = it.frame();
8179 List<JSFunction*> functions(2);
8180 frame->GetFunctions(&functions);
8181 if (functions.length() > 1) {
8182 int inlined_jsframe_index = functions.length() - 1;
8183 JSFunction* inlined_function = functions[inlined_jsframe_index];
8184 SlotRefValueBuilder slot_refs(
8186 inlined_jsframe_index,
8187 inlined_function->shared()->formal_parameter_count());
8189 int args_count = slot_refs.args_length();
8191 *total_argc = prefix_argc + args_count;
8192 SmartArrayPointer<Handle<Object> > param_data(
8194 slot_refs.Prepare(isolate);
8195 for (
int i = 0; i < args_count; i++) {
8197 param_data[prefix_argc + i] = val;
8199 slot_refs.Finish(isolate);
8203 it.AdvanceToArgumentsFrame();
8205 int args_count = frame->ComputeParametersCount();
8207 *total_argc = prefix_argc + args_count;
8208 SmartArrayPointer<Handle<Object> > param_data(
8209 NewArray<Handle<Object> >(*total_argc));
8210 for (
int i = 0; i < args_count; i++) {
8211 Handle<Object> val = Handle<Object>(frame->GetParameter(i), isolate);
8212 param_data[prefix_argc + i] = val;
8221 ASSERT(args.length() == 4);
8227 bound_function->shared()->set_bound(
true);
8231 GetCallerArguments(isolate, 0, &argc);
8234 ASSERT(*arguments[0] == args[2]);
8237 ASSERT(args[2]->IsUndefined());
8243 if (bindee->IsJSFunction() &&
JSFunction::cast(*bindee)->shared()->bound()) {
8247 isolate->factory()->NewFixedArray(old_bindings->length() + argc);
8251 for (
int n = old_bindings->length(); i < n; i++) {
8252 new_bindings->set(i, old_bindings->get(i));
8256 new_bindings = isolate->factory()->NewFixedArray(array_size);
8262 for (
int j = 0; j < argc; j++, i++) {
8263 new_bindings->set(i, *arguments[j + 1]);
8265 new_bindings->set_map_no_write_barrier(
8266 isolate->heap()->fixed_cow_array_map());
8267 bound_function->set_function_bindings(*new_bindings);
8270 Handle<String> length_string = isolate->factory()->length_string();
8275 return *bound_function;
8281 ASSERT(args.length() == 1);
8283 if (callable->IsJSFunction()) {
8285 if (function->shared()->bound()) {
8287 ASSERT(bindings->map() == isolate->heap()->fixed_cow_array_map());
8288 return *isolate->factory()->NewJSArrayWithElements(bindings);
8291 return isolate->heap()->undefined_value();
8297 ASSERT(args.length() == 1);
8310 ASSERT(!bound_function->IsJSFunction() ||
8315 GetCallerArguments(isolate, bound_argc, &total_argc);
8316 for (
int i = 0; i < bound_argc; i++) {
8321 if (!bound_function->IsJSFunction()) {
8322 bool exception_thrown;
8328 ASSERT(bound_function->IsJSFunction());
8330 bool exception =
false;
8333 total_argc, param_data.
get(), &exception);
8337 ASSERT(!result.is_null());
8342 static MaybeObject* Runtime_NewObjectHelper(
Isolate* isolate,
8346 if (!constructor->IsJSFunction()) {
8347 Vector< Handle<Object> > arguments =
HandleVector(&constructor, 1);
8349 isolate->factory()->NewTypeError(
"not_constructor", arguments);
8350 return isolate->Throw(*type_error);
8357 if (!function->should_have_prototype() && !
function->shared()->bound()) {
8358 Vector< Handle<Object> > arguments =
HandleVector(&constructor, 1);
8359 Handle<Object> type_error =
8360 isolate->factory()->NewTypeError(
"not_constructor", arguments);
8361 return isolate->Throw(*type_error);
8364 #ifdef ENABLE_DEBUGGER_SUPPORT
8365 Debug* debug = isolate->debug();
8367 if (debug->StepInActive()) {
8368 debug->HandleStepIn(
function, Handle<Object>::null(), 0,
true);
8372 if (function->has_initial_map()) {
8385 return isolate->context()->global_object();
8393 Handle<SharedFunctionInfo> shared(function->shared(), isolate);
8394 if (!function->has_initial_map() &&
8395 shared->IsInobjectSlackTrackingInProgress()) {
8399 shared->CompleteInobjectSlackTracking();
8402 Handle<JSObject> result;
8403 if (site.is_null()) {
8404 result = isolate->factory()->NewJSObject(
function);
8406 result = isolate->factory()->NewJSObjectWithMemento(
function, site);
8410 isolate->counters()->constructed_objects()->Increment();
8411 isolate->counters()->constructed_objects_runtime()->Increment();
8419 ASSERT(args.length() == 1);
8422 return Runtime_NewObjectHelper(isolate,
8430 ASSERT(args.length() == 2);
8435 if (feedback->IsAllocationSite()) {
8439 return Runtime_NewObjectHelper(isolate,
8447 ASSERT(args.length() == 1);
8450 function->shared()->CompleteInobjectSlackTracking();
8452 return isolate->heap()->undefined_value();
8458 ASSERT(args.length() == 1);
8462 if (FLAG_trace_lazy && !function->shared()->is_compiled()) {
8463 PrintF(
"[unoptimized: ");
8464 function->PrintName();
8470 ASSERT(function->shared()->allows_lazy_compilation());
8474 function->ReplaceCode(*code);
8477 ASSERT(function->is_compiled());
8478 ASSERT(function->code()->kind() == Code::FUNCTION ||
8480 function->code()->kind() == Code::OPTIMIZED_FUNCTION));
8487 ASSERT(args.length() == 2);
8492 if (!function->shared()->is_compiled()) {
8497 function->ReplaceCode(function->shared()->code());
8498 }
else if (!isolate->use_crankshaft() ||
8499 function->shared()->optimization_disabled() ||
8500 isolate->DebuggerHasBreakPoints()) {
8503 if (FLAG_trace_opt) {
8504 PrintF(
"[failed to optimize ");
8505 function->PrintName();
8506 PrintF(
": is code optimizable: %s, is debugger enabled: %s]\n",
8507 function->shared()->optimization_disabled() ?
"F" :
"T",
8508 isolate->DebuggerHasBreakPoints() ?
"T" :
"F");
8510 function->ReplaceCode(*unoptimized);
8515 function->ReplaceCode(code.
is_null() ? *unoptimized : *
code);
8518 ASSERT(function->code()->kind() == Code::FUNCTION ||
8519 function->code()->kind() == Code::OPTIMIZED_FUNCTION ||
8520 function->IsInOptimizationQueue());
8521 return function->code();
8535 JavaScriptFrameIterator it(isolate, top);
8540 for (; !it->done(); it->Advance()) {
8550 ASSERT(args.length() == 0);
8552 ASSERT(AllowHeapAllocation::IsAllowed());
8554 return isolate->heap()->undefined_value();
8560 ASSERT(args.length() == 1);
8565 ASSERT(AllowHeapAllocation::IsAllowed());
8570 ASSERT(optimized_code->kind() == Code::OPTIMIZED_FUNCTION);
8574 JavaScriptFrameIterator it(isolate);
8585 return isolate->heap()->undefined_value();
8591 isolate->thread_manager()->IterateArchivedThreads(&activations_finder);
8594 if (function->code() == *optimized_code) {
8595 if (FLAG_trace_deopt) {
8596 PrintF(
"[removing optimized code for: ");
8597 function->PrintName();
8600 function->ReplaceCode(function->shared()->code());
8603 function->shared()->EvictFromOptimizedCodeMap(*optimized_code,
8604 "notify deoptimized");
8613 return isolate->heap()->undefined_value();
8619 ASSERT(args.length() == 1);
8621 if (!function->IsOptimized())
return isolate->heap()->undefined_value();
8625 return isolate->heap()->undefined_value();
8631 ASSERT(args.length() == 1);
8633 Code* unoptimized =
function->shared()->code();
8634 if (unoptimized->
kind() == Code::FUNCTION) {
8638 return isolate->heap()->undefined_value();
8643 SealHandleScope shs(isolate);
8644 #if defined(USE_SIMULATOR)
8645 return isolate->heap()->true_value();
8647 return isolate->heap()->false_value();
8654 return isolate->concurrent_recompilation_enabled()
8655 ? isolate->heap()->true_value() : isolate->heap()->false_value();
8664 if (!function->IsOptimizable() &&
8665 !
function->IsMarkedForConcurrentOptimization() &&
8666 !
function->IsInOptimizationQueue()) {
8667 return isolate->heap()->undefined_value();
8670 function->MarkForOptimization();
8672 Code* unoptimized =
function->shared()->code();
8673 if (args.length() == 2 &&
8674 unoptimized->
kind() == Code::FUNCTION) {
8679 ASSERT(BackEdgeTable::Verify(isolate, unoptimized, current_level));
8682 isolate->runtime_profiler()->AttemptOnStackReplacement(*
function);
8685 isolate->concurrent_recompilation_enabled()) {
8686 function->MarkForConcurrentOptimization();
8690 return isolate->heap()->undefined_value();
8696 ASSERT(args.length() == 1);
8698 function->shared()->set_optimization_disabled(
true);
8699 return isolate->heap()->undefined_value();
8706 if (!isolate->use_crankshaft()) {
8709 bool sync_with_compiler_thread =
true;
8710 if (args.length() == 2) {
8713 sync_with_compiler_thread =
false;
8717 if (isolate->concurrent_recompilation_enabled() &&
8718 sync_with_compiler_thread) {
8719 while (function->IsInOptimizationQueue()) {
8720 isolate->optimizing_compiler_thread()->InstallOptimizedFunctions();
8724 if (FLAG_always_opt) {
8730 if (FLAG_deopt_every_n_times) {
8741 isolate->optimizing_compiler_thread()->Unblock();
8742 return isolate->heap()->undefined_value();
8748 ASSERT(args.length() == 1);
8754 static bool IsSuitableForOnStackReplacement(
Isolate* isolate,
8758 if (!isolate->use_crankshaft() || !current_code->
optimizable())
return false;
8764 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) {
8765 JavaScriptFrame* frame = it.frame();
8766 if (frame->is_optimized() && frame->function() == *
function)
return false;
8775 ASSERT(args.length() == 1);
8780 ASSERT(!function->shared()->uses_arguments());
8784 JavaScriptFrameIterator it(isolate);
8786 if (!caller_code->contains(frame->pc())) {
8792 uint32_t pc_offset =
static_cast<uint32_t
>(
8793 frame->pc() - caller_code->instruction_start());
8797 ASSERT_EQ(frame->LookupCode(), *caller_code);
8798 ASSERT(caller_code->contains(frame->pc()));
8802 BailoutId ast_id = caller_code->TranslatePcOffsetToAstId(pc_offset);
8816 if (FLAG_trace_osr) {
8817 PrintF(
"[OSR - Still waiting for queued: ");
8818 function->PrintName();
8828 if (FLAG_trace_osr) {
8829 PrintF(
"[OSR - Found ready: ");
8830 function->PrintName();
8834 }
else if (result.
is_null() &&
8835 IsSuitableForOnStackReplacement(isolate,
function, caller_code)) {
8836 if (FLAG_trace_osr) {
8837 PrintF(
"[OSR - Compiling: ");
8838 function->PrintName();
8842 if (result.is_identical_to(isolate->builtins()->InOptimizationQueue())) {
8852 if (!result.
is_null() && result->kind() == Code::OPTIMIZED_FUNCTION) {
8856 if (data->OsrPcOffset()->value() >= 0) {
8858 if (FLAG_trace_osr) {
8859 PrintF(
"[OSR - Entry at AST id %d, offset %d in optimized code]\n",
8860 ast_id.
ToInt(), data->OsrPcOffset()->value());
8864 function->shared()->increment_deopt_count();
8867 function->ReplaceCode(*result);
8873 if (FLAG_trace_osr) {
8874 PrintF(
"[OSR - Failed: ");
8875 function->PrintName();
8879 if (!function->IsOptimized()) {
8880 function->ReplaceCode(function->shared()->code());
8887 SealHandleScope shs(isolate);
8888 ASSERT(args.length() == 2 || args.length() == 3);
8892 isolate->heap()->set_allocation_timeout(timeout);
8893 FLAG_gc_interval = interval;
8894 if (args.length() == 3) {
8897 if (inline_allocation) {
8898 isolate->heap()->EnableInlineAllocation();
8900 isolate->heap()->DisableInlineAllocation();
8904 return isolate->heap()->undefined_value();
8909 SealHandleScope shs(isolate);
8911 return isolate->heap()->undefined_value();
8916 SealHandleScope shs(isolate);
8918 return isolate->heap()->nan_value();
8924 ASSERT(args.length() >= 2);
8925 int argc = args.length() - 2;
8927 Object* receiver = args[0];
8930 const int argv_small_size = 10;
8934 if (argc > argv_small_size) {
8936 if (argv ==
NULL)
return isolate->StackOverflow();
8940 for (
int i = 0; i < argc; ++i) {
8941 MaybeObject* maybe = args[1 + i];
8943 if (!maybe->To<
Object>(&
object))
return maybe;
8951 isolate, hfun, hreceiver, argc, argv, &threw,
true);
8960 ASSERT(args.length() == 5);
8970 const int argv_small_size = 10;
8974 if (argc > argv_small_size) {
8976 if (argv ==
NULL)
return isolate->StackOverflow();
8980 for (
int i = 0; i < argc; ++i) {
8987 isolate, fun, receiver, argc, argv, &threw,
true);
8996 ASSERT(args.length() == 1);
9004 ASSERT(args.length() == 1);
9011 SealHandleScope shs(isolate);
9012 ASSERT(args.length() == 2);
9017 MaybeObject* maybe_result =
9018 isolate->heap()->AllocateGlobalContext(
function, scope_info);
9019 if (!maybe_result->To(&result))
return maybe_result;
9021 ASSERT(function->context() == isolate->context());
9030 SealHandleScope shs(isolate);
9031 ASSERT(args.length() == 1);
9034 int length =
function->shared()->scope_info()->ContextLength();
9035 return isolate->heap()->AllocateFunctionContext(length,
function);
9040 SealHandleScope shs(isolate);
9041 ASSERT(args.length() == 2);
9043 if (args[0]->IsJSReceiver()) {
9047 MaybeObject* maybe_js_object = args[0]->ToObject(isolate);
9048 if (!maybe_js_object->To(&extension_object)) {
9053 isolate->factory()->NewTypeError(
"with_expression",
9055 return isolate->Throw(*result);
9057 return maybe_js_object;
9063 if (args[1]->IsSmi()) {
9067 function = isolate->context()->native_context()->closure();
9073 MaybeObject* maybe_context =
9074 isolate->heap()->AllocateWithContext(
function,
9077 if (!maybe_context->To(&context))
return maybe_context;
9078 isolate->set_context(context);
9084 SealHandleScope shs(isolate);
9085 ASSERT(args.length() == 3);
9087 Object* thrown_object = args[1];
9089 if (args[2]->IsSmi()) {
9093 function = isolate->context()->native_context()->closure();
9098 MaybeObject* maybe_context =
9099 isolate->heap()->AllocateCatchContext(
function,
9103 if (!maybe_context->To(&context))
return maybe_context;
9104 isolate->set_context(context);
9110 SealHandleScope shs(isolate);
9111 ASSERT(args.length() == 2);
9114 if (args[1]->IsSmi()) {
9118 function = isolate->context()->native_context()->closure();
9123 MaybeObject* maybe_context =
9124 isolate->heap()->AllocateBlockContext(
function,
9127 if (!maybe_context->To(&context))
return maybe_context;
9128 isolate->set_context(context);
9134 SealHandleScope shs(isolate);
9135 ASSERT(args.length() == 1);
9137 return isolate->heap()->ToBoolean(obj->IsJSModule());
9142 SealHandleScope shs(isolate);
9143 ASSERT(args.length() == 2);
9146 if (!args[1]->IsScopeInfo()) {
9151 isolate->set_context(context);
9159 Factory* factory = isolate->factory();
9163 Context* previous = isolate->context();
9167 isolate->set_context(*context);
9178 ASSERT(args.length() == 1);
9180 Context* host_context = isolate->context();
9182 for (
int i = 0; i < descriptions->length(); ++i) {
9184 int host_index = description->host_index();
9188 for (
int j = 0; j < description->length(); ++j) {
9191 int index = description->index(j);
9202 ASSERT(!(result.is_null() || result->IsUndefined()));
9224 ASSERT(!isolate->has_pending_exception());
9225 return isolate->heap()->undefined_value();
9231 ASSERT(args.length() == 2);
9247 if (holder.is_null()) {
9248 return isolate->heap()->true_value();
9252 if (holder->IsContext()) {
9253 return isolate->heap()->false_value();
9274 #ifdef V8_HOST_ARCH_64_BIT
9281 static inline ObjectPair MakePair(MaybeObject* x, MaybeObject* y) {
9289 static inline ObjectPair MakePair(MaybeObject* x, MaybeObject* y) {
9290 return reinterpret_cast<uint32_t
>(x) |
9291 (reinterpret_cast<ObjectPair>(y) << 32);
9296 static inline MaybeObject* Unhole(Heap* heap,
9301 return x->IsTheHole() ? heap->undefined_value() : x;
9305 static Object* ComputeReceiverForNonGlobal(Isolate* isolate,
9307 ASSERT(!holder->IsGlobalObject());
9308 Context* top = isolate->context();
9310 JSFunction* context_extension_function =
9311 top->native_context()->context_extension_function();
9316 Object* constructor = holder->map()->constructor();
9317 if (constructor != context_extension_function)
return holder;
9321 return isolate->heap()->undefined_value();
9325 static ObjectPair LoadContextSlotHelper(Arguments args,
9328 HandleScope scope(isolate);
9331 if (!args[0]->IsContext() || !args[1]->IsString()) {
9332 return MakePair(isolate->ThrowIllegalOperation(),
NULL);
9334 Handle<Context> context = args.at<Context>(0);
9335 Handle<String> name = args.at<String>(1);
9341 Handle<Object> holder = context->Lookup(name,
9346 if (isolate->has_pending_exception()) {
9352 ASSERT(holder->IsContext());
9355 Handle<Object> receiver = isolate->factory()->undefined_value();
9358 switch (binding_flags) {
9361 if (value->IsTheHole()) {
9362 Handle<Object> reference_error =
9363 isolate->factory()->NewReferenceError(
"not_defined",
9365 return MakePair(isolate->Throw(*reference_error),
NULL);
9371 ASSERT(!value->IsTheHole());
9372 return MakePair(value, *receiver);
9374 return MakePair(Unhole(isolate->heap(), value, attributes), *receiver);
9384 if (!holder.is_null()) {
9388 Handle<Object> receiver_handle(
9389 object->IsGlobalObject()
9391 : object->IsJSProxy() ?
static_cast<Object*
>(*object)
9397 MaybeObject* value =
object->GetProperty(*name);
9398 return MakePair(value, *receiver_handle);
9403 Handle<Object> reference_error =
9404 isolate->factory()->NewReferenceError(
"not_defined",
9406 return MakePair(isolate->Throw(*reference_error),
NULL);
9409 return MakePair(isolate->heap()->undefined_value(),
9410 isolate->heap()->undefined_value());
9416 return LoadContextSlotHelper(args, isolate,
true);
9421 return LoadContextSlotHelper(args, isolate,
false);
9427 ASSERT(args.length() == 4);
9449 context->
get(index)->IsTheHole()) {
9451 isolate->factory()->NewReferenceError(
"not_defined",
9453 return isolate->Throw(*error);
9456 if ((attributes & READ_ONLY) == 0) {
9458 context->
set(index, *value);
9459 }
else if (strict_mode ==
STRICT) {
9462 isolate->factory()->NewTypeError(
"strict_cannot_assign",
9464 return isolate->Throw(*error);
9474 if (!holder.is_null()) {
9481 if (strict_mode ==
STRICT) {
9484 isolate->factory()->NewReferenceError(
9486 return isolate->Throw(*error);
9494 if ((attributes & READ_ONLY) == 0 ||
9499 }
else if (strict_mode ==
STRICT && (attributes & READ_ONLY) != 0) {
9502 isolate->factory()->NewTypeError(
9504 return isolate->Throw(*error);
9512 ASSERT(args.length() == 1);
9514 return isolate->Throw(args[0]);
9520 ASSERT(args.length() == 1);
9522 return isolate->ReThrow(args[0]);
9527 SealHandleScope shs(isolate);
9529 return isolate->PromoteScheduledException();
9535 ASSERT(args.length() == 1);
9539 isolate->factory()->NewReferenceError(
"not_defined",
9541 return isolate->Throw(*reference_error);
9547 ASSERT(args.length() == 0);
9548 return isolate->Throw(*isolate->factory()->NewTypeError(
9549 "not_date_object", HandleVector<Object>(
NULL, 0)));
9555 ASSERT(args.length() == 1);
9558 static_cast<BailoutReason>(message_id));
9560 isolate->factory()->NewStringFromAscii(
CStrVector(message));
9562 return isolate->Throw(*message_handle);
9567 SealHandleScope shs(isolate);
9568 ASSERT(args.length() == 0);
9571 if (isolate->stack_guard()->IsStackOverflow()) {
9572 return isolate->StackOverflow();
9581 ASSERT(args.length() == 1);
9585 if (isolate->stack_guard()->IsStackOverflow()) {
9586 SealHandleScope shs(isolate);
9587 return isolate->StackOverflow();
9590 isolate->optimizing_compiler_thread()->InstallOptimizedFunctions();
9591 return (function->IsOptimized()) ? function->code()
9592 :
function->shared()->code();
9597 SealHandleScope shs(isolate);
9598 ASSERT(args.length() == 0);
9603 static int StackSize(
Isolate* isolate) {
9605 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) n++;
9610 static void PrintTransition(Isolate* isolate,
Object* result) {
9612 {
const int nmax = 80;
9613 int n = StackSize(isolate);
9615 PrintF(
"%4d:%*s", n, n,
"");
9617 PrintF(
"%4d:%*s", n, nmax,
"...");
9620 if (result ==
NULL) {
9626 result->ShortPrint();
9633 SealHandleScope shs(isolate);
9634 ASSERT(args.length() == 0);
9635 PrintTransition(isolate,
NULL);
9636 return isolate->heap()->undefined_value();
9641 SealHandleScope shs(isolate);
9642 PrintTransition(isolate, args[0]);
9648 SealHandleScope shs(isolate);
9649 ASSERT(args.length() == 1);
9652 if (args[0]->IsString()) {
9655 JavaScriptFrameIterator it(isolate);
9657 PrintF(
"fp = %p, sp = %p, caller_sp = %p: ",
9658 frame->fp(), frame->sp(), frame->caller_sp());
9663 if (args[0]->IsHeapObject()) {
9679 SealHandleScope shs(isolate);
9680 ASSERT(args.length() == 0);
9681 isolate->PrintStack(stdout);
9682 return isolate->heap()->undefined_value();
9687 SealHandleScope shs(isolate);
9688 ASSERT(args.length() == 0);
9695 return isolate->heap()->NumberFromDouble(millis);
9701 ASSERT(args.length() == 2);
9720 isolate->unicode_cache());
9725 isolate->unicode_cache());
9731 return isolate->heap()->null_value();
9737 SealHandleScope shs(isolate);
9738 ASSERT(args.length() == 1);
9742 isolate->date_cache()->LocalTimezone(static_cast<int64_t>(x));
9743 return isolate->heap()->AllocateStringFromUtf8(
CStrVector(zone));
9748 SealHandleScope shs(isolate);
9749 ASSERT(args.length() == 1);
9752 int64_t time = isolate->date_cache()->ToUTC(static_cast<int64_t>(x));
9754 return isolate->heap()->NumberFromDouble(static_cast<double>(time));
9760 ASSERT(args.length() == 0);
9763 isolate->factory()->NewFixedArray(1,
TENURED);
9765 isolate->eternal_handles()->CreateSingleton(
9773 isolate->factory()->NewJSObject(isolate->array_function());
9780 SealHandleScope shs(isolate);
9781 ASSERT(args.length() == 1);
9782 Object* global = args[0];
9783 if (!global->IsJSGlobalObject())
return isolate->heap()->null_value();
9789 SealHandleScope shs(isolate);
9790 ASSERT(args.length() == 1);
9791 Object* global = args[0];
9792 if (!global->IsJSGlobalObject())
return isolate->heap()->false_value();
9793 return isolate->heap()->ToBoolean(
9806 if (source->IsSeqOneByteString()) {
9807 result = JsonParser<true>::Parse(source);
9809 result = JsonParser<false>::Parse(source);
9813 ASSERT(isolate->has_pending_exception());
9822 ASSERT(context->allow_code_gen_from_strings()->IsFalse());
9825 isolate->allow_code_gen_callback();
9826 if (callback ==
NULL) {
9848 if (context->allow_code_gen_from_strings()->IsFalse() &&
9851 context->ErrorMessageForCodeGenerationFromStrings();
9852 return isolate->Throw(*isolate->factory()->NewEvalError(
9853 "code_gen_from_strings", HandleVector<Object>(&error_message, 1)));
9860 source, context,
SLOPPY, restriction, RelocInfo::kNoPosition);
9870 int scope_position) {
9876 if (native_context->allow_code_gen_from_strings()->IsFalse() &&
9880 isolate->Throw(*isolate->factory()->NewEvalError(
9881 "code_gen_from_strings", HandleVector<Object>(&error_message, 1)));
9889 source, context, strict_mode, restriction, scope_position);
9892 return MakePair(*compiled, *receiver);
9898 ASSERT(args.length() == 5);
9907 if (*callee != isolate->native_context()->global_eval_fun() ||
9908 !args[1]->IsString()) {
9909 return MakePair(*callee, isolate->heap()->undefined_value());
9912 ASSERT(args[3]->IsSmi());
9915 ASSERT(args[4]->IsSmi());
9916 return CompileGlobalEval(isolate,
9926 static MaybeObject* Allocate(
Isolate* isolate,
9930 Heap* heap = isolate->heap();
9934 HeapObject* allocation;
9935 { MaybeObject* maybe_allocation = heap->AllocateRaw(size, space, space);
9936 if (!maybe_allocation->To(&allocation))
return maybe_allocation;
9940 ASSERT(chunk->owner()->identity() == space);
9942 heap->CreateFillerObjectAt(allocation->address(),
size);
9948 SealHandleScope shs(isolate);
9949 ASSERT(args.length() == 1);
9951 return Allocate(isolate, size,
false,
NEW_SPACE);
9956 SealHandleScope shs(isolate);
9957 ASSERT(args.length() == 2);
9962 return Allocate(isolate, size, double_align, space);
9971 ASSERT(args.length() == 2);
9975 int length =
Smi::cast(array->length())->value();
9977 for (
int i = 0; i < length; i++) {
9978 if (elements->
get(i) == *element)
return isolate->heap()->false_value();
9986 return isolate->heap()->true_value();
10005 bool fast_elements) :
10008 isolate->global_handles()->Create(*storage))),
10010 fast_elements_(fast_elements),
10011 exceeds_array_limit_(
false) { }
10019 exceeds_array_limit_ =
true;
10022 uint32_t index = index_offset_ + i;
10024 if (fast_elements_) {
10025 if (index < static_cast<uint32_t>(storage_->length())) {
10026 storage_->set(index, *elm);
10033 SetDictionaryMode(index);
10036 ASSERT(!fast_elements_);
10041 if (!result.is_identical_to(dict)) {
10044 set_storage(*result);
10052 index_offset_ += delta;
10057 return exceeds_array_limit_;
10065 if (fast_elements_) {
10070 array->set_map(*map);
10071 array->set_length(*length);
10072 array->set_elements(*storage_);
10078 void SetDictionaryMode(uint32_t index) {
10083 current_storage->length()));
10084 uint32_t current_length =
static_cast<uint32_t
>(current_storage->length());
10085 for (uint32_t i = 0; i < current_length; i++) {
10088 if (!element->IsTheHole()) {
10091 if (!new_storage.is_identical_to(slow_storage)) {
10092 slow_storage = loop_scope.CloseAndEscape(new_storage);
10097 set_storage(*slow_storage);
10098 fast_elements_ =
false;
10101 inline void clear_storage() {
10105 inline void set_storage(FixedArray* storage) {
10111 Handle<FixedArray> storage_;
10114 uint32_t index_offset_;
10115 bool fast_elements_ : 1;
10116 bool exceeds_array_limit_ : 1;
10120 static uint32_t EstimateElementCount(Handle<JSArray> array) {
10121 uint32_t length =
static_cast<uint32_t
>(array->length()->Number());
10122 int element_count = 0;
10123 switch (array->GetElementsKind()) {
10131 int fast_length =
static_cast<int>(length);
10133 for (
int i = 0; i < fast_length; i++) {
10134 if (!elements->get(i)->IsTheHole()) element_count++;
10143 int fast_length =
static_cast<int>(length);
10144 if (array->elements()->IsFixedArray()) {
10148 Handle<FixedDoubleArray> elements(
10150 for (
int i = 0; i < fast_length; i++) {
10151 if (!elements->is_the_hole(i)) element_count++;
10156 Handle<SeededNumberDictionary> dictionary(
10158 int capacity = dictionary->Capacity();
10159 for (
int i = 0; i < capacity; i++) {
10160 Handle<Object> key(dictionary->KeyAt(i), array->GetIsolate());
10161 if (dictionary->IsKey(*key)) {
10168 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
10169 case EXTERNAL_##TYPE##_ELEMENTS: \
10170 case TYPE##_ELEMENTS: \
10173 #undef TYPED_ARRAY_CASE
10179 return element_count;
10184 template<
class ExternalArrayClass,
class ElementType>
10185 static void IterateExternalArrayElements(Isolate* isolate,
10186 Handle<JSObject> receiver,
10187 bool elements_are_ints,
10188 bool elements_are_guaranteed_smis,
10189 ArrayConcatVisitor* visitor) {
10190 Handle<ExternalArrayClass> array(
10191 ExternalArrayClass::cast(receiver->elements()));
10192 uint32_t len =
static_cast<uint32_t
>(array->length());
10195 if (elements_are_ints) {
10196 if (elements_are_guaranteed_smis) {
10197 for (uint32_t j = 0; j < len; j++) {
10198 HandleScope loop_scope(isolate);
10199 Handle<Smi> e(
Smi::FromInt(static_cast<int>(array->get_scalar(j))),
10201 visitor->visit(j, e);
10204 for (uint32_t j = 0; j < len; j++) {
10205 HandleScope loop_scope(isolate);
10206 int64_t val =
static_cast<int64_t
>(array->get_scalar(j));
10208 Handle<Smi> e(
Smi::FromInt(static_cast<int>(val)), isolate);
10209 visitor->visit(j, e);
10212 isolate->factory()->NewNumber(static_cast<ElementType>(val));
10213 visitor->visit(j, e);
10218 for (uint32_t j = 0; j < len; j++) {
10219 HandleScope loop_scope(isolate);
10220 Handle<Object> e = isolate->factory()->NewNumber(array->get_scalar(j));
10221 visitor->visit(j, e);
10228 static int compareUInt32(
const uint32_t* ap,
const uint32_t* bp) {
10231 return (a == b) ? 0 : (a < b) ? -1 : 1;
10235 static void CollectElementIndices(Handle<JSObject>
object,
10237 List<uint32_t>* indices) {
10238 Isolate* isolate =
object->GetIsolate();
10246 uint32_t length =
static_cast<uint32_t
>(elements->length());
10247 if (range < length) length = range;
10248 for (uint32_t i = 0; i < length; i++) {
10249 if (!elements->get(i)->IsTheHole()) {
10262 Handle<SeededNumberDictionary> dict(
10264 uint32_t capacity = dict->Capacity();
10265 for (uint32_t j = 0; j < capacity; j++) {
10266 HandleScope loop_scope(isolate);
10267 Handle<Object> k(dict->KeyAt(j), isolate);
10268 if (dict->IsKey(*k)) {
10270 uint32_t index =
static_cast<uint32_t
>(k->Number());
10271 if (index < range) {
10272 indices->Add(index);
10279 int dense_elements_length;
10281 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
10282 case EXTERNAL_##TYPE##_ELEMENTS: { \
10283 dense_elements_length = \
10284 External##Type##Array::cast(object->elements())->length(); \
10289 #undef TYPED_ARRAY_CASE
10293 dense_elements_length = 0;
10296 uint32_t length =
static_cast<uint32_t
>(dense_elements_length);
10297 if (range <= length) {
10303 for (uint32_t i = 0; i < length; i++) {
10306 if (length == range)
return;
10311 Handle<Object> prototype(object->GetPrototype(), isolate);
10312 if (prototype->IsJSObject()) {
10315 CollectElementIndices(Handle<JSObject>::cast(prototype), range, indices);
10330 static bool IterateElements(Isolate* isolate,
10331 Handle<JSArray> receiver,
10332 ArrayConcatVisitor* visitor) {
10333 uint32_t length =
static_cast<uint32_t
>(receiver->length()->Number());
10334 switch (receiver->GetElementsKind()) {
10342 int fast_length =
static_cast<int>(length);
10343 ASSERT(fast_length <= elements->length());
10344 for (
int j = 0; j < fast_length; j++) {
10345 HandleScope loop_scope(isolate);
10346 Handle<Object> element_value(elements->get(j), isolate);
10347 if (!element_value->IsTheHole()) {
10348 visitor->visit(j, element_value);
10354 visitor->visit(j, element_value);
10363 Handle<FixedDoubleArray> elements(
10365 int fast_length =
static_cast<int>(length);
10366 ASSERT(fast_length <= elements->length());
10367 for (
int j = 0; j < fast_length; j++) {
10368 HandleScope loop_scope(isolate);
10369 if (!elements->is_the_hole(j)) {
10370 double double_value = elements->get_scalar(j);
10371 Handle<Object> element_value =
10372 isolate->factory()->NewNumber(double_value);
10373 visitor->visit(j, element_value);
10377 Handle<Object> element_value =
10380 visitor->visit(j, element_value);
10386 Handle<SeededNumberDictionary> dict(receiver->element_dictionary());
10387 List<uint32_t> indices(dict->Capacity() / 2);
10390 CollectElementIndices(receiver, length, &indices);
10391 indices.Sort(&compareUInt32);
10393 int n = indices.length();
10395 HandleScope loop_scope(isolate);
10396 uint32_t index = indices[j];
10399 visitor->visit(index, element);
10403 }
while (j < n && indices[j] == index);
10409 receiver->elements()));
10410 for (uint32_t j = 0; j < length; j++) {
10411 Handle<Smi> e(
Smi::FromInt(pixels->get_scalar(j)), isolate);
10412 visitor->visit(j, e);
10417 IterateExternalArrayElements<ExternalInt8Array, int8_t>(
10418 isolate, receiver,
true,
true, visitor);
10422 IterateExternalArrayElements<ExternalUint8Array, uint8_t>(
10423 isolate, receiver,
true,
true, visitor);
10427 IterateExternalArrayElements<ExternalInt16Array, int16_t>(
10428 isolate, receiver,
true,
true, visitor);
10432 IterateExternalArrayElements<ExternalUint16Array, uint16_t>(
10433 isolate, receiver,
true,
true, visitor);
10437 IterateExternalArrayElements<ExternalInt32Array, int32_t>(
10438 isolate, receiver,
true,
false, visitor);
10442 IterateExternalArrayElements<ExternalUint32Array, uint32_t>(
10443 isolate, receiver,
true,
false, visitor);
10447 IterateExternalArrayElements<ExternalFloat32Array, float>(
10448 isolate, receiver,
false,
false, visitor);
10452 IterateExternalArrayElements<ExternalFloat64Array, double>(
10453 isolate, receiver,
false,
false, visitor);
10460 visitor->increase_index_offset(length);
10473 ASSERT(args.length() == 1);
10476 int argument_count =
static_cast<int>(arguments->length()->Number());
10487 uint32_t estimate_result_length = 0;
10488 uint32_t estimate_nof_elements = 0;
10489 for (
int i = 0; i < argument_count; i++) {
10492 uint32_t length_estimate;
10493 uint32_t element_estimate;
10494 if (obj->IsJSArray()) {
10496 length_estimate =
static_cast<uint32_t
>(array->length()->Number());
10497 if (length_estimate != 0) {
10504 element_estimate = EstimateElementCount(array);
10506 if (obj->IsHeapObject()) {
10507 if (obj->IsNumber()) {
10515 length_estimate = 1;
10516 element_estimate = 1;
10523 estimate_result_length += length_estimate;
10526 element_estimate) {
10529 estimate_nof_elements += element_estimate;
10536 bool fast_case = (estimate_nof_elements * 2) >= estimate_result_length;
10542 isolate->factory()->NewFixedDoubleArray(estimate_result_length);
10544 bool failure =
false;
10545 for (
int i = 0; i < argument_count; i++) {
10547 if (obj->IsSmi()) {
10550 }
else if (obj->IsNumber()) {
10551 double_storage->set(j, obj->Number());
10555 uint32_t length =
static_cast<uint32_t
>(array->length()->
Number());
10560 if (array->elements()->IsFixedArray())
break;
10563 for (uint32_t i = 0; i < length; i++) {
10568 double double_value = elements->
get_scalar(i);
10569 double_storage->set(j, double_value);
10578 for (uint32_t i = 0; i < length; i++) {
10580 if (element->IsTheHole()) {
10585 double_storage->set(j, int_value);
10597 if (failure)
break;
10603 array->set_map(*map);
10604 array->set_length(length);
10605 array->set_elements(*double_storage);
10610 storage = isolate->factory()->NewFixedArrayWithHoles(
10611 estimate_result_length);
10614 uint32_t at_least_space_for = estimate_nof_elements +
10615 (estimate_nof_elements >> 2);
10617 isolate->factory()->NewSeededNumberDictionary(at_least_space_for));
10622 for (
int i = 0; i < argument_count; i++) {
10624 if (obj->IsJSArray()) {
10626 if (!IterateElements(isolate, array, &visitor)) {
10630 visitor.
visit(0, obj);
10636 return isolate->Throw(
10637 *isolate->factory()->NewRangeError(
"invalid_array_length",
10638 HandleVector<Object>(
NULL, 0)));
10647 SealHandleScope shs(isolate);
10648 ASSERT(args.length() == 1);
10654 uint16_t character = stream.
GetNext();
10655 PrintF(
"%c", character);
10669 ASSERT(args.length() == 2);
10678 SealHandleScope shs(isolate);
10679 ASSERT(args.length() == 2);
10682 from->ValidateElements();
10683 to->ValidateElements();
10686 MaybeObject* maybe_new_map;
10687 maybe_new_map = to->GetElementsTransitionMap(isolate, from_kind);
10689 if (!maybe_new_map->ToObject(&new_map))
return maybe_new_map;
10690 to->set_map_and_elements(
Map::cast(new_map), new_elements);
10691 to->set_length(from->length());
10693 { MaybeObject* maybe_obj = from->ResetElements();
10694 if (!maybe_obj->ToObject(&obj))
return maybe_obj;
10697 to->ValidateElements();
10704 SealHandleScope shs(isolate);
10705 ASSERT(args.length() == 1);
10708 if (elements->IsDictionary()) {
10711 }
else if (object->IsJSArray()) {
10726 ASSERT(args.length() == 2);
10729 if (array->elements()->IsDictionary()) {
10737 return *isolate->factory()->NewNumberFromUint(length);
10741 isolate->factory()->NewFixedArray(
10742 current->NumberOfLocalElements(
NONE));
10743 current->GetLocalElementKeys(*current_keys,
NONE);
10749 for (
int i = 0; i < keys->length(); i++) {
10750 if (
NumberToUint32(keys->get(i)) >= length) keys->set_undefined(i);
10752 return *isolate->factory()->NewJSArrayWithElements(keys);
10754 ASSERT(array->HasFastSmiOrObjectElements() ||
10755 array->HasFastDoubleElements());
10756 uint32_t actual_length =
static_cast<uint32_t
>(array->elements()->length());
10757 return *isolate->factory()->NewNumberFromUint(
Min(actual_length, length));
10764 ASSERT(args.length() == 3);
10769 if (!receiver->IsJSObject())
return isolate->heap()->undefined_value();
10777 #ifdef ENABLE_DEBUGGER_SUPPORT
10779 SealHandleScope shs(isolate);
10780 ASSERT(args.length() == 0);
10781 return Execution::DebugBreakHelper(isolate);
10786 static Smi* WrapFrameId(StackFrame::Id
id) {
10792 static StackFrame::Id UnwrapFrameId(
int wrapped) {
10793 return static_cast<StackFrame::Id
>(wrapped << 2);
10802 SealHandleScope shs(isolate);
10803 ASSERT(args.length() == 2);
10805 args[0]->IsUndefined() ||
10806 args[0]->IsNull());
10807 Handle<Object> callback = args.at<
Object>(0);
10808 Handle<Object> data = args.at<
Object>(1);
10809 isolate->debugger()->SetEventListener(callback, data);
10811 return isolate->heap()->undefined_value();
10816 SealHandleScope shs(isolate);
10817 ASSERT(args.length() == 0);
10818 isolate->stack_guard()->DebugBreak();
10819 return isolate->heap()->undefined_value();
10823 static MaybeObject* DebugLookupResultValue(Heap* heap,
10826 LookupResult* result,
10827 bool* caught_exception) {
10829 switch (result->type()) {
10831 value = result->holder()->GetNormalizedProperty(result);
10832 if (value->IsTheHole()) {
10833 return heap->undefined_value();
10838 MaybeObject* maybe_value =
10840 result->representation(),
10841 result->GetFieldIndex().field_index());
10842 if (!maybe_value->To(&value))
return maybe_value;
10843 if (value->IsTheHole()) {
10844 return heap->undefined_value();
10849 return result->GetConstant();
10851 Object* structure = result->GetCallbackObject();
10852 if (structure->IsForeign() || structure->IsAccessorInfo()) {
10853 Isolate* isolate = heap->isolate();
10854 HandleScope scope(isolate);
10856 handle(result->holder(), isolate),
10857 handle(receiver, isolate),
10858 handle(structure, isolate),
10860 if (value.is_null()) {
10861 MaybeObject* exception = heap->isolate()->pending_exception();
10862 heap->isolate()->clear_pending_exception();
10863 if (caught_exception !=
NULL) *caught_exception =
true;
10868 return heap->undefined_value();
10873 return heap->undefined_value();
10877 return heap->undefined_value();
10880 return heap->undefined_value();
10897 HandleScope scope(isolate);
10899 ASSERT(args.length() == 2);
10910 SaveContext save(isolate);
10911 if (isolate->debug()->InDebugger()) {
10912 isolate->set_context(*isolate->debug()->debugger_entry()->GetContext());
10917 if (obj->IsJSGlobalProxy()) {
10925 if (name->AsArrayIndex(&index)) {
10926 Handle<FixedArray> details = isolate->factory()->NewFixedArray(2);
10927 Handle<Object> element_or_char =
10930 details->set(0, *element_or_char);
10933 return *isolate->factory()->NewJSArrayWithElements(details);
10937 int length = LocalPrototypeChainLength(*obj);
10940 Handle<JSObject> jsproto =
obj;
10941 for (
int i = 0; i < length; i++) {
10942 LookupResult result(isolate);
10943 jsproto->LocalLookup(*name, &result);
10944 if (result.IsFound()) {
10948 Handle<Object> result_callback_obj;
10949 if (result.IsPropertyCallbacks()) {
10950 result_callback_obj = Handle<Object>(result.GetCallbackObject(),
10953 Smi* property_details = result.GetPropertyDetails().AsSmi();
10956 bool caught_exception =
false;
10958 { MaybeObject* maybe_raw_value =
10959 DebugLookupResultValue(isolate->heap(), *
obj, *
name,
10960 &result, &caught_exception);
10961 if (!maybe_raw_value->ToObject(&raw_value))
return maybe_raw_value;
10963 Handle<Object> value(raw_value, isolate);
10967 bool hasJavaScriptAccessors = result.IsPropertyCallbacks() &&
10968 result_callback_obj->IsAccessorPair();
10969 Handle<FixedArray> details =
10970 isolate->factory()->NewFixedArray(hasJavaScriptAccessors ? 5 : 2);
10971 details->set(0, *value);
10972 details->set(1, property_details);
10973 if (hasJavaScriptAccessors) {
10975 details->set(2, isolate->heap()->ToBoolean(caught_exception));
10980 return *isolate->factory()->NewJSArrayWithElements(details);
10982 if (i < length - 1) {
10983 jsproto = Handle<JSObject>(
JSObject::cast(jsproto->GetPrototype()));
10987 return isolate->heap()->undefined_value();
10992 HandleScope scope(isolate);
10994 ASSERT(args.length() == 2);
10999 LookupResult result(isolate);
11000 obj->Lookup(*name, &result);
11001 if (result.IsFound()) {
11002 return DebugLookupResultValue(isolate->heap(), *
obj, *
name, &result,
NULL);
11004 return isolate->heap()->undefined_value();
11011 SealHandleScope shs(isolate);
11012 ASSERT(args.length() == 1);
11014 return Smi::FromInt(static_cast<int>(details.type()));
11020 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyAttributesFromDetails) {
11021 SealHandleScope shs(isolate);
11022 ASSERT(args.length() == 1);
11024 return Smi::FromInt(static_cast<int>(details.attributes()));
11031 SealHandleScope shs(isolate);
11032 ASSERT(args.length() == 1);
11042 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugNamedInterceptorPropertyValue) {
11043 HandleScope scope(isolate);
11044 ASSERT(args.length() == 2);
11050 Handle<Object> result =
11060 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugIndexedInterceptorElementValue) {
11061 HandleScope scope(isolate);
11062 ASSERT(args.length() == 2);
11073 SealHandleScope shs(isolate);
11074 ASSERT(args.length() >= 1);
11077 if (isolate->debug()->break_id() == 0 ||
11078 break_id != isolate->debug()->break_id()) {
11079 return isolate->Throw(
11080 isolate->heap()->illegal_execution_state_string());
11083 return isolate->heap()->true_value();
11088 HandleScope scope(isolate);
11089 ASSERT(args.length() == 1);
11093 { MaybeObject* maybe_result = Runtime_CheckExecutionState(
11095 if (!maybe_result->ToObject(&result))
return maybe_result;
11100 StackFrame::Id
id = isolate->debug()->break_frame_id();
11101 if (
id == StackFrame::NO_ID) {
11106 for (JavaScriptFrameIterator it(isolate,
id); !it.done(); it.Advance()) {
11107 n += it.frame()->GetInlineCount();
11113 class FrameInspector {
11115 FrameInspector(JavaScriptFrame* frame,
11116 int inlined_jsframe_index,
11118 : frame_(frame), deoptimized_frame_(
NULL), isolate_(isolate) {
11120 if (frame->is_optimized()) {
11121 deoptimized_frame_ = Deoptimizer::DebuggerInspectableFrame(
11122 frame, inlined_jsframe_index, isolate);
11124 has_adapted_arguments_ = frame_->has_adapted_arguments();
11125 is_bottommost_ = inlined_jsframe_index == 0;
11126 is_optimized_ = frame_->is_optimized();
11129 ~FrameInspector() {
11131 if (deoptimized_frame_ !=
NULL) {
11132 Deoptimizer::DeleteDebuggerInspectableFrame(deoptimized_frame_,
11137 int GetParametersCount() {
11138 return is_optimized_
11139 ? deoptimized_frame_->parameters_count()
11140 : frame_->ComputeParametersCount();
11142 int expression_count() {
return deoptimized_frame_->expression_count(); }
11144 return is_optimized_
11145 ? deoptimized_frame_->GetFunction()
11146 : frame_->function();
11148 Object* GetParameter(
int index) {
11149 return is_optimized_
11150 ? deoptimized_frame_->GetParameter(index)
11151 : frame_->GetParameter(index);
11153 Object* GetExpression(
int index) {
11154 return is_optimized_
11155 ? deoptimized_frame_->GetExpression(index)
11156 : frame_->GetExpression(index);
11158 int GetSourcePosition() {
11159 return is_optimized_
11160 ? deoptimized_frame_->GetSourcePosition()
11161 : frame_->LookupCode()->SourcePosition(frame_->pc());
11163 bool IsConstructor() {
11164 return is_optimized_ && !is_bottommost_
11165 ? deoptimized_frame_->HasConstructStub()
11166 : frame_->IsConstructor();
11171 void SetArgumentsFrame(JavaScriptFrame* frame) {
11172 ASSERT(has_adapted_arguments_);
11174 is_optimized_ = frame_->is_optimized();
11179 JavaScriptFrame* frame_;
11180 DeoptimizedFrameInfo* deoptimized_frame_;
11182 bool is_optimized_;
11183 bool is_bottommost_;
11184 bool has_adapted_arguments_;
11190 static const int kFrameDetailsFrameIdIndex = 0;
11191 static const int kFrameDetailsReceiverIndex = 1;
11192 static const int kFrameDetailsFunctionIndex = 2;
11193 static const int kFrameDetailsArgumentCountIndex = 3;
11194 static const int kFrameDetailsLocalCountIndex = 4;
11195 static const int kFrameDetailsSourcePositionIndex = 5;
11196 static const int kFrameDetailsConstructCallIndex = 6;
11197 static const int kFrameDetailsAtReturnIndex = 7;
11198 static const int kFrameDetailsFlagsIndex = 8;
11199 static const int kFrameDetailsFirstDynamicIndex = 9;
11202 static SaveContext* FindSavedContextForFrame(Isolate* isolate,
11203 JavaScriptFrame* frame) {
11204 SaveContext* save = isolate->save_context();
11205 while (save !=
NULL && !save->IsBelowFrame(frame)) {
11206 save = save->prev();
11231 HandleScope scope(isolate);
11232 ASSERT(args.length() == 2);
11236 { MaybeObject* maybe_check = Runtime_CheckExecutionState(
11238 if (!maybe_check->ToObject(&check))
return maybe_check;
11241 Heap* heap = isolate->heap();
11244 StackFrame::Id
id = isolate->debug()->break_frame_id();
11245 if (
id == StackFrame::NO_ID) {
11247 return heap->undefined_value();
11251 JavaScriptFrameIterator it(isolate,
id);
11252 for (; !it.done(); it.Advance()) {
11253 if (index < count + it.frame()->GetInlineCount())
break;
11254 count += it.frame()->GetInlineCount();
11256 if (it.done())
return heap->undefined_value();
11258 bool is_optimized = it.frame()->is_optimized();
11260 int inlined_jsframe_index = 0;
11261 if (is_optimized) {
11262 inlined_jsframe_index =
11263 it.frame()->GetInlineCount() - (index - count) - 1;
11265 FrameInspector frame_inspector(it.frame(), inlined_jsframe_index, isolate);
11269 SaveContext* save = FindSavedContextForFrame(isolate, it.frame());
11272 Handle<Object> frame_id(WrapFrameId(it.frame()->id()), isolate);
11275 int position = frame_inspector.GetSourcePosition();
11278 bool constructor = frame_inspector.IsConstructor();
11281 Handle<JSFunction>
function(
JSFunction::cast(frame_inspector.GetFunction()));
11282 Handle<SharedFunctionInfo> shared(function->shared());
11283 Handle<ScopeInfo> scope_info(shared->scope_info());
11291 Handle<FixedArray> locals =
11292 isolate->factory()->NewFixedArray(scope_info->LocalCount() * 2);
11296 for (; i < scope_info->StackLocalCount(); ++i) {
11298 locals->set(i * 2, scope_info->LocalName(i));
11299 locals->set(i * 2 + 1, frame_inspector.GetExpression(i));
11301 if (i < scope_info->LocalCount()) {
11303 Handle<Context> context(
11304 Context::cast(it.frame()->context())->declaration_context());
11305 for (; i < scope_info->LocalCount(); ++i) {
11306 Handle<String>
name(scope_info->LocalName(i));
11309 locals->set(i * 2, *name);
11310 int context_slot_index =
11311 scope_info->ContextSlotIndex(*name, &mode, &init_flag);
11312 Object* value = context->
get(context_slot_index);
11313 locals->set(i * 2 + 1, value);
11319 bool at_return =
false;
11320 if (!is_optimized && index == 0) {
11321 at_return = isolate->debug()->IsBreakAtReturn(it.frame());
11326 Handle<Object> return_value = isolate->factory()->undefined_value();
11328 StackFrameIterator it2(isolate);
11330 while (!it2.done()) {
11331 if (it2.frame()->is_internal()) {
11332 internal_frame_sp = it2.frame()->sp();
11334 if (it2.frame()->is_java_script()) {
11335 if (it2.frame()->id() == it.frame()->id()) {
11340 if (internal_frame_sp !=
NULL) {
11350 internal_frame_sp =
NULL;
11360 if ((inlined_jsframe_index == 0) && it.frame()->has_adapted_arguments()) {
11361 it.AdvanceToArgumentsFrame();
11362 frame_inspector.SetArgumentsFrame(it.frame());
11367 int argument_count = scope_info->ParameterCount();
11368 if (argument_count < frame_inspector.GetParametersCount()) {
11369 argument_count = frame_inspector.GetParametersCount();
11373 int details_size = kFrameDetailsFirstDynamicIndex +
11374 2 * (argument_count + scope_info->LocalCount()) +
11375 (at_return ? 1 : 0);
11376 Handle<FixedArray> details = isolate->factory()->NewFixedArray(details_size);
11379 details->set(kFrameDetailsFrameIdIndex, *frame_id);
11382 details->set(kFrameDetailsFunctionIndex, frame_inspector.GetFunction());
11385 details->set(kFrameDetailsArgumentCountIndex,
Smi::FromInt(argument_count));
11388 details->set(kFrameDetailsLocalCountIndex,
11392 if (position != RelocInfo::kNoPosition) {
11393 details->set(kFrameDetailsSourcePositionIndex,
Smi::FromInt(position));
11395 details->set(kFrameDetailsSourcePositionIndex, heap->undefined_value());
11399 details->set(kFrameDetailsConstructCallIndex, heap->ToBoolean(constructor));
11402 details->set(kFrameDetailsAtReturnIndex, heap->ToBoolean(at_return));
11409 if (*save->context() == *isolate->debug()->debug_context()) {
11412 if (is_optimized) {
11414 flags |= inlined_jsframe_index << 2;
11416 details->set(kFrameDetailsFlagsIndex,
Smi::FromInt(flags));
11419 int details_index = kFrameDetailsFirstDynamicIndex;
11422 for (
int i = 0; i < argument_count; i++) {
11424 if (i < scope_info->ParameterCount()) {
11425 details->set(details_index++, scope_info->ParameterName(i));
11427 details->set(details_index++, heap->undefined_value());
11431 if (i < frame_inspector.GetParametersCount()) {
11433 details->set(details_index++, frame_inspector.GetParameter(i));
11435 details->set(details_index++, heap->undefined_value());
11440 for (
int i = 0; i < scope_info->LocalCount() * 2; i++) {
11441 details->set(details_index++, locals->get(i));
11446 details->set(details_index++, *return_value);
11452 Handle<Object> receiver(it.frame()->receiver(), isolate);
11453 if (!receiver->IsJSObject() &&
11454 shared->strict_mode() ==
SLOPPY &&
11455 !
function->IsBuiltin()) {
11463 if (receiver->IsUndefined()) {
11464 Context* context =
function->context();
11465 receiver =
handle(context->global_object()->global_receiver());
11467 ASSERT(!receiver->IsNull());
11469 Handle<Context> native_context(
Context::cast(context->native_context()));
11470 receiver = isolate->factory()->ToObject(receiver, native_context);
11473 details->set(kFrameDetailsReceiverIndex, *receiver);
11475 ASSERT_EQ(details_size, details_index);
11476 return *isolate->factory()->NewJSArrayWithElements(details);
11480 static bool ParameterIsShadowedByContextLocal(Handle<ScopeInfo> info,
11484 return info->ContextSlotIndex(info->ParameterName(index), &
mode, &
flag) != -1;
11490 static Handle<JSObject> MaterializeStackLocalsWithFrameInspector(
11492 Handle<JSObject> target,
11493 Handle<JSFunction>
function,
11494 FrameInspector* frame_inspector) {
11495 Handle<SharedFunctionInfo> shared(function->shared());
11496 Handle<ScopeInfo> scope_info(shared->scope_info());
11499 for (
int i = 0; i < scope_info->ParameterCount(); ++i) {
11501 if (ParameterIsShadowedByContextLocal(scope_info, i))
continue;
11503 HandleScope scope(isolate);
11504 Handle<Object> value(i < frame_inspector->GetParametersCount()
11505 ? frame_inspector->GetParameter(i)
11506 : isolate->heap()->undefined_value(),
11508 ASSERT(!value->IsTheHole());
11509 Handle<String>
name(scope_info->ParameterName(i));
11514 Handle<JSObject>());
11518 for (
int i = 0; i < scope_info->StackLocalCount(); ++i) {
11519 Handle<String>
name(scope_info->StackLocalName(i));
11520 Handle<Object> value(frame_inspector->GetExpression(i), isolate);
11521 if (value->IsTheHole())
continue;
11526 Handle<JSObject>());
11533 static void UpdateStackLocalsFromMaterializedObject(Isolate* isolate,
11534 Handle<JSObject> target,
11535 Handle<JSFunction>
function,
11536 JavaScriptFrame* frame,
11537 int inlined_jsframe_index) {
11538 if (inlined_jsframe_index != 0 || frame->is_optimized()) {
11545 Handle<SharedFunctionInfo> shared(function->shared());
11546 Handle<ScopeInfo> scope_info(shared->scope_info());
11549 for (
int i = 0; i < scope_info->ParameterCount(); ++i) {
11551 if (ParameterIsShadowedByContextLocal(scope_info, i))
continue;
11553 ASSERT(!frame->GetParameter(i)->IsTheHole());
11554 HandleScope scope(isolate);
11555 Handle<String>
name(scope_info->ParameterName(i));
11556 Handle<Object> value =
GetProperty(isolate, target, name);
11557 frame->SetParameterValue(i, *value);
11561 for (
int i = 0; i < scope_info->StackLocalCount(); ++i) {
11562 if (frame->GetExpression(i)->IsTheHole())
continue;
11563 HandleScope scope(isolate);
11565 isolate, target, Handle<String>(scope_info->StackLocalName(i)));
11566 frame->SetExpression(i, *value);
11571 static Handle<JSObject> MaterializeLocalContext(Isolate* isolate,
11572 Handle<JSObject> target,
11573 Handle<JSFunction>
function,
11574 JavaScriptFrame* frame) {
11575 HandleScope scope(isolate);
11576 Handle<SharedFunctionInfo> shared(function->shared());
11577 Handle<ScopeInfo> scope_info(shared->scope_info());
11579 if (!scope_info->HasContext())
return target;
11582 Handle<Context> frame_context(
Context::cast(frame->context()));
11583 Handle<Context> function_context(frame_context->declaration_context());
11585 scope_info, function_context, target)) {
11586 return Handle<JSObject>();
11591 if (function_context->closure() == *
function) {
11592 if (function_context->has_extension() &&
11593 !function_context->IsNativeContext()) {
11594 Handle<JSObject> ext(
JSObject::cast(function_context->extension()));
11595 bool threw =
false;
11596 Handle<FixedArray>
keys =
11598 if (threw)
return Handle<JSObject>();
11600 for (
int i = 0; i < keys->length(); i++) {
11602 ASSERT(keys->get(i)->IsString());
11612 Handle<JSObject>());
11621 static Handle<JSObject> MaterializeLocalScope(
11623 JavaScriptFrame* frame,
11624 int inlined_jsframe_index) {
11625 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate);
11626 Handle<JSFunction>
function(
JSFunction::cast(frame_inspector.GetFunction()));
11628 Handle<JSObject> local_scope =
11629 isolate->factory()->NewJSObject(isolate->object_function());
11630 local_scope = MaterializeStackLocalsWithFrameInspector(
11631 isolate, local_scope,
function, &frame_inspector);
11634 return MaterializeLocalContext(isolate, local_scope,
function, frame);
11639 static bool SetContextLocalValue(Isolate* isolate,
11640 Handle<ScopeInfo> scope_info,
11641 Handle<Context> context,
11642 Handle<String> variable_name,
11643 Handle<Object> new_value) {
11644 for (
int i = 0; i < scope_info->ContextLocalCount(); i++) {
11645 Handle<String> next_name(scope_info->ContextLocalName(i));
11646 if (variable_name->Equals(*next_name)) {
11649 int context_index =
11650 scope_info->ContextSlotIndex(*next_name, &mode, &init_flag);
11651 context->set(context_index, *new_value);
11660 static bool SetLocalVariableValue(Isolate* isolate,
11661 JavaScriptFrame* frame,
11662 int inlined_jsframe_index,
11663 Handle<String> variable_name,
11664 Handle<Object> new_value) {
11665 if (inlined_jsframe_index != 0 || frame->is_optimized()) {
11670 Handle<JSFunction>
function(frame->function());
11671 Handle<SharedFunctionInfo> shared(function->shared());
11672 Handle<ScopeInfo> scope_info(shared->scope_info());
11674 bool default_result =
false;
11677 for (
int i = 0; i < scope_info->ParameterCount(); ++i) {
11678 if (scope_info->ParameterName(i)->Equals(*variable_name)) {
11679 frame->SetParameterValue(i, *new_value);
11681 default_result =
true;
11686 for (
int i = 0; i < scope_info->StackLocalCount(); ++i) {
11687 if (scope_info->StackLocalName(i)->Equals(*variable_name)) {
11688 frame->SetExpression(i, *new_value);
11693 if (scope_info->HasContext()) {
11695 Handle<Context> frame_context(
Context::cast(frame->context()));
11696 Handle<Context> function_context(frame_context->declaration_context());
11697 if (SetContextLocalValue(
11698 isolate, scope_info, function_context, variable_name, new_value)) {
11703 if (function_context->closure() == *
function) {
11704 if (function_context->has_extension() &&
11705 !function_context->IsNativeContext()) {
11706 Handle<JSObject> ext(
JSObject::cast(function_context->extension()));
11719 return default_result;
11725 static Handle<JSObject> MaterializeClosure(Isolate* isolate,
11726 Handle<Context> context) {
11727 ASSERT(context->IsFunctionContext());
11729 Handle<SharedFunctionInfo> shared(context->closure()->shared());
11730 Handle<ScopeInfo> scope_info(shared->scope_info());
11734 Handle<JSObject> closure_scope =
11735 isolate->factory()->NewJSObject(isolate->object_function());
11739 scope_info, context, closure_scope)) {
11740 return Handle<JSObject>();
11745 if (context->has_extension()) {
11747 bool threw =
false;
11748 Handle<FixedArray> keys =
11750 if (threw)
return Handle<JSObject>();
11752 for (
int i = 0; i < keys->length(); i++) {
11754 ASSERT(keys->get(i)->IsString());
11761 Handle<JSObject>());
11765 return closure_scope;
11770 static bool SetClosureVariableValue(Isolate* isolate,
11771 Handle<Context> context,
11772 Handle<String> variable_name,
11773 Handle<Object> new_value) {
11774 ASSERT(context->IsFunctionContext());
11776 Handle<SharedFunctionInfo> shared(context->closure()->shared());
11777 Handle<ScopeInfo> scope_info(shared->scope_info());
11780 if (SetContextLocalValue(
11781 isolate, scope_info, context, variable_name, new_value)) {
11787 if (context->has_extension()) {
11803 static Handle<JSObject> MaterializeCatchScope(Isolate* isolate,
11804 Handle<Context> context) {
11805 ASSERT(context->IsCatchContext());
11809 Handle<JSObject> catch_scope =
11810 isolate->factory()->NewJSObject(isolate->object_function());
11815 Handle<JSObject>());
11816 return catch_scope;
11820 static bool SetCatchVariableValue(Isolate* isolate,
11821 Handle<Context> context,
11822 Handle<String> variable_name,
11823 Handle<Object> new_value) {
11824 ASSERT(context->IsCatchContext());
11826 if (!name->Equals(*variable_name)) {
11836 static Handle<JSObject> MaterializeBlockScope(
11838 Handle<Context> context) {
11839 ASSERT(context->IsBlockContext());
11844 Handle<JSObject> block_scope =
11845 isolate->factory()->NewJSObject(isolate->object_function());
11849 scope_info, context, block_scope)) {
11850 return Handle<JSObject>();
11853 return block_scope;
11859 static Handle<JSObject> MaterializeModuleScope(
11861 Handle<Context> context) {
11862 ASSERT(context->IsModuleContext());
11867 Handle<JSObject> module_scope =
11868 isolate->factory()->NewJSObject(isolate->object_function());
11872 scope_info, context, module_scope)) {
11873 return Handle<JSObject>();
11876 return module_scope;
11884 class ScopeIterator {
11887 ScopeTypeGlobal = 0,
11896 ScopeIterator(Isolate* isolate,
11897 JavaScriptFrame* frame,
11898 int inlined_jsframe_index,
11899 bool ignore_nested_scopes =
false)
11900 : isolate_(isolate),
11902 inlined_jsframe_index_(inlined_jsframe_index),
11903 function_(frame->function()),
11904 context_(Context::cast(frame->context())),
11905 nested_scope_chain_(4),
11909 Handle<SharedFunctionInfo> shared_info(function_->shared());
11910 Handle<ScopeInfo> scope_info(shared_info->scope_info());
11911 if (shared_info->script() == isolate->heap()->undefined_value()) {
11912 while (context_->closure() == *function_) {
11913 context_ = Handle<Context>(context_->previous(), isolate_);
11919 if (!isolate->debug()->EnsureDebugInfo(shared_info, function_)) {
11930 if (!ignore_nested_scopes) {
11931 Handle<DebugInfo> debug_info = Debug::GetDebugInfo(shared_info);
11934 BreakLocationIterator break_location_iterator(debug_info,
11935 ALL_BREAK_LOCATIONS);
11938 break_location_iterator.FindBreakLocationFromAddress(frame->pc() - 1);
11944 ignore_nested_scopes = break_location_iterator.IsExit();
11947 if (ignore_nested_scopes) {
11948 if (scope_info->HasContext()) {
11949 context_ = Handle<Context>(context_->declaration_context(), isolate_);
11951 while (context_->closure() == *function_) {
11952 context_ = Handle<Context>(context_->previous(), isolate_);
11956 nested_scope_chain_.Add(scope_info);
11960 Handle<Script> script(
Script::cast(shared_info->script()));
11961 Scope* scope =
NULL;
11964 Handle<ScopeInfo> scope_info(shared_info->scope_info());
11967 CompilationInfoWithZone
info(script);
11969 info.MarkAsGlobal();
11973 info.SetContext(Handle<Context>(function_->context()));
11976 scope = info.function()->scope();
11978 RetrieveScopeChain(scope, shared_info);
11981 CompilationInfoWithZone
info(shared_info);
11983 scope = info.function()->scope();
11985 RetrieveScopeChain(scope, shared_info);
11990 ScopeIterator(Isolate* isolate,
11991 Handle<JSFunction>
function)
11992 : isolate_(isolate),
11994 inlined_jsframe_index_(0),
11995 function_(function),
11996 context_(function->context()),
11998 if (function->IsBuiltin()) {
11999 context_ = Handle<Context>();
12006 return context_.is_null();
12009 bool Failed() {
return failed_; }
12015 if (scope_type == ScopeTypeGlobal) {
12017 ASSERT(context_->IsNativeContext());
12018 context_ = Handle<Context>();
12021 if (nested_scope_chain_.is_empty()) {
12022 context_ = Handle<Context>(context_->previous(), isolate_);
12024 if (nested_scope_chain_.last()->HasContext()) {
12026 context_ = Handle<Context>(context_->previous(), isolate_);
12028 nested_scope_chain_.RemoveLast();
12035 if (!nested_scope_chain_.is_empty()) {
12036 Handle<ScopeInfo> scope_info = nested_scope_chain_.last();
12037 switch (scope_info->scope_type()) {
12039 ASSERT(context_->IsFunctionContext() ||
12040 !scope_info->HasContext());
12041 return ScopeTypeLocal;
12043 ASSERT(context_->IsModuleContext());
12044 return ScopeTypeModule;
12046 ASSERT(context_->IsNativeContext());
12047 return ScopeTypeGlobal;
12049 ASSERT(context_->IsWithContext());
12050 return ScopeTypeWith;
12052 ASSERT(context_->IsCatchContext());
12053 return ScopeTypeCatch;
12055 ASSERT(!scope_info->HasContext() ||
12056 context_->IsBlockContext());
12057 return ScopeTypeBlock;
12062 if (context_->IsNativeContext()) {
12063 ASSERT(context_->global_object()->IsGlobalObject());
12064 return ScopeTypeGlobal;
12066 if (context_->IsFunctionContext()) {
12067 return ScopeTypeClosure;
12069 if (context_->IsCatchContext()) {
12070 return ScopeTypeCatch;
12072 if (context_->IsBlockContext()) {
12073 return ScopeTypeBlock;
12075 if (context_->IsModuleContext()) {
12076 return ScopeTypeModule;
12078 ASSERT(context_->IsWithContext());
12079 return ScopeTypeWith;
12083 Handle<JSObject> ScopeObject() {
12086 case ScopeIterator::ScopeTypeGlobal:
12087 return Handle<JSObject>(CurrentContext()->global_object());
12088 case ScopeIterator::ScopeTypeLocal:
12090 ASSERT(nested_scope_chain_.length() == 1);
12091 return MaterializeLocalScope(isolate_, frame_, inlined_jsframe_index_);
12092 case ScopeIterator::ScopeTypeWith:
12094 return Handle<JSObject>(
JSObject::cast(CurrentContext()->extension()));
12095 case ScopeIterator::ScopeTypeCatch:
12096 return MaterializeCatchScope(isolate_, CurrentContext());
12097 case ScopeIterator::ScopeTypeClosure:
12099 return MaterializeClosure(isolate_, CurrentContext());
12100 case ScopeIterator::ScopeTypeBlock:
12101 return MaterializeBlockScope(isolate_, CurrentContext());
12102 case ScopeIterator::ScopeTypeModule:
12103 return MaterializeModuleScope(isolate_, CurrentContext());
12106 return Handle<JSObject>();
12109 bool SetVariableValue(Handle<String> variable_name,
12110 Handle<Object> new_value) {
12113 case ScopeIterator::ScopeTypeGlobal:
12115 case ScopeIterator::ScopeTypeLocal:
12116 return SetLocalVariableValue(isolate_, frame_, inlined_jsframe_index_,
12117 variable_name, new_value);
12118 case ScopeIterator::ScopeTypeWith:
12120 case ScopeIterator::ScopeTypeCatch:
12121 return SetCatchVariableValue(isolate_, CurrentContext(),
12122 variable_name, new_value);
12123 case ScopeIterator::ScopeTypeClosure:
12124 return SetClosureVariableValue(isolate_, CurrentContext(),
12125 variable_name, new_value);
12126 case ScopeIterator::ScopeTypeBlock:
12129 case ScopeIterator::ScopeTypeModule:
12136 Handle<ScopeInfo> CurrentScopeInfo() {
12138 if (!nested_scope_chain_.is_empty()) {
12139 return nested_scope_chain_.last();
12140 }
else if (context_->IsBlockContext()) {
12142 }
else if (context_->IsFunctionContext()) {
12143 return Handle<ScopeInfo>(context_->closure()->shared()->scope_info());
12150 Handle<Context> CurrentContext() {
12152 if (
Type() == ScopeTypeGlobal ||
12153 nested_scope_chain_.is_empty()) {
12155 }
else if (nested_scope_chain_.last()->HasContext()) {
12158 return Handle<Context>();
12164 void DebugPrint() {
12167 case ScopeIterator::ScopeTypeGlobal:
12169 CurrentContext()->Print();
12172 case ScopeIterator::ScopeTypeLocal: {
12174 function_->shared()->scope_info()->Print();
12175 if (!CurrentContext().is_null()) {
12176 CurrentContext()->Print();
12177 if (CurrentContext()->has_extension()) {
12178 Handle<Object> extension(CurrentContext()->extension(), isolate_);
12179 if (extension->IsJSContextExtensionObject()) {
12180 extension->Print();
12187 case ScopeIterator::ScopeTypeWith:
12189 CurrentContext()->extension()->Print();
12192 case ScopeIterator::ScopeTypeCatch:
12194 CurrentContext()->extension()->Print();
12198 case ScopeIterator::ScopeTypeClosure:
12200 CurrentContext()->Print();
12201 if (CurrentContext()->has_extension()) {
12202 Handle<Object> extension(CurrentContext()->extension(), isolate_);
12203 if (extension->IsJSContextExtensionObject()) {
12204 extension->Print();
12218 JavaScriptFrame* frame_;
12219 int inlined_jsframe_index_;
12220 Handle<JSFunction> function_;
12221 Handle<Context> context_;
12222 List<Handle<ScopeInfo> > nested_scope_chain_;
12225 void RetrieveScopeChain(Scope* scope,
12226 Handle<SharedFunctionInfo> shared_info) {
12227 if (scope !=
NULL) {
12228 int source_position = shared_info->code()->SourcePosition(frame_->pc());
12229 scope->GetNestedScopeChain(&nested_scope_chain_, source_position);
12237 ASSERT(isolate_->has_pending_exception());
12247 HandleScope scope(isolate);
12248 ASSERT(args.length() == 2);
12252 { MaybeObject* maybe_check = Runtime_CheckExecutionState(
12254 if (!maybe_check->ToObject(&check))
return maybe_check;
12259 StackFrame::Id
id = UnwrapFrameId(wrapped_id);
12260 JavaScriptFrameIterator it(isolate,
id);
12261 JavaScriptFrame* frame = it.frame();
12265 for (ScopeIterator it(isolate, frame, 0);
12279 HandleScope scope(isolate);
12280 ASSERT(args.length() == 2);
12284 { MaybeObject* maybe_check = Runtime_CheckExecutionState(
12286 if (!maybe_check->ToObject(&check))
return maybe_check;
12291 StackFrame::Id
id = UnwrapFrameId(wrapped_id);
12292 JavaScriptFrameIterator frame_it(isolate,
id);
12295 JavaScriptFrame* frame = frame_it.frame();
12297 Handle<JSFunction> fun =
12298 Handle<JSFunction>(frame->function());
12299 Handle<SharedFunctionInfo> shared =
12300 Handle<SharedFunctionInfo>(fun->shared());
12302 if (!isolate->debug()->EnsureDebugInfo(shared, fun)) {
12303 return isolate->heap()->undefined_value();
12306 Handle<DebugInfo> debug_info = Debug::GetDebugInfo(shared);
12309 Handle<JSArray> array(isolate->factory()->NewJSArray(10));
12311 BreakLocationIterator break_location_iterator(debug_info,
12312 ALL_BREAK_LOCATIONS);
12314 break_location_iterator.FindBreakLocationFromAddress(frame->pc() - 1);
12315 int current_statement_pos = break_location_iterator.statement_position();
12317 while (!break_location_iterator.Done()) {
12319 if (break_location_iterator.pc() > frame->pc()) {
12322 StackFrame::Id break_frame_id = isolate->debug()->break_frame_id();
12325 if (break_frame_id == StackFrame::NO_ID) {
12329 JavaScriptFrameIterator additional_frame_it(isolate, break_frame_id);
12332 accept = additional_frame_it.frame()->id() == id;
12336 if (break_location_iterator.IsStepInLocation(isolate)) {
12337 Smi* position_value =
Smi::FromInt(break_location_iterator.position());
12339 Handle<Object>(position_value, isolate),
12345 break_location_iterator.Next();
12346 if (current_statement_pos !=
12347 break_location_iterator.statement_position()) {
12355 static const int kScopeDetailsTypeIndex = 0;
12356 static const int kScopeDetailsObjectIndex = 1;
12357 static const int kScopeDetailsSize = 2;
12360 static Handle<JSObject> MaterializeScopeDetails(Isolate* isolate,
12361 ScopeIterator* it) {
12363 int details_size = kScopeDetailsSize;
12364 Handle<FixedArray> details = isolate->factory()->NewFixedArray(details_size);
12367 details->set(kScopeDetailsTypeIndex,
Smi::FromInt(it->Type()));
12368 Handle<JSObject> scope_object = it->ScopeObject();
12370 details->set(kScopeDetailsObjectIndex, *scope_object);
12372 return isolate->factory()->NewJSArrayWithElements(details);
12386 HandleScope scope(isolate);
12387 ASSERT(args.length() == 4);
12391 { MaybeObject* maybe_check = Runtime_CheckExecutionState(
12393 if (!maybe_check->ToObject(&check))
return maybe_check;
12400 StackFrame::Id
id = UnwrapFrameId(wrapped_id);
12401 JavaScriptFrameIterator frame_it(isolate,
id);
12402 JavaScriptFrame* frame = frame_it.frame();
12406 ScopeIterator it(isolate, frame, inlined_jsframe_index);
12407 for (; !it.Done() && n < index; it.Next()) {
12411 return isolate->heap()->undefined_value();
12413 Handle<JSObject> details = MaterializeScopeDetails(isolate, &it);
12429 HandleScope scope(isolate);
12430 ASSERT(args.length() == 3 || args.length() == 4);
12434 { MaybeObject* maybe_check = Runtime_CheckExecutionState(
12436 if (!maybe_check->ToObject(&check))
return maybe_check;
12441 bool ignore_nested_scopes =
false;
12442 if (args.length() == 4) {
12444 ignore_nested_scopes =
flag;
12448 StackFrame::Id
id = UnwrapFrameId(wrapped_id);
12449 JavaScriptFrameIterator frame_it(isolate,
id);
12450 JavaScriptFrame* frame = frame_it.frame();
12452 List<Handle<JSObject> > result(4);
12453 ScopeIterator it(isolate, frame, inlined_jsframe_index, ignore_nested_scopes);
12454 for (; !it.Done(); it.Next()) {
12455 Handle<JSObject> details = MaterializeScopeDetails(isolate, &it);
12457 result.Add(details);
12460 Handle<FixedArray> array = isolate->factory()->NewFixedArray(result.length());
12461 for (
int i = 0; i < result.length(); ++i) {
12462 array->set(i, *result[i]);
12464 return *isolate->factory()->NewJSArrayWithElements(array);
12469 HandleScope scope(isolate);
12470 ASSERT(args.length() == 1);
12477 for (ScopeIterator it(isolate, fun); !it.Done(); it.Next()) {
12486 HandleScope scope(isolate);
12487 ASSERT(args.length() == 2);
12495 ScopeIterator it(isolate, fun);
12496 for (; !it.Done() && n < index; it.Next()) {
12500 return isolate->heap()->undefined_value();
12503 Handle<JSObject> details = MaterializeScopeDetails(isolate, &it);
12509 static bool SetScopeVariableValue(ScopeIterator* it,
int index,
12510 Handle<String> variable_name,
12511 Handle<Object> new_value) {
12512 for (
int n = 0; !it->Done() && n < index; it->Next()) {
12518 return it->SetVariableValue(variable_name, new_value);
12532 HandleScope scope(isolate);
12533 ASSERT(args.length() == 6);
12538 Handle<Object> new_value = args.at<
Object>(5);
12541 if (args[0]->IsNumber()) {
12543 { MaybeObject* maybe_check = Runtime_CheckExecutionState(
12545 if (!maybe_check->ToObject(&check))
return maybe_check;
12551 StackFrame::Id
id = UnwrapFrameId(wrapped_id);
12552 JavaScriptFrameIterator frame_it(isolate,
id);
12553 JavaScriptFrame* frame = frame_it.frame();
12555 ScopeIterator it(isolate, frame, inlined_jsframe_index);
12556 res = SetScopeVariableValue(&it, index, variable_name, new_value);
12559 ScopeIterator it(isolate, fun);
12560 res = SetScopeVariableValue(&it, index, variable_name, new_value);
12563 return isolate->heap()->ToBoolean(res);
12568 HandleScope scope(isolate);
12569 ASSERT(args.length() == 0);
12573 StackFrameLocator locator(isolate);
12574 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0);
12575 for (ScopeIterator it(isolate, frame, 0);
12581 return isolate->heap()->undefined_value();
12586 HandleScope scope(isolate);
12587 ASSERT(args.length() == 1);
12591 { MaybeObject* maybe_result = Runtime_CheckExecutionState(
12593 if (!maybe_result->ToObject(&result))
return maybe_result;
12598 for (ThreadState* thread =
12599 isolate->thread_manager()->FirstThreadStateInUse();
12601 thread = thread->Next()) {
12610 static const int kThreadDetailsCurrentThreadIndex = 0;
12611 static const int kThreadDetailsThreadIdIndex = 1;
12612 static const int kThreadDetailsSize = 2;
12622 HandleScope scope(isolate);
12623 ASSERT(args.length() == 2);
12627 { MaybeObject* maybe_check = Runtime_CheckExecutionState(
12629 if (!maybe_check->ToObject(&check))
return maybe_check;
12634 Handle<FixedArray> details =
12635 isolate->factory()->NewFixedArray(kThreadDetailsSize);
12640 details->set(kThreadDetailsCurrentThreadIndex,
12641 isolate->heap()->true_value());
12642 details->set(kThreadDetailsThreadIdIndex,
12647 ThreadState* thread =
12648 isolate->thread_manager()->FirstThreadStateInUse();
12649 while (index != n && thread !=
NULL) {
12650 thread = thread->Next();
12653 if (thread ==
NULL) {
12654 return isolate->heap()->undefined_value();
12658 details->set(kThreadDetailsCurrentThreadIndex,
12659 isolate->heap()->false_value());
12660 details->set(kThreadDetailsThreadIdIndex,
12665 return *isolate->factory()->NewJSArrayWithElements(details);
12672 HandleScope scope(isolate);
12673 ASSERT(args.length() == 1);
12675 isolate->debug()->set_disable_break(disable_break);
12676 return isolate->heap()->undefined_value();
12680 static bool IsPositionAlignmentCodeCorrect(
int alignment) {
12681 return alignment == STATEMENT_ALIGNED || alignment == BREAK_POSITION_ALIGNED;
12686 HandleScope scope(isolate);
12687 ASSERT(args.length() == 2);
12692 if (!IsPositionAlignmentCodeCorrect(statement_aligned_code)) {
12693 return isolate->ThrowIllegalOperation();
12695 BreakPositionAlignment alignment =
12696 static_cast<BreakPositionAlignment
>(statement_aligned_code);
12698 Handle<SharedFunctionInfo> shared(fun->shared());
12700 Handle<Object> break_locations =
12701 Debug::GetSourceBreakLocations(shared, alignment);
12702 if (break_locations->IsUndefined())
return isolate->heap()->undefined_value();
12704 return *isolate->factory()->NewJSArrayWithElements(
12705 Handle<FixedArray>::cast(break_locations));
12714 HandleScope scope(isolate);
12715 ASSERT(args.length() == 3);
12719 Handle<Object> break_point_object_arg = args.at<
Object>(2);
12722 isolate->debug()->SetBreakPoint(
function, break_point_object_arg,
12737 HandleScope scope(isolate);
12738 ASSERT(args.length() == 4);
12743 Handle<Object> break_point_object_arg = args.at<
Object>(3);
12745 if (!IsPositionAlignmentCodeCorrect(statement_aligned_code)) {
12746 return isolate->ThrowIllegalOperation();
12748 BreakPositionAlignment alignment =
12749 static_cast<BreakPositionAlignment
>(statement_aligned_code);
12753 Handle<Script> script(
Script::cast(wrapper->value()));
12756 if (!isolate->debug()->SetBreakPointForScript(script, break_point_object_arg,
12759 return isolate->heap()->undefined_value();
12769 HandleScope scope(isolate);
12770 ASSERT(args.length() == 1);
12771 Handle<Object> break_point_object_arg = args.at<
Object>(0);
12774 isolate->debug()->ClearBreakPoint(break_point_object_arg);
12776 return isolate->heap()->undefined_value();
12784 HandleScope scope(isolate);
12785 ASSERT(args.length() == 2);
12791 ExceptionBreakType type =
12794 isolate->debug()->ChangeBreakOnException(type, enable);
12795 return isolate->heap()->undefined_value();
12802 HandleScope scope(isolate);
12803 ASSERT(args.length() == 1);
12806 ExceptionBreakType type =
12808 bool result = isolate->debug()->IsBreakOnException(type);
12819 HandleScope scope(isolate);
12820 ASSERT(args.length() == 4);
12823 { MaybeObject* maybe_check = Runtime_CheckExecutionState(
12825 if (!maybe_check->ToObject(&check))
return maybe_check;
12827 if (!args[1]->IsNumber() || !args[2]->IsNumber()) {
12828 return isolate->Throw(isolate->heap()->illegal_argument_string());
12833 StackFrame::Id frame_id;
12834 if (wrapped_frame_id == 0) {
12835 frame_id = StackFrame::NO_ID;
12837 frame_id = UnwrapFrameId(wrapped_frame_id);
12841 StepAction step_action =
static_cast<StepAction
>(
NumberToInt32(args[1]));
12842 if (step_action != StepIn &&
12843 step_action != StepNext &&
12844 step_action != StepOut &&
12845 step_action != StepInMin &&
12846 step_action != StepMin) {
12847 return isolate->Throw(isolate->heap()->illegal_argument_string());
12850 if (frame_id != StackFrame::NO_ID && step_action != StepNext &&
12851 step_action != StepMin && step_action != StepOut) {
12852 return isolate->ThrowIllegalOperation();
12857 if (step_count < 1) {
12858 return isolate->Throw(isolate->heap()->illegal_argument_string());
12862 isolate->debug()->ClearStepping();
12865 isolate->debug()->PrepareStep(static_cast<StepAction>(step_action),
12868 return isolate->heap()->undefined_value();
12874 HandleScope scope(isolate);
12875 ASSERT(args.length() == 0);
12876 isolate->debug()->ClearStepping();
12877 return isolate->heap()->undefined_value();
12883 static Handle<JSObject> MaterializeArgumentsObject(
12885 Handle<JSObject> target,
12886 Handle<JSFunction>
function) {
12889 if (!function->shared()->is_function() ||
12891 isolate->factory()->arguments_string())) {
12899 isolate->factory()->arguments_string(),
12908 static MaybeObject* DebugEvaluate(Isolate* isolate,
12909 Handle<Context> context,
12910 Handle<Object> context_extension,
12911 Handle<Object> receiver,
12912 Handle<String> source) {
12913 if (context_extension->IsJSObject()) {
12915 Handle<JSFunction> closure(context->closure(), isolate);
12916 context = isolate->factory()->NewWithContext(closure, context, extension);
12919 Handle<JSFunction> eval_fun =
12924 RelocInfo::kNoPosition);
12927 bool pending_exception;
12929 isolate, eval_fun, receiver, 0,
NULL, &pending_exception);
12935 if (result->IsJSGlobalProxy()) {
12936 result = Handle<JSObject>(
JSObject::cast(result->GetPrototype(isolate)));
12940 isolate->debug()->ClearStepping();
12951 HandleScope scope(isolate);
12955 ASSERT(args.length() == 6);
12957 { MaybeObject* maybe_result = Runtime_CheckExecutionState(
12959 if (!maybe_result->ToObject(&check_result))
return maybe_result;
12965 Handle<Object> context_extension(args[5], isolate);
12968 DisableBreak disable_break_save(isolate, disable_break);
12971 StackFrame::Id
id = UnwrapFrameId(wrapped_id);
12972 JavaScriptFrameIterator it(isolate,
id);
12973 JavaScriptFrame* frame = it.frame();
12974 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate);
12975 Handle<JSFunction>
function(
JSFunction::cast(frame_inspector.GetFunction()));
12979 SaveContext* save = FindSavedContextForFrame(isolate, frame);
12981 SaveContext savex(isolate);
12982 isolate->set_context(*(save->context()));
12986 ASSERT(!context.is_null());
12989 Handle<JSObject> materialized =
12990 isolate->factory()->NewJSObject(isolate->object_function());
12992 materialized = MaterializeStackLocalsWithFrameInspector(
12993 isolate, materialized,
function, &frame_inspector);
12996 materialized = MaterializeArgumentsObject(isolate, materialized,
function);
13000 context = isolate->factory()->NewWithContext(
function, context, materialized);
13002 Handle<Object> receiver(frame->receiver(), isolate);
13003 Object* evaluate_result_object;
13004 { MaybeObject* maybe_result =
13005 DebugEvaluate(isolate, context, context_extension, receiver, source);
13006 if (!maybe_result->ToObject(&evaluate_result_object))
return maybe_result;
13009 Handle<Object> result(evaluate_result_object, isolate);
13012 UpdateStackLocalsFromMaterializedObject(
13013 isolate, materialized,
function, frame, inlined_jsframe_index);
13020 HandleScope scope(isolate);
13024 ASSERT(args.length() == 4);
13026 { MaybeObject* maybe_result = Runtime_CheckExecutionState(
13028 if (!maybe_result->ToObject(&check_result))
return maybe_result;
13032 Handle<Object> context_extension(args[3], isolate);
13035 DisableBreak disable_break_save(isolate, disable_break);
13038 SaveContext save(isolate);
13039 SaveContext* top = &save;
13040 while (top !=
NULL && *top->context() == *isolate->debug()->debug_context()) {
13044 isolate->set_context(*top->context());
13049 Handle<Context> context = isolate->native_context();
13050 Handle<Object> receiver = isolate->global_object();
13051 return DebugEvaluate(isolate, context, context_extension, receiver, source);
13056 HandleScope scope(isolate);
13057 ASSERT(args.length() == 0);
13060 Handle<FixedArray> instances = isolate->debug()->GetLoadedScripts();
13063 for (
int i = 0; i < instances->length(); i++) {
13064 Handle<Script> script = Handle<Script>(
Script::cast(instances->get(i)));
13071 instances->set(i, *wrapper);
13075 Handle<JSObject> result =
13076 isolate->factory()->NewJSObject(isolate->array_function());
13083 static int DebugReferencedBy(HeapIterator* iterator,
13085 Object* instance_filter,
int max_references,
13086 FixedArray* instances,
int instances_size,
13087 JSFunction* arguments_function) {
13088 Isolate* isolate = target->GetIsolate();
13089 SealHandleScope shs(isolate);
13094 JSObject* last =
NULL;
13095 HeapObject* heap_obj =
NULL;
13096 while (((heap_obj = iterator->next()) !=
NULL) &&
13097 (max_references == 0 || count < max_references)) {
13099 if (heap_obj->IsJSObject()) {
13103 if (obj->IsJSContextExtensionObject() ||
13104 obj->map()->constructor() == arguments_function) {
13109 if (obj->ReferencesObject(target)) {
13112 if (!instance_filter->IsUndefined()) {
13115 Object* prototype = V->GetPrototype(isolate);
13116 if (prototype->IsNull()) {
13119 if (instance_filter == prototype) {
13130 if (instances !=
NULL && count < instances_size) {
13131 instances->set(count, obj);
13144 if (count == 1 && last == target) {
13158 HandleScope scope(isolate);
13159 ASSERT(args.length() == 3);
13162 Heap* heap = isolate->heap();
13171 Handle<Object> instance_filter = args.at<
Object>(1);
13173 instance_filter->IsJSObject());
13179 Handle<JSObject> arguments_boilerplate(
13180 isolate->context()->native_context()->sloppy_arguments_boilerplate());
13181 Handle<JSFunction> arguments_function(
13186 HeapIterator heap_iterator(heap);
13187 count = DebugReferencedBy(&heap_iterator,
13188 *target, *instance_filter, max_references,
13189 NULL, 0, *arguments_function);
13192 Handle<FixedArray> instances = isolate->factory()->NewFixedArray(count);
13196 ASSERT(heap->IsHeapIterable());
13197 HeapIterator heap_iterator2(heap);
13198 count = DebugReferencedBy(&heap_iterator2,
13199 *target, *instance_filter, max_references,
13200 *instances, count, *arguments_function);
13203 Handle<JSFunction> constructor(
13204 isolate->context()->native_context()->array_function());
13206 Handle<JSObject> result = isolate->factory()->NewJSObject(constructor);
13213 static int DebugConstructedBy(HeapIterator* iterator,
13214 JSFunction* constructor,
13215 int max_references,
13216 FixedArray* instances,
13217 int instances_size) {
13222 HeapObject* heap_obj =
NULL;
13223 while (((heap_obj = iterator->next()) !=
NULL) &&
13224 (max_references == 0 || count < max_references)) {
13226 if (heap_obj->IsJSObject()) {
13228 if (obj->map()->constructor() == constructor) {
13231 if (instances !=
NULL && count < instances_size) {
13232 instances->set(count, obj);
13248 HandleScope scope(isolate);
13249 ASSERT(args.length() == 2);
13252 Heap* heap = isolate->heap();
13262 HeapIterator heap_iterator(heap);
13263 count = DebugConstructedBy(&heap_iterator,
13270 Handle<FixedArray> instances = isolate->factory()->NewFixedArray(count);
13272 ASSERT(heap->IsHeapIterable());
13274 HeapIterator heap_iterator2(heap);
13275 count = DebugConstructedBy(&heap_iterator2,
13282 Handle<JSFunction> array_function(
13283 isolate->context()->native_context()->array_function());
13284 Handle<JSObject> result = isolate->factory()->NewJSObject(array_function);
13293 SealHandleScope shs(isolate);
13294 ASSERT(args.length() == 1);
13296 return GetPrototypeSkipHiddenPrototypes(isolate, obj);
13302 HandleScope scope(isolate);
13303 ASSERT(args.length() == 2);
13309 Handle<Script> script(
Script::cast(script_wrapper->value()));
13311 int compilation_state = script->compilation_state();
13313 script->set_source(*source);
13315 return isolate->heap()->undefined_value();
13320 SealHandleScope shs(isolate);
13321 ASSERT(args.length() == 0);
13323 return isolate->heap()->undefined_value();
13328 HandleScope scope(isolate);
13330 ASSERT(args.length() == 1);
13336 func->code()->PrintLn();
13338 return isolate->heap()->undefined_value();
13343 HandleScope scope(isolate);
13345 ASSERT(args.length() == 1);
13351 func->shared()->construct_stub()->PrintLn();
13353 return isolate->heap()->undefined_value();
13358 SealHandleScope shs(isolate);
13359 ASSERT(args.length() == 1);
13362 return f->shared()->inferred_name();
13366 static int FindSharedFunctionInfosForScript(HeapIterator* iterator,
13368 FixedArray* buffer) {
13371 int buffer_size = buffer->length();
13372 for (HeapObject* obj = iterator->next();
13374 obj = iterator->next()) {
13376 if (!obj->IsSharedFunctionInfo()) {
13380 if (shared->script() != script) {
13383 if (counter < buffer_size) {
13384 buffer->set(counter, shared);
13396 Runtime_LiveEditFindSharedFunctionInfosForScript) {
13397 HandleScope scope(isolate);
13398 CHECK(isolate->debugger()->live_edit_enabled());
13399 ASSERT(args.length() == 1);
13403 Handle<Script> script = Handle<Script>(
Script::cast(script_value->value()));
13405 const int kBufferSize = 32;
13407 Handle<FixedArray> array;
13408 array = isolate->factory()->NewFixedArray(kBufferSize);
13410 Heap* heap = isolate->heap();
13412 heap->EnsureHeapIsIterable();
13414 HeapIterator heap_iterator(heap);
13415 Script* scr = *script;
13416 FixedArray* arr = *array;
13417 number = FindSharedFunctionInfosForScript(&heap_iterator, scr, arr);
13419 if (number > kBufferSize) {
13420 array = isolate->factory()->NewFixedArray(number);
13421 heap->EnsureHeapIsIterable();
13423 HeapIterator heap_iterator(heap);
13424 Script* scr = *script;
13425 FixedArray* arr = *array;
13426 FindSharedFunctionInfosForScript(&heap_iterator, scr, arr);
13429 Handle<JSArray> result = isolate->factory()->NewJSArrayWithElements(array);
13432 LiveEdit::WrapSharedFunctionInfos(result);
13446 HandleScope scope(isolate);
13447 CHECK(isolate->debugger()->live_edit_enabled());
13448 ASSERT(args.length() == 2);
13453 Handle<Script> script_handle = Handle<Script>(
Script::cast(script->value()));
13455 JSArray* result = LiveEdit::GatherCompileInfo(script_handle, source);
13457 if (isolate->has_pending_exception()) {
13469 HandleScope scope(isolate);
13470 CHECK(isolate->debugger()->live_edit_enabled());
13471 ASSERT(args.length() == 3);
13474 Handle<Object> old_script_name(args[2], isolate);
13477 Handle<Script> original_script(
Script::cast(original_script_value->value()));
13479 Object* old_script = LiveEdit::ChangeScriptSource(original_script,
13483 if (old_script->IsScript()) {
13484 Handle<Script> script_handle(
Script::cast(old_script));
13487 return isolate->heap()->null_value();
13493 HandleScope scope(isolate);
13494 CHECK(isolate->debugger()->live_edit_enabled());
13495 ASSERT(args.length() == 1);
13497 return LiveEdit::FunctionSourceUpdated(shared_info);
13503 HandleScope scope(isolate);
13504 CHECK(isolate->debugger()->live_edit_enabled());
13505 ASSERT(args.length() == 2);
13509 return LiveEdit::ReplaceFunctionCode(new_compile_info, shared_info);
13515 HandleScope scope(isolate);
13516 CHECK(isolate->debugger()->live_edit_enabled());
13517 ASSERT(args.length() == 2);
13518 Handle<Object> function_object(args[0], isolate);
13519 Handle<Object> script_object(args[1], isolate);
13521 if (function_object->IsJSValue()) {
13523 if (script_object->IsJSValue()) {
13526 script_object = Handle<Object>(script, isolate);
13529 LiveEdit::SetFunctionScript(function_wrapper, script_object);
13535 return isolate->heap()->undefined_value();
13541 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditReplaceRefToNestedFunction) {
13542 HandleScope scope(isolate);
13543 CHECK(isolate->debugger()->live_edit_enabled());
13544 ASSERT(args.length() == 3);
13550 LiveEdit::ReplaceRefToNestedFunction(parent_wrapper, orig_wrapper,
13553 return isolate->heap()->undefined_value();
13563 HandleScope scope(isolate);
13564 CHECK(isolate->debugger()->live_edit_enabled());
13565 ASSERT(args.length() == 2);
13569 return LiveEdit::PatchFunctionPositions(shared_array, position_change_array);
13578 HandleScope scope(isolate);
13579 CHECK(isolate->debugger()->live_edit_enabled());
13580 ASSERT(args.length() == 2);
13584 return *LiveEdit::CheckAndDropActivations(shared_array, do_drop);
13592 HandleScope scope(isolate);
13593 CHECK(isolate->debugger()->live_edit_enabled());
13594 ASSERT(args.length() == 2);
13598 return *LiveEdit::CompareStrings(
s1,
s2);
13605 HandleScope scope(isolate);
13606 CHECK(isolate->debugger()->live_edit_enabled());
13607 ASSERT(args.length() == 2);
13611 { MaybeObject* maybe_check = Runtime_CheckExecutionState(
13613 if (!maybe_check->ToObject(&check))
return maybe_check;
13616 Heap* heap = isolate->heap();
13619 StackFrame::Id
id = isolate->debug()->break_frame_id();
13620 if (
id == StackFrame::NO_ID) {
13622 return heap->undefined_value();
13626 JavaScriptFrameIterator it(isolate,
id);
13627 for (; !it.done(); it.Advance()) {
13628 if (index < count + it.frame()->GetInlineCount())
break;
13629 count += it.frame()->GetInlineCount();
13631 if (it.done())
return heap->undefined_value();
13633 const char* error_message = LiveEdit::RestartFrame(it.frame());
13634 if (error_message) {
13635 return *(isolate->factory()->InternalizeUtf8String(error_message));
13637 return heap->true_value();
13643 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFunctionCodePositionFromSource) {
13644 HandleScope scope(isolate);
13645 CHECK(isolate->debugger()->live_edit_enabled());
13646 ASSERT(args.length() == 2);
13650 Handle<Code>
code(function->code(), isolate);
13652 if (
code->kind() != Code::FUNCTION &&
13653 code->kind() != Code::OPTIMIZED_FUNCTION) {
13654 return isolate->heap()->undefined_value();
13657 RelocIterator it(*
code, RelocInfo::ModeMask(RelocInfo::STATEMENT_POSITION));
13658 int closest_pc = 0;
13660 while (!it.done()) {
13661 int statement_position =
static_cast<int>(it.rinfo()->data());
13663 if (source_position <= statement_position &&
13664 statement_position - source_position < distance) {
13666 static_cast<int>(it.rinfo()->pc() -
code->instruction_start());
13667 distance = statement_position - source_position;
13669 if (distance == 0)
break;
13682 HandleScope scope(isolate);
13683 ASSERT(args.length() == 2);
13687 Handle<Object> result;
13688 bool pending_exception;
13690 if (without_debugger) {
13693 isolate->global_object(),
13696 &pending_exception);
13698 EnterDebugger enter_debugger(isolate);
13701 isolate->global_object(),
13704 &pending_exception);
13707 if (!pending_exception) {
13717 SealHandleScope shs(isolate);
13719 SmartArrayPointer<char> flags =
13721 FlagList::SetFlagsFromString(flags.get(),
StrLength(flags.get()));
13722 return isolate->heap()->undefined_value();
13729 SealHandleScope shs(isolate);
13731 return isolate->heap()->undefined_value();
13737 SealHandleScope shs(isolate);
13738 int usage =
static_cast<int>(isolate->heap()->SizeOfObjects());
13740 return *isolate->factory()->NewNumberFromInt(usage);
13745 #endif // ENABLE_DEBUGGER_SUPPORT
13748 #ifdef V8_I18N_SUPPORT
13750 HandleScope scope(isolate);
13752 ASSERT(args.length() == 1);
13758 const char*
const kInvalidTag =
"invalid-tag";
13760 UErrorCode error = U_ZERO_ERROR;
13761 char icu_result[ULOC_FULLNAME_CAPACITY];
13762 int icu_length = 0;
13764 uloc_forLanguageTag(*locale_id, icu_result, ULOC_FULLNAME_CAPACITY,
13765 &icu_length, &error);
13766 if (U_FAILURE(error) || icu_length == 0) {
13767 return isolate->heap()->AllocateStringFromOneByte(
CStrVector(kInvalidTag));
13770 char result[ULOC_FULLNAME_CAPACITY];
13773 uloc_toLanguageTag(icu_result, result, ULOC_FULLNAME_CAPACITY, TRUE, &error);
13775 if (U_FAILURE(error)) {
13776 return isolate->heap()->AllocateStringFromOneByte(
CStrVector(kInvalidTag));
13779 return isolate->heap()->AllocateStringFromOneByte(
CStrVector(result));
13784 HandleScope scope(isolate);
13786 ASSERT(args.length() == 1);
13789 const icu::Locale* available_locales =
NULL;
13792 if (service->IsUtf8EqualTo(
CStrVector(
"collator"))) {
13793 available_locales = icu::Collator::getAvailableLocales(count);
13794 }
else if (service->IsUtf8EqualTo(
CStrVector(
"numberformat"))) {
13795 available_locales = icu::NumberFormat::getAvailableLocales(count);
13796 }
else if (service->IsUtf8EqualTo(
CStrVector(
"dateformat"))) {
13797 available_locales = icu::DateFormat::getAvailableLocales(count);
13798 }
else if (service->IsUtf8EqualTo(
CStrVector(
"breakiterator"))) {
13799 available_locales = icu::BreakIterator::getAvailableLocales(count);
13802 UErrorCode error = U_ZERO_ERROR;
13803 char result[ULOC_FULLNAME_CAPACITY];
13804 Handle<JSObject> locales =
13805 isolate->factory()->NewJSObject(isolate->object_function());
13807 for (int32_t i = 0; i < count; ++i) {
13808 const char* icu_name = available_locales[i].getName();
13810 error = U_ZERO_ERROR;
13812 uloc_toLanguageTag(icu_name, result, ULOC_FULLNAME_CAPACITY, FALSE, &error);
13813 if (U_FAILURE(error)) {
13821 isolate->factory()->NewStringFromAscii(
CStrVector(result)),
13822 isolate->factory()->NewNumber(i),
13831 SealHandleScope shs(isolate);
13833 ASSERT(args.length() == 0);
13835 icu::Locale default_locale;
13838 char result[ULOC_FULLNAME_CAPACITY];
13839 UErrorCode status = U_ZERO_ERROR;
13840 uloc_toLanguageTag(
13841 default_locale.getName(), result, ULOC_FULLNAME_CAPACITY, FALSE, &status);
13842 if (U_SUCCESS(status)) {
13843 return isolate->heap()->AllocateStringFromOneByte(
CStrVector(result));
13846 return isolate->heap()->AllocateStringFromOneByte(
CStrVector(
"und"));
13851 HandleScope scope(isolate);
13853 ASSERT(args.length() == 1);
13857 uint32_t length =
static_cast<uint32_t
>(input->length()->Number());
13858 Handle<FixedArray> output = isolate->factory()->NewFixedArray(length);
13859 Handle<Name> maximized =
13860 isolate->factory()->NewStringFromAscii(
CStrVector(
"maximized"));
13861 Handle<Name> base =
13862 isolate->factory()->NewStringFromAscii(
CStrVector(
"base"));
13863 for (
unsigned int i = 0; i < length; ++i) {
13866 if (!locale_id->IsString()) {
13867 return isolate->Throw(isolate->heap()->illegal_argument_string());
13873 UErrorCode error = U_ZERO_ERROR;
13877 char icu_locale[ULOC_FULLNAME_CAPACITY];
13878 int icu_locale_length = 0;
13879 uloc_forLanguageTag(*utf8_locale_id, icu_locale, ULOC_FULLNAME_CAPACITY,
13880 &icu_locale_length, &error);
13881 if (U_FAILURE(error) || icu_locale_length == 0) {
13882 return isolate->Throw(isolate->heap()->illegal_argument_string());
13887 char icu_max_locale[ULOC_FULLNAME_CAPACITY];
13888 uloc_addLikelySubtags(
13889 icu_locale, icu_max_locale, ULOC_FULLNAME_CAPACITY, &error);
13893 char icu_base_max_locale[ULOC_FULLNAME_CAPACITY];
13895 icu_max_locale, icu_base_max_locale, ULOC_FULLNAME_CAPACITY, &error);
13899 char icu_base_locale[ULOC_FULLNAME_CAPACITY];
13901 icu_locale, icu_base_locale, ULOC_FULLNAME_CAPACITY, &error);
13905 char base_max_locale[ULOC_FULLNAME_CAPACITY];
13906 uloc_toLanguageTag(icu_base_max_locale, base_max_locale,
13907 ULOC_FULLNAME_CAPACITY, FALSE, &error);
13910 char base_locale[ULOC_FULLNAME_CAPACITY];
13911 uloc_toLanguageTag(
13912 icu_base_locale, base_locale, ULOC_FULLNAME_CAPACITY, FALSE, &error);
13914 if (U_FAILURE(error)) {
13915 return isolate->Throw(isolate->heap()->illegal_argument_string());
13918 Handle<JSObject> result =
13919 isolate->factory()->NewJSObject(isolate->object_function());
13924 isolate->factory()->NewStringFromAscii(
CStrVector(base_max_locale)),
13930 isolate->factory()->NewStringFromAscii(
CStrVector(base_locale)),
13932 output->set(i, *result);
13935 Handle<JSArray> result = isolate->factory()->NewJSArrayWithElements(output);
13942 HandleScope scope(isolate);
13944 ASSERT(args.length() == 3);
13950 Handle<ObjectTemplateInfo> date_format_template =
13954 bool has_pending_exception =
false;
13956 date_format_template, &has_pending_exception);
13957 if (has_pending_exception) {
13958 ASSERT(isolate->has_pending_exception());
13964 isolate, locale, options, resolved);
13966 if (!date_format)
return isolate->ThrowIllegalOperation();
13968 local_object->SetInternalField(0, reinterpret_cast<Smi*>(date_format));
13973 isolate->factory()->NewStringFromAscii(
CStrVector(
"dateFormat")),
13974 isolate->factory()->NewStringFromAscii(
CStrVector(
"valid")),
13978 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object);
13980 reinterpret_cast<void*
>(wrapper.location()),
13982 return *local_object;
13987 HandleScope scope(isolate);
13989 ASSERT(args.length() == 2);
13994 bool has_pending_exception =
false;
13995 Handle<Object> value =
13997 if (has_pending_exception) {
13998 ASSERT(isolate->has_pending_exception());
14002 icu::SimpleDateFormat* date_format =
14004 if (!date_format)
return isolate->ThrowIllegalOperation();
14006 icu::UnicodeString result;
14007 date_format->format(value->Number(), result);
14009 return *isolate->factory()->NewStringFromTwoByte(
14010 Vector<const uint16_t>(
14011 reinterpret_cast<const uint16_t*>(result.getBuffer()),
14017 HandleScope scope(isolate);
14019 ASSERT(args.length() == 2);
14025 icu::UnicodeString u_date(icu::UnicodeString::fromUTF8(*utf8_date));
14026 icu::SimpleDateFormat* date_format =
14028 if (!date_format)
return isolate->ThrowIllegalOperation();
14030 UErrorCode status = U_ZERO_ERROR;
14031 UDate date = date_format->parse(u_date, status);
14032 if (U_FAILURE(status))
return isolate->heap()->undefined_value();
14034 bool has_pending_exception =
false;
14037 isolate, static_cast<double>(date), &has_pending_exception));
14038 if (has_pending_exception) {
14039 ASSERT(isolate->has_pending_exception());
14047 HandleScope scope(isolate);
14049 ASSERT(args.length() == 3);
14055 Handle<ObjectTemplateInfo> number_format_template =
14059 bool has_pending_exception =
false;
14061 number_format_template, &has_pending_exception);
14062 if (has_pending_exception) {
14063 ASSERT(isolate->has_pending_exception());
14069 isolate, locale, options, resolved);
14071 if (!number_format)
return isolate->ThrowIllegalOperation();
14073 local_object->SetInternalField(0, reinterpret_cast<Smi*>(number_format));
14078 isolate->factory()->NewStringFromAscii(
CStrVector(
"numberFormat")),
14079 isolate->factory()->NewStringFromAscii(
CStrVector(
"valid")),
14082 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object);
14084 reinterpret_cast<void*
>(wrapper.location()),
14086 return *local_object;
14091 HandleScope scope(isolate);
14093 ASSERT(args.length() == 2);
14098 bool has_pending_exception =
false;
14100 isolate, number, &has_pending_exception);
14101 if (has_pending_exception) {
14102 ASSERT(isolate->has_pending_exception());
14106 icu::DecimalFormat* number_format =
14108 if (!number_format)
return isolate->ThrowIllegalOperation();
14110 icu::UnicodeString result;
14111 number_format->format(value->Number(), result);
14113 return *isolate->factory()->NewStringFromTwoByte(
14114 Vector<const uint16_t>(
14115 reinterpret_cast<const uint16_t*>(result.getBuffer()),
14121 HandleScope scope(isolate);
14123 ASSERT(args.length() == 2);
14129 icu::UnicodeString u_number(icu::UnicodeString::fromUTF8(*utf8_number));
14130 icu::DecimalFormat* number_format =
14132 if (!number_format)
return isolate->ThrowIllegalOperation();
14134 UErrorCode status = U_ZERO_ERROR;
14135 icu::Formattable result;
14142 number_format->parse(u_number, result, status);
14143 if (U_FAILURE(status))
return isolate->heap()->undefined_value();
14145 switch (result.getType()) {
14146 case icu::Formattable::kDouble:
14147 return *isolate->factory()->NewNumber(result.getDouble());
14148 case icu::Formattable::kLong:
14149 return *isolate->factory()->NewNumberFromInt(result.getLong());
14150 case icu::Formattable::kInt64:
14151 return *isolate->factory()->NewNumber(
14152 static_cast<double>(result.getInt64()));
14154 return isolate->heap()->undefined_value();
14160 HandleScope scope(isolate);
14162 ASSERT(args.length() == 3);
14171 bool has_pending_exception =
false;
14173 collator_template, &has_pending_exception);
14174 if (has_pending_exception) {
14175 ASSERT(isolate->has_pending_exception());
14181 isolate, locale, options, resolved);
14183 if (!collator)
return isolate->ThrowIllegalOperation();
14185 local_object->SetInternalField(0, reinterpret_cast<Smi*>(collator));
14190 isolate->factory()->NewStringFromAscii(
CStrVector(
"collator")),
14191 isolate->factory()->NewStringFromAscii(
CStrVector(
"valid")),
14194 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object);
14196 reinterpret_cast<void*
>(wrapper.location()),
14198 return *local_object;
14203 HandleScope scope(isolate);
14205 ASSERT(args.length() == 3);
14212 if (!collator)
return isolate->ThrowIllegalOperation();
14216 const UChar* u_string1 =
reinterpret_cast<const UChar*
>(*string_value1);
14217 const UChar* u_string2 =
reinterpret_cast<const UChar*
>(*string_value2);
14218 UErrorCode status = U_ZERO_ERROR;
14219 UCollationResult result = collator->compare(u_string1,
14220 string_value1.length(),
14222 string_value2.length(),
14224 if (U_FAILURE(status))
return isolate->ThrowIllegalOperation();
14226 return *isolate->factory()->NewNumberFromInt(result);
14231 HandleScope scope(isolate);
14232 static const UNormalizationMode normalizationForms[] =
14233 { UNORM_NFC, UNORM_NFD, UNORM_NFKC, UNORM_NFKD };
14235 ASSERT(args.length() == 2);
14241 const UChar* u_value =
reinterpret_cast<const UChar*
>(*string_value);
14244 UErrorCode status = U_ZERO_ERROR;
14245 icu::UnicodeString result;
14246 icu::Normalizer::normalize(u_value, normalizationForms[form_id], 0,
14248 if (U_FAILURE(status)) {
14249 return isolate->heap()->undefined_value();
14252 return *isolate->factory()->NewStringFromTwoByte(
14253 Vector<const uint16_t>(
14254 reinterpret_cast<const uint16_t*>(result.getBuffer()),
14260 HandleScope scope(isolate);
14262 ASSERT(args.length() == 3);
14268 Handle<ObjectTemplateInfo> break_iterator_template =
14272 bool has_pending_exception =
false;
14274 break_iterator_template, &has_pending_exception);
14275 if (has_pending_exception) {
14276 ASSERT(isolate->has_pending_exception());
14282 isolate, locale, options, resolved);
14284 if (!break_iterator)
return isolate->ThrowIllegalOperation();
14286 local_object->SetInternalField(0, reinterpret_cast<Smi*>(break_iterator));
14288 local_object->SetInternalField(1, reinterpret_cast<Smi*>(
NULL));
14293 isolate->factory()->NewStringFromAscii(
CStrVector(
"breakIterator")),
14294 isolate->factory()->NewStringFromAscii(
CStrVector(
"valid")),
14299 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object);
14301 reinterpret_cast<void*
>(wrapper.location()),
14303 return *local_object;
14308 HandleScope scope(isolate);
14310 ASSERT(args.length() == 2);
14315 icu::BreakIterator* break_iterator =
14317 if (!break_iterator)
return isolate->ThrowIllegalOperation();
14319 icu::UnicodeString* u_text =
reinterpret_cast<icu::UnicodeString*
>(
14320 break_iterator_holder->GetInternalField(1));
14324 u_text =
new icu::UnicodeString(
14325 reinterpret_cast<const UChar*>(*text_value), text_value.length());
14326 break_iterator_holder->SetInternalField(1, reinterpret_cast<Smi*>(u_text));
14328 break_iterator->setText(*u_text);
14330 return isolate->heap()->undefined_value();
14335 HandleScope scope(isolate);
14337 ASSERT(args.length() == 1);
14341 icu::BreakIterator* break_iterator =
14343 if (!break_iterator)
return isolate->ThrowIllegalOperation();
14345 return *isolate->factory()->NewNumberFromInt(break_iterator->first());
14350 HandleScope scope(isolate);
14352 ASSERT(args.length() == 1);
14356 icu::BreakIterator* break_iterator =
14358 if (!break_iterator)
return isolate->ThrowIllegalOperation();
14360 return *isolate->factory()->NewNumberFromInt(break_iterator->next());
14365 HandleScope scope(isolate);
14367 ASSERT(args.length() == 1);
14371 icu::BreakIterator* break_iterator =
14373 if (!break_iterator)
return isolate->ThrowIllegalOperation();
14375 return *isolate->factory()->NewNumberFromInt(break_iterator->current());
14380 HandleScope scope(isolate);
14382 ASSERT(args.length() == 1);
14386 icu::BreakIterator* break_iterator =
14388 if (!break_iterator)
return isolate->ThrowIllegalOperation();
14391 icu::RuleBasedBreakIterator* rule_based_iterator =
14392 static_cast<icu::RuleBasedBreakIterator*
>(break_iterator);
14393 int32_t status = rule_based_iterator->getRuleStatus();
14395 if (status >= UBRK_WORD_NONE && status < UBRK_WORD_NONE_LIMIT) {
14396 return *isolate->factory()->NewStringFromAscii(
CStrVector(
"none"));
14397 }
else if (status >= UBRK_WORD_NUMBER && status < UBRK_WORD_NUMBER_LIMIT) {
14398 return *isolate->factory()->NewStringFromAscii(
CStrVector(
"number"));
14399 }
else if (status >= UBRK_WORD_LETTER && status < UBRK_WORD_LETTER_LIMIT) {
14400 return *isolate->factory()->NewStringFromAscii(
CStrVector(
"letter"));
14401 }
else if (status >= UBRK_WORD_KANA && status < UBRK_WORD_KANA_LIMIT) {
14402 return *isolate->factory()->NewStringFromAscii(
CStrVector(
"kana"));
14403 }
else if (status >= UBRK_WORD_IDEO && status < UBRK_WORD_IDEO_LIMIT) {
14404 return *isolate->factory()->NewStringFromAscii(
CStrVector(
"ideo"));
14406 return *isolate->factory()->NewStringFromAscii(
CStrVector(
"unknown"));
14409 #endif // V8_I18N_SUPPORT
14418 static Handle<Object> Runtime_GetScriptFromScriptName(
14419 Handle<String> script_name) {
14422 Handle<Script> script;
14423 Factory* factory = script_name->GetIsolate()->factory();
14424 Heap* heap = script_name->GetHeap();
14425 heap->EnsureHeapIsIterable();
14427 HeapIterator iterator(heap);
14428 HeapObject* obj =
NULL;
14429 while (script.is_null() && ((obj = iterator.next()) !=
NULL)) {
14431 if (obj->IsScript()) {
14441 if (script.is_null())
return factory->undefined_value();
14454 ASSERT(args.length() == 1);
14476 isolate->CaptureAndSetDetailedStackTrace(error_object);
14478 return *isolate->CaptureSimpleStackTrace(error_object, caller, limit);
14488 Handle<String> key = isolate->factory()->hidden_stack_trace_string();
14489 Handle<Object> result(error_object->GetHiddenProperty(*key), isolate);
14490 if (result->IsTheHole())
return isolate->heap()->undefined_value();
14499 SealHandleScope shs(isolate);
14504 return isolate->heap()->AllocateStringFromOneByte(
CStrVector(version_string),
14510 SealHandleScope shs(isolate);
14511 ASSERT(args.length() == 1);
14514 static_cast<BailoutReason>(message_id));
14516 isolate->PrintStack(stderr);
14525 ASSERT(args.length() == 1);
14528 isolate->PrintStack(stderr);
14537 ASSERT(args.length() == 1);
14540 return isolate->heap()->undefined_value();
14546 ASSERT(args.length() == 0);
14547 isolate->heap()->NotifyContextDisposed();
14548 return isolate->heap()->undefined_value();
14554 ASSERT(args.length() == 1);
14558 if (!js_object->map()->is_deprecated())
return Smi::FromInt(0);
14570 SealHandleScope shs(isolate);
14575 int finger_index = cache->finger_index();
14576 Object* o = cache->get(finger_index);
14579 return cache->get(finger_index + 1);
14582 for (
int i = finger_index - 2;
14587 cache->set_finger_index(i);
14588 return cache->get(i + 1);
14592 int size = cache->size();
14593 ASSERT(size <= cache->length());
14595 for (
int i = size - 2; i > finger_index; i -= 2) {
14598 cache->set_finger_index(i);
14599 return cache->get(i + 1);
14613 Handle<Object> receiver(isolate->native_context()->global_object(),
14617 bool pending_exception;
14623 &pending_exception);
14628 if (FLAG_verify_heap) {
14629 cache_handle->JSFunctionResultCacheVerify();
14634 finger_index = cache_handle->finger_index();
14635 size = cache_handle->size();
14640 if (size < cache_handle->length()) {
14645 if (index == cache_handle->length()) {
14652 ASSERT(index < cache_handle->length());
14654 cache_handle->set(index, *key_handle);
14655 cache_handle->set(index + 1, *value);
14656 cache_handle->set_finger_index(index);
14659 if (FLAG_verify_heap) {
14660 cache_handle->JSFunctionResultCacheVerify();
14669 SealHandleScope shs(isolate);
14676 SealHandleScope shs(isolate);
14687 ASSERT(args.length() == 0);
14688 #define COUNT_ENTRY(Name, argc, ressize) + 1
14689 int entry_count = 0
14694 Factory* factory = isolate->factory();
14697 bool inline_runtime_functions =
false;
14698 #define ADD_ENTRY(Name, argc, ressize) \
14700 HandleScope inner(isolate); \
14701 Handle<String> name; \
14703 if (inline_runtime_functions) { \
14704 name = factory->NewStringFromAscii( \
14705 Vector<const char>("_" #Name, StrLength("_" #Name))); \
14707 name = factory->NewStringFromAscii( \
14708 Vector<const char>(#Name, StrLength(#Name))); \
14710 Handle<FixedArray> pair_elements = factory->NewFixedArray(2); \
14711 pair_elements->set(0, *name); \
14712 pair_elements->set(1, Smi::FromInt(argc)); \
14713 Handle<JSArray> pair = factory->NewJSArrayWithElements(pair_elements); \
14714 elements->set(index++, *pair); \
14716 inline_runtime_functions =
false;
14720 inline_runtime_functions =
true;
14732 ASSERT(args.length() == 2);
14737 isolate->logger()->LogRuntime(
14739 return isolate->heap()->undefined_value();
14749 #define ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(Name) \
14750 RUNTIME_FUNCTION(MaybeObject*, Runtime_Has##Name) { \
14751 CONVERT_ARG_CHECKED(JSObject, obj, 0); \
14752 return isolate->heap()->ToBoolean(obj->Has##Name()); \
14766 #undef ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION
14769 #define TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION(Type, type, TYPE, ctype, size) \
14770 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasExternal##Type##Elements) { \
14771 CONVERT_ARG_CHECKED(JSObject, obj, 0); \
14772 return isolate->heap()->ToBoolean(obj->HasExternal##Type##Elements()); \
14777 #undef TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION
14780 #define FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION(Type, type, TYPE, ctype, s) \
14781 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasFixed##Type##Elements) { \
14782 CONVERT_ARG_CHECKED(JSObject, obj, 0); \
14783 return isolate->heap()->ToBoolean(obj->HasFixed##Type##Elements()); \
14788 #undef FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION
14792 SealHandleScope shs(isolate);
14793 ASSERT(args.length() == 2);
14796 return isolate->heap()->ToBoolean(obj1->map() == obj2->map());
14801 SealHandleScope shs(isolate);
14802 ASSERT(args.length() == 1);
14804 return isolate->heap()->ToBoolean(obj->IsAccessCheckNeeded());
14809 SealHandleScope shs(isolate);
14810 ASSERT(args.length() == 1);
14812 if (!args[0]->IsJSReceiver())
return isolate->heap()->false_value();
14814 if (obj->IsJSGlobalProxy()) {
14816 if (proto->IsNull())
return isolate->heap()->false_value();
14817 ASSERT(proto->IsJSGlobalObject());
14826 ASSERT(args.length() == 1);
14828 if (obj->IsJSGlobalProxy()) {
14830 if (proto->IsNull())
return isolate->heap()->undefined_value();
14831 ASSERT(proto->IsJSGlobalObject());
14834 if (obj->IsJSProxy())
14835 return isolate->heap()->undefined_value();
14837 ASSERT(!(obj->map()->is_observed() && obj->IsJSObject() &&
14839 ASSERT(obj->IsJSObject());
14841 return isolate->heap()->undefined_value();
14846 SealHandleScope shs(isolate);
14847 ASSERT(args.length() == 1);
14849 bool old_state = isolate->microtask_pending();
14850 isolate->set_microtask_pending(new_state);
14851 return isolate->heap()->ToBoolean(old_state);
14857 ASSERT(args.length() == 0);
14858 if (isolate->microtask_pending())
14860 return isolate->heap()->undefined_value();
14865 SealHandleScope shs(isolate);
14866 ASSERT(args.length() == 0);
14867 return isolate->heap()->microtask_state();
14872 SealHandleScope shs(isolate);
14873 ASSERT(args.length() == 0);
14874 return isolate->heap()->observation_state();
14880 ASSERT(args.length() == 0);
14888 return WeakCollectionInitialize(isolate, weakmap);
14893 SealHandleScope shs(isolate);
14894 ASSERT(args.length() == 1);
14895 Object*
object = args[0];
14896 if (object->IsJSGlobalProxy()) {
14898 if (object->IsNull())
return isolate->heap()->undefined_value();
14906 ASSERT(args.length() == 3);
14909 ASSERT(object->map()->is_access_check_needed());
14911 SaveContext save(isolate);
14912 isolate->set_context(observer->context());
14913 if (!isolate->MayNamedAccessWrapper(
object,
14914 isolate->factory()->undefined_value(),
14916 return isolate->heap()->false_value();
14918 bool access_allowed =
false;
14919 uint32_t index = 0;
14920 if (key->ToArrayIndex(&index) ||
14923 isolate->MayIndexedAccessWrapper(
object, index,
v8::ACCESS_GET) &&
14924 isolate->MayIndexedAccessWrapper(
object, index,
v8::ACCESS_HAS);
14930 return isolate->heap()->ToBoolean(access_allowed);
14934 static MaybeObject* ArrayConstructorCommon(
Isolate* isolate,
14937 Arguments* caller_args) {
14938 Factory* factory = isolate->factory();
14940 bool holey =
false;
14941 bool can_use_type_feedback =
true;
14942 if (caller_args->length() == 1) {
14944 if (argument_one->IsSmi()) {
14948 can_use_type_feedback =
false;
14949 }
else if (value != 0) {
14954 can_use_type_feedback =
false;
14958 Handle<JSArray> array;
14959 if (!site.is_null() && can_use_type_feedback) {
14970 Handle<Map> initial_map(constructor->
initial_map(), isolate);
14971 if (to_kind != initial_map->elements_kind()) {
14978 Handle<AllocationSite> allocation_site;
14980 allocation_site = site;
14984 initial_map,
NOT_TENURED,
true, allocation_site));
15001 if (!site.is_null() &&
15002 (old_kind != array->GetElementsKind() ||
15003 !can_use_type_feedback)) {
15020 Arguments empty_args(0,
NULL);
15021 bool no_caller_args = args.length() == 2;
15022 ASSERT(no_caller_args || args.length() == 4);
15023 int parameters_start = no_caller_args ? 0 : 1;
15024 Arguments* caller_args = no_caller_args
15026 :
reinterpret_cast<Arguments*
>(args[0]);
15030 if (!no_caller_args) {
15032 ASSERT(arg_count == caller_args->length());
15037 if (!type_info.is_null() &&
15038 *type_info != isolate->heap()->undefined_value()) {
15040 ASSERT(!site->SitePointsToLiteral());
15043 return ArrayConstructorCommon(isolate,
15052 Arguments empty_args(0,
NULL);
15053 bool no_caller_args = args.length() == 1;
15054 ASSERT(no_caller_args || args.length() == 3);
15055 int parameters_start = no_caller_args ? 0 : 1;
15056 Arguments* caller_args = no_caller_args
15058 :
reinterpret_cast<Arguments*
>(args[0]);
15061 if (!no_caller_args) {
15063 ASSERT(arg_count == caller_args->length());
15066 return ArrayConstructorCommon(isolate,
15081 #define F(name, number_of_args, result_size) \
15082 { Runtime::k##name, Runtime::RUNTIME, #name, \
15083 FUNCTION_ADDR(Runtime_##name), number_of_args, result_size },
15086 #define FH(name, number_of_args, result_size) \
15087 { Runtime::kHidden##name, Runtime::RUNTIME_HIDDEN, NULL, \
15088 FUNCTION_ADDR(RuntimeHidden_##name), number_of_args, result_size },
15091 #define I(name, number_of_args, result_size) \
15092 { Runtime::kInline##name, Runtime::INLINE, \
15093 "_" #name, NULL, number_of_args, result_size },
15096 #define IO(name, number_of_args, result_size) \
15097 { Runtime::kInlineOptimized##name, Runtime::INLINE_OPTIMIZED, \
15098 "_" #name, FUNCTION_ADDR(Runtime_##name), number_of_args, result_size },
15101 static const Runtime::Function kIntrinsicFunctions[] = {
15119 const char* name = kIntrinsicFunctions[i].
name;
15120 if (name ==
NULL)
continue;
15122 { MaybeObject* maybe_name_string =
15124 if (!maybe_name_string->ToObject(&name_string))
return maybe_name_string;
15127 { MaybeObject* maybe_dictionary = name_dictionary->
Add(
15131 if (!maybe_dictionary->ToObject(&dictionary)) {
15134 return maybe_dictionary;
15143 Heap* heap = name->GetHeap();
15144 int entry = heap->intrinsic_function_names()->FindEntry(*name);
15146 Object* smi_index = heap->intrinsic_function_names()->ValueAt(entry);
15148 return &(kIntrinsicFunctions[function_index]);
15155 return &(kIntrinsicFunctions[
static_cast<int>(id)]);
15161 if (failure->IsRetryAfterGC()) {
15169 "Runtime::PerformGC");
15173 isolate->
counters()->gc_last_resort_from_js()->Increment();
15175 "Runtime::PerformGC");
Handle< AllocationSite > EnterNewScope()
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter NULL
#define INLINE_FUNCTION_LIST(F)
static Handle< Object > SetElement(Handle< JSObject > object, uint32_t index, Handle< Object > value, PropertyAttributes attributes, StrictMode strict_mode, bool check_prototype=true, SetPropertyMode set_mode=SET_PROPERTY)
#define CHECK_NOT_EMPTY_HANDLE(isolate, call)
static Handle< Object > New(Handle< JSFunction > func, int argc, Handle< Object > argv[], bool *pending_exception)
STATIC_CHECK((kStringRepresentationMask|kStringEncodingMask)==Internals::kFullStringRepresentationMask)
static const int kMaxLength
static void Destroy(Object **location)
void FlattenString(Handle< String > string)
int allow_osr_at_loop_nesting_level()
Handle< JSObject > NewJSObject(Handle< JSFunction > constructor, PretenureFlag pretenure=NOT_TENURED)
static const int kNotFound
#define CHECK_EQ(expected, value)
FixedArray * function_bindings()
static Object *& Object_at(Address addr)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in only print modified registers Don t break for ASM_UNIMPLEMENTED_BREAK macros print stack trace when an illegal exception is thrown randomize hashes to avoid predictable hash Fixed seed to use to hash property keys(0 means random)" "(with snapshots this option cannot override the baked-in seed)") DEFINE_bool(profile_deserialization
bool IsExternalArrayElementsKind(ElementsKind kind)
Handle< Context > NewModuleContext(Handle< ScopeInfo > scope_info)
#define DATA_VIEW_SETTER(TypeName, Type)
bool exceeds_array_limit()
int inobject_properties()
int16_t DataViewConvertValue< int16_t >(double value)
static Handle< Object > SetPropertyWithCallback(Handle< JSObject > object, Handle< Object > structure, Handle< Name > name, Handle< Object > value, Handle< JSObject > holder, StrictMode strict_mode)
static const int kNotFound
ElementsKind GetPackedElementsKind(ElementsKind holey_kind)
int Lookup(Map *map, Name *name)
#define CONVERT_SMI_ARG_CHECKED(name, index)
#define RETURN_IF_SCHEDULED_EXCEPTION(isolate)
static const int kGlobalFieldIndex
bool is_hidden_prototype()
void set(int index, Object *value)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths true
#define CONVERT_DOUBLE_ARG_CHECKED(name, index)
#define ARRAY_ID_CASE(Type, type, TYPE, ctype, size)
void PrintF(const char *format,...)
void CollectAllGarbage(int flags, const char *gc_reason=NULL, const GCCallbackFlags gc_callback_flags=kNoGCCallbackFlags)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf map
bool InNewSpace(Object *object)
static Handle< Object > ToNumber(Isolate *isolate, Handle< Object > obj, bool *exc)
static String * cast(Object *obj)
MUST_USE_RESULT MaybeObject * Add(Key key, Object *value, PropertyDetails details)
int64_t ToUTC(int64_t time_ms)
MaybeObject * TryFlatten(PretenureFlag pretenure=NOT_TENURED)
static void DeleteHiddenProperty(Handle< JSObject > object, Handle< Name > key)
uint32_t NumberToUint32(Object *number)
void ClearTypeFeedbackInfo(Heap *heap)
static void SetObserved(Handle< JSObject > object)
Object * ToBoolean(bool condition)
bool Compile(Handle< String > replacement, int capture_count, int subject_length)
double DoubleToInteger(double x)
void ReportFailedAccessCheckWrapper(Handle< JSObject > receiver, v8::AccessType type)
int64_t AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes)
void set_length(Smi *length)
static Smi * FromInt(int value)
bool IsFastObjectElementsKind(ElementsKind kind)
static Handle< Code > GetUnoptimizedCode(Handle< JSFunction > function)
v8::Handle< v8::Array > GetKeysForIndexedInterceptor(Handle< JSReceiver > receiver, Handle< JSObject > object)
static const Function * FunctionForName(Handle< String > name)
static Handle< Map > Copy(Handle< Map > map)
uint8_t DataViewConvertValue< uint8_t >(double value)
uint64_t double_to_uint64(double d)
virtual void * AllocateUninitialized(size_t length)=0
static MemoryChunk * FromAddress(Address a)
static Handle< ObjectTemplateInfo > GetTemplate(Isolate *isolate)
static Handle< JSFunction > GetFunctionFromEval(Handle< String > source, Handle< Context > context, StrictMode strict_mode, ParseRestriction restriction, int scope_position)
MaybeObject * TransitionElements(Handle< Object > object, ElementsKind to_kind, Isolate *isolate)
static HeapObject * cast(Object *obj)
static Handle< T > cast(Handle< S > that)
double power_helper(double x, double y)
bool is_access_check_needed()
static const int kSourceFieldIndex
#define DATA_VIEW_GETTER(TypeName, Type, Converter)
static bool Analyze(CompilationInfo *info)
#define TYPED_ARRAY_GETTER(getter, accessor)
static AccessorPair * cast(Object *obj)
static const int64_t kMaxTimeBeforeUTCInMs
static Handle< FixedArray > GetElements(Handle< FixedArray > value)
double fast_sqrt(double input)
void RestoreOperandStack(FixedArray *store, int stack_handler_index)
static Handle< Object > CreateRegExpLiteral(Handle< JSFunction > constructor, Handle< String > pattern, Handle< String > flags, bool *has_pending_exception)
static Map * cast(Object *obj)
static bool Parse(Vector< Char > str, FixedArray *output, UnicodeCache *cache)
void IncrementCharacterCount(int by)
void SaveOperandStack(FixedArray *store, int *stack_handler_index) const
static void EnsureCanContainHeapObjectElements(Handle< JSObject > obj)
BailoutType bailout_type() const
static const uint32_t kMaxElementCount
kSerializedDataOffset Object
static Handle< Object > SetPrototype(Handle< JSObject > object, Handle< Object > value, bool skip_hidden_prototypes=false)
static bool HasRealNamedProperty(Handle< JSObject > object, Handle< Name > key)
static const int kGeneratorClosed
TypeImpl< ZoneTypeConfig > Type
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in only print modified registers Don t break for ASM_UNIMPLEMENTED_BREAK macros print stack trace when an illegal exception is thrown randomize hashes to avoid predictable hash Fixed seed to use to hash property Print the time it takes to deserialize the snapshot testing_bool_flag testing_int_flag string flag tmp file in which to serialize heap Print the time it takes to lazily compile hydrogen code stubs concurrent_recompilation concurrent_sweeping Print usage message
static AllocationSite * cast(Object *obj)
static void DeleteCollator(const v8::WeakCallbackData< v8::Value, void > &data)
size_t NumberToSize(Isolate *isolate, Object *number)
bool SameValue(Object *other)
static SeqOneByteString * cast(Object *obj)
WriteBarrierMode GetWriteBarrierMode(const DisallowHeapAllocation &promise)
static Failure * Exception()
static Handle< Object > GetFunctionDelegate(Isolate *isolate, Handle< Object > object)
int Search(Vector< const SubjectChar > subject, int index)
bool MayIndexedAccessWrapper(Handle< JSObject > receiver, uint32_t index, v8::AccessType type)
static ScopeInfo * Empty(Isolate *isolate)
#define CONVERT_STRICT_MODE_ARG_CHECKED(name, index)
PropertyDescriptorIndices
#define RUNTIME_ARGUMENTS(isolate, args)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in only print modified registers Don t break for ASM_UNIMPLEMENTED_BREAK macros print stack trace when an illegal exception is thrown randomize hashes to avoid predictable hash Fixed seed to use to hash property Print the time it takes to deserialize the snapshot testing_bool_flag testing_int_flag string flag tmp file in which to serialize heap Print the time it takes to lazily compile hydrogen code stubs concurrent_recompilation concurrent_sweeping Print usage including on console Map counters to a file Enable debugger compile events enable GDBJIT enable GDBJIT interface for all code objects dump only objects containing this substring stress the GC compactor to flush out pretty print source code print source AST function name where to insert a breakpoint print scopes for builtins trace contexts operations print stuff during garbage collection report code statistics after GC report handles after GC trace cache state transitions print interface inference details prints when objects are turned into dictionaries report heap spill statistics along with trace isolate state changes trace regexp bytecode execution Minimal Log all events to the log file Log API events to the log file Log heap samples on garbage collection for the hp2ps tool log positions Log suspect operations Used with turns on browser compatible mode for profiling v8 log
static const Function * FunctionForId(FunctionId id)
static Handle< Object > GetPropertyWithCallback(Handle< JSObject > object, Handle< Object > receiver, Handle< Object > structure, Handle< Name > name)
Context * global_context()
static bool EnsureCompiled(Handle< JSFunction > function, ClearExceptionFlag flag)
Handle< FixedArray > UnionOfKeys(Handle< FixedArray > first, Handle< FixedArray > second)
BitField< int, 0, kStringBuilderConcatHelperLengthBits > StringBuilderSubstringLength
static Handle< Object > SetHiddenProperty(Handle< JSObject > object, Handle< Name > key, Handle< Object > value)
static Handle< Object > NewDate(Isolate *isolate, double time, bool *exc)
Handle< Object > ArrayConstructInitializeElements(Handle< JSArray > array, Arguments *args)
#define ASSERT(condition)
static void DeoptimizeFunction(JSFunction *function)
#define ASSERT_GE(v1, v2)
virtual void * Allocate(size_t length)=0
Handle< JSArray > ToArray()
static void DeleteBreakIterator(const v8::WeakCallbackData< v8::Value, void > &data)
static Handle< Object > SetLocalPropertyIgnoreAttributes(Handle< JSObject > object, Handle< Name > key, Handle< Object > value, PropertyAttributes attributes, ValueType value_type=OPTIMAL_REPRESENTATION, StoreMode mode=ALLOW_AS_CONSTANT, ExtensibilityCheck extensibility_check=PERFORM_EXTENSIBILITY_CHECK)
int IntegerLog2(uint32_t value)
KeyedLookupCache * keyed_lookup_cache()
static Handle< JSObject > DeepCopy(Handle< JSObject > object, AllocationSiteUsageContext *site_context, DeepCopyHints hints=kNoHints)
void LocalLookup(Name *name, LookupResult *result, bool search_hidden_prototypes=false)
static Handle< Object > TryGetFunctionDelegate(Isolate *isolate, Handle< Object > object, bool *has_pending_exception)
Handle< JSArray > GetKeysFor(Handle< JSReceiver > object, bool *threw)
static Script * cast(Object *obj)
Handle< JSFunction > function() const
Handle< AllocationSite > EnterNewScope()
ArrayConcatVisitor(Isolate *isolate, Handle< FixedArray > storage, bool fast_elements)
static Context * cast(Object *context)
static SharedFunctionInfo * cast(Object *obj)
static Handle< Object > SetAccessor(Handle< JSObject > object, Handle< AccessorInfo > info)
static Handle< Object > FunctionSetPrototype(Handle< JSFunction > object, Handle< Object > value)
void MaterializeHeapObjects(JavaScriptFrameIterator *it)
static v8::ArrayBuffer::Allocator * ArrayBufferAllocator()
Object * DataAt(int index)
Handle< Object > NewNumber(double value, PretenureFlag pretenure=NOT_TENURED)
static bool HasHiddenProperties(Handle< JSObject > object)
bool IsInternalError() const
FixedArrayBuilder(Handle< FixedArray > backing_store)
int isless(double x, double y)
#define IO(name, number_of_args, result_size)
static icu::BreakIterator * InitializeBreakIterator(Isolate *isolate, Handle< String > locale, Handle< JSObject > options, Handle< JSObject > resolved)
Handle< Object > GetProperty(Handle< JSReceiver > obj, const char *name)
void set_module(JSModule *module)
#define RETURN_IF_EMPTY_HANDLE(isolate, call)
bool IsFastElementsKind(ElementsKind kind)
void Lookup(Name *name, LookupResult *result)
static void NeuterArrayBuffer(Handle< JSArrayBuffer > array_buffer)
ActivationsFinder(Code *code)
static const int kInternalFieldCount
OptimizedCompileJob * FindReadyOSRCandidate(Handle< JSFunction > function, BailoutId osr_ast_id)
static Handle< Object > Freeze(Handle< JSObject > object)
void visit(uint32_t i, Handle< Object > elm)
int ComputeParametersCount() const
PerThreadAssertScopeDebugOnly< HEAP_ALLOCATION_ASSERT, true > AllowHeapAllocation
static void AddStackCheck(Handle< Code > code, uint32_t pc_offset)
#define CALL_HEAP_FUNCTION_PASS_EXCEPTION(ISOLATE, FUNCTION_CALL)
bool has_code_activations_
static MUST_USE_RESULT MaybeObject * HasObjectProperty(Isolate *isolate, Handle< JSReceiver > object, Handle< Object > key)
void EnsureCapacity(int elements)
bool AsArrayIndex(uint32_t *index)
static Symbol * cast(Object *obj)
void SetDoNotInlineCall()
static MUST_USE_RESULT Handle< String > Truncate(Handle< SeqString > string, int new_length)
#define RUNTIME_FUNCTION_LIST(F)
Object * GetValue(int descriptor_number)
static bool HasElement(Handle< JSReceiver > object, uint32_t index)
static Object ** RawField(HeapObject *obj, int offset)
#define RETURN_IF_EMPTY_HANDLE_VALUE(isolate, call, value)
bool MayNamedAccessWrapper(Handle< JSObject > receiver, Handle< Object > key, v8::AccessType type)
static Smi * cast(Object *object)
Handle< String > FlattenGetString(Handle< String > string)
void FindStringIndices(Isolate *isolate, Vector< const SubjectChar > subject, Vector< const PatternChar > pattern, ZoneList< int > *indices, unsigned int limit, Zone *zone)
bool Equals(String *other)
static const int kHeaderSize
static MUST_USE_RESULT MaybeObject * InitializeIntrinsicFunctionNames(Heap *heap, Object *dictionary)
static const int kMultilineFieldIndex
void set_closure(JSFunction *closure)
kInstanceClassNameOffset flag
static ScopeInfo * cast(Object *object)
static Handle< ObjectHashSet > Add(Handle< ObjectHashSet > table, Handle< Object > key)
int get(uchar c, uchar n, uchar *result)
static void TransitionElementsKind(Handle< JSObject > object, ElementsKind to_kind)
static Handle< Object > TryMigrateInstance(Handle< JSObject > instance)
static const int kInternalFieldCount
#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 void SetContent(Handle< JSArray > array, Handle< FixedArrayBase > storage)
Handle< SeededNumberDictionary > DictionaryAtNumberPut(Handle< SeededNumberDictionary >, uint32_t key, Handle< Object > value)
Object * receiver() const
static Handle< Code > GetConcurrentlyOptimizedCode(OptimizedCompileJob *job)
static MUST_USE_RESULT MaybeObject * DeleteObjectProperty(Isolate *isolate, Handle< JSReceiver > object, Handle< Object > key, JSReceiver::DeleteMode mode)
double fast_exp(double input)
static void DefineAccessor(Handle< JSObject > object, Handle< Name > name, Handle< Object > getter, Handle< Object > setter, PropertyAttributes attributes, v8::AccessControl access_control=v8::DEFAULT)
V8_INLINE bool IsNull() const
static Handle< Object > CharAt(Handle< String > str, uint32_t index)
static bool CopyContextLocalsToScopeObject(Handle< ScopeInfo > scope_info, Handle< Context > context, Handle< JSObject > scope_object)
Handle< Object > Lookup(Handle< String > name, ContextLookupFlags flags, int *index, PropertyAttributes *attributes, BindingFlags *binding_flags)
static JSGeneratorObject * cast(Object *obj)
Handle< Code > compiled_code() const
static const int kLiteralNativeContextIndex
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction pairs(ARM only)") DEFINE_bool(enable_unaligned_accesses
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long mode(MIPS only)") DEFINE_string(expose_natives_as
Handle< JSArray > ToJSArray(Handle< JSArray > target_array)
static Handle< ObjectTemplateInfo > GetTemplate2(Isolate *isolate)
double StringToInt(UnicodeCache *unicode_cache, String *str, int radix)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object size
void set_global_object(GlobalObject *object)
Handle< SeqTwoByteString > NewRawTwoByteString(int length, PretenureFlag pretenure=NOT_TENURED)
static SeededNumberDictionary * cast(Object *obj)
static const int kFactoryIndex
void Apply(ReplacementStringBuilder *builder, int match_from, int match_to, int32_t *match)
bool IsConstructor() const
STATIC_ASSERT(sizeof(CPURegister)==sizeof(Register))
static icu::Collator * UnpackCollator(Isolate *isolate, Handle< JSObject > obj)
static const int kInputIndex
Handle< String > NewSubString(Handle< String > str, int begin, int end)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in only print modified registers Don t break for ASM_UNIMPLEMENTED_BREAK macros print stack trace when an illegal exception is thrown randomize hashes to avoid predictable hash Fixed seed to use to hash property Print the time it takes to deserialize the snapshot testing_bool_flag testing_int_flag string flag tmp file in which to serialize heap Print the time it takes to lazily compile hydrogen code stubs concurrent_recompilation concurrent_sweeping Print usage including flags
#define CONVERT_BOOLEAN_ARG_CHECKED(name, index)
virtual void Free(void *data, size_t length)=0
static LiteralType GetLiteralType(Handle< FixedArray > value)
static ThreadId Current()
MUST_USE_RESULT MaybeObject * AsElementsKind(ElementsKind kind)
Context * native_context()
int FastD2IChecked(double x)
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
static Handle< Map > GetElementsTransitionMap(Handle< JSObject > object, ElementsKind to_kind)
static void PrintTop(Isolate *isolate, FILE *file, bool print_args, bool print_line_number)
static void AddSubjectSlice(FixedArrayBuilder *builder, int from, int to)
bool TryNumberToSize(Isolate *isolate, Object *number, size_t *result)
void check(i::Vector< const uint8_t > string)
static ModuleInfo * cast(Object *description)
Handle< Object > NewTypeError(const char *message, Vector< Handle< Object > > args)
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
void lazily_initialize_fast_exp()
static Handle< JSArray > SetLastMatchInfo(Handle< JSArray > last_match_info, Handle< String > subject, int capture_count, int32_t *match)
static void PerformGC(Object *result, Isolate *isolate)
const char * DoubleToCString(double v, Vector< char > buffer)
int ComputeOperandsCount() const
static Handle< Object > GetPropertyWithInterceptor(Handle< JSObject > object, Handle< Object > receiver, Handle< Name > name, PropertyAttributes *attributes)
bool IsAligned(T value, U alignment)
Object * GetPrototype(Isolate *isolate)
#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName)
static Handle< Object > ForceSetObjectProperty(Isolate *isolate, Handle< JSObject > object, Handle< Object > key, Handle< Object > value, PropertyAttributes attr)
Object * RawFastPropertyAt(int index)
static const int64_t kMaxTimeInMs
double power_double_double(double x, double y)
static Handle< ObjectHashSet > Remove(Handle< ObjectHashSet > table, Handle< Object > key)
static Handle< Code > GetOptimizedCode(Handle< JSFunction > function, Handle< Code > current_code, ConcurrencyMode mode, BailoutId osr_ast_id=BailoutId::None())
GlobalHandles * global_handles()
Handle< JSValue > GetScriptWrapper(Handle< Script > script)
bool IsMoreGeneralElementsKindTransition(ElementsKind from_kind, ElementsKind to_kind)
AllocationSpace allocation_space() const
void increase_index_offset(uint32_t delta)
static void TransformToFastProperties(Handle< JSObject > object, int unused_property_fields)
const uintptr_t kUintptrAllBitsSet
static const int kMaxRegularHeapObjectSize
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra code(assertions) for debugging") DEFINE_bool(code_comments
static void Enter(Heap *heap, String *key_string, Object *key_pattern, FixedArray *value_array, ResultsCacheType type)
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
double uint64_to_double(uint64_t d64)
static Handle< Object > Exec(Handle< JSRegExp > regexp, Handle< String > subject, int index, Handle< JSArray > lastMatchInfo)
Vector< const uc16 > ToUC16Vector()
static PropertyAttributes GetPropertyAttribute(Handle< JSReceiver > object, Handle< Name > name)
double modulo(double x, double y)
double DataViewConvertValue< double >(double value)
static JSTypedArray * cast(Object *obj)
void EnsureCapacity(int elements)
Handle< FixedArray > GetKeysInFixedArrayFor(Handle< JSReceiver > object, KeyCollectionType type, bool *threw)
static double TimeCurrentMillis()
static FixedDoubleArray * cast(Object *obj)
static NameDictionary * cast(Object *obj)
ElementsKind GetElementsKind()
static Handle< Object > TryGetConstructorDelegate(Isolate *isolate, Handle< Object > object, bool *has_pending_exception)
static Handle< Object > SetOwnElement(Handle< JSObject > object, uint32_t index, Handle< Object > value, StrictMode strict_mode)
bool IsFastSmiElementsKind(ElementsKind kind)
Handle< String > ToString()
static const int kMakeHeapIterableMask
static const int kIgnoreCaseFieldIndex
double power_double_int(double x, int y)
MUST_USE_RESULT MaybeObject * FastPropertyAt(Representation representation, int index)
static Handle< Object > GetElementOrCharAt(Isolate *isolate, Handle< Object > object, uint32_t index)
int8_t DataViewConvertValue< int8_t >(double value)
static void FatalProcessOutOfMemory(const char *location, bool take_snapshot=false)
int CompareChars(const lchar *lhs, const rchar *rhs, int chars)
PropertyDetails GetDetails(int descriptor_number)
static PropertyCell * cast(Object *obj)
Failure * Throw(Object *exception, MessageLocation *location=NULL)
uint32_t DataViewConvertValue< uint32_t >(double value)
#define RUNTIME_UNARY_MATH(NAME)
#define STATIC_ASCII_VECTOR(x)
static ExternalUint8ClampedArray * cast(Object *obj)
V8_INLINE bool IsUndefined() const
double get_scalar(int index)
static v8::internal::Handle< To > OpenHandle(v8::Local< From > handle)
unibrow::Mapping< unibrow::ToUppercase, 128 > * to_upper_mapping()
static void Fix(Handle< JSProxy > proxy)
static uint32_t MakeArrayIndexHash(uint32_t value, int length)
static Object * Lookup(Heap *heap, String *key_string, Object *key_pattern, ResultsCacheType type)
Handle< FixedArray > CopyFixedArray(Handle< FixedArray > array)
static void Sleep(const int milliseconds)
Vector< const char > CStrVector(const char *data)
bool CollectGarbage(AllocationSpace space, const char *gc_reason=NULL, const GCCallbackFlags gc_callback_flags=kNoGCCallbackFlags)
MUST_USE_RESULT MaybeObject * GetProperty(Name *key)
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)
#define T(name, string, precedence)
CompiledReplacement(Zone *zone)
#define ASSERT_LT(v1, v2)
static const int kMaxLoopNestingMarker
static bool HasProperty(Handle< JSReceiver > object, Handle< Name > name)
bool IsFastSmiOrObjectElementsKind(ElementsKind kind)
void FindStringIndicesDispatch(Isolate *isolate, String *subject, String *pattern, ZoneList< int > *indices, unsigned int limit, Zone *zone)
V8_INLINE bool IsString() const
static int StringMatch(Isolate *isolate, Handle< String > sub, Handle< String > pat, int index)
static Handle< Object > SetFastElement(Handle< JSObject > object, uint32_t index, Handle< Object > value, StrictMode strict_mode, bool check_prototype)
static SeqTwoByteString * cast(Object *obj)
static Handle< AccessorInfo > MakeModuleExport(Handle< String > name, int index, PropertyAttributes attributes)
#define RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, T)
void Lookup(Name *name, LookupResult *result)
void ExitScope(Handle< AllocationSite > scope_site, Handle< JSObject > object)
FlatContent GetFlatContent()
int ArithmeticShiftRight(int x, int s)
void set(int index, double value)
void SetElementsKind(ElementsKind kind)
static JSDataView * cast(Object *obj)
static Handle< Object > FunctionGetArguments(Handle< JSFunction > object)
void Update(Map *map, Name *name, int field_offset)
uint32_t DoubleToUint32(double x)
bool AsArrayIndex(uint32_t *index)
bool has_named_interceptor()
char * DoubleToPrecisionCString(double value, int p)
int32_t DoubleToInt32(double x)
uint16_t DataViewConvertValue< uint16_t >(double value)
static HeapNumber * cast(Object *obj)
static icu::BreakIterator * UnpackBreakIterator(Isolate *isolate, Handle< JSObject > obj)
static void EnqueueChangeRecord(Handle< JSObject > object, const char *type, Handle< Name > name, Handle< Object > old_value)
static void WriteToFlat(String *source, sinkchar *sink, int from, int to)
NameDictionary * property_dictionary()
const int kStringBuilderConcatHelperLengthBits
#define FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION(Type, type, TYPE, ctype, s)
void FindAsciiStringIndices(Vector< const uint8_t > subject, char pattern, ZoneList< int > *indices, unsigned int limit, Zone *zone)
const char * GetBailoutReason(BailoutReason reason)
bool IsWhiteSpaceOrLineTerminator(unibrow::uchar c)
v8::Handle< v8::Array > GetKeysForNamedInterceptor(Handle< JSReceiver > receiver, Handle< JSObject > object)
static double nan_value()
static Handle< Object > GetElementWithInterceptor(Handle< JSObject > object, Handle< Object > receiver, uint32_t index)
static ObjectHashTable * cast(Object *obj)
static Handle< Object > Call(Isolate *isolate, Handle< Object > callable, Handle< Object > receiver, int argc, Handle< Object > argv[], bool *pending_exception, bool convert_receiver=false)
static Handle< Object > SetProperty(Handle< JSReceiver > object, Handle< Name > key, Handle< Object > value, PropertyAttributes attributes, StrictMode strict_mode, StoreFromKeyed store_mode=MAY_BE_STORE_FROM_KEYED)
Handle< T > handle(T *t, Isolate *isolate)
bool is_the_hole(int index)
V8_INLINE bool IsEmpty() const
static void SetNormalizedProperty(Handle< JSObject > object, const LookupResult *result, Handle< Object > value)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function info
int32_t DataViewConvertValue< int32_t >(double value)
#define RUNTIME_ASSERT(value)
Handle< String > LookupSingleCharacterStringFromCode(Isolate *isolate, uint32_t index)
static const int kAtomPatternIndex
void AddSubjectSlice(int from, int to)
static void Revert(Isolate *isolate, Code *unoptimized_code)
static Object * cast(Object *value)
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)
static Handle< Object > CreateArrayLiteralBoilerplate(Isolate *isolate, Handle< FixedArray > literals, Handle< FixedArray > elements)
void VisitFrames(JavaScriptFrameIterator *it)
static icu::Collator * InitializeCollator(Isolate *isolate, Handle< String > locale, Handle< JSObject > options, Handle< JSObject > resolved)
static bool is_valid(T value)
static MUST_USE_RESULT MaybeObject * GetObjectPropertyOrFail(Isolate *isolate, Handle< Object > object, Handle< Object > key)
static Handle< Object > GetConstructorDelegate(Isolate *isolate, Handle< Object > object)
static void MakeWeak(Object **location, void *parameter, WeakCallback weak_callback)
static JSReceiver * cast(Object *obj)
static JSValue * cast(Object *obj)
void CopyBytes(uint8_t *target, uint8_t *source)
Handle< JSModule > NewJSModule(Handle< Context > context, Handle< ScopeInfo > scope_info)
void ShortPrint(FILE *out=stdout)
void AddString(Handle< String > string)
static AllocationSiteMode GetMode(ElementsKind boilerplate_elements_kind)
static void PrintError(const char *format,...)
static void SetupArrayBuffer(Isolate *isolate, Handle< JSArrayBuffer > array_buffer, bool is_external, void *data, size_t allocated_length)
static Handle< SeededNumberDictionary > NormalizeElements(Handle< JSObject > object)
static Handle< T > null()
void ExitScope(Handle< AllocationSite > site, Handle< JSObject > object)
Handle< SeqOneByteString > NewRawOneByteString(int length, PretenureFlag pretenure=NOT_TENURED)
void MemsetPointer(T **dest, U *value, int counter)
#define RUNTIME_HIDDEN_FUNCTION_LIST(F)
void FlipBytes(uint8_t *target, uint8_t *source)
int SearchString(Isolate *isolate, Vector< const SubjectChar > subject, Vector< const PatternChar > pattern, int start_index)
static const int kGeneratorExecuting
void set_is_access_check_needed(bool access_check_needed)
static MUST_USE_RESULT MaybeObject * GetObjectProperty(Isolate *isolate, Handle< Object > object, Handle< Object > key)
#define ASSERT_EQ(v1, v2)
static const int kIndexIndex
bool HasFastObjectElements()
static PropertyAttributes GetLocalPropertyAttribute(Handle< JSReceiver > object, Handle< Name > name)
InstanceType instance_type()
#define CONVERT_ARG_HANDLE_CHECKED(Type, name, index)
static Handle< Object > SetPropertyForResult(Handle< JSObject > object, LookupResult *result, Handle< Name > name, Handle< Object > value, PropertyAttributes attributes, StrictMode strict_mode, StoreFromKeyed store_mode=MAY_BE_STORE_FROM_KEYED)
int32_t NumberToInt32(Object *number)
static Handle< JSObject > InstantiateObject(Handle< ObjectTemplateInfo > data, bool *exc)
#define ASSERT_NE(v1, v2)
PerThreadAssertScopeDebugOnly< HEAP_ALLOCATION_ASSERT, false > DisallowHeapAllocation
static AccessorInfo * cast(Object *obj)
static FixedArray * cast(Object *obj)
void FindTwoByteStringIndices(const Vector< const uc16 > subject, uc16 pattern, ZoneList< int > *indices, unsigned int limit, Zone *zone)
MUST_USE_RESULT MaybeObject * InternalizeUtf8String(const char *str)
static const int kHeaderSize
static bool SetupArrayBufferAllocatingData(Isolate *isolate, Handle< JSArrayBuffer > array_buffer, size_t allocated_length, bool initialize=true)
#define ASSERT_OBJECT_SIZE(size)
Handle< FixedDoubleArray > CopyFixedDoubleArray(Handle< FixedDoubleArray > array)
ElementsKind elements_kind()
void set_previous(Context *context)
static const int kBoundFunctionIndex
Failure * ThrowIllegalOperation()
static Handle< Object > SetObjectProperty(Isolate *isolate, Handle< Object > object, Handle< Object > key, Handle< Object > value, PropertyAttributes attr, StrictMode strict_mode)
static Handle< Object > PreventExtensions(Handle< JSObject > object)
void Add(const T &element, AllocationPolicy allocator=AllocationPolicy())
bool HasCapacity(int elements)
static Handle< ObjectHashTable > Put(Handle< ObjectHashTable > table, Handle< Object > key, Handle< Object > value)
#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size)
static Handle< Object > DeleteElement(Handle< JSReceiver > object, uint32_t index, DeleteMode mode=NORMAL_DELETION)
static void NormalizeProperties(Handle< JSObject > object, PropertyNormalizationMode mode, int expected_additional_properties)
Handle< Object > ErrorMessageForCodeGenerationFromStrings()
bool IsFastHoleyElementsKind(ElementsKind kind)
static Handle< Object > GetElement(Isolate *isolate, Handle< Object > object, uint32_t index)
bool HasOnlyOneByteChars()
Handle< FixedArray > array()
static const int kMaxLength
Local< Object > ToObject() const
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric literals(0o77, 0b11)") DEFINE_bool(harmony_strings
Handle< Object > ForceSetProperty(Handle< JSObject > object, Handle< Object > key, Handle< Object > value, PropertyAttributes attributes)
Object * array_buffers_list()
char * DoubleToExponentialCString(double value, int f)
static Name * cast(Object *obj)
static bool decode(uint32_tvalue)
static JSArrayBuffer * cast(Object *obj)
BitField< int, kStringBuilderConcatHelperLengthBits, kStringBuilderConcatHelperPositionBits > StringBuilderSubstringPosition
bool HasIndexedInterceptor()
static Representation None()
Handle< String > NewConsString(Handle< String > left, Handle< String > right)
static const int kMaxLength
bool IsImmutableVariableMode(VariableMode mode)
static Handle< Object > Compile(Handle< JSRegExp > re, Handle< String > pattern, Handle< String > flags)
static const int kEntrySize
Handle< Object > NewNumberFromSize(size_t value, PretenureFlag pretenure=NOT_TENURED)
Vector< Handle< Object > > HandleVector(v8::internal::Handle< T > *elms, int length)
char * DoubleToRadixCString(double value, int radix)
AccessorPair * GetLocalPropertyAccessorPair(Name *name)
#define FH(name, number_of_args, result_size)
static Handle< Object > DeleteProperty(Handle< JSReceiver > object, Handle< Name > name, DeleteMode mode=NORMAL_DELETION)
static const int kLastIndexFieldIndex
static const int kBoundThisIndex
Vector< const uint8_t > ToOneByteVector()
void DeleteArray(T *array)
static void RunMicrotasks(Isolate *isolate)
static ConsString * cast(Object *obj)
static FixedArrayBase * cast(Object *object)
#define CONVERT_NUMBER_CHECKED(type, name, Type, obj)
static Context * NativeContextFromLiterals(FixedArray *literals)
float DataViewConvertValue< float >(double value)
void set_array_buffers_list(Object *object)
static const int kInitialMaxFastElementArray
#define CONVERT_PROPERTY_DETAILS_CHECKED(name, index)
static void ArrayIdToTypeAndSize(int array_id, ExternalArrayType *type, ElementsKind *external_elements_kind, ElementsKind *fixed_elements_kind, size_t *element_size)
static Handle< Object > GetAccessor(Handle< JSObject > object, Handle< Name > name, AccessorComponent component)
static const int kMaxValue
static Handle< Object > PrepareElementsForSort(Handle< JSObject > object, uint32_t limit)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in name
static const int kBoundArgumentsStartIndex
static const int kNotFound
static Handle< Object > ToString(Isolate *isolate, Handle< Object > obj, bool *exc)
MUST_USE_RESULT MaybeObject * CopyReplaceDescriptor(DescriptorArray *descriptors, Descriptor *descriptor, int index, TransitionFlag flag)
ElementsKind GetHoleyElementsKind(ElementsKind packed_kind)
static const int32_t kMaxOneByteCharCode
Object * GetParameter(int index) const
static JSArrayBufferView * cast(Object *obj)
#define ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(Name)
void set_hash_field(uint32_t value)
void set_allow_osr_at_loop_nesting_level(int level)
#define TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION(Type, type, TYPE, ctype, size)
static void OutOfMemory()
static ObjectHashSet * cast(Object *obj)
static JSObject * cast(Object *obj)
static const int kMaxArrayIndexSize
JSFunction * function() const
bool IsQueuedForOSR(Handle< JSFunction > function, BailoutId osr_ast_id)
Handle< JSArray > NewJSArray(ElementsKind elements_kind, int length, int capacity, ArrayStorageAllocationMode mode=INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE, PretenureFlag pretenure=NOT_TENURED)
Local< Uint32 > ToArrayIndex() const
static uint32_t encode(T value)
bool IsFastDoubleElementsKind(ElementsKind kind)
static void FreeArrayBuffer(Isolate *isolate, JSArrayBuffer *phantom_array_buffer)
char * DoubleToFixedCString(double value, int f)
static Handle< JSObject > DeepWalk(Handle< JSObject > object, AllocationSiteCreationContext *site_context)
Handle< SeededNumberDictionary > NewSeededNumberDictionary(int at_least_space_for)
FixedArrayBuilder(Isolate *isolate, int initial_capacity)
#define INLINE_OPTIMIZED_FUNCTION_LIST(F)
static bool HasLocalProperty(Handle< JSReceiver >, Handle< Name > name)
static JSGlobalObject * cast(Object *obj)
static JSFunction * cast(Object *obj)