Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Side by Side Diff: src/runtime.cc

Issue 12518004: Ensure runtime functions have a NoHandleAllocation scope. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 683
684 684
685 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateSymbol) { 685 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateSymbol) {
686 NoHandleAllocation ha(isolate); 686 NoHandleAllocation ha(isolate);
687 ASSERT(args.length() == 0); 687 ASSERT(args.length() == 0);
688 return isolate->heap()->AllocateSymbol(); 688 return isolate->heap()->AllocateSymbol();
689 } 689 }
690 690
691 691
692 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateJSProxy) { 692 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateJSProxy) {
693 NoHandleAllocation ha(isolate);
693 ASSERT(args.length() == 2); 694 ASSERT(args.length() == 2);
694 CONVERT_ARG_CHECKED(JSReceiver, handler, 0); 695 CONVERT_ARG_CHECKED(JSReceiver, handler, 0);
695 Object* prototype = args[1]; 696 Object* prototype = args[1];
696 Object* used_prototype = 697 Object* used_prototype =
697 prototype->IsJSReceiver() ? prototype : isolate->heap()->null_value(); 698 prototype->IsJSReceiver() ? prototype : isolate->heap()->null_value();
698 return isolate->heap()->AllocateJSProxy(handler, used_prototype); 699 return isolate->heap()->AllocateJSProxy(handler, used_prototype);
699 } 700 }
700 701
701 702
702 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateJSFunctionProxy) { 703 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateJSFunctionProxy) {
704 NoHandleAllocation ha(isolate);
703 ASSERT(args.length() == 4); 705 ASSERT(args.length() == 4);
704 CONVERT_ARG_CHECKED(JSReceiver, handler, 0); 706 CONVERT_ARG_CHECKED(JSReceiver, handler, 0);
705 Object* call_trap = args[1]; 707 Object* call_trap = args[1];
706 RUNTIME_ASSERT(call_trap->IsJSFunction() || call_trap->IsJSFunctionProxy()); 708 RUNTIME_ASSERT(call_trap->IsJSFunction() || call_trap->IsJSFunctionProxy());
707 CONVERT_ARG_CHECKED(JSFunction, construct_trap, 2); 709 CONVERT_ARG_CHECKED(JSFunction, construct_trap, 2);
708 Object* prototype = args[3]; 710 Object* prototype = args[3];
709 Object* used_prototype = 711 Object* used_prototype =
710 prototype->IsJSReceiver() ? prototype : isolate->heap()->null_value(); 712 prototype->IsJSReceiver() ? prototype : isolate->heap()->null_value();
711 return isolate->heap()->AllocateJSFunctionProxy( 713 return isolate->heap()->AllocateJSFunctionProxy(
712 handler, call_trap, construct_trap, used_prototype); 714 handler, call_trap, construct_trap, used_prototype);
713 } 715 }
714 716
715 717
716 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsJSProxy) { 718 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsJSProxy) {
719 NoHandleAllocation ha(isolate);
717 ASSERT(args.length() == 1); 720 ASSERT(args.length() == 1);
718 Object* obj = args[0]; 721 Object* obj = args[0];
719 return isolate->heap()->ToBoolean(obj->IsJSProxy()); 722 return isolate->heap()->ToBoolean(obj->IsJSProxy());
720 } 723 }
721 724
722 725
723 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsJSFunctionProxy) { 726 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsJSFunctionProxy) {
727 NoHandleAllocation ha(isolate);
724 ASSERT(args.length() == 1); 728 ASSERT(args.length() == 1);
725 Object* obj = args[0]; 729 Object* obj = args[0];
726 return isolate->heap()->ToBoolean(obj->IsJSFunctionProxy()); 730 return isolate->heap()->ToBoolean(obj->IsJSFunctionProxy());
727 } 731 }
728 732
729 733
730 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetHandler) { 734 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetHandler) {
735 NoHandleAllocation ha(isolate);
731 ASSERT(args.length() == 1); 736 ASSERT(args.length() == 1);
732 CONVERT_ARG_CHECKED(JSProxy, proxy, 0); 737 CONVERT_ARG_CHECKED(JSProxy, proxy, 0);
733 return proxy->handler(); 738 return proxy->handler();
734 } 739 }
735 740
736 741
737 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetCallTrap) { 742 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetCallTrap) {
743 NoHandleAllocation ha(isolate);
738 ASSERT(args.length() == 1); 744 ASSERT(args.length() == 1);
739 CONVERT_ARG_CHECKED(JSFunctionProxy, proxy, 0); 745 CONVERT_ARG_CHECKED(JSFunctionProxy, proxy, 0);
740 return proxy->call_trap(); 746 return proxy->call_trap();
741 } 747 }
742 748
743 749
744 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetConstructTrap) { 750 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetConstructTrap) {
751 NoHandleAllocation ha(isolate);
745 ASSERT(args.length() == 1); 752 ASSERT(args.length() == 1);
746 CONVERT_ARG_CHECKED(JSFunctionProxy, proxy, 0); 753 CONVERT_ARG_CHECKED(JSFunctionProxy, proxy, 0);
747 return proxy->construct_trap(); 754 return proxy->construct_trap();
748 } 755 }
749 756
750 757
751 RUNTIME_FUNCTION(MaybeObject*, Runtime_Fix) { 758 RUNTIME_FUNCTION(MaybeObject*, Runtime_Fix) {
759 NoHandleAllocation ha(isolate);
752 ASSERT(args.length() == 1); 760 ASSERT(args.length() == 1);
753 CONVERT_ARG_CHECKED(JSProxy, proxy, 0); 761 CONVERT_ARG_CHECKED(JSProxy, proxy, 0);
754 proxy->Fix(); 762 proxy->Fix();
755 return isolate->heap()->undefined_value(); 763 return isolate->heap()->undefined_value();
756 } 764 }
757 765
758 766
759 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetInitialize) { 767 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetInitialize) {
760 HandleScope scope(isolate); 768 HandleScope scope(isolate);
761 ASSERT(args.length() == 1); 769 ASSERT(args.length() == 1);
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 1170
1163 1171
1164 // Returns an array with the property description: 1172 // Returns an array with the property description:
1165 // if args[1] is not a property on args[0] 1173 // if args[1] is not a property on args[0]
1166 // returns undefined 1174 // returns undefined
1167 // if args[1] is a data property on args[0] 1175 // if args[1] is a data property on args[0]
1168 // [false, value, Writeable, Enumerable, Configurable] 1176 // [false, value, Writeable, Enumerable, Configurable]
1169 // if args[1] is an accessor on args[0] 1177 // if args[1] is an accessor on args[0]
1170 // [true, GetFunction, SetFunction, Enumerable, Configurable] 1178 // [true, GetFunction, SetFunction, Enumerable, Configurable]
1171 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOwnProperty) { 1179 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOwnProperty) {
1180 HandleScope scope(isolate);
1172 ASSERT(args.length() == 2); 1181 ASSERT(args.length() == 2);
1173 HandleScope scope(isolate);
1174 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); 1182 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
1175 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); 1183 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1);
1176 return GetOwnProperty(isolate, obj, name); 1184 return GetOwnProperty(isolate, obj, name);
1177 } 1185 }
1178 1186
1179 1187
1180 RUNTIME_FUNCTION(MaybeObject*, Runtime_PreventExtensions) { 1188 RUNTIME_FUNCTION(MaybeObject*, Runtime_PreventExtensions) {
1189 NoHandleAllocation ha(isolate);
1181 ASSERT(args.length() == 1); 1190 ASSERT(args.length() == 1);
1182 CONVERT_ARG_CHECKED(JSObject, obj, 0); 1191 CONVERT_ARG_CHECKED(JSObject, obj, 0);
1183 return obj->PreventExtensions(); 1192 return obj->PreventExtensions();
1184 } 1193 }
1185 1194
1186 1195
1187 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsExtensible) { 1196 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsExtensible) {
1197 NoHandleAllocation ha(isolate);
1188 ASSERT(args.length() == 1); 1198 ASSERT(args.length() == 1);
1189 CONVERT_ARG_CHECKED(JSObject, obj, 0); 1199 CONVERT_ARG_CHECKED(JSObject, obj, 0);
1190 if (obj->IsJSGlobalProxy()) { 1200 if (obj->IsJSGlobalProxy()) {
1191 Object* proto = obj->GetPrototype(); 1201 Object* proto = obj->GetPrototype();
1192 if (proto->IsNull()) return isolate->heap()->false_value(); 1202 if (proto->IsNull()) return isolate->heap()->false_value();
1193 ASSERT(proto->IsJSGlobalObject()); 1203 ASSERT(proto->IsJSGlobalObject());
1194 obj = JSObject::cast(proto); 1204 obj = JSObject::cast(proto);
1195 } 1205 }
1196 return isolate->heap()->ToBoolean(obj->map()->is_extensible()); 1206 return isolate->heap()->ToBoolean(obj->map()->is_extensible());
1197 } 1207 }
(...skipping 14 matching lines...) Expand all
1212 1222
1213 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateApiFunction) { 1223 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateApiFunction) {
1214 HandleScope scope(isolate); 1224 HandleScope scope(isolate);
1215 ASSERT(args.length() == 1); 1225 ASSERT(args.length() == 1);
1216 CONVERT_ARG_HANDLE_CHECKED(FunctionTemplateInfo, data, 0); 1226 CONVERT_ARG_HANDLE_CHECKED(FunctionTemplateInfo, data, 0);
1217 return *isolate->factory()->CreateApiFunction(data); 1227 return *isolate->factory()->CreateApiFunction(data);
1218 } 1228 }
1219 1229
1220 1230
1221 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsTemplate) { 1231 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsTemplate) {
1232 NoHandleAllocation ha(isolate);
1222 ASSERT(args.length() == 1); 1233 ASSERT(args.length() == 1);
1223 Object* arg = args[0]; 1234 Object* arg = args[0];
1224 bool result = arg->IsObjectTemplateInfo() || arg->IsFunctionTemplateInfo(); 1235 bool result = arg->IsObjectTemplateInfo() || arg->IsFunctionTemplateInfo();
1225 return isolate->heap()->ToBoolean(result); 1236 return isolate->heap()->ToBoolean(result);
1226 } 1237 }
1227 1238
1228 1239
1229 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetTemplateField) { 1240 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetTemplateField) {
1241 NoHandleAllocation ha(isolate);
1230 ASSERT(args.length() == 2); 1242 ASSERT(args.length() == 2);
1231 CONVERT_ARG_CHECKED(HeapObject, templ, 0); 1243 CONVERT_ARG_CHECKED(HeapObject, templ, 0);
1232 CONVERT_SMI_ARG_CHECKED(index, 1) 1244 CONVERT_SMI_ARG_CHECKED(index, 1)
1233 int offset = index * kPointerSize + HeapObject::kHeaderSize; 1245 int offset = index * kPointerSize + HeapObject::kHeaderSize;
1234 InstanceType type = templ->map()->instance_type(); 1246 InstanceType type = templ->map()->instance_type();
1235 RUNTIME_ASSERT(type == FUNCTION_TEMPLATE_INFO_TYPE || 1247 RUNTIME_ASSERT(type == FUNCTION_TEMPLATE_INFO_TYPE ||
1236 type == OBJECT_TEMPLATE_INFO_TYPE); 1248 type == OBJECT_TEMPLATE_INFO_TYPE);
1237 RUNTIME_ASSERT(offset > 0); 1249 RUNTIME_ASSERT(offset > 0);
1238 if (type == FUNCTION_TEMPLATE_INFO_TYPE) { 1250 if (type == FUNCTION_TEMPLATE_INFO_TYPE) {
1239 RUNTIME_ASSERT(offset < FunctionTemplateInfo::kSize); 1251 RUNTIME_ASSERT(offset < FunctionTemplateInfo::kSize);
1240 } else { 1252 } else {
1241 RUNTIME_ASSERT(offset < ObjectTemplateInfo::kSize); 1253 RUNTIME_ASSERT(offset < ObjectTemplateInfo::kSize);
1242 } 1254 }
1243 return *HeapObject::RawField(templ, offset); 1255 return *HeapObject::RawField(templ, offset);
1244 } 1256 }
1245 1257
1246 1258
1247 RUNTIME_FUNCTION(MaybeObject*, Runtime_DisableAccessChecks) { 1259 RUNTIME_FUNCTION(MaybeObject*, Runtime_DisableAccessChecks) {
1260 NoHandleAllocation ha(isolate);
1248 ASSERT(args.length() == 1); 1261 ASSERT(args.length() == 1);
1249 CONVERT_ARG_CHECKED(HeapObject, object, 0); 1262 CONVERT_ARG_CHECKED(HeapObject, object, 0);
1250 Map* old_map = object->map(); 1263 Map* old_map = object->map();
1251 bool needs_access_checks = old_map->is_access_check_needed(); 1264 bool needs_access_checks = old_map->is_access_check_needed();
1252 if (needs_access_checks) { 1265 if (needs_access_checks) {
1253 // Copy map so it won't interfere constructor's initial map. 1266 // Copy map so it won't interfere constructor's initial map.
1254 Map* new_map; 1267 Map* new_map;
1255 MaybeObject* maybe_new_map = old_map->Copy(); 1268 MaybeObject* maybe_new_map = old_map->Copy();
1256 if (!maybe_new_map->To(&new_map)) return maybe_new_map; 1269 if (!maybe_new_map->To(&new_map)) return maybe_new_map;
1257 1270
1258 new_map->set_is_access_check_needed(false); 1271 new_map->set_is_access_check_needed(false);
1259 object->set_map(new_map); 1272 object->set_map(new_map);
1260 } 1273 }
1261 return isolate->heap()->ToBoolean(needs_access_checks); 1274 return isolate->heap()->ToBoolean(needs_access_checks);
1262 } 1275 }
1263 1276
1264 1277
1265 RUNTIME_FUNCTION(MaybeObject*, Runtime_EnableAccessChecks) { 1278 RUNTIME_FUNCTION(MaybeObject*, Runtime_EnableAccessChecks) {
1279 NoHandleAllocation ha(isolate);
1266 ASSERT(args.length() == 1); 1280 ASSERT(args.length() == 1);
1267 CONVERT_ARG_CHECKED(HeapObject, object, 0); 1281 CONVERT_ARG_CHECKED(HeapObject, object, 0);
1268 Map* old_map = object->map(); 1282 Map* old_map = object->map();
1269 if (!old_map->is_access_check_needed()) { 1283 if (!old_map->is_access_check_needed()) {
1270 // Copy map so it won't interfere constructor's initial map. 1284 // Copy map so it won't interfere constructor's initial map.
1271 Map* new_map; 1285 Map* new_map;
1272 MaybeObject* maybe_new_map = old_map->Copy(); 1286 MaybeObject* maybe_new_map = old_map->Copy();
1273 if (!maybe_new_map->To(&new_map)) return maybe_new_map; 1287 if (!maybe_new_map->To(&new_map)) return maybe_new_map;
1274 1288
1275 new_map->set_is_access_check_needed(true); 1289 new_map->set_is_access_check_needed(true);
(...skipping 10 matching lines...) Expand all
1286 Handle<Object> type_handle = 1300 Handle<Object> type_handle =
1287 isolate->factory()->NewStringFromAscii(CStrVector(type)); 1301 isolate->factory()->NewStringFromAscii(CStrVector(type));
1288 Handle<Object> args[2] = { type_handle, name }; 1302 Handle<Object> args[2] = { type_handle, name };
1289 Handle<Object> error = 1303 Handle<Object> error =
1290 isolate->factory()->NewTypeError("redeclaration", HandleVector(args, 2)); 1304 isolate->factory()->NewTypeError("redeclaration", HandleVector(args, 2));
1291 return isolate->Throw(*error); 1305 return isolate->Throw(*error);
1292 } 1306 }
1293 1307
1294 1308
1295 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareGlobals) { 1309 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareGlobals) {
1310 HandleScope scope(isolate);
1296 ASSERT(args.length() == 3); 1311 ASSERT(args.length() == 3);
1297 HandleScope scope(isolate);
1298 Handle<GlobalObject> global = Handle<GlobalObject>( 1312 Handle<GlobalObject> global = Handle<GlobalObject>(
1299 isolate->context()->global_object()); 1313 isolate->context()->global_object());
1300 1314
1301 Handle<Context> context = args.at<Context>(0); 1315 Handle<Context> context = args.at<Context>(0);
1302 CONVERT_ARG_HANDLE_CHECKED(FixedArray, pairs, 1); 1316 CONVERT_ARG_HANDLE_CHECKED(FixedArray, pairs, 1);
1303 CONVERT_SMI_ARG_CHECKED(flags, 2); 1317 CONVERT_SMI_ARG_CHECKED(flags, 2);
1304 1318
1305 // Traverse the name/value pairs and set the properties. 1319 // Traverse the name/value pairs and set the properties.
1306 int length = pairs->length(); 1320 int length = pairs->length();
1307 for (int i = 0; i < length; i += 2) { 1321 for (int i = 0; i < length; i += 2) {
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
1544 // Reload global in case the loop above performed a GC. 1558 // Reload global in case the loop above performed a GC.
1545 global = isolate->context()->global_object(); 1559 global = isolate->context()->global_object();
1546 if (assign) { 1560 if (assign) {
1547 return global->SetProperty(*name, args[2], attributes, strict_mode_flag); 1561 return global->SetProperty(*name, args[2], attributes, strict_mode_flag);
1548 } 1562 }
1549 return isolate->heap()->undefined_value(); 1563 return isolate->heap()->undefined_value();
1550 } 1564 }
1551 1565
1552 1566
1553 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeConstGlobal) { 1567 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeConstGlobal) {
1568 NoHandleAllocation ha(isolate);
1554 // All constants are declared with an initial value. The name 1569 // All constants are declared with an initial value. The name
1555 // of the constant is the first argument and the initial value 1570 // of the constant is the first argument and the initial value
1556 // is the second. 1571 // is the second.
1557 RUNTIME_ASSERT(args.length() == 2); 1572 RUNTIME_ASSERT(args.length() == 2);
1558 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); 1573 CONVERT_ARG_HANDLE_CHECKED(String, name, 0);
1559 Handle<Object> value = args.at<Object>(1); 1574 Handle<Object> value = args.at<Object>(1);
1560 1575
1561 // Get the current global object from top. 1576 // Get the current global object from top.
1562 GlobalObject* global = isolate->context()->global_object(); 1577 GlobalObject* global = isolate->context()->global_object();
1563 1578
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1749 Handle<Object> result = RegExpImpl::Exec(regexp, 1764 Handle<Object> result = RegExpImpl::Exec(regexp,
1750 subject, 1765 subject,
1751 index, 1766 index,
1752 last_match_info); 1767 last_match_info);
1753 if (result.is_null()) return Failure::Exception(); 1768 if (result.is_null()) return Failure::Exception();
1754 return *result; 1769 return *result;
1755 } 1770 }
1756 1771
1757 1772
1758 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpConstructResult) { 1773 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpConstructResult) {
1774 NoHandleAllocation ha(isolate);
1759 ASSERT(args.length() == 3); 1775 ASSERT(args.length() == 3);
1760 CONVERT_SMI_ARG_CHECKED(elements_count, 0); 1776 CONVERT_SMI_ARG_CHECKED(elements_count, 0);
1761 if (elements_count < 0 || 1777 if (elements_count < 0 ||
1762 elements_count > FixedArray::kMaxLength || 1778 elements_count > FixedArray::kMaxLength ||
1763 !Smi::IsValid(elements_count)) { 1779 !Smi::IsValid(elements_count)) {
1764 return isolate->ThrowIllegalOperation(); 1780 return isolate->ThrowIllegalOperation();
1765 } 1781 }
1766 Object* new_object; 1782 Object* new_object;
1767 { MaybeObject* maybe_new_object = 1783 { MaybeObject* maybe_new_object =
1768 isolate->heap()->AllocateFixedArrayWithHoles(elements_count); 1784 isolate->heap()->AllocateFixedArrayWithHoles(elements_count);
(...skipping 15 matching lines...) Expand all
1784 array->set_elements(elements); 1800 array->set_elements(elements);
1785 array->set_length(Smi::FromInt(elements_count)); 1801 array->set_length(Smi::FromInt(elements_count));
1786 // Write in-object properties after the length of the array. 1802 // Write in-object properties after the length of the array.
1787 array->InObjectPropertyAtPut(JSRegExpResult::kIndexIndex, args[1]); 1803 array->InObjectPropertyAtPut(JSRegExpResult::kIndexIndex, args[1]);
1788 array->InObjectPropertyAtPut(JSRegExpResult::kInputIndex, args[2]); 1804 array->InObjectPropertyAtPut(JSRegExpResult::kInputIndex, args[2]);
1789 return array; 1805 return array;
1790 } 1806 }
1791 1807
1792 1808
1793 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpInitializeObject) { 1809 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpInitializeObject) {
1810 NoHandleAllocation ha(isolate);
1794 AssertNoAllocation no_alloc; 1811 AssertNoAllocation no_alloc;
1795 ASSERT(args.length() == 5); 1812 ASSERT(args.length() == 5);
1796 CONVERT_ARG_CHECKED(JSRegExp, regexp, 0); 1813 CONVERT_ARG_CHECKED(JSRegExp, regexp, 0);
1797 CONVERT_ARG_CHECKED(String, source, 1); 1814 CONVERT_ARG_CHECKED(String, source, 1);
1798 // If source is the empty string we set it to "(?:)" instead as 1815 // If source is the empty string we set it to "(?:)" instead as
1799 // suggested by ECMA-262, 5th, section 15.10.4.1. 1816 // suggested by ECMA-262, 5th, section 15.10.4.1.
1800 if (source->length() == 0) source = isolate->heap()->query_colon_string(); 1817 if (source->length() == 0) source = isolate->heap()->query_colon_string();
1801 1818
1802 Object* global = args[2]; 1819 Object* global = args[2];
1803 if (!global->IsTrue()) global = isolate->heap()->false_value(); 1820 if (!global->IsTrue()) global = isolate->heap()->false_value();
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1903 InstallBuiltin(isolate, holder, "unshift", Builtins::kArrayUnshift); 1920 InstallBuiltin(isolate, holder, "unshift", Builtins::kArrayUnshift);
1904 InstallBuiltin(isolate, holder, "slice", Builtins::kArraySlice); 1921 InstallBuiltin(isolate, holder, "slice", Builtins::kArraySlice);
1905 InstallBuiltin(isolate, holder, "splice", Builtins::kArraySplice); 1922 InstallBuiltin(isolate, holder, "splice", Builtins::kArraySplice);
1906 InstallBuiltin(isolate, holder, "concat", Builtins::kArrayConcat); 1923 InstallBuiltin(isolate, holder, "concat", Builtins::kArrayConcat);
1907 1924
1908 return *holder; 1925 return *holder;
1909 } 1926 }
1910 1927
1911 1928
1912 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDefaultReceiver) { 1929 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDefaultReceiver) {
1930 NoHandleAllocation ha(isolate);
1913 ASSERT(args.length() == 1); 1931 ASSERT(args.length() == 1);
1914 CONVERT_ARG_CHECKED(JSReceiver, callable, 0); 1932 CONVERT_ARG_CHECKED(JSReceiver, callable, 0);
1915 1933
1916 if (!callable->IsJSFunction()) { 1934 if (!callable->IsJSFunction()) {
1917 HandleScope scope(isolate); 1935 HandleScope scope(isolate);
1918 bool threw = false; 1936 bool threw = false;
1919 Handle<Object> delegate = 1937 Handle<Object> delegate =
1920 Execution::TryGetFunctionDelegate(Handle<JSReceiver>(callable), &threw); 1938 Execution::TryGetFunctionDelegate(Handle<JSReceiver>(callable), &threw);
1921 if (threw) return Failure::Exception(); 1939 if (threw) return Failure::Exception();
1922 callable = JSFunction::cast(*delegate); 1940 callable = JSFunction::cast(*delegate);
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
2041 NoHandleAllocation ha(isolate); 2059 NoHandleAllocation ha(isolate);
2042 ASSERT(args.length() == 1); 2060 ASSERT(args.length() == 1);
2043 2061
2044 CONVERT_ARG_CHECKED(JSFunction, fun, 0); 2062 CONVERT_ARG_CHECKED(JSFunction, fun, 0);
2045 int pos = fun->shared()->start_position(); 2063 int pos = fun->shared()->start_position();
2046 return Smi::FromInt(pos); 2064 return Smi::FromInt(pos);
2047 } 2065 }
2048 2066
2049 2067
2050 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetPositionForOffset) { 2068 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetPositionForOffset) {
2069 NoHandleAllocation ha(isolate);
2051 ASSERT(args.length() == 2); 2070 ASSERT(args.length() == 2);
2052 2071
2053 CONVERT_ARG_CHECKED(Code, code, 0); 2072 CONVERT_ARG_CHECKED(Code, code, 0);
2054 CONVERT_NUMBER_CHECKED(int, offset, Int32, args[1]); 2073 CONVERT_NUMBER_CHECKED(int, offset, Int32, args[1]);
2055 2074
2056 RUNTIME_ASSERT(0 <= offset && offset < code->Size()); 2075 RUNTIME_ASSERT(0 <= offset && offset < code->Size());
2057 2076
2058 Address pc = code->address() + offset; 2077 Address pc = code->address() + offset;
2059 return Smi::FromInt(code->SourcePosition(pc)); 2078 return Smi::FromInt(code->SourcePosition(pc));
2060 } 2079 }
(...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after
3184 isolate->heap()->CreateFillerObjectAt(end_of_string, delta); 3203 isolate->heap()->CreateFillerObjectAt(end_of_string, delta);
3185 if (Marking::IsBlack(Marking::MarkBitFrom(*answer))) { 3204 if (Marking::IsBlack(Marking::MarkBitFrom(*answer))) {
3186 MemoryChunk::IncrementLiveBytesFromMutator(answer->address(), -delta); 3205 MemoryChunk::IncrementLiveBytesFromMutator(answer->address(), -delta);
3187 } 3206 }
3188 3207
3189 return *answer; 3208 return *answer;
3190 } 3209 }
3191 3210
3192 3211
3193 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringReplaceGlobalRegExpWithString) { 3212 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringReplaceGlobalRegExpWithString) {
3213 HandleScope scope(isolate);
3194 ASSERT(args.length() == 4); 3214 ASSERT(args.length() == 4);
3195 3215
3196 HandleScope scope(isolate);
3197
3198 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); 3216 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0);
3199 CONVERT_ARG_HANDLE_CHECKED(String, replacement, 2); 3217 CONVERT_ARG_HANDLE_CHECKED(String, replacement, 2);
3200 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1); 3218 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1);
3201 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 3); 3219 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 3);
3202 3220
3203 ASSERT(regexp->GetFlags().is_global()); 3221 ASSERT(regexp->GetFlags().is_global());
3204 3222
3205 if (!subject->IsFlat()) subject = FlattenGetString(subject); 3223 if (!subject->IsFlat()) subject = FlattenGetString(subject);
3206 3224
3207 if (replacement->length() == 0) { 3225 if (replacement->length() == 0) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
3260 Handle<String> first = isolate->factory()->NewSubString(subject, 0, index); 3278 Handle<String> first = isolate->factory()->NewSubString(subject, 0, index);
3261 Handle<String> cons1 = isolate->factory()->NewConsString(first, replace); 3279 Handle<String> cons1 = isolate->factory()->NewConsString(first, replace);
3262 Handle<String> second = 3280 Handle<String> second =
3263 isolate->factory()->NewSubString(subject, index + 1, subject->length()); 3281 isolate->factory()->NewSubString(subject, index + 1, subject->length());
3264 return isolate->factory()->NewConsString(cons1, second); 3282 return isolate->factory()->NewConsString(cons1, second);
3265 } 3283 }
3266 } 3284 }
3267 3285
3268 3286
3269 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringReplaceOneCharWithString) { 3287 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringReplaceOneCharWithString) {
3288 HandleScope scope(isolate);
3270 ASSERT(args.length() == 3); 3289 ASSERT(args.length() == 3);
3271 HandleScope scope(isolate);
3272 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); 3290 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0);
3273 CONVERT_ARG_HANDLE_CHECKED(String, search, 1); 3291 CONVERT_ARG_HANDLE_CHECKED(String, search, 1);
3274 CONVERT_ARG_HANDLE_CHECKED(String, replace, 2); 3292 CONVERT_ARG_HANDLE_CHECKED(String, replace, 2);
3275 3293
3276 // If the cons string tree is too deep, we simply abort the recursion and 3294 // If the cons string tree is too deep, we simply abort the recursion and
3277 // retry with a flattened subject string. 3295 // retry with a flattened subject string.
3278 const int kRecursionLimit = 0x1000; 3296 const int kRecursionLimit = 0x1000;
3279 bool found = false; 3297 bool found = false;
3280 Handle<String> result = StringReplaceOneCharWithString(isolate, 3298 Handle<String> result = StringReplaceOneCharWithString(isolate,
3281 subject, 3299 subject,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
3339 start_index); 3357 start_index);
3340 } 3358 }
3341 return SearchString(isolate, 3359 return SearchString(isolate,
3342 seq_sub.ToUC16Vector(), 3360 seq_sub.ToUC16Vector(),
3343 pat_vector, 3361 pat_vector,
3344 start_index); 3362 start_index);
3345 } 3363 }
3346 3364
3347 3365
3348 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringIndexOf) { 3366 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringIndexOf) {
3349 HandleScope scope(isolate); // create a new handle scope 3367 HandleScope scope(isolate);
3350 ASSERT(args.length() == 3); 3368 ASSERT(args.length() == 3);
3351 3369
3352 CONVERT_ARG_HANDLE_CHECKED(String, sub, 0); 3370 CONVERT_ARG_HANDLE_CHECKED(String, sub, 0);
3353 CONVERT_ARG_HANDLE_CHECKED(String, pat, 1); 3371 CONVERT_ARG_HANDLE_CHECKED(String, pat, 1);
3354 3372
3355 Object* index = args[2]; 3373 Object* index = args[2];
3356 uint32_t start_index; 3374 uint32_t start_index;
3357 if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1); 3375 if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1);
3358 3376
3359 RUNTIME_ASSERT(start_index <= static_cast<uint32_t>(sub->length())); 3377 RUNTIME_ASSERT(start_index <= static_cast<uint32_t>(sub->length()));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
3391 j++; 3409 j++;
3392 } 3410 }
3393 if (j == pattern_length) { 3411 if (j == pattern_length) {
3394 return i; 3412 return i;
3395 } 3413 }
3396 } 3414 }
3397 return -1; 3415 return -1;
3398 } 3416 }
3399 3417
3400 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringLastIndexOf) { 3418 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringLastIndexOf) {
3401 HandleScope scope(isolate); // create a new handle scope 3419 HandleScope scope(isolate);
3402 ASSERT(args.length() == 3); 3420 ASSERT(args.length() == 3);
3403 3421
3404 CONVERT_ARG_HANDLE_CHECKED(String, sub, 0); 3422 CONVERT_ARG_HANDLE_CHECKED(String, sub, 0);
3405 CONVERT_ARG_HANDLE_CHECKED(String, pat, 1); 3423 CONVERT_ARG_HANDLE_CHECKED(String, pat, 1);
3406 3424
3407 Object* index = args[2]; 3425 Object* index = args[2];
3408 uint32_t start_index; 3426 uint32_t start_index;
3409 if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1); 3427 if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1);
3410 3428
3411 uint32_t pat_length = pat->length(); 3429 uint32_t pat_length = pat->length();
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
3529 isolate->counters()->sub_string_runtime()->Increment(); 3547 isolate->counters()->sub_string_runtime()->Increment();
3530 if (end - start == 1) { 3548 if (end - start == 1) {
3531 return isolate->heap()->LookupSingleCharacterStringFromCode( 3549 return isolate->heap()->LookupSingleCharacterStringFromCode(
3532 value->Get(start)); 3550 value->Get(start));
3533 } 3551 }
3534 return value->SubString(start, end); 3552 return value->SubString(start, end);
3535 } 3553 }
3536 3554
3537 3555
3538 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringMatch) { 3556 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringMatch) {
3557 HandleScope handles(isolate);
3539 ASSERT_EQ(3, args.length()); 3558 ASSERT_EQ(3, args.length());
3540 3559
3541 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); 3560 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0);
3542 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1); 3561 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1);
3543 CONVERT_ARG_HANDLE_CHECKED(JSArray, regexp_info, 2); 3562 CONVERT_ARG_HANDLE_CHECKED(JSArray, regexp_info, 2);
3544 HandleScope handles(isolate);
3545 3563
3546 RegExpImpl::GlobalCache global_cache(regexp, subject, true, isolate); 3564 RegExpImpl::GlobalCache global_cache(regexp, subject, true, isolate);
3547 if (global_cache.HasException()) return Failure::Exception(); 3565 if (global_cache.HasException()) return Failure::Exception();
3548 3566
3549 int capture_count = regexp->CaptureCount(); 3567 int capture_count = regexp->CaptureCount();
3550 3568
3551 Zone* zone = isolate->runtime_zone(); 3569 Zone* zone = isolate->runtime_zone();
3552 ZoneScope zone_space(zone, DELETE_ON_EXIT); 3570 ZoneScope zone_space(zone, DELETE_ON_EXIT);
3553 ZoneList<int> offsets(8, zone); 3571 ZoneList<int> offsets(8, zone);
3554 3572
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
3738 } else { 3756 } else {
3739 return isolate->heap()->null_value(); // No matches at all. 3757 return isolate->heap()->null_value(); // No matches at all.
3740 } 3758 }
3741 } 3759 }
3742 3760
3743 3761
3744 // This is only called for StringReplaceGlobalRegExpWithFunction. This sets 3762 // This is only called for StringReplaceGlobalRegExpWithFunction. This sets
3745 // lastMatchInfoOverride to maintain the last match info, so we don't need to 3763 // lastMatchInfoOverride to maintain the last match info, so we don't need to
3746 // set any other last match array info. 3764 // set any other last match array info.
3747 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpExecMultiple) { 3765 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpExecMultiple) {
3766 HandleScope handles(isolate);
3748 ASSERT(args.length() == 4); 3767 ASSERT(args.length() == 4);
3749 HandleScope handles(isolate);
3750 3768
3751 CONVERT_ARG_HANDLE_CHECKED(String, subject, 1); 3769 CONVERT_ARG_HANDLE_CHECKED(String, subject, 1);
3752 if (!subject->IsFlat()) FlattenString(subject); 3770 if (!subject->IsFlat()) FlattenString(subject);
3753 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0); 3771 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0);
3754 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 2); 3772 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 2);
3755 CONVERT_ARG_HANDLE_CHECKED(JSArray, result_array, 3); 3773 CONVERT_ARG_HANDLE_CHECKED(JSArray, result_array, 3);
3756 3774
3757 ASSERT(regexp->GetFlags().is_global()); 3775 ASSERT(regexp->GetFlags().is_global());
3758 3776
3759 if (regexp->CaptureCount() == 0) { 3777 if (regexp->CaptureCount() == 0) {
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
4045 } 4063 }
4046 4064
4047 4065
4048 // Implements part of 8.12.9 DefineOwnProperty. 4066 // Implements part of 8.12.9 DefineOwnProperty.
4049 // There are 3 cases that lead here: 4067 // There are 3 cases that lead here:
4050 // Step 4b - define a new accessor property. 4068 // Step 4b - define a new accessor property.
4051 // Steps 9c & 12 - replace an existing data property with an accessor property. 4069 // Steps 9c & 12 - replace an existing data property with an accessor property.
4052 // Step 12 - update an existing accessor property with an accessor or generic 4070 // Step 12 - update an existing accessor property with an accessor or generic
4053 // descriptor. 4071 // descriptor.
4054 RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineOrRedefineAccessorProperty) { 4072 RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineOrRedefineAccessorProperty) {
4073 HandleScope scope(isolate);
4055 ASSERT(args.length() == 5); 4074 ASSERT(args.length() == 5);
4056 HandleScope scope(isolate);
4057 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); 4075 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
4058 RUNTIME_ASSERT(!obj->IsNull()); 4076 RUNTIME_ASSERT(!obj->IsNull());
4059 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); 4077 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1);
4060 CONVERT_ARG_HANDLE_CHECKED(Object, getter, 2); 4078 CONVERT_ARG_HANDLE_CHECKED(Object, getter, 2);
4061 RUNTIME_ASSERT(IsValidAccessor(getter)); 4079 RUNTIME_ASSERT(IsValidAccessor(getter));
4062 CONVERT_ARG_HANDLE_CHECKED(Object, setter, 3); 4080 CONVERT_ARG_HANDLE_CHECKED(Object, setter, 3);
4063 RUNTIME_ASSERT(IsValidAccessor(setter)); 4081 RUNTIME_ASSERT(IsValidAccessor(setter));
4064 CONVERT_SMI_ARG_CHECKED(unchecked, 4); 4082 CONVERT_SMI_ARG_CHECKED(unchecked, 4);
4065 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); 4083 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0);
4066 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked); 4084 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked);
4067 4085
4068 bool fast = obj->HasFastProperties(); 4086 bool fast = obj->HasFastProperties();
4069 JSObject::DefineAccessor(obj, name, getter, setter, attr); 4087 JSObject::DefineAccessor(obj, name, getter, setter, attr);
4070 if (fast) JSObject::TransformToFastProperties(obj, 0); 4088 if (fast) JSObject::TransformToFastProperties(obj, 0);
4071 return isolate->heap()->undefined_value(); 4089 return isolate->heap()->undefined_value();
4072 } 4090 }
4073 4091
4074 // Implements part of 8.12.9 DefineOwnProperty. 4092 // Implements part of 8.12.9 DefineOwnProperty.
4075 // There are 3 cases that lead here: 4093 // There are 3 cases that lead here:
4076 // Step 4a - define a new data property. 4094 // Step 4a - define a new data property.
4077 // Steps 9b & 12 - replace an existing accessor property with a data property. 4095 // Steps 9b & 12 - replace an existing accessor property with a data property.
4078 // Step 12 - update an existing data property with a data or generic 4096 // Step 12 - update an existing data property with a data or generic
4079 // descriptor. 4097 // descriptor.
4080 RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineOrRedefineDataProperty) { 4098 RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineOrRedefineDataProperty) {
4099 HandleScope scope(isolate);
4081 ASSERT(args.length() == 4); 4100 ASSERT(args.length() == 4);
4082 HandleScope scope(isolate);
4083 CONVERT_ARG_HANDLE_CHECKED(JSObject, js_object, 0); 4101 CONVERT_ARG_HANDLE_CHECKED(JSObject, js_object, 0);
4084 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); 4102 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1);
4085 CONVERT_ARG_HANDLE_CHECKED(Object, obj_value, 2); 4103 CONVERT_ARG_HANDLE_CHECKED(Object, obj_value, 2);
4086 CONVERT_SMI_ARG_CHECKED(unchecked, 3); 4104 CONVERT_SMI_ARG_CHECKED(unchecked, 3);
4087 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); 4105 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0);
4088 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked); 4106 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked);
4089 4107
4090 LookupResult result(isolate); 4108 LookupResult result(isolate);
4091 js_object->LocalLookupRealNamedProperty(*name, &result); 4109 js_object->LocalLookupRealNamedProperty(*name, &result);
4092 4110
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
4145 return Runtime::ForceSetObjectProperty(isolate, 4163 return Runtime::ForceSetObjectProperty(isolate,
4146 js_object, 4164 js_object,
4147 name, 4165 name,
4148 obj_value, 4166 obj_value,
4149 attr); 4167 attr);
4150 } 4168 }
4151 4169
4152 4170
4153 // Return property without being observable by accessors or interceptors. 4171 // Return property without being observable by accessors or interceptors.
4154 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDataProperty) { 4172 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDataProperty) {
4173 NoHandleAllocation ha(isolate);
4155 ASSERT(args.length() == 2); 4174 ASSERT(args.length() == 2);
4156 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); 4175 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
4157 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); 4176 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1);
4158 LookupResult lookup(isolate); 4177 LookupResult lookup(isolate);
4159 object->LookupRealNamedProperty(*key, &lookup); 4178 object->LookupRealNamedProperty(*key, &lookup);
4160 if (!lookup.IsFound()) return isolate->heap()->undefined_value(); 4179 if (!lookup.IsFound()) return isolate->heap()->undefined_value();
4161 switch (lookup.type()) { 4180 switch (lookup.type()) {
4162 case NORMAL: 4181 case NORMAL:
4163 return lookup.holder()->GetNormalizedProperty(&lookup); 4182 return lookup.holder()->GetNormalizedProperty(&lookup);
4164 case FIELD: 4183 case FIELD:
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
4433 4452
4434 if (object->IsJSFunction()) { 4453 if (object->IsJSFunction()) {
4435 JSFunction* func = JSFunction::cast(*object); 4454 JSFunction* func = JSFunction::cast(*object);
4436 func->shared()->set_native(true); 4455 func->shared()->set_native(true);
4437 } 4456 }
4438 return isolate->heap()->undefined_value(); 4457 return isolate->heap()->undefined_value();
4439 } 4458 }
4440 4459
4441 4460
4442 RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreArrayLiteralElement) { 4461 RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreArrayLiteralElement) {
4462 HandleScope scope(isolate);
4443 RUNTIME_ASSERT(args.length() == 5); 4463 RUNTIME_ASSERT(args.length() == 5);
4444 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); 4464 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
4445 CONVERT_SMI_ARG_CHECKED(store_index, 1); 4465 CONVERT_SMI_ARG_CHECKED(store_index, 1);
4446 Handle<Object> value = args.at<Object>(2); 4466 Handle<Object> value = args.at<Object>(2);
4447 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 3); 4467 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 3);
4448 CONVERT_SMI_ARG_CHECKED(literal_index, 4); 4468 CONVERT_SMI_ARG_CHECKED(literal_index, 4);
4449 HandleScope scope(isolate);
4450 4469
4451 Object* raw_boilerplate_object = literals->get(literal_index); 4470 Object* raw_boilerplate_object = literals->get(literal_index);
4452 Handle<JSArray> boilerplate_object(JSArray::cast(raw_boilerplate_object)); 4471 Handle<JSArray> boilerplate_object(JSArray::cast(raw_boilerplate_object));
4453 ElementsKind elements_kind = object->GetElementsKind(); 4472 ElementsKind elements_kind = object->GetElementsKind();
4454 ASSERT(IsFastElementsKind(elements_kind)); 4473 ASSERT(IsFastElementsKind(elements_kind));
4455 // Smis should never trigger transitions. 4474 // Smis should never trigger transitions.
4456 ASSERT(!value->IsSmi()); 4475 ASSERT(!value->IsSmi());
4457 4476
4458 if (value->IsNumber()) { 4477 if (value->IsNumber()) {
4459 ASSERT(IsFastSmiElementsKind(elements_kind)); 4478 ASSERT(IsFastSmiElementsKind(elements_kind));
(...skipping 25 matching lines...) Expand all
4485 FixedArray* object_array = FixedArray::cast(object->elements()); 4504 FixedArray* object_array = FixedArray::cast(object->elements());
4486 object_array->set(store_index, *value); 4505 object_array->set(store_index, *value);
4487 } 4506 }
4488 return *object; 4507 return *object;
4489 } 4508 }
4490 4509
4491 4510
4492 // Check whether debugger and is about to step into the callback that is passed 4511 // Check whether debugger and is about to step into the callback that is passed
4493 // to a built-in function such as Array.forEach. 4512 // to a built-in function such as Array.forEach.
4494 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugCallbackSupportsStepping) { 4513 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugCallbackSupportsStepping) {
4514 NoHandleAllocation ha(isolate);
4495 #ifdef ENABLE_DEBUGGER_SUPPORT 4515 #ifdef ENABLE_DEBUGGER_SUPPORT
4496 if (!isolate->IsDebuggerActive() || !isolate->debug()->StepInActive()) { 4516 if (!isolate->IsDebuggerActive() || !isolate->debug()->StepInActive()) {
4497 return isolate->heap()->false_value(); 4517 return isolate->heap()->false_value();
4498 } 4518 }
4499 CONVERT_ARG_CHECKED(Object, callback, 0); 4519 CONVERT_ARG_CHECKED(Object, callback, 0);
4500 // We do not step into the callback if it's a builtin or not even a function. 4520 // We do not step into the callback if it's a builtin or not even a function.
4501 if (!callback->IsJSFunction() || JSFunction::cast(callback)->IsBuiltin()) { 4521 if (!callback->IsJSFunction() || JSFunction::cast(callback)->IsBuiltin()) {
4502 return isolate->heap()->false_value(); 4522 return isolate->heap()->false_value();
4503 } 4523 }
4504 return isolate->heap()->true_value(); 4524 return isolate->heap()->true_value();
4505 #else 4525 #else
4506 return isolate->heap()->false_value(); 4526 return isolate->heap()->false_value();
4507 #endif // ENABLE_DEBUGGER_SUPPORT 4527 #endif // ENABLE_DEBUGGER_SUPPORT
4508 } 4528 }
4509 4529
4510 4530
4511 // Set one shot breakpoints for the callback function that is passed to a 4531 // Set one shot breakpoints for the callback function that is passed to a
4512 // built-in function such as Array.forEach to enable stepping into the callback. 4532 // built-in function such as Array.forEach to enable stepping into the callback.
4513 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPrepareStepInIfStepping) { 4533 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPrepareStepInIfStepping) {
4534 NoHandleAllocation ha(isolate);
4514 #ifdef ENABLE_DEBUGGER_SUPPORT 4535 #ifdef ENABLE_DEBUGGER_SUPPORT
4515 Debug* debug = isolate->debug(); 4536 Debug* debug = isolate->debug();
4516 if (!debug->IsStepping()) return isolate->heap()->undefined_value(); 4537 if (!debug->IsStepping()) return isolate->heap()->undefined_value();
4517 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callback, 0); 4538 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callback, 0);
4518 HandleScope scope(isolate); 4539 HandleScope scope(isolate);
4519 // When leaving the callback, step out has been activated, but not performed 4540 // When leaving the callback, step out has been activated, but not performed
4520 // if we do not leave the builtin. To be able to step into the callback 4541 // if we do not leave the builtin. To be able to step into the callback
4521 // again, we need to clear the step out at this point. 4542 // again, we need to clear the step out at this point.
4522 debug->ClearStepOut(); 4543 debug->ClearStepOut();
4523 debug->FloodWithOneShot(callback); 4544 debug->FloodWithOneShot(callback);
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
4663 return *result; 4684 return *result;
4664 } 4685 }
4665 4686
4666 4687
4667 // Returns either a FixedArray as Runtime_GetPropertyNames, 4688 // Returns either a FixedArray as Runtime_GetPropertyNames,
4668 // or, if the given object has an enum cache that contains 4689 // or, if the given object has an enum cache that contains
4669 // all enumerable properties of the object and its prototypes 4690 // all enumerable properties of the object and its prototypes
4670 // have none, the map of the object. This is used to speed up 4691 // have none, the map of the object. This is used to speed up
4671 // the check for deletions during a for-in. 4692 // the check for deletions during a for-in.
4672 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNamesFast) { 4693 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNamesFast) {
4694 NoHandleAllocation ha(isolate);
4673 ASSERT(args.length() == 1); 4695 ASSERT(args.length() == 1);
4674 4696
4675 CONVERT_ARG_CHECKED(JSReceiver, raw_object, 0); 4697 CONVERT_ARG_CHECKED(JSReceiver, raw_object, 0);
4676 4698
4677 if (raw_object->IsSimpleEnum()) return raw_object->map(); 4699 if (raw_object->IsSimpleEnum()) return raw_object->map();
4678 4700
4679 HandleScope scope(isolate); 4701 HandleScope scope(isolate);
4680 Handle<JSReceiver> object(raw_object); 4702 Handle<JSReceiver> object(raw_object);
4681 bool threw = false; 4703 bool threw = false;
4682 Handle<FixedArray> content = 4704 Handle<FixedArray> content =
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
4851 4873
4852 if (obj->HasIndexedInterceptor()) { 4874 if (obj->HasIndexedInterceptor()) {
4853 v8::Handle<v8::Array> result = GetKeysForIndexedInterceptor(obj, obj); 4875 v8::Handle<v8::Array> result = GetKeysForIndexedInterceptor(obj, obj);
4854 if (!result.IsEmpty()) return *v8::Utils::OpenHandle(*result); 4876 if (!result.IsEmpty()) return *v8::Utils::OpenHandle(*result);
4855 } 4877 }
4856 return isolate->heap()->undefined_value(); 4878 return isolate->heap()->undefined_value();
4857 } 4879 }
4858 4880
4859 4881
4860 RUNTIME_FUNCTION(MaybeObject*, Runtime_LocalKeys) { 4882 RUNTIME_FUNCTION(MaybeObject*, Runtime_LocalKeys) {
4883 HandleScope scope(isolate);
4861 ASSERT_EQ(args.length(), 1); 4884 ASSERT_EQ(args.length(), 1);
4862 CONVERT_ARG_CHECKED(JSObject, raw_object, 0); 4885 CONVERT_ARG_CHECKED(JSObject, raw_object, 0);
4863 HandleScope scope(isolate);
4864 Handle<JSObject> object(raw_object); 4886 Handle<JSObject> object(raw_object);
4865 4887
4866 if (object->IsJSGlobalProxy()) { 4888 if (object->IsJSGlobalProxy()) {
4867 // Do access checks before going to the global object. 4889 // Do access checks before going to the global object.
4868 if (object->IsAccessCheckNeeded() && 4890 if (object->IsAccessCheckNeeded() &&
4869 !isolate->MayNamedAccess(*object, isolate->heap()->undefined_value(), 4891 !isolate->MayNamedAccess(*object, isolate->heap()->undefined_value(),
4870 v8::ACCESS_KEYS)) { 4892 v8::ACCESS_KEYS)) {
4871 isolate->ReportFailedAccessCheck(*object, v8::ACCESS_KEYS); 4893 isolate->ReportFailedAccessCheck(*object, v8::ACCESS_KEYS);
4872 return *isolate->factory()->NewJSArray(0); 4894 return *isolate->factory()->NewJSArray(0);
4873 } 4895 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
4958 } 4980 }
4959 return function; 4981 return function;
4960 } 4982 }
4961 4983
4962 // Lookup in the initial Object.prototype object. 4984 // Lookup in the initial Object.prototype object.
4963 return isolate->initial_object_prototype()->GetProperty(*key); 4985 return isolate->initial_object_prototype()->GetProperty(*key);
4964 } 4986 }
4965 4987
4966 4988
4967 RUNTIME_FUNCTION(MaybeObject*, Runtime_ToFastProperties) { 4989 RUNTIME_FUNCTION(MaybeObject*, Runtime_ToFastProperties) {
4990 NoHandleAllocation ha(isolate);
4968 ASSERT(args.length() == 1); 4991 ASSERT(args.length() == 1);
4969 Object* object = args[0]; 4992 Object* object = args[0];
4970 return (object->IsJSObject() && !object->IsGlobalObject()) 4993 return (object->IsJSObject() && !object->IsGlobalObject())
4971 ? JSObject::cast(object)->TransformToFastProperties(0) 4994 ? JSObject::cast(object)->TransformToFastProperties(0)
4972 : object; 4995 : object;
4973 } 4996 }
4974 4997
4975 4998
4976 RUNTIME_FUNCTION(MaybeObject*, Runtime_ToBool) { 4999 RUNTIME_FUNCTION(MaybeObject*, Runtime_ToBool) {
4977 NoHandleAllocation ha(isolate); 5000 NoHandleAllocation ha(isolate);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
5094 } 5117 }
5095 } 5118 }
5096 5119
5097 // Slower case. 5120 // Slower case.
5098 return isolate->heap()->NumberFromDouble( 5121 return isolate->heap()->NumberFromDouble(
5099 StringToDouble(isolate->unicode_cache(), subject, ALLOW_HEX)); 5122 StringToDouble(isolate->unicode_cache(), subject, ALLOW_HEX));
5100 } 5123 }
5101 5124
5102 5125
5103 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewString) { 5126 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewString) {
5127 NoHandleAllocation ha(isolate);
5104 CONVERT_SMI_ARG_CHECKED(length, 0); 5128 CONVERT_SMI_ARG_CHECKED(length, 0);
5105 CONVERT_BOOLEAN_ARG_CHECKED(is_one_byte, 1); 5129 CONVERT_BOOLEAN_ARG_CHECKED(is_one_byte, 1);
5106 if (length == 0) return isolate->heap()->empty_string(); 5130 if (length == 0) return isolate->heap()->empty_string();
5107 if (is_one_byte) { 5131 if (is_one_byte) {
5108 return isolate->heap()->AllocateRawOneByteString(length); 5132 return isolate->heap()->AllocateRawOneByteString(length);
5109 } else { 5133 } else {
5110 return isolate->heap()->AllocateRawTwoByteString(length); 5134 return isolate->heap()->AllocateRawTwoByteString(length);
5111 } 5135 }
5112 } 5136 }
5113 5137
5114 5138
5115 RUNTIME_FUNCTION(MaybeObject*, Runtime_TruncateString) { 5139 RUNTIME_FUNCTION(MaybeObject*, Runtime_TruncateString) {
5140 NoHandleAllocation ha(isolate);
5116 CONVERT_ARG_CHECKED(SeqString, string, 0); 5141 CONVERT_ARG_CHECKED(SeqString, string, 0);
5117 CONVERT_SMI_ARG_CHECKED(new_length, 1); 5142 CONVERT_SMI_ARG_CHECKED(new_length, 1);
5118 return string->Truncate(new_length); 5143 return string->Truncate(new_length);
5119 } 5144 }
5120 5145
5121 5146
5122 RUNTIME_FUNCTION(MaybeObject*, Runtime_URIEscape) { 5147 RUNTIME_FUNCTION(MaybeObject*, Runtime_URIEscape) {
5148 HandleScope scope(isolate);
5123 ASSERT(args.length() == 1); 5149 ASSERT(args.length() == 1);
5124 HandleScope scope(isolate);
5125 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); 5150 CONVERT_ARG_HANDLE_CHECKED(String, source, 0);
5126 Handle<String> string = FlattenGetString(source); 5151 Handle<String> string = FlattenGetString(source);
5127 String::FlatContent content = string->GetFlatContent(); 5152 String::FlatContent content = string->GetFlatContent();
5128 ASSERT(content.IsFlat()); 5153 ASSERT(content.IsFlat());
5129 Handle<String> result = 5154 Handle<String> result =
5130 content.IsAscii() ? URIEscape::Escape<uint8_t>(isolate, source) 5155 content.IsAscii() ? URIEscape::Escape<uint8_t>(isolate, source)
5131 : URIEscape::Escape<uc16>(isolate, source); 5156 : URIEscape::Escape<uc16>(isolate, source);
5132 if (result.is_null()) return Failure::OutOfMemoryException(0x12); 5157 if (result.is_null()) return Failure::OutOfMemoryException(0x12);
5133 return *result; 5158 return *result;
5134 } 5159 }
5135 5160
5136 5161
5137 RUNTIME_FUNCTION(MaybeObject*, Runtime_URIUnescape) { 5162 RUNTIME_FUNCTION(MaybeObject*, Runtime_URIUnescape) {
5163 HandleScope scope(isolate);
5138 ASSERT(args.length() == 1); 5164 ASSERT(args.length() == 1);
5139 HandleScope scope(isolate);
5140 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); 5165 CONVERT_ARG_HANDLE_CHECKED(String, source, 0);
5141 Handle<String> string = FlattenGetString(source); 5166 Handle<String> string = FlattenGetString(source);
5142 String::FlatContent content = string->GetFlatContent(); 5167 String::FlatContent content = string->GetFlatContent();
5143 ASSERT(content.IsFlat()); 5168 ASSERT(content.IsFlat());
5144 return content.IsAscii() ? *URIUnescape::Unescape<uint8_t>(isolate, source) 5169 return content.IsAscii() ? *URIUnescape::Unescape<uint8_t>(isolate, source)
5145 : *URIUnescape::Unescape<uc16>(isolate, source); 5170 : *URIUnescape::Unescape<uc16>(isolate, source);
5146 } 5171 }
5147 5172
5148 5173
5149 static const unsigned int kQuoteTableLength = 128u; 5174 static const unsigned int kQuoteTableLength = 128u;
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
5502 worst_case_length); 5527 worst_case_length);
5503 } else { 5528 } else {
5504 return QuoteJsonStringArray<uc16, SeqTwoByteString>(isolate, 5529 return QuoteJsonStringArray<uc16, SeqTwoByteString>(isolate,
5505 elements, 5530 elements,
5506 worst_case_length); 5531 worst_case_length);
5507 } 5532 }
5508 } 5533 }
5509 5534
5510 5535
5511 RUNTIME_FUNCTION(MaybeObject*, Runtime_BasicJSONStringify) { 5536 RUNTIME_FUNCTION(MaybeObject*, Runtime_BasicJSONStringify) {
5537 HandleScope scope(isolate);
5512 ASSERT(args.length() == 1); 5538 ASSERT(args.length() == 1);
5513 HandleScope scope(isolate);
5514 BasicJsonStringifier stringifier(isolate); 5539 BasicJsonStringifier stringifier(isolate);
5515 return stringifier.Stringify(Handle<Object>(args[0], isolate)); 5540 return stringifier.Stringify(Handle<Object>(args[0], isolate));
5516 } 5541 }
5517 5542
5518 5543
5519 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseInt) { 5544 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseInt) {
5520 NoHandleAllocation ha(isolate); 5545 NoHandleAllocation ha(isolate);
5521 5546
5522 CONVERT_ARG_CHECKED(String, s, 0); 5547 CONVERT_ARG_CHECKED(String, s, 0);
5523 CONVERT_SMI_ARG_CHECKED(radix, 1); 5548 CONVERT_SMI_ARG_CHECKED(radix, 1);
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
5907 if (trimRight) { 5932 if (trimRight) {
5908 while (right > left && IsTrimWhiteSpace(s->Get(right - 1))) { 5933 while (right > left && IsTrimWhiteSpace(s->Get(right - 1))) {
5909 right--; 5934 right--;
5910 } 5935 }
5911 } 5936 }
5912 return s->SubString(left, right); 5937 return s->SubString(left, right);
5913 } 5938 }
5914 5939
5915 5940
5916 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringSplit) { 5941 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringSplit) {
5942 HandleScope handle_scope(isolate);
5917 ASSERT(args.length() == 3); 5943 ASSERT(args.length() == 3);
5918 HandleScope handle_scope(isolate);
5919 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); 5944 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0);
5920 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 1); 5945 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 1);
5921 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[2]); 5946 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[2]);
5922 5947
5923 int subject_length = subject->length(); 5948 int subject_length = subject->length();
5924 int pattern_length = pattern->length(); 5949 int pattern_length = pattern->length();
5925 RUNTIME_ASSERT(pattern_length > 0); 5950 RUNTIME_ASSERT(pattern_length > 0);
5926 5951
5927 if (limit == 0xffffffffu) { 5952 if (limit == 0xffffffffu) {
5928 Handle<Object> cached_answer( 5953 Handle<Object> cached_answer(
(...skipping 1799 matching lines...) Expand 10 before | Expand all | Expand 10 after
7728 7753
7729 RUNTIME_FUNCTION(MaybeObject*, Runtime_ParallelRecompile) { 7754 RUNTIME_FUNCTION(MaybeObject*, Runtime_ParallelRecompile) {
7730 HandleScope handle_scope(isolate); 7755 HandleScope handle_scope(isolate);
7731 ASSERT(FLAG_parallel_recompilation); 7756 ASSERT(FLAG_parallel_recompilation);
7732 Compiler::RecompileParallel(args.at<JSFunction>(0)); 7757 Compiler::RecompileParallel(args.at<JSFunction>(0));
7733 return isolate->heap()->undefined_value(); 7758 return isolate->heap()->undefined_value();
7734 } 7759 }
7735 7760
7736 7761
7737 RUNTIME_FUNCTION(MaybeObject*, Runtime_ForceParallelRecompile) { 7762 RUNTIME_FUNCTION(MaybeObject*, Runtime_ForceParallelRecompile) {
7763 HandleScope handle_scope(isolate);
7738 if (!V8::UseCrankshaft()) return isolate->heap()->undefined_value(); 7764 if (!V8::UseCrankshaft()) return isolate->heap()->undefined_value();
7739 HandleScope handle_scope(isolate);
7740 ASSERT(FLAG_parallel_recompilation && FLAG_manual_parallel_recompilation); 7765 ASSERT(FLAG_parallel_recompilation && FLAG_manual_parallel_recompilation);
7741 if (!isolate->optimizing_compiler_thread()->IsQueueAvailable()) { 7766 if (!isolate->optimizing_compiler_thread()->IsQueueAvailable()) {
7742 return isolate->Throw(*isolate->factory()->InternalizeOneByteString( 7767 return isolate->Throw(*isolate->factory()->InternalizeOneByteString(
7743 STATIC_ASCII_VECTOR("Recompile queue is full."))); 7768 STATIC_ASCII_VECTOR("Recompile queue is full.")));
7744 } 7769 }
7745 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); 7770 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0);
7746 fun->ReplaceCode(isolate->builtins()->builtin(Builtins::kParallelRecompile)); 7771 fun->ReplaceCode(isolate->builtins()->builtin(Builtins::kParallelRecompile));
7747 Compiler::RecompileParallel(fun); 7772 Compiler::RecompileParallel(fun);
7748 return isolate->heap()->undefined_value(); 7773 return isolate->heap()->undefined_value();
7749 } 7774 }
7750 7775
7751 7776
7752 RUNTIME_FUNCTION(MaybeObject*, Runtime_InstallRecompiledCode) { 7777 RUNTIME_FUNCTION(MaybeObject*, Runtime_InstallRecompiledCode) {
7778 HandleScope handle_scope(isolate);
7753 if (!V8::UseCrankshaft()) return isolate->heap()->undefined_value(); 7779 if (!V8::UseCrankshaft()) return isolate->heap()->undefined_value();
7754 HandleScope handle_scope(isolate);
7755 ASSERT(FLAG_parallel_recompilation && FLAG_manual_parallel_recompilation); 7780 ASSERT(FLAG_parallel_recompilation && FLAG_manual_parallel_recompilation);
7756 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); 7781 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0);
7757 OptimizingCompilerThread* opt_thread = isolate->optimizing_compiler_thread(); 7782 OptimizingCompilerThread* opt_thread = isolate->optimizing_compiler_thread();
7758 Handle<SharedFunctionInfo> shared(fun->shared()); 7783 Handle<SharedFunctionInfo> shared(fun->shared());
7759 while (*opt_thread->InstallNextOptimizedFunction() != *shared) { } 7784 while (*opt_thread->InstallNextOptimizedFunction() != *shared) { }
7760 return isolate->heap()->undefined_value(); 7785 return isolate->heap()->undefined_value();
7761 } 7786 }
7762 7787
7763 7788
7764 class ActivationsFinder : public ThreadVisitor { 7789 class ActivationsFinder : public ThreadVisitor {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
7854 Deoptimizer::DeoptimizeFunction(*function); 7879 Deoptimizer::DeoptimizeFunction(*function);
7855 } 7880 }
7856 // Flush optimized code cache for this function. 7881 // Flush optimized code cache for this function.
7857 function->shared()->ClearOptimizedCodeMap(); 7882 function->shared()->ClearOptimizedCodeMap();
7858 7883
7859 return isolate->heap()->undefined_value(); 7884 return isolate->heap()->undefined_value();
7860 } 7885 }
7861 7886
7862 7887
7863 RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyOSR) { 7888 RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyOSR) {
7889 NoHandleAllocation ha(isolate);
7864 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); 7890 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate);
7865 delete deoptimizer; 7891 delete deoptimizer;
7866 return isolate->heap()->undefined_value(); 7892 return isolate->heap()->undefined_value();
7867 } 7893 }
7868 7894
7869 7895
7870 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeoptimizeFunction) { 7896 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeoptimizeFunction) {
7871 HandleScope scope(isolate); 7897 HandleScope scope(isolate);
7872 ASSERT(args.length() == 1); 7898 ASSERT(args.length() == 1);
7873 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 7899 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
(...skipping 12 matching lines...) Expand all
7886 Code* unoptimized = function->shared()->code(); 7912 Code* unoptimized = function->shared()->code();
7887 if (unoptimized->kind() == Code::FUNCTION) { 7913 if (unoptimized->kind() == Code::FUNCTION) {
7888 unoptimized->ClearInlineCaches(); 7914 unoptimized->ClearInlineCaches();
7889 unoptimized->ClearTypeFeedbackCells(isolate->heap()); 7915 unoptimized->ClearTypeFeedbackCells(isolate->heap());
7890 } 7916 }
7891 return isolate->heap()->undefined_value(); 7917 return isolate->heap()->undefined_value();
7892 } 7918 }
7893 7919
7894 7920
7895 RUNTIME_FUNCTION(MaybeObject*, Runtime_RunningInSimulator) { 7921 RUNTIME_FUNCTION(MaybeObject*, Runtime_RunningInSimulator) {
7922 NoHandleAllocation ha(isolate);
7896 #if defined(USE_SIMULATOR) 7923 #if defined(USE_SIMULATOR)
7897 return isolate->heap()->true_value(); 7924 return isolate->heap()->true_value();
7898 #else 7925 #else
7899 return isolate->heap()->false_value(); 7926 return isolate->heap()->false_value();
7900 #endif 7927 #endif
7901 } 7928 }
7902 7929
7903 7930
7904 RUNTIME_FUNCTION(MaybeObject*, Runtime_OptimizeFunctionOnNextCall) { 7931 RUNTIME_FUNCTION(MaybeObject*, Runtime_OptimizeFunctionOnNextCall) {
7905 HandleScope scope(isolate); 7932 HandleScope scope(isolate);
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
8064 } else { 8091 } else {
8065 if (function->IsMarkedForLazyRecompilation()) { 8092 if (function->IsMarkedForLazyRecompilation()) {
8066 function->ReplaceCode(function->shared()->code()); 8093 function->ReplaceCode(function->shared()->code());
8067 } 8094 }
8068 return Smi::FromInt(-1); 8095 return Smi::FromInt(-1);
8069 } 8096 }
8070 } 8097 }
8071 8098
8072 8099
8073 RUNTIME_FUNCTION(MaybeObject*, Runtime_CheckIsBootstrapping) { 8100 RUNTIME_FUNCTION(MaybeObject*, Runtime_CheckIsBootstrapping) {
8101 NoHandleAllocation ha(isolate);
8074 RUNTIME_ASSERT(isolate->bootstrapper()->IsActive()); 8102 RUNTIME_ASSERT(isolate->bootstrapper()->IsActive());
8075 return isolate->heap()->undefined_value(); 8103 return isolate->heap()->undefined_value();
8076 } 8104 }
8077 8105
8078 8106
8079 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetRootNaN) { 8107 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetRootNaN) {
8108 NoHandleAllocation ha(isolate);
8080 RUNTIME_ASSERT(isolate->bootstrapper()->IsActive()); 8109 RUNTIME_ASSERT(isolate->bootstrapper()->IsActive());
8081 return isolate->heap()->nan_value(); 8110 return isolate->heap()->nan_value();
8082 } 8111 }
8083 8112
8084 8113
8085 RUNTIME_FUNCTION(MaybeObject*, Runtime_Call) { 8114 RUNTIME_FUNCTION(MaybeObject*, Runtime_Call) {
8086 HandleScope scope(isolate); 8115 HandleScope scope(isolate);
8087 ASSERT(args.length() >= 2); 8116 ASSERT(args.length() >= 2);
8088 int argc = args.length() - 2; 8117 int argc = args.length() - 2;
8089 CONVERT_ARG_CHECKED(JSReceiver, fun, argc + 1); 8118 CONVERT_ARG_CHECKED(JSReceiver, fun, argc + 1);
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
8294 isolate->heap()->AllocateBlockContext(function, 8323 isolate->heap()->AllocateBlockContext(function,
8295 isolate->context(), 8324 isolate->context(),
8296 scope_info); 8325 scope_info);
8297 if (!maybe_context->To(&context)) return maybe_context; 8326 if (!maybe_context->To(&context)) return maybe_context;
8298 isolate->set_context(context); 8327 isolate->set_context(context);
8299 return context; 8328 return context;
8300 } 8329 }
8301 8330
8302 8331
8303 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsJSModule) { 8332 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsJSModule) {
8333 NoHandleAllocation ha(isolate);
8304 ASSERT(args.length() == 1); 8334 ASSERT(args.length() == 1);
8305 Object* obj = args[0]; 8335 Object* obj = args[0];
8306 return isolate->heap()->ToBoolean(obj->IsJSModule()); 8336 return isolate->heap()->ToBoolean(obj->IsJSModule());
8307 } 8337 }
8308 8338
8309 8339
8310 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushModuleContext) { 8340 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushModuleContext) {
8341 NoHandleAllocation ha(isolate);
8311 ASSERT(args.length() == 2); 8342 ASSERT(args.length() == 2);
8312 CONVERT_SMI_ARG_CHECKED(index, 0); 8343 CONVERT_SMI_ARG_CHECKED(index, 0);
8313 8344
8314 if (!args[1]->IsScopeInfo()) { 8345 if (!args[1]->IsScopeInfo()) {
8315 // Module already initialized. Find hosting context and retrieve context. 8346 // Module already initialized. Find hosting context and retrieve context.
8316 Context* host = Context::cast(isolate->context())->global_context(); 8347 Context* host = Context::cast(isolate->context())->global_context();
8317 Context* context = Context::cast(host->get(index)); 8348 Context* context = Context::cast(host->get(index));
8318 ASSERT(context->previous() == isolate->context()); 8349 ASSERT(context->previous() == isolate->context());
8319 isolate->set_context(context); 8350 isolate->set_context(context);
8320 return context; 8351 return context;
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
8684 8715
8685 RUNTIME_FUNCTION(MaybeObject*, Runtime_ReThrow) { 8716 RUNTIME_FUNCTION(MaybeObject*, Runtime_ReThrow) {
8686 HandleScope scope(isolate); 8717 HandleScope scope(isolate);
8687 ASSERT(args.length() == 1); 8718 ASSERT(args.length() == 1);
8688 8719
8689 return isolate->ReThrow(args[0]); 8720 return isolate->ReThrow(args[0]);
8690 } 8721 }
8691 8722
8692 8723
8693 RUNTIME_FUNCTION(MaybeObject*, Runtime_PromoteScheduledException) { 8724 RUNTIME_FUNCTION(MaybeObject*, Runtime_PromoteScheduledException) {
8725 NoHandleAllocation ha(isolate);
8694 ASSERT_EQ(0, args.length()); 8726 ASSERT_EQ(0, args.length());
8695 return isolate->PromoteScheduledException(); 8727 return isolate->PromoteScheduledException();
8696 } 8728 }
8697 8729
8698 8730
8699 RUNTIME_FUNCTION(MaybeObject*, Runtime_ThrowReferenceError) { 8731 RUNTIME_FUNCTION(MaybeObject*, Runtime_ThrowReferenceError) {
8700 HandleScope scope(isolate); 8732 HandleScope scope(isolate);
8701 ASSERT(args.length() == 1); 8733 ASSERT(args.length() == 1);
8702 8734
8703 Handle<Object> name(args[0], isolate); 8735 Handle<Object> name(args[0], isolate);
8704 Handle<Object> reference_error = 8736 Handle<Object> reference_error =
8705 isolate->factory()->NewReferenceError("not_defined", 8737 isolate->factory()->NewReferenceError("not_defined",
8706 HandleVector(&name, 1)); 8738 HandleVector(&name, 1));
8707 return isolate->Throw(*reference_error); 8739 return isolate->Throw(*reference_error);
8708 } 8740 }
8709 8741
8710 8742
8711 RUNTIME_FUNCTION(MaybeObject*, Runtime_ThrowNotDateError) { 8743 RUNTIME_FUNCTION(MaybeObject*, Runtime_ThrowNotDateError) {
8712 HandleScope scope(isolate); 8744 HandleScope scope(isolate);
8713 ASSERT(args.length() == 0); 8745 ASSERT(args.length() == 0);
8714 return isolate->Throw(*isolate->factory()->NewTypeError( 8746 return isolate->Throw(*isolate->factory()->NewTypeError(
8715 "not_date_object", HandleVector<Object>(NULL, 0))); 8747 "not_date_object", HandleVector<Object>(NULL, 0)));
8716 } 8748 }
8717 8749
8718 8750
8719 8751
8720 RUNTIME_FUNCTION(MaybeObject*, Runtime_StackGuard) { 8752 RUNTIME_FUNCTION(MaybeObject*, Runtime_StackGuard) {
8753 NoHandleAllocation ha(isolate);
8721 ASSERT(args.length() == 0); 8754 ASSERT(args.length() == 0);
8722 8755
8723 // First check if this is a real stack overflow. 8756 // First check if this is a real stack overflow.
8724 if (isolate->stack_guard()->IsStackOverflow()) { 8757 if (isolate->stack_guard()->IsStackOverflow()) {
8725 NoHandleAllocation na(isolate); 8758 NoHandleAllocation na(isolate);
8726 return isolate->StackOverflow(); 8759 return isolate->StackOverflow();
8727 } 8760 }
8728 8761
8729 return Execution::HandleStackGuardInterrupt(isolate); 8762 return Execution::HandleStackGuardInterrupt(isolate);
8730 } 8763 }
8731 8764
8732 8765
8733 RUNTIME_FUNCTION(MaybeObject*, Runtime_Interrupt) { 8766 RUNTIME_FUNCTION(MaybeObject*, Runtime_Interrupt) {
8767 NoHandleAllocation ha(isolate);
8734 ASSERT(args.length() == 0); 8768 ASSERT(args.length() == 0);
8735 return Execution::HandleStackGuardInterrupt(isolate); 8769 return Execution::HandleStackGuardInterrupt(isolate);
8736 } 8770 }
8737 8771
8738 8772
8739 static int StackSize(Isolate* isolate) { 8773 static int StackSize(Isolate* isolate) {
8740 int n = 0; 8774 int n = 0;
8741 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) n++; 8775 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) n++;
8742 return n; 8776 return n;
8743 } 8777 }
(...skipping 15 matching lines...) Expand all
8759 } else { 8793 } else {
8760 // function result 8794 // function result
8761 PrintF("} -> "); 8795 PrintF("} -> ");
8762 result->ShortPrint(); 8796 result->ShortPrint();
8763 PrintF("\n"); 8797 PrintF("\n");
8764 } 8798 }
8765 } 8799 }
8766 8800
8767 8801
8768 RUNTIME_FUNCTION(MaybeObject*, Runtime_TraceEnter) { 8802 RUNTIME_FUNCTION(MaybeObject*, Runtime_TraceEnter) {
8803 NoHandleAllocation ha(isolate);
8769 ASSERT(args.length() == 0); 8804 ASSERT(args.length() == 0);
8770 NoHandleAllocation ha(isolate);
8771 PrintTransition(isolate, NULL); 8805 PrintTransition(isolate, NULL);
8772 return isolate->heap()->undefined_value(); 8806 return isolate->heap()->undefined_value();
8773 } 8807 }
8774 8808
8775 8809
8776 RUNTIME_FUNCTION(MaybeObject*, Runtime_TraceExit) { 8810 RUNTIME_FUNCTION(MaybeObject*, Runtime_TraceExit) {
8777 NoHandleAllocation ha(isolate); 8811 NoHandleAllocation ha(isolate);
8778 PrintTransition(isolate, args[0]); 8812 PrintTransition(isolate, args[0]);
8779 return args[0]; // return TOS 8813 return args[0]; // return TOS
8780 } 8814 }
(...skipping 24 matching lines...) Expand all
8805 args[0]->ShortPrint(); 8839 args[0]->ShortPrint();
8806 #endif 8840 #endif
8807 PrintF("\n"); 8841 PrintF("\n");
8808 Flush(); 8842 Flush();
8809 8843
8810 return args[0]; // return TOS 8844 return args[0]; // return TOS
8811 } 8845 }
8812 8846
8813 8847
8814 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugTrace) { 8848 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugTrace) {
8849 NoHandleAllocation ha(isolate);
8815 ASSERT(args.length() == 0); 8850 ASSERT(args.length() == 0);
8816 NoHandleAllocation ha(isolate);
8817 isolate->PrintStack(); 8851 isolate->PrintStack();
8818 return isolate->heap()->undefined_value(); 8852 return isolate->heap()->undefined_value();
8819 } 8853 }
8820 8854
8821 8855
8822 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateCurrentTime) { 8856 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateCurrentTime) {
8823 NoHandleAllocation ha(isolate); 8857 NoHandleAllocation ha(isolate);
8824 ASSERT(args.length() == 0); 8858 ASSERT(args.length() == 0);
8825 8859
8826 // According to ECMA-262, section 15.9.1, page 117, the precision of 8860 // According to ECMA-262, section 15.9.1, page 117, the precision of
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
8887 ASSERT(args.length() == 1); 8921 ASSERT(args.length() == 1);
8888 8922
8889 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 8923 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
8890 int64_t time = isolate->date_cache()->ToUTC(static_cast<int64_t>(x)); 8924 int64_t time = isolate->date_cache()->ToUTC(static_cast<int64_t>(x));
8891 8925
8892 return isolate->heap()->NumberFromDouble(static_cast<double>(time)); 8926 return isolate->heap()->NumberFromDouble(static_cast<double>(time));
8893 } 8927 }
8894 8928
8895 8929
8896 RUNTIME_FUNCTION(MaybeObject*, Runtime_GlobalReceiver) { 8930 RUNTIME_FUNCTION(MaybeObject*, Runtime_GlobalReceiver) {
8931 NoHandleAllocation ha(isolate);
8897 ASSERT(args.length() == 1); 8932 ASSERT(args.length() == 1);
8898 Object* global = args[0]; 8933 Object* global = args[0];
8899 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value(); 8934 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value();
8900 return JSGlobalObject::cast(global)->global_receiver(); 8935 return JSGlobalObject::cast(global)->global_receiver();
8901 } 8936 }
8902 8937
8903 8938
8904 RUNTIME_FUNCTION(MaybeObject*, Runtime_ParseJson) { 8939 RUNTIME_FUNCTION(MaybeObject*, Runtime_ParseJson) {
8905 HandleScope scope(isolate); 8940 HandleScope scope(isolate);
8906 ASSERT_EQ(1, args.length()); 8941 ASSERT_EQ(1, args.length());
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
9000 scope_position); 9035 scope_position);
9001 if (shared.is_null()) return MakePair(Failure::Exception(), NULL); 9036 if (shared.is_null()) return MakePair(Failure::Exception(), NULL);
9002 Handle<JSFunction> compiled = 9037 Handle<JSFunction> compiled =
9003 isolate->factory()->NewFunctionFromSharedFunctionInfo( 9038 isolate->factory()->NewFunctionFromSharedFunctionInfo(
9004 shared, context, NOT_TENURED); 9039 shared, context, NOT_TENURED);
9005 return MakePair(*compiled, *receiver); 9040 return MakePair(*compiled, *receiver);
9006 } 9041 }
9007 9042
9008 9043
9009 RUNTIME_FUNCTION(ObjectPair, Runtime_ResolvePossiblyDirectEval) { 9044 RUNTIME_FUNCTION(ObjectPair, Runtime_ResolvePossiblyDirectEval) {
9045 HandleScope scope(isolate);
9010 ASSERT(args.length() == 5); 9046 ASSERT(args.length() == 5);
9011 9047
9012 HandleScope scope(isolate);
9013 Handle<Object> callee = args.at<Object>(0); 9048 Handle<Object> callee = args.at<Object>(0);
9014 9049
9015 // If "eval" didn't refer to the original GlobalEval, it's not a 9050 // If "eval" didn't refer to the original GlobalEval, it's not a
9016 // direct call to eval. 9051 // direct call to eval.
9017 // (And even if it is, but the first argument isn't a string, just let 9052 // (And even if it is, but the first argument isn't a string, just let
9018 // execution default to an indirect call to eval, which will also return 9053 // execution default to an indirect call to eval, which will also return
9019 // the first argument without doing anything). 9054 // the first argument without doing anything).
9020 if (*callee != isolate->native_context()->global_eval_fun() || 9055 if (*callee != isolate->native_context()->global_eval_fun() ||
9021 !args[1]->IsString()) { 9056 !args[1]->IsString()) {
9022 return MakePair(*callee, isolate->heap()->the_hole_value()); 9057 return MakePair(*callee, isolate->heap()->the_hole_value());
(...skipping 26 matching lines...) Expand all
9049 ASSERT(func->map()->instance_size() == map->instance_size()); 9084 ASSERT(func->map()->instance_size() == map->instance_size());
9050 func->set_map(*map); 9085 func->set_map(*map);
9051 return *func; 9086 return *func;
9052 } 9087 }
9053 9088
9054 9089
9055 RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateInNewSpace) { 9090 RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateInNewSpace) {
9056 // Allocate a block of memory in NewSpace (filled with a filler). 9091 // Allocate a block of memory in NewSpace (filled with a filler).
9057 // Use as fallback for allocation in generated code when NewSpace 9092 // Use as fallback for allocation in generated code when NewSpace
9058 // is full. 9093 // is full.
9094 NoHandleAllocation ha(isolate);
9059 ASSERT(args.length() == 1); 9095 ASSERT(args.length() == 1);
9060 CONVERT_ARG_HANDLE_CHECKED(Smi, size_smi, 0); 9096 CONVERT_ARG_HANDLE_CHECKED(Smi, size_smi, 0);
9061 int size = size_smi->value(); 9097 int size = size_smi->value();
9062 RUNTIME_ASSERT(IsAligned(size, kPointerSize)); 9098 RUNTIME_ASSERT(IsAligned(size, kPointerSize));
9063 RUNTIME_ASSERT(size > 0); 9099 RUNTIME_ASSERT(size > 0);
9064 Heap* heap = isolate->heap(); 9100 Heap* heap = isolate->heap();
9065 const int kMinFreeNewSpaceAfterGC = heap->InitialSemiSpaceSize() * 3/4; 9101 const int kMinFreeNewSpaceAfterGC = heap->InitialSemiSpaceSize() * 3/4;
9066 RUNTIME_ASSERT(size <= kMinFreeNewSpaceAfterGC); 9102 RUNTIME_ASSERT(size <= kMinFreeNewSpaceAfterGC);
9067 Object* allocation; 9103 Object* allocation;
9068 { MaybeObject* maybe_allocation = heap->new_space()->AllocateRaw(size); 9104 { MaybeObject* maybe_allocation = heap->new_space()->AllocateRaw(size);
9069 if (maybe_allocation->ToObject(&allocation)) { 9105 if (maybe_allocation->ToObject(&allocation)) {
9070 heap->CreateFillerObjectAt(HeapObject::cast(allocation)->address(), size); 9106 heap->CreateFillerObjectAt(HeapObject::cast(allocation)->address(), size);
9071 } 9107 }
9072 return maybe_allocation; 9108 return maybe_allocation;
9073 } 9109 }
9074 } 9110 }
9075 9111
9076 9112
9077 // Push an object unto an array of objects if it is not already in the 9113 // Push an object unto an array of objects if it is not already in the
9078 // array. Returns true if the element was pushed on the stack and 9114 // array. Returns true if the element was pushed on the stack and
9079 // false otherwise. 9115 // false otherwise.
9080 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushIfAbsent) { 9116 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushIfAbsent) {
9117 NoHandleAllocation ha(isolate);
9081 ASSERT(args.length() == 2); 9118 ASSERT(args.length() == 2);
9082 CONVERT_ARG_CHECKED(JSArray, array, 0); 9119 CONVERT_ARG_CHECKED(JSArray, array, 0);
9083 CONVERT_ARG_CHECKED(JSReceiver, element, 1); 9120 CONVERT_ARG_CHECKED(JSReceiver, element, 1);
9084 RUNTIME_ASSERT(array->HasFastSmiOrObjectElements()); 9121 RUNTIME_ASSERT(array->HasFastSmiOrObjectElements());
9085 int length = Smi::cast(array->length())->value(); 9122 int length = Smi::cast(array->length())->value();
9086 FixedArray* elements = FixedArray::cast(array->elements()); 9123 FixedArray* elements = FixedArray::cast(array->elements());
9087 for (int i = 0; i < length; i++) { 9124 for (int i = 0; i < length; i++) {
9088 if (elements->get(i) == element) return isolate->heap()->false_value(); 9125 if (elements->get(i) == element) return isolate->heap()->false_value();
9089 } 9126 }
9090 Object* obj; 9127 Object* obj;
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
9603 } 9640 }
9604 9641
9605 9642
9606 /** 9643 /**
9607 * Array::concat implementation. 9644 * Array::concat implementation.
9608 * See ECMAScript 262, 15.4.4.4. 9645 * See ECMAScript 262, 15.4.4.4.
9609 * TODO(581): Fix non-compliance for very large concatenations and update to 9646 * TODO(581): Fix non-compliance for very large concatenations and update to
9610 * following the ECMAScript 5 specification. 9647 * following the ECMAScript 5 specification.
9611 */ 9648 */
9612 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayConcat) { 9649 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayConcat) {
9650 HandleScope handle_scope(isolate);
9613 ASSERT(args.length() == 1); 9651 ASSERT(args.length() == 1);
9614 HandleScope handle_scope(isolate);
9615 9652
9616 CONVERT_ARG_HANDLE_CHECKED(JSArray, arguments, 0); 9653 CONVERT_ARG_HANDLE_CHECKED(JSArray, arguments, 0);
9617 int argument_count = static_cast<int>(arguments->length()->Number()); 9654 int argument_count = static_cast<int>(arguments->length()->Number());
9618 RUNTIME_ASSERT(arguments->HasFastObjectElements()); 9655 RUNTIME_ASSERT(arguments->HasFastObjectElements());
9619 Handle<FixedArray> elements(FixedArray::cast(arguments->elements())); 9656 Handle<FixedArray> elements(FixedArray::cast(arguments->elements()));
9620 9657
9621 // Pass 1: estimate the length and number of elements of the result. 9658 // Pass 1: estimate the length and number of elements of the result.
9622 // The actual length can be larger if any of the arguments have getters 9659 // The actual length can be larger if any of the arguments have getters
9623 // that mutate other arguments (but will otherwise be precise). 9660 // that mutate other arguments (but will otherwise be precise).
9624 // The number of elements is precise if there are no inherited elements. 9661 // The number of elements is precise if there are no inherited elements.
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
9792 } 9829 }
9793 return string; 9830 return string;
9794 } 9831 }
9795 9832
9796 // Moves all own elements of an object, that are below a limit, to positions 9833 // Moves all own elements of an object, that are below a limit, to positions
9797 // starting at zero. All undefined values are placed after non-undefined values, 9834 // starting at zero. All undefined values are placed after non-undefined values,
9798 // and are followed by non-existing element. Does not change the length 9835 // and are followed by non-existing element. Does not change the length
9799 // property. 9836 // property.
9800 // Returns the number of non-undefined elements collected. 9837 // Returns the number of non-undefined elements collected.
9801 RUNTIME_FUNCTION(MaybeObject*, Runtime_RemoveArrayHoles) { 9838 RUNTIME_FUNCTION(MaybeObject*, Runtime_RemoveArrayHoles) {
9839 NoHandleAllocation ha(isolate);
9802 ASSERT(args.length() == 2); 9840 ASSERT(args.length() == 2);
9803 CONVERT_ARG_CHECKED(JSObject, object, 0); 9841 CONVERT_ARG_CHECKED(JSObject, object, 0);
9804 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]); 9842 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]);
9805 return object->PrepareElementsForSort(limit); 9843 return object->PrepareElementsForSort(limit);
9806 } 9844 }
9807 9845
9808 9846
9809 // Move contents of argument 0 (an array) to argument 1 (an array) 9847 // Move contents of argument 0 (an array) to argument 1 (an array)
9810 RUNTIME_FUNCTION(MaybeObject*, Runtime_MoveArrayContents) { 9848 RUNTIME_FUNCTION(MaybeObject*, Runtime_MoveArrayContents) {
9849 NoHandleAllocation ha(isolate);
9811 ASSERT(args.length() == 2); 9850 ASSERT(args.length() == 2);
9812 CONVERT_ARG_CHECKED(JSArray, from, 0); 9851 CONVERT_ARG_CHECKED(JSArray, from, 0);
9813 CONVERT_ARG_CHECKED(JSArray, to, 1); 9852 CONVERT_ARG_CHECKED(JSArray, to, 1);
9814 from->ValidateElements(); 9853 from->ValidateElements();
9815 to->ValidateElements(); 9854 to->ValidateElements();
9816 FixedArrayBase* new_elements = from->elements(); 9855 FixedArrayBase* new_elements = from->elements();
9817 ElementsKind from_kind = from->GetElementsKind(); 9856 ElementsKind from_kind = from->GetElementsKind();
9818 MaybeObject* maybe_new_map; 9857 MaybeObject* maybe_new_map;
9819 maybe_new_map = to->GetElementsTransitionMap(isolate, from_kind); 9858 maybe_new_map = to->GetElementsTransitionMap(isolate, from_kind);
9820 Object* new_map; 9859 Object* new_map;
9821 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map; 9860 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map;
9822 to->set_map_and_elements(Map::cast(new_map), new_elements); 9861 to->set_map_and_elements(Map::cast(new_map), new_elements);
9823 to->set_length(from->length()); 9862 to->set_length(from->length());
9824 Object* obj; 9863 Object* obj;
9825 { MaybeObject* maybe_obj = from->ResetElements(); 9864 { MaybeObject* maybe_obj = from->ResetElements();
9826 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 9865 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
9827 } 9866 }
9828 from->set_length(Smi::FromInt(0)); 9867 from->set_length(Smi::FromInt(0));
9829 to->ValidateElements(); 9868 to->ValidateElements();
9830 return to; 9869 return to;
9831 } 9870 }
9832 9871
9833 9872
9834 // How many elements does this object/array have? 9873 // How many elements does this object/array have?
9835 RUNTIME_FUNCTION(MaybeObject*, Runtime_EstimateNumberOfElements) { 9874 RUNTIME_FUNCTION(MaybeObject*, Runtime_EstimateNumberOfElements) {
9875 NoHandleAllocation ha(isolate);
9836 ASSERT(args.length() == 1); 9876 ASSERT(args.length() == 1);
9837 CONVERT_ARG_CHECKED(JSObject, object, 0); 9877 CONVERT_ARG_CHECKED(JSObject, object, 0);
9838 HeapObject* elements = object->elements(); 9878 HeapObject* elements = object->elements();
9839 if (elements->IsDictionary()) { 9879 if (elements->IsDictionary()) {
9840 int result = SeededNumberDictionary::cast(elements)->NumberOfElements(); 9880 int result = SeededNumberDictionary::cast(elements)->NumberOfElements();
9841 return Smi::FromInt(result); 9881 return Smi::FromInt(result);
9842 } else if (object->IsJSArray()) { 9882 } else if (object->IsJSArray()) {
9843 return JSArray::cast(object)->length(); 9883 return JSArray::cast(object)->length();
9844 } else { 9884 } else {
9845 return Smi::FromInt(FixedArray::cast(elements)->length()); 9885 return Smi::FromInt(FixedArray::cast(elements)->length());
9846 } 9886 }
9847 } 9887 }
9848 9888
9849 9889
9850 // Returns an array that tells you where in the [0, length) interval an array 9890 // Returns an array that tells you where in the [0, length) interval an array
9851 // might have elements. Can either return keys (positive integers) or 9891 // might have elements. Can either return keys (positive integers) or
9852 // intervals (pair of a negative integer (-start-1) followed by a 9892 // intervals (pair of a negative integer (-start-1) followed by a
9853 // positive (length)) or undefined values. 9893 // positive (length)) or undefined values.
9854 // Intervals can span over some keys that are not in the object. 9894 // Intervals can span over some keys that are not in the object.
9855 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArrayKeys) { 9895 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArrayKeys) {
9896 HandleScope scope(isolate);
9856 ASSERT(args.length() == 2); 9897 ASSERT(args.length() == 2);
9857 HandleScope scope(isolate);
9858 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0); 9898 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0);
9859 CONVERT_NUMBER_CHECKED(uint32_t, length, Uint32, args[1]); 9899 CONVERT_NUMBER_CHECKED(uint32_t, length, Uint32, args[1]);
9860 if (array->elements()->IsDictionary()) { 9900 if (array->elements()->IsDictionary()) {
9861 // Create an array and get all the keys into it, then remove all the 9901 // Create an array and get all the keys into it, then remove all the
9862 // keys that are not integers in the range 0 to length-1. 9902 // keys that are not integers in the range 0 to length-1.
9863 bool threw = false; 9903 bool threw = false;
9864 Handle<FixedArray> keys = 9904 Handle<FixedArray> keys =
9865 GetKeysInFixedArrayFor(array, INCLUDE_PROTOS, &threw); 9905 GetKeysInFixedArrayFor(array, INCLUDE_PROTOS, &threw);
9866 if (threw) return Failure::Exception(); 9906 if (threw) return Failure::Exception();
9867 9907
(...skipping 19 matching lines...) Expand all
9887 uint32_t min_length = actual_length < length ? actual_length : length; 9927 uint32_t min_length = actual_length < length ? actual_length : length;
9888 Handle<Object> length_object = 9928 Handle<Object> length_object =
9889 isolate->factory()->NewNumber(static_cast<double>(min_length)); 9929 isolate->factory()->NewNumber(static_cast<double>(min_length));
9890 single_interval->set(1, *length_object); 9930 single_interval->set(1, *length_object);
9891 return *isolate->factory()->NewJSArrayWithElements(single_interval); 9931 return *isolate->factory()->NewJSArrayWithElements(single_interval);
9892 } 9932 }
9893 } 9933 }
9894 9934
9895 9935
9896 RUNTIME_FUNCTION(MaybeObject*, Runtime_LookupAccessor) { 9936 RUNTIME_FUNCTION(MaybeObject*, Runtime_LookupAccessor) {
9937 NoHandleAllocation ha(isolate);
9897 ASSERT(args.length() == 3); 9938 ASSERT(args.length() == 3);
9898 CONVERT_ARG_CHECKED(JSReceiver, receiver, 0); 9939 CONVERT_ARG_CHECKED(JSReceiver, receiver, 0);
9899 CONVERT_ARG_CHECKED(Name, name, 1); 9940 CONVERT_ARG_CHECKED(Name, name, 1);
9900 CONVERT_SMI_ARG_CHECKED(flag, 2); 9941 CONVERT_SMI_ARG_CHECKED(flag, 2);
9901 AccessorComponent component = flag == 0 ? ACCESSOR_GETTER : ACCESSOR_SETTER; 9942 AccessorComponent component = flag == 0 ? ACCESSOR_GETTER : ACCESSOR_SETTER;
9902 if (!receiver->IsJSObject()) return isolate->heap()->undefined_value(); 9943 if (!receiver->IsJSObject()) return isolate->heap()->undefined_value();
9903 return JSObject::cast(receiver)->LookupAccessor(name, component); 9944 return JSObject::cast(receiver)->LookupAccessor(name, component);
9904 } 9945 }
9905 9946
9906 9947
9907 #ifdef ENABLE_DEBUGGER_SUPPORT 9948 #ifdef ENABLE_DEBUGGER_SUPPORT
9908 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugBreak) { 9949 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugBreak) {
9950 NoHandleAllocation ha(isolate);
9909 ASSERT(args.length() == 0); 9951 ASSERT(args.length() == 0);
9910 return Execution::DebugBreakHelper(); 9952 return Execution::DebugBreakHelper();
9911 } 9953 }
9912 9954
9913 9955
9914 // Helper functions for wrapping and unwrapping stack frame ids. 9956 // Helper functions for wrapping and unwrapping stack frame ids.
9915 static Smi* WrapFrameId(StackFrame::Id id) { 9957 static Smi* WrapFrameId(StackFrame::Id id) {
9916 ASSERT(IsAligned(OffsetFrom(id), static_cast<intptr_t>(4))); 9958 ASSERT(IsAligned(OffsetFrom(id), static_cast<intptr_t>(4)));
9917 return Smi::FromInt(id >> 2); 9959 return Smi::FromInt(id >> 2);
9918 } 9960 }
9919 9961
9920 9962
9921 static StackFrame::Id UnwrapFrameId(int wrapped) { 9963 static StackFrame::Id UnwrapFrameId(int wrapped) {
9922 return static_cast<StackFrame::Id>(wrapped << 2); 9964 return static_cast<StackFrame::Id>(wrapped << 2);
9923 } 9965 }
9924 9966
9925 9967
9926 // Adds a JavaScript function as a debug event listener. 9968 // Adds a JavaScript function as a debug event listener.
9927 // args[0]: debug event listener function to set or null or undefined for 9969 // args[0]: debug event listener function to set or null or undefined for
9928 // clearing the event listener function 9970 // clearing the event listener function
9929 // args[1]: object supplied during callback 9971 // args[1]: object supplied during callback
9930 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDebugEventListener) { 9972 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDebugEventListener) {
9973 NoHandleAllocation ha(isolate);
9931 ASSERT(args.length() == 2); 9974 ASSERT(args.length() == 2);
9932 RUNTIME_ASSERT(args[0]->IsJSFunction() || 9975 RUNTIME_ASSERT(args[0]->IsJSFunction() ||
9933 args[0]->IsUndefined() || 9976 args[0]->IsUndefined() ||
9934 args[0]->IsNull()); 9977 args[0]->IsNull());
9935 Handle<Object> callback = args.at<Object>(0); 9978 Handle<Object> callback = args.at<Object>(0);
9936 Handle<Object> data = args.at<Object>(1); 9979 Handle<Object> data = args.at<Object>(1);
9937 isolate->debugger()->SetEventListener(callback, data); 9980 isolate->debugger()->SetEventListener(callback, data);
9938 9981
9939 return isolate->heap()->undefined_value(); 9982 return isolate->heap()->undefined_value();
9940 } 9983 }
9941 9984
9942 9985
9943 RUNTIME_FUNCTION(MaybeObject*, Runtime_Break) { 9986 RUNTIME_FUNCTION(MaybeObject*, Runtime_Break) {
9987 NoHandleAllocation ha(isolate);
9944 ASSERT(args.length() == 0); 9988 ASSERT(args.length() == 0);
9945 isolate->stack_guard()->DebugBreak(); 9989 isolate->stack_guard()->DebugBreak();
9946 return isolate->heap()->undefined_value(); 9990 return isolate->heap()->undefined_value();
9947 } 9991 }
9948 9992
9949 9993
9950 static MaybeObject* DebugLookupResultValue(Heap* heap, 9994 static MaybeObject* DebugLookupResultValue(Heap* heap,
9951 Object* receiver, 9995 Object* receiver,
9952 Name* name, 9996 Name* name,
9953 LookupResult* result, 9997 LookupResult* result,
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
10126 if (result.IsFound()) { 10170 if (result.IsFound()) {
10127 return DebugLookupResultValue(isolate->heap(), *obj, *name, &result, NULL); 10171 return DebugLookupResultValue(isolate->heap(), *obj, *name, &result, NULL);
10128 } 10172 }
10129 return isolate->heap()->undefined_value(); 10173 return isolate->heap()->undefined_value();
10130 } 10174 }
10131 10175
10132 10176
10133 // Return the property type calculated from the property details. 10177 // Return the property type calculated from the property details.
10134 // args[0]: smi with property details. 10178 // args[0]: smi with property details.
10135 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyTypeFromDetails) { 10179 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyTypeFromDetails) {
10180 NoHandleAllocation ha(isolate);
10136 ASSERT(args.length() == 1); 10181 ASSERT(args.length() == 1);
10137 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); 10182 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0);
10138 return Smi::FromInt(static_cast<int>(details.type())); 10183 return Smi::FromInt(static_cast<int>(details.type()));
10139 } 10184 }
10140 10185
10141 10186
10142 // Return the property attribute calculated from the property details. 10187 // Return the property attribute calculated from the property details.
10143 // args[0]: smi with property details. 10188 // args[0]: smi with property details.
10144 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyAttributesFromDetails) { 10189 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyAttributesFromDetails) {
10190 NoHandleAllocation ha(isolate);
10145 ASSERT(args.length() == 1); 10191 ASSERT(args.length() == 1);
10146 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); 10192 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0);
10147 return Smi::FromInt(static_cast<int>(details.attributes())); 10193 return Smi::FromInt(static_cast<int>(details.attributes()));
10148 } 10194 }
10149 10195
10150 10196
10151 // Return the property insertion index calculated from the property details. 10197 // Return the property insertion index calculated from the property details.
10152 // args[0]: smi with property details. 10198 // args[0]: smi with property details.
10153 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyIndexFromDetails) { 10199 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyIndexFromDetails) {
10200 NoHandleAllocation ha(isolate);
10154 ASSERT(args.length() == 1); 10201 ASSERT(args.length() == 1);
10155 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); 10202 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0);
10156 // TODO(verwaest): Depends on the type of details. 10203 // TODO(verwaest): Depends on the type of details.
10157 return Smi::FromInt(details.dictionary_index()); 10204 return Smi::FromInt(details.dictionary_index());
10158 } 10205 }
10159 10206
10160 10207
10161 // Return property value from named interceptor. 10208 // Return property value from named interceptor.
10162 // args[0]: object 10209 // args[0]: object
10163 // args[1]: property name 10210 // args[1]: property name
(...skipping 17 matching lines...) Expand all
10181 ASSERT(args.length() == 2); 10228 ASSERT(args.length() == 2);
10182 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); 10229 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
10183 RUNTIME_ASSERT(obj->HasIndexedInterceptor()); 10230 RUNTIME_ASSERT(obj->HasIndexedInterceptor());
10184 CONVERT_NUMBER_CHECKED(uint32_t, index, Uint32, args[1]); 10231 CONVERT_NUMBER_CHECKED(uint32_t, index, Uint32, args[1]);
10185 10232
10186 return obj->GetElementWithInterceptor(*obj, index); 10233 return obj->GetElementWithInterceptor(*obj, index);
10187 } 10234 }
10188 10235
10189 10236
10190 RUNTIME_FUNCTION(MaybeObject*, Runtime_CheckExecutionState) { 10237 RUNTIME_FUNCTION(MaybeObject*, Runtime_CheckExecutionState) {
10238 NoHandleAllocation ha(isolate);
10191 ASSERT(args.length() >= 1); 10239 ASSERT(args.length() >= 1);
10192 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); 10240 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]);
10193 // Check that the break id is valid. 10241 // Check that the break id is valid.
10194 if (isolate->debug()->break_id() == 0 || 10242 if (isolate->debug()->break_id() == 0 ||
10195 break_id != isolate->debug()->break_id()) { 10243 break_id != isolate->debug()->break_id()) {
10196 return isolate->Throw( 10244 return isolate->Throw(
10197 isolate->heap()->illegal_execution_state_string()); 10245 isolate->heap()->illegal_execution_state_string());
10198 } 10246 }
10199 10247
10200 return isolate->heap()->true_value(); 10248 return isolate->heap()->true_value();
(...skipping 2010 matching lines...) Expand 10 before | Expand all | Expand 10 after
12211 // Return the number of referencing objects found. 12259 // Return the number of referencing objects found.
12212 return count; 12260 return count;
12213 } 12261 }
12214 12262
12215 12263
12216 // Scan the heap for objects with direct references to an object 12264 // Scan the heap for objects with direct references to an object
12217 // args[0]: the object to find references to 12265 // args[0]: the object to find references to
12218 // args[1]: constructor function for instances to exclude (Mirror) 12266 // args[1]: constructor function for instances to exclude (Mirror)
12219 // args[2]: the the maximum number of objects to return 12267 // args[2]: the the maximum number of objects to return
12220 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugReferencedBy) { 12268 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugReferencedBy) {
12269 NoHandleAllocation ha(isolate);
12221 ASSERT(args.length() == 3); 12270 ASSERT(args.length() == 3);
12222 12271
12223 // First perform a full GC in order to avoid references from dead objects. 12272 // First perform a full GC in order to avoid references from dead objects.
12224 isolate->heap()->CollectAllGarbage(Heap::kMakeHeapIterableMask, 12273 isolate->heap()->CollectAllGarbage(Heap::kMakeHeapIterableMask,
12225 "%DebugReferencedBy"); 12274 "%DebugReferencedBy");
12226 // The heap iterator reserves the right to do a GC to make the heap iterable. 12275 // The heap iterator reserves the right to do a GC to make the heap iterable.
12227 // Due to the GC above we know it won't need to do that, but it seems cleaner 12276 // Due to the GC above we know it won't need to do that, but it seems cleaner
12228 // to get the heap iterator constructed before we start having unprotected 12277 // to get the heap iterator constructed before we start having unprotected
12229 // Object* locals that are not protected by handles. 12278 // Object* locals that are not protected by handles.
12230 12279
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
12304 12353
12305 // Return the number of referencing objects found. 12354 // Return the number of referencing objects found.
12306 return count; 12355 return count;
12307 } 12356 }
12308 12357
12309 12358
12310 // Scan the heap for objects constructed by a specific function. 12359 // Scan the heap for objects constructed by a specific function.
12311 // args[0]: the constructor to find instances of 12360 // args[0]: the constructor to find instances of
12312 // args[1]: the the maximum number of objects to return 12361 // args[1]: the the maximum number of objects to return
12313 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugConstructedBy) { 12362 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugConstructedBy) {
12363 NoHandleAllocation ha(isolate);
12314 ASSERT(args.length() == 2); 12364 ASSERT(args.length() == 2);
12315 12365
12316 // First perform a full GC in order to avoid dead objects. 12366 // First perform a full GC in order to avoid dead objects.
12317 Heap* heap = isolate->heap(); 12367 Heap* heap = isolate->heap();
12318 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, "%DebugConstructedBy"); 12368 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, "%DebugConstructedBy");
12319 12369
12320 // Check parameters. 12370 // Check parameters.
12321 CONVERT_ARG_CHECKED(JSFunction, constructor, 0); 12371 CONVERT_ARG_CHECKED(JSFunction, constructor, 0);
12322 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[1]); 12372 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[1]);
12323 RUNTIME_ASSERT(max_references >= 0); 12373 RUNTIME_ASSERT(max_references >= 0);
(...skipping 29 matching lines...) Expand all
12353 isolate->context()->native_context()->array_function()); 12403 isolate->context()->native_context()->array_function());
12354 if (!maybe_result->ToObject(&result)) return maybe_result; 12404 if (!maybe_result->ToObject(&result)) return maybe_result;
12355 } 12405 }
12356 return JSArray::cast(result)->SetContent(instances); 12406 return JSArray::cast(result)->SetContent(instances);
12357 } 12407 }
12358 12408
12359 12409
12360 // Find the effective prototype object as returned by __proto__. 12410 // Find the effective prototype object as returned by __proto__.
12361 // args[0]: the object to find the prototype for. 12411 // args[0]: the object to find the prototype for.
12362 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetPrototype) { 12412 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetPrototype) {
12413 NoHandleAllocation ha(isolate);
12363 ASSERT(args.length() == 1); 12414 ASSERT(args.length() == 1);
12364 12415
12365 CONVERT_ARG_CHECKED(JSObject, obj, 0); 12416 CONVERT_ARG_CHECKED(JSObject, obj, 0);
12366 12417
12367 // Use the __proto__ accessor. 12418 // Use the __proto__ accessor.
12368 return Accessors::ObjectPrototype.getter(obj, NULL); 12419 return Accessors::ObjectPrototype.getter(obj, NULL);
12369 } 12420 }
12370 12421
12371 12422
12372 // Patches script source (should be called upon BeforeCompile event). 12423 // Patches script source (should be called upon BeforeCompile event).
12373 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugSetScriptSource) { 12424 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugSetScriptSource) {
12374 HandleScope scope(isolate); 12425 HandleScope scope(isolate);
12375 ASSERT(args.length() == 2); 12426 ASSERT(args.length() == 2);
12376 12427
12377 CONVERT_ARG_HANDLE_CHECKED(JSValue, script_wrapper, 0); 12428 CONVERT_ARG_HANDLE_CHECKED(JSValue, script_wrapper, 0);
12378 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); 12429 CONVERT_ARG_HANDLE_CHECKED(String, source, 1);
12379 12430
12380 RUNTIME_ASSERT(script_wrapper->value()->IsScript()); 12431 RUNTIME_ASSERT(script_wrapper->value()->IsScript());
12381 Handle<Script> script(Script::cast(script_wrapper->value())); 12432 Handle<Script> script(Script::cast(script_wrapper->value()));
12382 12433
12383 int compilation_state = Smi::cast(script->compilation_state())->value(); 12434 int compilation_state = Smi::cast(script->compilation_state())->value();
12384 RUNTIME_ASSERT(compilation_state == Script::COMPILATION_STATE_INITIAL); 12435 RUNTIME_ASSERT(compilation_state == Script::COMPILATION_STATE_INITIAL);
12385 script->set_source(*source); 12436 script->set_source(*source);
12386 12437
12387 return isolate->heap()->undefined_value(); 12438 return isolate->heap()->undefined_value();
12388 } 12439 }
12389 12440
12390 12441
12391 RUNTIME_FUNCTION(MaybeObject*, Runtime_SystemBreak) { 12442 RUNTIME_FUNCTION(MaybeObject*, Runtime_SystemBreak) {
12443 NoHandleAllocation ha(isolate);
12392 ASSERT(args.length() == 0); 12444 ASSERT(args.length() == 0);
12393 CPU::DebugBreak(); 12445 CPU::DebugBreak();
12394 return isolate->heap()->undefined_value(); 12446 return isolate->heap()->undefined_value();
12395 } 12447 }
12396 12448
12397 12449
12398 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugDisassembleFunction) { 12450 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugDisassembleFunction) {
12451 HandleScope scope(isolate);
12399 #ifdef DEBUG 12452 #ifdef DEBUG
12400 HandleScope scope(isolate);
12401 ASSERT(args.length() == 1); 12453 ASSERT(args.length() == 1);
12402 // Get the function and make sure it is compiled. 12454 // Get the function and make sure it is compiled.
12403 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0); 12455 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0);
12404 if (!JSFunction::EnsureCompiled(func, KEEP_EXCEPTION)) { 12456 if (!JSFunction::EnsureCompiled(func, KEEP_EXCEPTION)) {
12405 return Failure::Exception(); 12457 return Failure::Exception();
12406 } 12458 }
12407 func->code()->PrintLn(); 12459 func->code()->PrintLn();
12408 #endif // DEBUG 12460 #endif // DEBUG
12409 return isolate->heap()->undefined_value(); 12461 return isolate->heap()->undefined_value();
12410 } 12462 }
12411 12463
12412 12464
12413 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugDisassembleConstructor) { 12465 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugDisassembleConstructor) {
12466 HandleScope scope(isolate);
12414 #ifdef DEBUG 12467 #ifdef DEBUG
12415 HandleScope scope(isolate);
12416 ASSERT(args.length() == 1); 12468 ASSERT(args.length() == 1);
12417 // Get the function and make sure it is compiled. 12469 // Get the function and make sure it is compiled.
12418 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0); 12470 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0);
12419 if (!JSFunction::EnsureCompiled(func, KEEP_EXCEPTION)) { 12471 if (!JSFunction::EnsureCompiled(func, KEEP_EXCEPTION)) {
12420 return Failure::Exception(); 12472 return Failure::Exception();
12421 } 12473 }
12422 func->shared()->construct_stub()->PrintLn(); 12474 func->shared()->construct_stub()->PrintLn();
12423 #endif // DEBUG 12475 #endif // DEBUG
12424 return isolate->heap()->undefined_value(); 12476 return isolate->heap()->undefined_value();
12425 } 12477 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
12457 counter++; 12509 counter++;
12458 } 12510 }
12459 return counter; 12511 return counter;
12460 } 12512 }
12461 12513
12462 // For a script finds all SharedFunctionInfo's in the heap that points 12514 // For a script finds all SharedFunctionInfo's in the heap that points
12463 // to this script. Returns JSArray of SharedFunctionInfo wrapped 12515 // to this script. Returns JSArray of SharedFunctionInfo wrapped
12464 // in OpaqueReferences. 12516 // in OpaqueReferences.
12465 RUNTIME_FUNCTION(MaybeObject*, 12517 RUNTIME_FUNCTION(MaybeObject*,
12466 Runtime_LiveEditFindSharedFunctionInfosForScript) { 12518 Runtime_LiveEditFindSharedFunctionInfosForScript) {
12519 HandleScope scope(isolate);
12467 CHECK(isolate->debugger()->live_edit_enabled()); 12520 CHECK(isolate->debugger()->live_edit_enabled());
12468 ASSERT(args.length() == 1); 12521 ASSERT(args.length() == 1);
12469 HandleScope scope(isolate);
12470 CONVERT_ARG_CHECKED(JSValue, script_value, 0); 12522 CONVERT_ARG_CHECKED(JSValue, script_value, 0);
12471 12523
12472 RUNTIME_ASSERT(script_value->value()->IsScript()); 12524 RUNTIME_ASSERT(script_value->value()->IsScript());
12473 Handle<Script> script = Handle<Script>(Script::cast(script_value->value())); 12525 Handle<Script> script = Handle<Script>(Script::cast(script_value->value()));
12474 12526
12475 const int kBufferSize = 32; 12527 const int kBufferSize = 32;
12476 12528
12477 Handle<FixedArray> array; 12529 Handle<FixedArray> array;
12478 array = isolate->factory()->NewFixedArray(kBufferSize); 12530 array = isolate->factory()->NewFixedArray(kBufferSize);
12479 int number; 12531 int number;
(...skipping 25 matching lines...) Expand all
12505 } 12557 }
12506 12558
12507 // For a script calculates compilation information about all its functions. 12559 // For a script calculates compilation information about all its functions.
12508 // The script source is explicitly specified by the second argument. 12560 // The script source is explicitly specified by the second argument.
12509 // The source of the actual script is not used, however it is important that 12561 // The source of the actual script is not used, however it is important that
12510 // all generated code keeps references to this particular instance of script. 12562 // all generated code keeps references to this particular instance of script.
12511 // Returns a JSArray of compilation infos. The array is ordered so that 12563 // Returns a JSArray of compilation infos. The array is ordered so that
12512 // each function with all its descendant is always stored in a continues range 12564 // each function with all its descendant is always stored in a continues range
12513 // with the function itself going first. The root function is a script function. 12565 // with the function itself going first. The root function is a script function.
12514 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditGatherCompileInfo) { 12566 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditGatherCompileInfo) {
12567 HandleScope scope(isolate);
12515 CHECK(isolate->debugger()->live_edit_enabled()); 12568 CHECK(isolate->debugger()->live_edit_enabled());
12516 ASSERT(args.length() == 2); 12569 ASSERT(args.length() == 2);
12517 HandleScope scope(isolate);
12518 CONVERT_ARG_CHECKED(JSValue, script, 0); 12570 CONVERT_ARG_CHECKED(JSValue, script, 0);
12519 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); 12571 CONVERT_ARG_HANDLE_CHECKED(String, source, 1);
12520 12572
12521 RUNTIME_ASSERT(script->value()->IsScript()); 12573 RUNTIME_ASSERT(script->value()->IsScript());
12522 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); 12574 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value()));
12523 12575
12524 JSArray* result = LiveEdit::GatherCompileInfo(script_handle, source); 12576 JSArray* result = LiveEdit::GatherCompileInfo(script_handle, source);
12525 12577
12526 if (isolate->has_pending_exception()) { 12578 if (isolate->has_pending_exception()) {
12527 return Failure::Exception(); 12579 return Failure::Exception();
12528 } 12580 }
12529 12581
12530 return result; 12582 return result;
12531 } 12583 }
12532 12584
12533 // Changes the source of the script to a new_source. 12585 // Changes the source of the script to a new_source.
12534 // If old_script_name is provided (i.e. is a String), also creates a copy of 12586 // If old_script_name is provided (i.e. is a String), also creates a copy of
12535 // the script with its original source and sends notification to debugger. 12587 // the script with its original source and sends notification to debugger.
12536 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditReplaceScript) { 12588 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditReplaceScript) {
12589 HandleScope scope(isolate);
12537 CHECK(isolate->debugger()->live_edit_enabled()); 12590 CHECK(isolate->debugger()->live_edit_enabled());
12538 ASSERT(args.length() == 3); 12591 ASSERT(args.length() == 3);
12539 HandleScope scope(isolate);
12540 CONVERT_ARG_CHECKED(JSValue, original_script_value, 0); 12592 CONVERT_ARG_CHECKED(JSValue, original_script_value, 0);
12541 CONVERT_ARG_HANDLE_CHECKED(String, new_source, 1); 12593 CONVERT_ARG_HANDLE_CHECKED(String, new_source, 1);
12542 Handle<Object> old_script_name(args[2], isolate); 12594 Handle<Object> old_script_name(args[2], isolate);
12543 12595
12544 RUNTIME_ASSERT(original_script_value->value()->IsScript()); 12596 RUNTIME_ASSERT(original_script_value->value()->IsScript());
12545 Handle<Script> original_script(Script::cast(original_script_value->value())); 12597 Handle<Script> original_script(Script::cast(original_script_value->value()));
12546 12598
12547 Object* old_script = LiveEdit::ChangeScriptSource(original_script, 12599 Object* old_script = LiveEdit::ChangeScriptSource(original_script,
12548 new_source, 12600 new_source,
12549 old_script_name); 12601 old_script_name);
12550 12602
12551 if (old_script->IsScript()) { 12603 if (old_script->IsScript()) {
12552 Handle<Script> script_handle(Script::cast(old_script)); 12604 Handle<Script> script_handle(Script::cast(old_script));
12553 return *(GetScriptWrapper(script_handle)); 12605 return *(GetScriptWrapper(script_handle));
12554 } else { 12606 } else {
12555 return isolate->heap()->null_value(); 12607 return isolate->heap()->null_value();
12556 } 12608 }
12557 } 12609 }
12558 12610
12559 12611
12560 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditFunctionSourceUpdated) { 12612 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditFunctionSourceUpdated) {
12613 HandleScope scope(isolate);
12561 CHECK(isolate->debugger()->live_edit_enabled()); 12614 CHECK(isolate->debugger()->live_edit_enabled());
12562 ASSERT(args.length() == 1); 12615 ASSERT(args.length() == 1);
12563 HandleScope scope(isolate);
12564 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_info, 0); 12616 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_info, 0);
12565 return LiveEdit::FunctionSourceUpdated(shared_info); 12617 return LiveEdit::FunctionSourceUpdated(shared_info);
12566 } 12618 }
12567 12619
12568 12620
12569 // Replaces code of SharedFunctionInfo with a new one. 12621 // Replaces code of SharedFunctionInfo with a new one.
12570 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditReplaceFunctionCode) { 12622 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditReplaceFunctionCode) {
12623 HandleScope scope(isolate);
12571 CHECK(isolate->debugger()->live_edit_enabled()); 12624 CHECK(isolate->debugger()->live_edit_enabled());
12572 ASSERT(args.length() == 2); 12625 ASSERT(args.length() == 2);
12573 HandleScope scope(isolate);
12574 CONVERT_ARG_HANDLE_CHECKED(JSArray, new_compile_info, 0); 12626 CONVERT_ARG_HANDLE_CHECKED(JSArray, new_compile_info, 0);
12575 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_info, 1); 12627 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_info, 1);
12576 12628
12577 return LiveEdit::ReplaceFunctionCode(new_compile_info, shared_info); 12629 return LiveEdit::ReplaceFunctionCode(new_compile_info, shared_info);
12578 } 12630 }
12579 12631
12580 // Connects SharedFunctionInfo to another script. 12632 // Connects SharedFunctionInfo to another script.
12581 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditFunctionSetScript) { 12633 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditFunctionSetScript) {
12634 HandleScope scope(isolate);
12582 CHECK(isolate->debugger()->live_edit_enabled()); 12635 CHECK(isolate->debugger()->live_edit_enabled());
12583 ASSERT(args.length() == 2); 12636 ASSERT(args.length() == 2);
12584 HandleScope scope(isolate);
12585 Handle<Object> function_object(args[0], isolate); 12637 Handle<Object> function_object(args[0], isolate);
12586 Handle<Object> script_object(args[1], isolate); 12638 Handle<Object> script_object(args[1], isolate);
12587 12639
12588 if (function_object->IsJSValue()) { 12640 if (function_object->IsJSValue()) {
12589 Handle<JSValue> function_wrapper = Handle<JSValue>::cast(function_object); 12641 Handle<JSValue> function_wrapper = Handle<JSValue>::cast(function_object);
12590 if (script_object->IsJSValue()) { 12642 if (script_object->IsJSValue()) {
12591 RUNTIME_ASSERT(JSValue::cast(*script_object)->value()->IsScript()); 12643 RUNTIME_ASSERT(JSValue::cast(*script_object)->value()->IsScript());
12592 Script* script = Script::cast(JSValue::cast(*script_object)->value()); 12644 Script* script = Script::cast(JSValue::cast(*script_object)->value());
12593 script_object = Handle<Object>(script, isolate); 12645 script_object = Handle<Object>(script, isolate);
12594 } 12646 }
12595 12647
12596 LiveEdit::SetFunctionScript(function_wrapper, script_object); 12648 LiveEdit::SetFunctionScript(function_wrapper, script_object);
12597 } else { 12649 } else {
12598 // Just ignore this. We may not have a SharedFunctionInfo for some functions 12650 // Just ignore this. We may not have a SharedFunctionInfo for some functions
12599 // and we check it in this function. 12651 // and we check it in this function.
12600 } 12652 }
12601 12653
12602 return isolate->heap()->undefined_value(); 12654 return isolate->heap()->undefined_value();
12603 } 12655 }
12604 12656
12605 12657
12606 // In a code of a parent function replaces original function as embedded object 12658 // In a code of a parent function replaces original function as embedded object
12607 // with a substitution one. 12659 // with a substitution one.
12608 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditReplaceRefToNestedFunction) { 12660 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditReplaceRefToNestedFunction) {
12661 HandleScope scope(isolate);
12609 CHECK(isolate->debugger()->live_edit_enabled()); 12662 CHECK(isolate->debugger()->live_edit_enabled());
12610 ASSERT(args.length() == 3); 12663 ASSERT(args.length() == 3);
12611 HandleScope scope(isolate);
12612 12664
12613 CONVERT_ARG_HANDLE_CHECKED(JSValue, parent_wrapper, 0); 12665 CONVERT_ARG_HANDLE_CHECKED(JSValue, parent_wrapper, 0);
12614 CONVERT_ARG_HANDLE_CHECKED(JSValue, orig_wrapper, 1); 12666 CONVERT_ARG_HANDLE_CHECKED(JSValue, orig_wrapper, 1);
12615 CONVERT_ARG_HANDLE_CHECKED(JSValue, subst_wrapper, 2); 12667 CONVERT_ARG_HANDLE_CHECKED(JSValue, subst_wrapper, 2);
12616 12668
12617 LiveEdit::ReplaceRefToNestedFunction(parent_wrapper, orig_wrapper, 12669 LiveEdit::ReplaceRefToNestedFunction(parent_wrapper, orig_wrapper,
12618 subst_wrapper); 12670 subst_wrapper);
12619 12671
12620 return isolate->heap()->undefined_value(); 12672 return isolate->heap()->undefined_value();
12621 } 12673 }
12622 12674
12623 12675
12624 // Updates positions of a shared function info (first parameter) according 12676 // Updates positions of a shared function info (first parameter) according
12625 // to script source change. Text change is described in second parameter as 12677 // to script source change. Text change is described in second parameter as
12626 // array of groups of 3 numbers: 12678 // array of groups of 3 numbers:
12627 // (change_begin, change_end, change_end_new_position). 12679 // (change_begin, change_end, change_end_new_position).
12628 // Each group describes a change in text; groups are sorted by change_begin. 12680 // Each group describes a change in text; groups are sorted by change_begin.
12629 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditPatchFunctionPositions) { 12681 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditPatchFunctionPositions) {
12682 HandleScope scope(isolate);
12630 CHECK(isolate->debugger()->live_edit_enabled()); 12683 CHECK(isolate->debugger()->live_edit_enabled());
12631 ASSERT(args.length() == 2); 12684 ASSERT(args.length() == 2);
12632 HandleScope scope(isolate);
12633 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_array, 0); 12685 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_array, 0);
12634 CONVERT_ARG_HANDLE_CHECKED(JSArray, position_change_array, 1); 12686 CONVERT_ARG_HANDLE_CHECKED(JSArray, position_change_array, 1);
12635 12687
12636 return LiveEdit::PatchFunctionPositions(shared_array, position_change_array); 12688 return LiveEdit::PatchFunctionPositions(shared_array, position_change_array);
12637 } 12689 }
12638 12690
12639 12691
12640 // For array of SharedFunctionInfo's (each wrapped in JSValue) 12692 // For array of SharedFunctionInfo's (each wrapped in JSValue)
12641 // checks that none of them have activations on stacks (of any thread). 12693 // checks that none of them have activations on stacks (of any thread).
12642 // Returns array of the same length with corresponding results of 12694 // Returns array of the same length with corresponding results of
12643 // LiveEdit::FunctionPatchabilityStatus type. 12695 // LiveEdit::FunctionPatchabilityStatus type.
12644 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCheckAndDropActivations) { 12696 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCheckAndDropActivations) {
12697 HandleScope scope(isolate);
12645 CHECK(isolate->debugger()->live_edit_enabled()); 12698 CHECK(isolate->debugger()->live_edit_enabled());
12646 ASSERT(args.length() == 2); 12699 ASSERT(args.length() == 2);
12647 HandleScope scope(isolate);
12648 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_array, 0); 12700 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_array, 0);
12649 CONVERT_BOOLEAN_ARG_CHECKED(do_drop, 1); 12701 CONVERT_BOOLEAN_ARG_CHECKED(do_drop, 1);
12650 12702
12651 return *LiveEdit::CheckAndDropActivations(shared_array, do_drop, 12703 return *LiveEdit::CheckAndDropActivations(shared_array, do_drop,
12652 isolate->runtime_zone()); 12704 isolate->runtime_zone());
12653 } 12705 }
12654 12706
12655 // Compares 2 strings line-by-line, then token-wise and returns diff in form 12707 // Compares 2 strings line-by-line, then token-wise and returns diff in form
12656 // of JSArray of triplets (pos1, pos1_end, pos2_end) describing list 12708 // of JSArray of triplets (pos1, pos1_end, pos2_end) describing list
12657 // of diff chunks. 12709 // of diff chunks.
12658 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCompareStrings) { 12710 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCompareStrings) {
12711 HandleScope scope(isolate);
12659 CHECK(isolate->debugger()->live_edit_enabled()); 12712 CHECK(isolate->debugger()->live_edit_enabled());
12660 ASSERT(args.length() == 2); 12713 ASSERT(args.length() == 2);
12661 HandleScope scope(isolate);
12662 CONVERT_ARG_HANDLE_CHECKED(String, s1, 0); 12714 CONVERT_ARG_HANDLE_CHECKED(String, s1, 0);
12663 CONVERT_ARG_HANDLE_CHECKED(String, s2, 1); 12715 CONVERT_ARG_HANDLE_CHECKED(String, s2, 1);
12664 12716
12665 return *LiveEdit::CompareStrings(s1, s2); 12717 return *LiveEdit::CompareStrings(s1, s2);
12666 } 12718 }
12667 12719
12668 12720
12669 // Restarts a call frame and completely drops all frames above. 12721 // Restarts a call frame and completely drops all frames above.
12670 // Returns true if successful. Otherwise returns undefined or an error message. 12722 // Returns true if successful. Otherwise returns undefined or an error message.
12671 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditRestartFrame) { 12723 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditRestartFrame) {
12724 HandleScope scope(isolate);
12672 CHECK(isolate->debugger()->live_edit_enabled()); 12725 CHECK(isolate->debugger()->live_edit_enabled());
12673 HandleScope scope(isolate);
12674 ASSERT(args.length() == 2); 12726 ASSERT(args.length() == 2);
12675 12727
12676 // Check arguments. 12728 // Check arguments.
12677 Object* check; 12729 Object* check;
12678 { MaybeObject* maybe_check = Runtime_CheckExecutionState( 12730 { MaybeObject* maybe_check = Runtime_CheckExecutionState(
12679 RUNTIME_ARGUMENTS(isolate, args)); 12731 RUNTIME_ARGUMENTS(isolate, args));
12680 if (!maybe_check->ToObject(&check)) return maybe_check; 12732 if (!maybe_check->ToObject(&check)) return maybe_check;
12681 } 12733 }
12682 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); 12734 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]);
12683 Heap* heap = isolate->heap(); 12735 Heap* heap = isolate->heap();
(...skipping 18 matching lines...) Expand all
12702 if (error_message) { 12754 if (error_message) {
12703 return *(isolate->factory()->InternalizeUtf8String(error_message)); 12755 return *(isolate->factory()->InternalizeUtf8String(error_message));
12704 } 12756 }
12705 return heap->true_value(); 12757 return heap->true_value();
12706 } 12758 }
12707 12759
12708 12760
12709 // A testing entry. Returns statement position which is the closest to 12761 // A testing entry. Returns statement position which is the closest to
12710 // source_position. 12762 // source_position.
12711 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFunctionCodePositionFromSource) { 12763 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFunctionCodePositionFromSource) {
12764 HandleScope scope(isolate);
12712 CHECK(isolate->debugger()->live_edit_enabled()); 12765 CHECK(isolate->debugger()->live_edit_enabled());
12713 ASSERT(args.length() == 2); 12766 ASSERT(args.length() == 2);
12714 HandleScope scope(isolate);
12715 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 12767 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
12716 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); 12768 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]);
12717 12769
12718 Handle<Code> code(function->code(), isolate); 12770 Handle<Code> code(function->code(), isolate);
12719 12771
12720 if (code->kind() != Code::FUNCTION && 12772 if (code->kind() != Code::FUNCTION &&
12721 code->kind() != Code::OPTIMIZED_FUNCTION) { 12773 code->kind() != Code::OPTIMIZED_FUNCTION) {
12722 return isolate->heap()->undefined_value(); 12774 return isolate->heap()->undefined_value();
12723 } 12775 }
12724 12776
(...skipping 15 matching lines...) Expand all
12740 } 12792 }
12741 12793
12742 return Smi::FromInt(closest_pc); 12794 return Smi::FromInt(closest_pc);
12743 } 12795 }
12744 12796
12745 12797
12746 // Calls specified function with or without entering the debugger. 12798 // Calls specified function with or without entering the debugger.
12747 // This is used in unit tests to run code as if debugger is entered or simply 12799 // This is used in unit tests to run code as if debugger is entered or simply
12748 // to have a stack with C++ frame in the middle. 12800 // to have a stack with C++ frame in the middle.
12749 RUNTIME_FUNCTION(MaybeObject*, Runtime_ExecuteInDebugContext) { 12801 RUNTIME_FUNCTION(MaybeObject*, Runtime_ExecuteInDebugContext) {
12802 HandleScope scope(isolate);
12750 ASSERT(args.length() == 2); 12803 ASSERT(args.length() == 2);
12751 HandleScope scope(isolate);
12752 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 12804 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
12753 CONVERT_BOOLEAN_ARG_CHECKED(without_debugger, 1); 12805 CONVERT_BOOLEAN_ARG_CHECKED(without_debugger, 1);
12754 12806
12755 Handle<Object> result; 12807 Handle<Object> result;
12756 bool pending_exception; 12808 bool pending_exception;
12757 { 12809 {
12758 if (without_debugger) { 12810 if (without_debugger) {
12759 result = Execution::Call(function, isolate->global_object(), 0, NULL, 12811 result = Execution::Call(function, isolate->global_object(), 0, NULL,
12760 &pending_exception); 12812 &pending_exception);
12761 } else { 12813 } else {
12762 EnterDebugger enter_debugger; 12814 EnterDebugger enter_debugger;
12763 result = Execution::Call(function, isolate->global_object(), 0, NULL, 12815 result = Execution::Call(function, isolate->global_object(), 0, NULL,
12764 &pending_exception); 12816 &pending_exception);
12765 } 12817 }
12766 } 12818 }
12767 if (!pending_exception) { 12819 if (!pending_exception) {
12768 return *result; 12820 return *result;
12769 } else { 12821 } else {
12770 return Failure::Exception(); 12822 return Failure::Exception();
12771 } 12823 }
12772 } 12824 }
12773 12825
12774 12826
12775 // Sets a v8 flag. 12827 // Sets a v8 flag.
12776 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetFlags) { 12828 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetFlags) {
12829 NoHandleAllocation ha(isolate);
12777 CONVERT_ARG_CHECKED(String, arg, 0); 12830 CONVERT_ARG_CHECKED(String, arg, 0);
12778 SmartArrayPointer<char> flags = 12831 SmartArrayPointer<char> flags =
12779 arg->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 12832 arg->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
12780 FlagList::SetFlagsFromString(*flags, StrLength(*flags)); 12833 FlagList::SetFlagsFromString(*flags, StrLength(*flags));
12781 return isolate->heap()->undefined_value(); 12834 return isolate->heap()->undefined_value();
12782 } 12835 }
12783 12836
12784 12837
12785 // Performs a GC. 12838 // Performs a GC.
12786 // Presently, it only does a full GC. 12839 // Presently, it only does a full GC.
12787 RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectGarbage) { 12840 RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectGarbage) {
12841 NoHandleAllocation ha(isolate);
12788 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, "%CollectGarbage"); 12842 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, "%CollectGarbage");
12789 return isolate->heap()->undefined_value(); 12843 return isolate->heap()->undefined_value();
12790 } 12844 }
12791 12845
12792 12846
12793 // Gets the current heap usage. 12847 // Gets the current heap usage.
12794 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetHeapUsage) { 12848 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetHeapUsage) {
12849 NoHandleAllocation ha(isolate);
12795 int usage = static_cast<int>(isolate->heap()->SizeOfObjects()); 12850 int usage = static_cast<int>(isolate->heap()->SizeOfObjects());
12796 if (!Smi::IsValid(usage)) { 12851 if (!Smi::IsValid(usage)) {
12797 return *isolate->factory()->NewNumberFromInt(usage); 12852 return *isolate->factory()->NewNumberFromInt(usage);
12798 } 12853 }
12799 return Smi::FromInt(usage); 12854 return Smi::FromInt(usage);
12800 } 12855 }
12801 12856
12802 #endif // ENABLE_DEBUGGER_SUPPORT 12857 #endif // ENABLE_DEBUGGER_SUPPORT
12803 12858
12804 12859
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
12865 Handle<Object> result = 12920 Handle<Object> result =
12866 Runtime_GetScriptFromScriptName(Handle<String>(script_name)); 12921 Runtime_GetScriptFromScriptName(Handle<String>(script_name));
12867 return *result; 12922 return *result;
12868 } 12923 }
12869 12924
12870 12925
12871 // Collect the raw data for a stack trace. Returns an array of 4 12926 // Collect the raw data for a stack trace. Returns an array of 4
12872 // element segments each containing a receiver, function, code and 12927 // element segments each containing a receiver, function, code and
12873 // native code offset. 12928 // native code offset.
12874 RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectStackTrace) { 12929 RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectStackTrace) {
12930 HandleScope scope(isolate);
12875 ASSERT_EQ(args.length(), 3); 12931 ASSERT_EQ(args.length(), 3);
12876 CONVERT_ARG_HANDLE_CHECKED(JSObject, error_object, 0); 12932 CONVERT_ARG_HANDLE_CHECKED(JSObject, error_object, 0);
12877 Handle<Object> caller = args.at<Object>(1); 12933 Handle<Object> caller = args.at<Object>(1);
12878 CONVERT_NUMBER_CHECKED(int32_t, limit, Int32, args[2]); 12934 CONVERT_NUMBER_CHECKED(int32_t, limit, Int32, args[2]);
12879 12935
12880 HandleScope scope(isolate);
12881 // Optionally capture a more detailed stack trace for the message. 12936 // Optionally capture a more detailed stack trace for the message.
12882 isolate->CaptureAndSetDetailedStackTrace(error_object); 12937 isolate->CaptureAndSetDetailedStackTrace(error_object);
12883 // Capture a simple stack trace for the stack property. 12938 // Capture a simple stack trace for the stack property.
12884 return *isolate->CaptureSimpleStackTrace(error_object, caller, limit); 12939 return *isolate->CaptureSimpleStackTrace(error_object, caller, limit);
12885 } 12940 }
12886 12941
12887 12942
12888 // Mark a function to recognize when called after GC to format the stack trace. 12943 // Mark a function to recognize when called after GC to format the stack trace.
12889 RUNTIME_FUNCTION(MaybeObject*, Runtime_MarkOneShotGetter) { 12944 RUNTIME_FUNCTION(MaybeObject*, Runtime_MarkOneShotGetter) {
12945 HandleScope scope(isolate);
12890 ASSERT_EQ(args.length(), 1); 12946 ASSERT_EQ(args.length(), 1);
12891 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); 12947 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0);
12892 HandleScope scope(isolate);
12893 Handle<String> key = isolate->factory()->hidden_stack_trace_string(); 12948 Handle<String> key = isolate->factory()->hidden_stack_trace_string();
12894 JSObject::SetHiddenProperty(fun, key, key); 12949 JSObject::SetHiddenProperty(fun, key, key);
12895 return *fun; 12950 return *fun;
12896 } 12951 }
12897 12952
12898 12953
12899 // Retrieve the stack trace. This could be the raw stack trace collected 12954 // Retrieve the stack trace. This could be the raw stack trace collected
12900 // on stack overflow or the already formatted stack trace string. 12955 // on stack overflow or the already formatted stack trace string.
12901 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOverflowedStackTrace) { 12956 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOverflowedStackTrace) {
12902 HandleScope scope(isolate); 12957 HandleScope scope(isolate);
(...skipping 20 matching lines...) Expand all
12923 } else { 12978 } else {
12924 RUNTIME_ASSERT(value->IsString()); 12979 RUNTIME_ASSERT(value->IsString());
12925 JSObject::SetHiddenProperty(error_object, key, value); 12980 JSObject::SetHiddenProperty(error_object, key, value);
12926 } 12981 }
12927 return *error_object; 12982 return *error_object;
12928 } 12983 }
12929 12984
12930 12985
12931 // Returns V8 version as a string. 12986 // Returns V8 version as a string.
12932 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetV8Version) { 12987 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetV8Version) {
12988 NoHandleAllocation ha(isolate);
12933 ASSERT_EQ(args.length(), 0); 12989 ASSERT_EQ(args.length(), 0);
12934 12990
12935 NoHandleAllocation ha(isolate);
12936
12937 const char* version_string = v8::V8::GetVersion(); 12991 const char* version_string = v8::V8::GetVersion();
12938 12992
12939 return isolate->heap()->AllocateStringFromOneByte(CStrVector(version_string), 12993 return isolate->heap()->AllocateStringFromOneByte(CStrVector(version_string),
12940 NOT_TENURED); 12994 NOT_TENURED);
12941 } 12995 }
12942 12996
12943 12997
12944 RUNTIME_FUNCTION(MaybeObject*, Runtime_Abort) { 12998 RUNTIME_FUNCTION(MaybeObject*, Runtime_Abort) {
12999 NoHandleAllocation ha(isolate);
12945 ASSERT(args.length() == 2); 13000 ASSERT(args.length() == 2);
12946 OS::PrintError("abort: %s\n", 13001 OS::PrintError("abort: %s\n",
12947 reinterpret_cast<char*>(args[0]) + args.smi_at(1)); 13002 reinterpret_cast<char*>(args[0]) + args.smi_at(1));
12948 isolate->PrintStack(); 13003 isolate->PrintStack();
12949 OS::Abort(); 13004 OS::Abort();
12950 UNREACHABLE(); 13005 UNREACHABLE();
12951 return NULL; 13006 return NULL;
12952 } 13007 }
12953 13008
12954 13009
12955 RUNTIME_FUNCTION(MaybeObject*, Runtime_FlattenString) { 13010 RUNTIME_FUNCTION(MaybeObject*, Runtime_FlattenString) {
12956 HandleScope scope(isolate); 13011 HandleScope scope(isolate);
12957 ASSERT(args.length() == 1); 13012 ASSERT(args.length() == 1);
12958 CONVERT_ARG_HANDLE_CHECKED(String, str, 0); 13013 CONVERT_ARG_HANDLE_CHECKED(String, str, 0);
12959 FlattenString(str); 13014 FlattenString(str);
12960 return isolate->heap()->undefined_value(); 13015 return isolate->heap()->undefined_value();
12961 } 13016 }
12962 13017
12963 13018
12964 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFromCache) { 13019 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFromCache) {
13020 NoHandleAllocation ha(isolate);
12965 // This is only called from codegen, so checks might be more lax. 13021 // This is only called from codegen, so checks might be more lax.
12966 CONVERT_ARG_CHECKED(JSFunctionResultCache, cache, 0); 13022 CONVERT_ARG_CHECKED(JSFunctionResultCache, cache, 0);
12967 Object* key = args[1]; 13023 Object* key = args[1];
12968 13024
12969 int finger_index = cache->finger_index(); 13025 int finger_index = cache->finger_index();
12970 Object* o = cache->get(finger_index); 13026 Object* o = cache->get(finger_index);
12971 if (o == key) { 13027 if (o == key) {
12972 // The fastest case: hit the same place again. 13028 // The fastest case: hit the same place again.
12973 return cache->get(finger_index + 1); 13029 return cache->get(finger_index + 1);
12974 } 13030 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
13052 if (FLAG_verify_heap) { 13108 if (FLAG_verify_heap) {
13053 cache_handle->JSFunctionResultCacheVerify(); 13109 cache_handle->JSFunctionResultCacheVerify();
13054 } 13110 }
13055 #endif 13111 #endif
13056 13112
13057 return *value; 13113 return *value;
13058 } 13114 }
13059 13115
13060 13116
13061 RUNTIME_FUNCTION(MaybeObject*, Runtime_MessageGetStartPosition) { 13117 RUNTIME_FUNCTION(MaybeObject*, Runtime_MessageGetStartPosition) {
13118 NoHandleAllocation ha(isolate);
13062 CONVERT_ARG_CHECKED(JSMessageObject, message, 0); 13119 CONVERT_ARG_CHECKED(JSMessageObject, message, 0);
13063 return Smi::FromInt(message->start_position()); 13120 return Smi::FromInt(message->start_position());
13064 } 13121 }
13065 13122
13066 13123
13067 RUNTIME_FUNCTION(MaybeObject*, Runtime_MessageGetScript) { 13124 RUNTIME_FUNCTION(MaybeObject*, Runtime_MessageGetScript) {
13125 NoHandleAllocation ha(isolate);
13068 CONVERT_ARG_CHECKED(JSMessageObject, message, 0); 13126 CONVERT_ARG_CHECKED(JSMessageObject, message, 0);
13069 return message->script(); 13127 return message->script();
13070 } 13128 }
13071 13129
13072 13130
13073 #ifdef DEBUG 13131 #ifdef DEBUG
13074 // ListNatives is ONLY used by the fuzz-natives.js in debug mode 13132 // ListNatives is ONLY used by the fuzz-natives.js in debug mode
13075 // Exclude the code in release mode. 13133 // Exclude the code in release mode.
13076 RUNTIME_FUNCTION(MaybeObject*, Runtime_ListNatives) { 13134 RUNTIME_FUNCTION(MaybeObject*, Runtime_ListNatives) {
13135 HandleScope scope(isolate);
13077 ASSERT(args.length() == 0); 13136 ASSERT(args.length() == 0);
13078 HandleScope scope(isolate);
13079 #define COUNT_ENTRY(Name, argc, ressize) + 1 13137 #define COUNT_ENTRY(Name, argc, ressize) + 1
13080 int entry_count = 0 13138 int entry_count = 0
13081 RUNTIME_FUNCTION_LIST(COUNT_ENTRY) 13139 RUNTIME_FUNCTION_LIST(COUNT_ENTRY)
13082 INLINE_FUNCTION_LIST(COUNT_ENTRY) 13140 INLINE_FUNCTION_LIST(COUNT_ENTRY)
13083 INLINE_RUNTIME_FUNCTION_LIST(COUNT_ENTRY); 13141 INLINE_RUNTIME_FUNCTION_LIST(COUNT_ENTRY);
13084 #undef COUNT_ENTRY 13142 #undef COUNT_ENTRY
13085 Factory* factory = isolate->factory(); 13143 Factory* factory = isolate->factory();
13086 Handle<FixedArray> elements = factory->NewFixedArray(entry_count); 13144 Handle<FixedArray> elements = factory->NewFixedArray(entry_count);
13087 int index = 0; 13145 int index = 0;
13088 bool inline_runtime_functions = false; 13146 bool inline_runtime_functions = false;
(...skipping 22 matching lines...) Expand all
13111 INLINE_RUNTIME_FUNCTION_LIST(ADD_ENTRY) 13169 INLINE_RUNTIME_FUNCTION_LIST(ADD_ENTRY)
13112 #undef ADD_ENTRY 13170 #undef ADD_ENTRY
13113 ASSERT_EQ(index, entry_count); 13171 ASSERT_EQ(index, entry_count);
13114 Handle<JSArray> result = factory->NewJSArrayWithElements(elements); 13172 Handle<JSArray> result = factory->NewJSArrayWithElements(elements);
13115 return *result; 13173 return *result;
13116 } 13174 }
13117 #endif 13175 #endif
13118 13176
13119 13177
13120 RUNTIME_FUNCTION(MaybeObject*, Runtime_Log) { 13178 RUNTIME_FUNCTION(MaybeObject*, Runtime_Log) {
13179 NoHandleAllocation ha(isolate);
13121 ASSERT(args.length() == 2); 13180 ASSERT(args.length() == 2);
13122 CONVERT_ARG_CHECKED(String, format, 0); 13181 CONVERT_ARG_CHECKED(String, format, 0);
13123 CONVERT_ARG_CHECKED(JSArray, elms, 1); 13182 CONVERT_ARG_CHECKED(JSArray, elms, 1);
13124 String::FlatContent format_content = format->GetFlatContent(); 13183 String::FlatContent format_content = format->GetFlatContent();
13125 RUNTIME_ASSERT(format_content.IsAscii()); 13184 RUNTIME_ASSERT(format_content.IsAscii());
13126 Vector<const uint8_t> chars = format_content.ToOneByteVector(); 13185 Vector<const uint8_t> chars = format_content.ToOneByteVector();
13127 LOGGER->LogRuntime(isolate, Vector<const char>::cast(chars), elms); 13186 LOGGER->LogRuntime(isolate, Vector<const char>::cast(chars), elms);
13128 return isolate->heap()->undefined_value(); 13187 return isolate->heap()->undefined_value();
13129 } 13188 }
13130 13189
(...skipping 26 matching lines...) Expand all
13157 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalUnsignedIntElements) 13216 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalUnsignedIntElements)
13158 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalFloatElements) 13217 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalFloatElements)
13159 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalDoubleElements) 13218 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalDoubleElements)
13160 // Properties test sitting with elements tests - not fooling anyone. 13219 // Properties test sitting with elements tests - not fooling anyone.
13161 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastProperties) 13220 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastProperties)
13162 13221
13163 #undef ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION 13222 #undef ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION
13164 13223
13165 13224
13166 RUNTIME_FUNCTION(MaybeObject*, Runtime_HaveSameMap) { 13225 RUNTIME_FUNCTION(MaybeObject*, Runtime_HaveSameMap) {
13226 NoHandleAllocation ha(isolate);
13167 ASSERT(args.length() == 2); 13227 ASSERT(args.length() == 2);
13168 CONVERT_ARG_CHECKED(JSObject, obj1, 0); 13228 CONVERT_ARG_CHECKED(JSObject, obj1, 0);
13169 CONVERT_ARG_CHECKED(JSObject, obj2, 1); 13229 CONVERT_ARG_CHECKED(JSObject, obj2, 1);
13170 return isolate->heap()->ToBoolean(obj1->map() == obj2->map()); 13230 return isolate->heap()->ToBoolean(obj1->map() == obj2->map());
13171 } 13231 }
13172 13232
13173 13233
13174 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsObserved) { 13234 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsObserved) {
13235 NoHandleAllocation ha(isolate);
13175 ASSERT(args.length() == 1); 13236 ASSERT(args.length() == 1);
13176 CONVERT_ARG_CHECKED(JSReceiver, obj, 0); 13237 CONVERT_ARG_CHECKED(JSReceiver, obj, 0);
13177 if (obj->IsJSGlobalProxy()) { 13238 if (obj->IsJSGlobalProxy()) {
13178 Object* proto = obj->GetPrototype(); 13239 Object* proto = obj->GetPrototype();
13179 if (obj->IsNull()) return isolate->heap()->false_value(); 13240 if (obj->IsNull()) return isolate->heap()->false_value();
13180 ASSERT(proto->IsJSGlobalObject()); 13241 ASSERT(proto->IsJSGlobalObject());
13181 obj = JSReceiver::cast(proto); 13242 obj = JSReceiver::cast(proto);
13182 } 13243 }
13183 return isolate->heap()->ToBoolean(obj->map()->is_observed()); 13244 return isolate->heap()->ToBoolean(obj->map()->is_observed());
13184 } 13245 }
13185 13246
13186 13247
13187 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetIsObserved) { 13248 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetIsObserved) {
13249 NoHandleAllocation ha(isolate);
13188 ASSERT(args.length() == 2); 13250 ASSERT(args.length() == 2);
13189 CONVERT_ARG_CHECKED(JSReceiver, obj, 0); 13251 CONVERT_ARG_CHECKED(JSReceiver, obj, 0);
13190 CONVERT_BOOLEAN_ARG_CHECKED(is_observed, 1); 13252 CONVERT_BOOLEAN_ARG_CHECKED(is_observed, 1);
13191 if (obj->IsJSGlobalProxy()) { 13253 if (obj->IsJSGlobalProxy()) {
13192 Object* proto = obj->GetPrototype(); 13254 Object* proto = obj->GetPrototype();
13193 if (obj->IsNull()) return isolate->heap()->undefined_value(); 13255 if (obj->IsNull()) return isolate->heap()->undefined_value();
13194 ASSERT(proto->IsJSGlobalObject()); 13256 ASSERT(proto->IsJSGlobalObject());
13195 obj = JSReceiver::cast(proto); 13257 obj = JSReceiver::cast(proto);
13196 } 13258 }
13197 ASSERT(!(obj->map()->is_observed() && obj->IsJSObject() && 13259 ASSERT(!(obj->map()->is_observed() && obj->IsJSObject() &&
(...skipping 10 matching lines...) Expand all
13208 Map* map; 13270 Map* map;
13209 if (!maybe->To(&map)) return maybe; 13271 if (!maybe->To(&map)) return maybe;
13210 map->set_is_observed(is_observed); 13272 map->set_is_observed(is_observed);
13211 obj->set_map(map); 13273 obj->set_map(map);
13212 } 13274 }
13213 return isolate->heap()->undefined_value(); 13275 return isolate->heap()->undefined_value();
13214 } 13276 }
13215 13277
13216 13278
13217 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetObserverDeliveryPending) { 13279 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetObserverDeliveryPending) {
13280 NoHandleAllocation ha(isolate);
13218 ASSERT(args.length() == 0); 13281 ASSERT(args.length() == 0);
13219 isolate->set_observer_delivery_pending(true); 13282 isolate->set_observer_delivery_pending(true);
13220 return isolate->heap()->undefined_value(); 13283 return isolate->heap()->undefined_value();
13221 } 13284 }
13222 13285
13223 13286
13224 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetObservationState) { 13287 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetObservationState) {
13288 NoHandleAllocation ha(isolate);
13225 ASSERT(args.length() == 0); 13289 ASSERT(args.length() == 0);
13226 return isolate->heap()->observation_state(); 13290 return isolate->heap()->observation_state();
13227 } 13291 }
13228 13292
13229 13293
13230 RUNTIME_FUNCTION(MaybeObject*, Runtime_ObservationWeakMapCreate) { 13294 RUNTIME_FUNCTION(MaybeObject*, Runtime_ObservationWeakMapCreate) {
13231 HandleScope scope(isolate); 13295 HandleScope scope(isolate);
13232 ASSERT(args.length() == 0); 13296 ASSERT(args.length() == 0);
13233 // TODO(adamk): Currently this runtime function is only called three times per 13297 // TODO(adamk): Currently this runtime function is only called three times per
13234 // isolate. If it's called more often, the map should be moved into the 13298 // isolate. If it's called more often, the map should be moved into the
13235 // strong root list. 13299 // strong root list.
13236 Handle<Map> map = 13300 Handle<Map> map =
13237 isolate->factory()->NewMap(JS_WEAK_MAP_TYPE, JSWeakMap::kSize); 13301 isolate->factory()->NewMap(JS_WEAK_MAP_TYPE, JSWeakMap::kSize);
13238 Handle<JSWeakMap> weakmap = 13302 Handle<JSWeakMap> weakmap =
13239 Handle<JSWeakMap>::cast(isolate->factory()->NewJSObjectFromMap(map)); 13303 Handle<JSWeakMap>::cast(isolate->factory()->NewJSObjectFromMap(map));
13240 return WeakMapInitialize(isolate, weakmap); 13304 return WeakMapInitialize(isolate, weakmap);
13241 } 13305 }
13242 13306
13243 13307
13244 RUNTIME_FUNCTION(MaybeObject*, Runtime_UnwrapGlobalProxy) { 13308 RUNTIME_FUNCTION(MaybeObject*, Runtime_UnwrapGlobalProxy) {
13309 NoHandleAllocation ha(isolate);
13245 ASSERT(args.length() == 1); 13310 ASSERT(args.length() == 1);
13246 Object* object = args[0]; 13311 Object* object = args[0];
13247 if (object->IsJSGlobalProxy()) { 13312 if (object->IsJSGlobalProxy()) {
13248 object = object->GetPrototype(isolate); 13313 object = object->GetPrototype(isolate);
13249 if (object->IsNull()) return isolate->heap()->undefined_value(); 13314 if (object->IsNull()) return isolate->heap()->undefined_value();
13250 } 13315 }
13251 return object; 13316 return object;
13252 } 13317 }
13253 13318
13254 13319
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
13331 // Handle last resort GC and make sure to allow future allocations 13396 // Handle last resort GC and make sure to allow future allocations
13332 // to grow the heap without causing GCs (if possible). 13397 // to grow the heap without causing GCs (if possible).
13333 isolate->counters()->gc_last_resort_from_js()->Increment(); 13398 isolate->counters()->gc_last_resort_from_js()->Increment();
13334 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 13399 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
13335 "Runtime::PerformGC"); 13400 "Runtime::PerformGC");
13336 } 13401 }
13337 } 13402 }
13338 13403
13339 13404
13340 } } // namespace v8::internal 13405 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698