OLD | NEW |
---|---|
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
62 namespace v8 { | 62 namespace v8 { |
63 namespace internal { | 63 namespace internal { |
64 | 64 |
65 | 65 |
66 #define RUNTIME_ASSERT(value) \ | 66 #define RUNTIME_ASSERT(value) \ |
67 if (!(value)) return isolate->ThrowIllegalOperation(); | 67 if (!(value)) return isolate->ThrowIllegalOperation(); |
68 | 68 |
69 // Cast the given object to a value of the specified type and store | 69 // Cast the given object to a value of the specified type and store |
70 // it in a variable with the given name. If the object is not of the | 70 // it in a variable with the given name. If the object is not of the |
71 // expected type call IllegalOperation and return. | 71 // expected type call IllegalOperation and return. |
72 #define CONVERT_CHECKED(Type, name, obj) \ | 72 #define CONVERT_CHECKED(Type, name, index) \ |
Jakob Kummerow
2012/02/20 17:31:47
Now that there's so little difference between CONV
Sven Panne
2012/02/21 07:21:01
I am not 100% sure if we can really handlify every
| |
73 RUNTIME_ASSERT(obj->Is##Type()); \ | 73 RUNTIME_ASSERT(args[index]->Is##Type()); \ |
74 Type* name = Type::cast(obj); | 74 Type* name = Type::cast(args[index]); |
75 | 75 |
76 #define CONVERT_ARG_CHECKED(Type, name, index) \ | 76 #define CONVERT_ARG_CHECKED(Type, name, index) \ |
77 RUNTIME_ASSERT(args[index]->Is##Type()); \ | 77 RUNTIME_ASSERT(args[index]->Is##Type()); \ |
78 Handle<Type> name = args.at<Type>(index); | 78 Handle<Type> name = args.at<Type>(index); |
79 | 79 |
80 // Cast the given object to a boolean and store it in a variable with | 80 // Cast the given object to a boolean and store it in a variable with |
81 // the given name. If the object is not a boolean call IllegalOperation | 81 // the given name. If the object is not a boolean call IllegalOperation |
82 // and return. | 82 // and return. |
83 #define CONVERT_BOOLEAN_CHECKED(name, obj) \ | 83 #define CONVERT_BOOLEAN_CHECKED(name, index) \ |
84 RUNTIME_ASSERT(obj->IsBoolean()); \ | 84 RUNTIME_ASSERT(args[index]->IsBoolean()); \ |
85 bool name = (obj)->IsTrue(); | 85 bool name = args[index]->IsTrue(); |
86 | 86 |
87 // Cast the given argument to a Smi and store its value in an int variable | 87 // Cast the given argument to a Smi and store its value in an int variable |
88 // with the given name. If the argument is not a Smi call IllegalOperation | 88 // with the given name. If the argument is not a Smi call IllegalOperation |
89 // and return. | 89 // and return. |
90 #define CONVERT_SMI_ARG_CHECKED(name, index) \ | 90 #define CONVERT_SMI_ARG_CHECKED(name, index) \ |
91 RUNTIME_ASSERT(args[index]->IsSmi()); \ | 91 RUNTIME_ASSERT(args[index]->IsSmi()); \ |
92 int name = args.smi_at(index); | 92 int name = args.smi_at(index); |
93 | 93 |
94 // Cast the given argument to a double and store it in a variable with | 94 // Cast the given argument to a double and store it in a variable with |
95 // the given name. If the argument is not a number (as opposed to | 95 // the given name. If the argument is not a number (as opposed to |
96 // the number not-a-number) call IllegalOperation and return. | 96 // the number not-a-number) call IllegalOperation and return. |
97 #define CONVERT_DOUBLE_ARG_CHECKED(name, index) \ | 97 #define CONVERT_DOUBLE_ARG_CHECKED(name, index) \ |
98 RUNTIME_ASSERT(args[index]->IsNumber()); \ | 98 RUNTIME_ASSERT(args[index]->IsNumber()); \ |
99 double name = args.number_at(index); | 99 double name = args.number_at(index); |
100 | 100 |
101 // Call the specified converter on the object *comand store the result in | 101 // Call the specified converter on the object *comand store the result in |
102 // a variable of the specified type with the given name. If the | 102 // a variable of the specified type with the given name. If the |
103 // object is not a Number call IllegalOperation and return. | 103 // object is not a Number call IllegalOperation and return. |
104 #define CONVERT_NUMBER_CHECKED(type, name, Type, obj) \ | 104 #define CONVERT_NUMBER_CHECKED(type, name, Type, obj) \ |
105 RUNTIME_ASSERT(obj->IsNumber()); \ | 105 RUNTIME_ASSERT(obj->IsNumber()); \ |
106 type name = NumberTo##Type(obj); | 106 type name = NumberTo##Type(obj); |
107 | 107 |
108 | 108 |
109 // Cast the given argument to PropertyDetails and store its value in a | |
110 // variable with the given name. If the argument is not a Smi call | |
111 // IllegalOperation and return. | |
112 #define CONVERT_PROPERTY_DETAILS_CHECKED(name, index) \ | |
113 RUNTIME_ASSERT(args[index]->IsSmi()); \ | |
114 PropertyDetails name = PropertyDetails(Smi::cast(args[index])); | |
115 | |
116 | |
109 // Assert that the given argument has a valid value for a StrictModeFlag | 117 // Assert that the given argument has a valid value for a StrictModeFlag |
110 // and store it in a StrictModeFlag variable with the given name. | 118 // and store it in a StrictModeFlag variable with the given name. |
111 #define CONVERT_STRICT_MODE_ARG(name, index) \ | 119 #define CONVERT_STRICT_MODE_ARG(name, index) \ |
112 ASSERT(args[index]->IsSmi()); \ | 120 RUNTIME_ASSERT(args[index]->IsSmi()); \ |
113 ASSERT(args.smi_at(index) == kStrictMode || \ | 121 RUNTIME_ASSERT(args.smi_at(index) == kStrictMode || \ |
114 args.smi_at(index) == kNonStrictMode); \ | 122 args.smi_at(index) == kNonStrictMode); \ |
115 StrictModeFlag name = \ | 123 StrictModeFlag name = \ |
116 static_cast<StrictModeFlag>(args.smi_at(index)); | 124 static_cast<StrictModeFlag>(args.smi_at(index)); |
117 | 125 |
118 | 126 |
119 // Assert that the given argument has a valid value for a LanguageMode | 127 // Assert that the given argument has a valid value for a LanguageMode |
120 // and store it in a LanguageMode variable with the given name. | 128 // and store it in a LanguageMode variable with the given name. |
121 #define CONVERT_LANGUAGE_MODE_ARG(name, index) \ | 129 #define CONVERT_LANGUAGE_MODE_ARG(name, index) \ |
122 ASSERT(args[index]->IsSmi()); \ | 130 ASSERT(args[index]->IsSmi()); \ |
Jakob Kummerow
2012/02/20 17:31:47
RUNTIME_ASSERT here, too?
Sven Panne
2012/02/21 07:21:01
This is what initially thought, too, but the funct
| |
123 ASSERT(args.smi_at(index) == CLASSIC_MODE || \ | 131 ASSERT(args.smi_at(index) == CLASSIC_MODE || \ |
124 args.smi_at(index) == STRICT_MODE || \ | 132 args.smi_at(index) == STRICT_MODE || \ |
125 args.smi_at(index) == EXTENDED_MODE); \ | 133 args.smi_at(index) == EXTENDED_MODE); \ |
126 LanguageMode name = \ | 134 LanguageMode name = \ |
127 static_cast<LanguageMode>(args.smi_at(index)); | 135 static_cast<LanguageMode>(args.smi_at(index)); |
128 | 136 |
129 | 137 |
130 MUST_USE_RESULT static MaybeObject* DeepCopyBoilerplate(Isolate* isolate, | 138 MUST_USE_RESULT static MaybeObject* DeepCopyBoilerplate(Isolate* isolate, |
131 JSObject* boilerplate) { | 139 JSObject* boilerplate) { |
132 StackLimitCheck check(isolate); | 140 StackLimitCheck check(isolate); |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
684 | 692 |
685 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsJSFunctionProxy) { | 693 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsJSFunctionProxy) { |
686 ASSERT(args.length() == 1); | 694 ASSERT(args.length() == 1); |
687 Object* obj = args[0]; | 695 Object* obj = args[0]; |
688 return isolate->heap()->ToBoolean(obj->IsJSFunctionProxy()); | 696 return isolate->heap()->ToBoolean(obj->IsJSFunctionProxy()); |
689 } | 697 } |
690 | 698 |
691 | 699 |
692 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetHandler) { | 700 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetHandler) { |
693 ASSERT(args.length() == 1); | 701 ASSERT(args.length() == 1); |
694 CONVERT_CHECKED(JSProxy, proxy, args[0]); | 702 CONVERT_CHECKED(JSProxy, proxy, 0); |
695 return proxy->handler(); | 703 return proxy->handler(); |
696 } | 704 } |
697 | 705 |
698 | 706 |
699 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetCallTrap) { | 707 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetCallTrap) { |
700 ASSERT(args.length() == 1); | 708 ASSERT(args.length() == 1); |
701 CONVERT_CHECKED(JSFunctionProxy, proxy, args[0]); | 709 CONVERT_CHECKED(JSFunctionProxy, proxy, 0); |
702 return proxy->call_trap(); | 710 return proxy->call_trap(); |
703 } | 711 } |
704 | 712 |
705 | 713 |
706 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetConstructTrap) { | 714 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetConstructTrap) { |
707 ASSERT(args.length() == 1); | 715 ASSERT(args.length() == 1); |
708 CONVERT_CHECKED(JSFunctionProxy, proxy, args[0]); | 716 CONVERT_CHECKED(JSFunctionProxy, proxy, 0); |
709 return proxy->construct_trap(); | 717 return proxy->construct_trap(); |
710 } | 718 } |
711 | 719 |
712 | 720 |
713 RUNTIME_FUNCTION(MaybeObject*, Runtime_Fix) { | 721 RUNTIME_FUNCTION(MaybeObject*, Runtime_Fix) { |
714 ASSERT(args.length() == 1); | 722 ASSERT(args.length() == 1); |
715 CONVERT_CHECKED(JSProxy, proxy, args[0]); | 723 CONVERT_CHECKED(JSProxy, proxy, 0); |
716 proxy->Fix(); | 724 proxy->Fix(); |
717 return isolate->heap()->undefined_value(); | 725 return isolate->heap()->undefined_value(); |
718 } | 726 } |
719 | 727 |
720 | 728 |
721 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetInitialize) { | 729 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetInitialize) { |
722 HandleScope scope(isolate); | 730 HandleScope scope(isolate); |
723 ASSERT(args.length() == 1); | 731 ASSERT(args.length() == 1); |
724 CONVERT_ARG_CHECKED(JSSet, holder, 0); | 732 CONVERT_ARG_CHECKED(JSSet, holder, 0); |
725 Handle<ObjectHashSet> table = isolate->factory()->NewObjectHashSet(0); | 733 Handle<ObjectHashSet> table = isolate->factory()->NewObjectHashSet(0); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
833 ASSERT(args.length() == 1); | 841 ASSERT(args.length() == 1); |
834 Object* obj = args[0]; | 842 Object* obj = args[0]; |
835 if (!obj->IsJSObject()) return isolate->heap()->null_value(); | 843 if (!obj->IsJSObject()) return isolate->heap()->null_value(); |
836 return JSObject::cast(obj)->class_name(); | 844 return JSObject::cast(obj)->class_name(); |
837 } | 845 } |
838 | 846 |
839 | 847 |
840 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPrototype) { | 848 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPrototype) { |
841 NoHandleAllocation ha; | 849 NoHandleAllocation ha; |
842 ASSERT(args.length() == 1); | 850 ASSERT(args.length() == 1); |
843 CONVERT_CHECKED(JSReceiver, input_obj, args[0]); | 851 CONVERT_CHECKED(JSReceiver, input_obj, 0); |
844 Object* obj = input_obj; | 852 Object* obj = input_obj; |
845 // We don't expect access checks to be needed on JSProxy objects. | 853 // We don't expect access checks to be needed on JSProxy objects. |
846 ASSERT(!obj->IsAccessCheckNeeded() || obj->IsJSObject()); | 854 ASSERT(!obj->IsAccessCheckNeeded() || obj->IsJSObject()); |
847 do { | 855 do { |
848 if (obj->IsAccessCheckNeeded() && | 856 if (obj->IsAccessCheckNeeded() && |
849 !isolate->MayNamedAccess(JSObject::cast(obj), | 857 !isolate->MayNamedAccess(JSObject::cast(obj), |
850 isolate->heap()->Proto_symbol(), | 858 isolate->heap()->Proto_symbol(), |
851 v8::ACCESS_GET)) { | 859 v8::ACCESS_GET)) { |
852 isolate->ReportFailedAccessCheck(JSObject::cast(obj), v8::ACCESS_GET); | 860 isolate->ReportFailedAccessCheck(JSObject::cast(obj), v8::ACCESS_GET); |
853 return isolate->heap()->undefined_value(); | 861 return isolate->heap()->undefined_value(); |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1140 } | 1148 } |
1141 elms->set(VALUE_INDEX, value); | 1149 elms->set(VALUE_INDEX, value); |
1142 } | 1150 } |
1143 | 1151 |
1144 return *desc; | 1152 return *desc; |
1145 } | 1153 } |
1146 | 1154 |
1147 | 1155 |
1148 RUNTIME_FUNCTION(MaybeObject*, Runtime_PreventExtensions) { | 1156 RUNTIME_FUNCTION(MaybeObject*, Runtime_PreventExtensions) { |
1149 ASSERT(args.length() == 1); | 1157 ASSERT(args.length() == 1); |
1150 CONVERT_CHECKED(JSObject, obj, args[0]); | 1158 CONVERT_CHECKED(JSObject, obj, 0); |
1151 return obj->PreventExtensions(); | 1159 return obj->PreventExtensions(); |
1152 } | 1160 } |
1153 | 1161 |
1154 | 1162 |
1155 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsExtensible) { | 1163 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsExtensible) { |
1156 ASSERT(args.length() == 1); | 1164 ASSERT(args.length() == 1); |
1157 CONVERT_CHECKED(JSObject, obj, args[0]); | 1165 CONVERT_CHECKED(JSObject, obj, 0); |
1158 if (obj->IsJSGlobalProxy()) { | 1166 if (obj->IsJSGlobalProxy()) { |
1159 Object* proto = obj->GetPrototype(); | 1167 Object* proto = obj->GetPrototype(); |
1160 if (proto->IsNull()) return isolate->heap()->false_value(); | 1168 if (proto->IsNull()) return isolate->heap()->false_value(); |
1161 ASSERT(proto->IsJSGlobalObject()); | 1169 ASSERT(proto->IsJSGlobalObject()); |
1162 obj = JSObject::cast(proto); | 1170 obj = JSObject::cast(proto); |
1163 } | 1171 } |
1164 return isolate->heap()->ToBoolean(obj->map()->is_extensible()); | 1172 return isolate->heap()->ToBoolean(obj->map()->is_extensible()); |
1165 } | 1173 } |
1166 | 1174 |
1167 | 1175 |
(...skipping 20 matching lines...) Expand all Loading... | |
1188 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsTemplate) { | 1196 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsTemplate) { |
1189 ASSERT(args.length() == 1); | 1197 ASSERT(args.length() == 1); |
1190 Object* arg = args[0]; | 1198 Object* arg = args[0]; |
1191 bool result = arg->IsObjectTemplateInfo() || arg->IsFunctionTemplateInfo(); | 1199 bool result = arg->IsObjectTemplateInfo() || arg->IsFunctionTemplateInfo(); |
1192 return isolate->heap()->ToBoolean(result); | 1200 return isolate->heap()->ToBoolean(result); |
1193 } | 1201 } |
1194 | 1202 |
1195 | 1203 |
1196 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetTemplateField) { | 1204 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetTemplateField) { |
1197 ASSERT(args.length() == 2); | 1205 ASSERT(args.length() == 2); |
1198 CONVERT_CHECKED(HeapObject, templ, args[0]); | 1206 CONVERT_CHECKED(HeapObject, templ, 0); |
1199 CONVERT_CHECKED(Smi, field, args[1]); | 1207 CONVERT_SMI_ARG_CHECKED(index, 1) |
1200 int index = field->value(); | |
1201 int offset = index * kPointerSize + HeapObject::kHeaderSize; | 1208 int offset = index * kPointerSize + HeapObject::kHeaderSize; |
1202 InstanceType type = templ->map()->instance_type(); | 1209 InstanceType type = templ->map()->instance_type(); |
1203 RUNTIME_ASSERT(type == FUNCTION_TEMPLATE_INFO_TYPE || | 1210 RUNTIME_ASSERT(type == FUNCTION_TEMPLATE_INFO_TYPE || |
1204 type == OBJECT_TEMPLATE_INFO_TYPE); | 1211 type == OBJECT_TEMPLATE_INFO_TYPE); |
1205 RUNTIME_ASSERT(offset > 0); | 1212 RUNTIME_ASSERT(offset > 0); |
1206 if (type == FUNCTION_TEMPLATE_INFO_TYPE) { | 1213 if (type == FUNCTION_TEMPLATE_INFO_TYPE) { |
1207 RUNTIME_ASSERT(offset < FunctionTemplateInfo::kSize); | 1214 RUNTIME_ASSERT(offset < FunctionTemplateInfo::kSize); |
1208 } else { | 1215 } else { |
1209 RUNTIME_ASSERT(offset < ObjectTemplateInfo::kSize); | 1216 RUNTIME_ASSERT(offset < ObjectTemplateInfo::kSize); |
1210 } | 1217 } |
1211 return *HeapObject::RawField(templ, offset); | 1218 return *HeapObject::RawField(templ, offset); |
1212 } | 1219 } |
1213 | 1220 |
1214 | 1221 |
1215 RUNTIME_FUNCTION(MaybeObject*, Runtime_DisableAccessChecks) { | 1222 RUNTIME_FUNCTION(MaybeObject*, Runtime_DisableAccessChecks) { |
1216 ASSERT(args.length() == 1); | 1223 ASSERT(args.length() == 1); |
1217 CONVERT_CHECKED(HeapObject, object, args[0]); | 1224 CONVERT_CHECKED(HeapObject, object, 0); |
1218 Map* old_map = object->map(); | 1225 Map* old_map = object->map(); |
1219 bool needs_access_checks = old_map->is_access_check_needed(); | 1226 bool needs_access_checks = old_map->is_access_check_needed(); |
1220 if (needs_access_checks) { | 1227 if (needs_access_checks) { |
1221 // Copy map so it won't interfere constructor's initial map. | 1228 // Copy map so it won't interfere constructor's initial map. |
1222 Object* new_map; | 1229 Object* new_map; |
1223 { MaybeObject* maybe_new_map = old_map->CopyDropTransitions(); | 1230 { MaybeObject* maybe_new_map = old_map->CopyDropTransitions(); |
1224 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map; | 1231 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map; |
1225 } | 1232 } |
1226 | 1233 |
1227 Map::cast(new_map)->set_is_access_check_needed(false); | 1234 Map::cast(new_map)->set_is_access_check_needed(false); |
1228 object->set_map(Map::cast(new_map)); | 1235 object->set_map(Map::cast(new_map)); |
1229 } | 1236 } |
1230 return isolate->heap()->ToBoolean(needs_access_checks); | 1237 return isolate->heap()->ToBoolean(needs_access_checks); |
1231 } | 1238 } |
1232 | 1239 |
1233 | 1240 |
1234 RUNTIME_FUNCTION(MaybeObject*, Runtime_EnableAccessChecks) { | 1241 RUNTIME_FUNCTION(MaybeObject*, Runtime_EnableAccessChecks) { |
1235 ASSERT(args.length() == 1); | 1242 ASSERT(args.length() == 1); |
1236 CONVERT_CHECKED(HeapObject, object, args[0]); | 1243 CONVERT_CHECKED(HeapObject, object, 0); |
1237 Map* old_map = object->map(); | 1244 Map* old_map = object->map(); |
1238 if (!old_map->is_access_check_needed()) { | 1245 if (!old_map->is_access_check_needed()) { |
1239 // Copy map so it won't interfere constructor's initial map. | 1246 // Copy map so it won't interfere constructor's initial map. |
1240 Object* new_map; | 1247 Object* new_map; |
1241 { MaybeObject* maybe_new_map = old_map->CopyDropTransitions(); | 1248 { MaybeObject* maybe_new_map = old_map->CopyDropTransitions(); |
1242 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map; | 1249 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map; |
1243 } | 1250 } |
1244 | 1251 |
1245 Map::cast(new_map)->set_is_access_check_needed(true); | 1252 Map::cast(new_map)->set_is_access_check_needed(true); |
1246 object->set_map(Map::cast(new_map)); | 1253 object->set_map(Map::cast(new_map)); |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1762 // Write in-object properties after the length of the array. | 1769 // Write in-object properties after the length of the array. |
1763 array->InObjectPropertyAtPut(JSRegExpResult::kIndexIndex, args[1]); | 1770 array->InObjectPropertyAtPut(JSRegExpResult::kIndexIndex, args[1]); |
1764 array->InObjectPropertyAtPut(JSRegExpResult::kInputIndex, args[2]); | 1771 array->InObjectPropertyAtPut(JSRegExpResult::kInputIndex, args[2]); |
1765 return array; | 1772 return array; |
1766 } | 1773 } |
1767 | 1774 |
1768 | 1775 |
1769 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpInitializeObject) { | 1776 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpInitializeObject) { |
1770 AssertNoAllocation no_alloc; | 1777 AssertNoAllocation no_alloc; |
1771 ASSERT(args.length() == 5); | 1778 ASSERT(args.length() == 5); |
1772 CONVERT_CHECKED(JSRegExp, regexp, args[0]); | 1779 CONVERT_CHECKED(JSRegExp, regexp, 0); |
1773 CONVERT_CHECKED(String, source, args[1]); | 1780 CONVERT_CHECKED(String, source, 1); |
1774 | 1781 |
1775 Object* global = args[2]; | 1782 Object* global = args[2]; |
1776 if (!global->IsTrue()) global = isolate->heap()->false_value(); | 1783 if (!global->IsTrue()) global = isolate->heap()->false_value(); |
1777 | 1784 |
1778 Object* ignoreCase = args[3]; | 1785 Object* ignoreCase = args[3]; |
1779 if (!ignoreCase->IsTrue()) ignoreCase = isolate->heap()->false_value(); | 1786 if (!ignoreCase->IsTrue()) ignoreCase = isolate->heap()->false_value(); |
1780 | 1787 |
1781 Object* multiline = args[4]; | 1788 Object* multiline = args[4]; |
1782 if (!multiline->IsTrue()) multiline = isolate->heap()->false_value(); | 1789 if (!multiline->IsTrue()) multiline = isolate->heap()->false_value(); |
1783 | 1790 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1876 InstallBuiltin(isolate, holder, "slice", Builtins::kArraySlice); | 1883 InstallBuiltin(isolate, holder, "slice", Builtins::kArraySlice); |
1877 InstallBuiltin(isolate, holder, "splice", Builtins::kArraySplice); | 1884 InstallBuiltin(isolate, holder, "splice", Builtins::kArraySplice); |
1878 InstallBuiltin(isolate, holder, "concat", Builtins::kArrayConcat); | 1885 InstallBuiltin(isolate, holder, "concat", Builtins::kArrayConcat); |
1879 | 1886 |
1880 return *holder; | 1887 return *holder; |
1881 } | 1888 } |
1882 | 1889 |
1883 | 1890 |
1884 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDefaultReceiver) { | 1891 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDefaultReceiver) { |
1885 ASSERT(args.length() == 1); | 1892 ASSERT(args.length() == 1); |
1886 CONVERT_CHECKED(JSReceiver, callable, args[0]); | 1893 CONVERT_CHECKED(JSReceiver, callable, 0); |
1887 | 1894 |
1888 if (!callable->IsJSFunction()) { | 1895 if (!callable->IsJSFunction()) { |
1889 HandleScope scope(isolate); | 1896 HandleScope scope(isolate); |
1890 bool threw = false; | 1897 bool threw = false; |
1891 Handle<Object> delegate = | 1898 Handle<Object> delegate = |
1892 Execution::TryGetFunctionDelegate(Handle<JSReceiver>(callable), &threw); | 1899 Execution::TryGetFunctionDelegate(Handle<JSReceiver>(callable), &threw); |
1893 if (threw) return Failure::Exception(); | 1900 if (threw) return Failure::Exception(); |
1894 callable = JSFunction::cast(*delegate); | 1901 callable = JSFunction::cast(*delegate); |
1895 } | 1902 } |
1896 JSFunction* function = JSFunction::cast(callable); | 1903 JSFunction* function = JSFunction::cast(callable); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1935 } | 1942 } |
1936 literals->set(index, *regexp); | 1943 literals->set(index, *regexp); |
1937 return *regexp; | 1944 return *regexp; |
1938 } | 1945 } |
1939 | 1946 |
1940 | 1947 |
1941 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetName) { | 1948 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetName) { |
1942 NoHandleAllocation ha; | 1949 NoHandleAllocation ha; |
1943 ASSERT(args.length() == 1); | 1950 ASSERT(args.length() == 1); |
1944 | 1951 |
1945 CONVERT_CHECKED(JSFunction, f, args[0]); | 1952 CONVERT_CHECKED(JSFunction, f, 0); |
1946 return f->shared()->name(); | 1953 return f->shared()->name(); |
1947 } | 1954 } |
1948 | 1955 |
1949 | 1956 |
1950 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetName) { | 1957 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetName) { |
1951 NoHandleAllocation ha; | 1958 NoHandleAllocation ha; |
1952 ASSERT(args.length() == 2); | 1959 ASSERT(args.length() == 2); |
1953 | 1960 |
1954 CONVERT_CHECKED(JSFunction, f, args[0]); | 1961 CONVERT_CHECKED(JSFunction, f, 0); |
1955 CONVERT_CHECKED(String, name, args[1]); | 1962 CONVERT_CHECKED(String, name, 1); |
1956 f->shared()->set_name(name); | 1963 f->shared()->set_name(name); |
1957 return isolate->heap()->undefined_value(); | 1964 return isolate->heap()->undefined_value(); |
1958 } | 1965 } |
1959 | 1966 |
1960 | 1967 |
1961 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionNameShouldPrintAsAnonymous) { | 1968 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionNameShouldPrintAsAnonymous) { |
1962 NoHandleAllocation ha; | 1969 NoHandleAllocation ha; |
1963 ASSERT(args.length() == 1); | 1970 ASSERT(args.length() == 1); |
1964 CONVERT_CHECKED(JSFunction, f, args[0]); | 1971 CONVERT_CHECKED(JSFunction, f, 0); |
1965 return isolate->heap()->ToBoolean( | 1972 return isolate->heap()->ToBoolean( |
1966 f->shared()->name_should_print_as_anonymous()); | 1973 f->shared()->name_should_print_as_anonymous()); |
1967 } | 1974 } |
1968 | 1975 |
1969 | 1976 |
1970 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionMarkNameShouldPrintAsAnonymous) { | 1977 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionMarkNameShouldPrintAsAnonymous) { |
1971 NoHandleAllocation ha; | 1978 NoHandleAllocation ha; |
1972 ASSERT(args.length() == 1); | 1979 ASSERT(args.length() == 1); |
1973 CONVERT_CHECKED(JSFunction, f, args[0]); | 1980 CONVERT_CHECKED(JSFunction, f, 0); |
1974 f->shared()->set_name_should_print_as_anonymous(true); | 1981 f->shared()->set_name_should_print_as_anonymous(true); |
1975 return isolate->heap()->undefined_value(); | 1982 return isolate->heap()->undefined_value(); |
1976 } | 1983 } |
1977 | 1984 |
1978 | 1985 |
1979 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionRemovePrototype) { | 1986 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionRemovePrototype) { |
1980 NoHandleAllocation ha; | 1987 NoHandleAllocation ha; |
1981 ASSERT(args.length() == 1); | 1988 ASSERT(args.length() == 1); |
1982 | 1989 |
1983 CONVERT_CHECKED(JSFunction, f, args[0]); | 1990 CONVERT_CHECKED(JSFunction, f, 0); |
1984 Object* obj = f->RemovePrototype(); | 1991 Object* obj = f->RemovePrototype(); |
1985 if (obj->IsFailure()) return obj; | 1992 if (obj->IsFailure()) return obj; |
1986 | 1993 |
1987 return isolate->heap()->undefined_value(); | 1994 return isolate->heap()->undefined_value(); |
1988 } | 1995 } |
1989 | 1996 |
1990 | 1997 |
1991 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetScript) { | 1998 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetScript) { |
1992 HandleScope scope(isolate); | 1999 HandleScope scope(isolate); |
1993 ASSERT(args.length() == 1); | 2000 ASSERT(args.length() == 1); |
1994 | 2001 |
1995 CONVERT_CHECKED(JSFunction, fun, args[0]); | 2002 CONVERT_CHECKED(JSFunction, fun, 0); |
1996 Handle<Object> script = Handle<Object>(fun->shared()->script(), isolate); | 2003 Handle<Object> script = Handle<Object>(fun->shared()->script(), isolate); |
1997 if (!script->IsScript()) return isolate->heap()->undefined_value(); | 2004 if (!script->IsScript()) return isolate->heap()->undefined_value(); |
1998 | 2005 |
1999 return *GetScriptWrapper(Handle<Script>::cast(script)); | 2006 return *GetScriptWrapper(Handle<Script>::cast(script)); |
2000 } | 2007 } |
2001 | 2008 |
2002 | 2009 |
2003 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetSourceCode) { | 2010 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetSourceCode) { |
2004 HandleScope scope(isolate); | 2011 HandleScope scope(isolate); |
2005 ASSERT(args.length() == 1); | 2012 ASSERT(args.length() == 1); |
2006 | 2013 |
2007 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 2014 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
2008 Handle<SharedFunctionInfo> shared(f->shared()); | 2015 Handle<SharedFunctionInfo> shared(f->shared()); |
2009 return *shared->GetSourceCode(); | 2016 return *shared->GetSourceCode(); |
2010 } | 2017 } |
2011 | 2018 |
2012 | 2019 |
2013 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetScriptSourcePosition) { | 2020 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetScriptSourcePosition) { |
2014 NoHandleAllocation ha; | 2021 NoHandleAllocation ha; |
2015 ASSERT(args.length() == 1); | 2022 ASSERT(args.length() == 1); |
2016 | 2023 |
2017 CONVERT_CHECKED(JSFunction, fun, args[0]); | 2024 CONVERT_CHECKED(JSFunction, fun, 0); |
2018 int pos = fun->shared()->start_position(); | 2025 int pos = fun->shared()->start_position(); |
2019 return Smi::FromInt(pos); | 2026 return Smi::FromInt(pos); |
2020 } | 2027 } |
2021 | 2028 |
2022 | 2029 |
2023 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetPositionForOffset) { | 2030 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetPositionForOffset) { |
2024 ASSERT(args.length() == 2); | 2031 ASSERT(args.length() == 2); |
2025 | 2032 |
2026 CONVERT_CHECKED(Code, code, args[0]); | 2033 CONVERT_CHECKED(Code, code, 0); |
2027 CONVERT_NUMBER_CHECKED(int, offset, Int32, args[1]); | 2034 CONVERT_NUMBER_CHECKED(int, offset, Int32, args[1]); |
2028 | 2035 |
2029 RUNTIME_ASSERT(0 <= offset && offset < code->Size()); | 2036 RUNTIME_ASSERT(0 <= offset && offset < code->Size()); |
2030 | 2037 |
2031 Address pc = code->address() + offset; | 2038 Address pc = code->address() + offset; |
2032 return Smi::FromInt(code->SourcePosition(pc)); | 2039 return Smi::FromInt(code->SourcePosition(pc)); |
2033 } | 2040 } |
2034 | 2041 |
2035 | 2042 |
2036 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetInstanceClassName) { | 2043 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetInstanceClassName) { |
2037 NoHandleAllocation ha; | 2044 NoHandleAllocation ha; |
2038 ASSERT(args.length() == 2); | 2045 ASSERT(args.length() == 2); |
2039 | 2046 |
2040 CONVERT_CHECKED(JSFunction, fun, args[0]); | 2047 CONVERT_CHECKED(JSFunction, fun, 0); |
2041 CONVERT_CHECKED(String, name, args[1]); | 2048 CONVERT_CHECKED(String, name, 1); |
2042 fun->SetInstanceClassName(name); | 2049 fun->SetInstanceClassName(name); |
2043 return isolate->heap()->undefined_value(); | 2050 return isolate->heap()->undefined_value(); |
2044 } | 2051 } |
2045 | 2052 |
2046 | 2053 |
2047 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetLength) { | 2054 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetLength) { |
2048 NoHandleAllocation ha; | 2055 NoHandleAllocation ha; |
2049 ASSERT(args.length() == 2); | 2056 ASSERT(args.length() == 2); |
2050 | 2057 |
2051 CONVERT_CHECKED(JSFunction, fun, args[0]); | 2058 CONVERT_CHECKED(JSFunction, fun, 0); |
2052 CONVERT_CHECKED(Smi, length, args[1]); | 2059 CONVERT_SMI_ARG_CHECKED(length, 1); |
2053 fun->shared()->set_length(length->value()); | 2060 fun->shared()->set_length(length); |
2054 return length; | 2061 return fun; |
Jakob Kummerow
2012/02/20 17:31:47
Is this change intentional?
Sven Panne
2012/02/21 07:21:01
Yep, it is just our usual ultra-confusing way of s
| |
2055 } | 2062 } |
2056 | 2063 |
2057 | 2064 |
2058 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetPrototype) { | 2065 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetPrototype) { |
2059 NoHandleAllocation ha; | 2066 NoHandleAllocation ha; |
2060 ASSERT(args.length() == 2); | 2067 ASSERT(args.length() == 2); |
2061 | 2068 |
2062 CONVERT_CHECKED(JSFunction, fun, args[0]); | 2069 CONVERT_CHECKED(JSFunction, fun, 0); |
2063 ASSERT(fun->should_have_prototype()); | 2070 ASSERT(fun->should_have_prototype()); |
2064 Object* obj; | 2071 Object* obj; |
2065 { MaybeObject* maybe_obj = | 2072 { MaybeObject* maybe_obj = |
2066 Accessors::FunctionSetPrototype(fun, args[1], NULL); | 2073 Accessors::FunctionSetPrototype(fun, args[1], NULL); |
2067 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 2074 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
2068 } | 2075 } |
2069 return args[0]; // return TOS | 2076 return args[0]; // return TOS |
2070 } | 2077 } |
2071 | 2078 |
2072 | 2079 |
2073 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetReadOnlyPrototype) { | 2080 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetReadOnlyPrototype) { |
2074 NoHandleAllocation ha; | 2081 NoHandleAllocation ha; |
2075 RUNTIME_ASSERT(args.length() == 1); | 2082 RUNTIME_ASSERT(args.length() == 1); |
2076 CONVERT_CHECKED(JSFunction, function, args[0]); | 2083 CONVERT_CHECKED(JSFunction, function, 0); |
2077 | 2084 |
2078 MaybeObject* maybe_name = | 2085 MaybeObject* maybe_name = |
2079 isolate->heap()->AllocateStringFromAscii(CStrVector("prototype")); | 2086 isolate->heap()->AllocateStringFromAscii(CStrVector("prototype")); |
2080 String* name; | 2087 String* name; |
2081 if (!maybe_name->To(&name)) return maybe_name; | 2088 if (!maybe_name->To(&name)) return maybe_name; |
2082 | 2089 |
2083 if (function->HasFastProperties()) { | 2090 if (function->HasFastProperties()) { |
2084 // Construct a new field descriptor with updated attributes. | 2091 // Construct a new field descriptor with updated attributes. |
2085 DescriptorArray* instance_desc = function->map()->instance_descriptors(); | 2092 DescriptorArray* instance_desc = function->map()->instance_descriptors(); |
2086 int index = instance_desc->Search(name); | 2093 int index = instance_desc->Search(name); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2122 function->property_dictionary()->DetailsAtPut(entry, new_details); | 2129 function->property_dictionary()->DetailsAtPut(entry, new_details); |
2123 } | 2130 } |
2124 return function; | 2131 return function; |
2125 } | 2132 } |
2126 | 2133 |
2127 | 2134 |
2128 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsAPIFunction) { | 2135 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsAPIFunction) { |
2129 NoHandleAllocation ha; | 2136 NoHandleAllocation ha; |
2130 ASSERT(args.length() == 1); | 2137 ASSERT(args.length() == 1); |
2131 | 2138 |
2132 CONVERT_CHECKED(JSFunction, f, args[0]); | 2139 CONVERT_CHECKED(JSFunction, f, 0); |
2133 return isolate->heap()->ToBoolean(f->shared()->IsApiFunction()); | 2140 return isolate->heap()->ToBoolean(f->shared()->IsApiFunction()); |
2134 } | 2141 } |
2135 | 2142 |
2136 | 2143 |
2137 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsBuiltin) { | 2144 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsBuiltin) { |
2138 NoHandleAllocation ha; | 2145 NoHandleAllocation ha; |
2139 ASSERT(args.length() == 1); | 2146 ASSERT(args.length() == 1); |
2140 | 2147 |
2141 CONVERT_CHECKED(JSFunction, f, args[0]); | 2148 CONVERT_CHECKED(JSFunction, f, 0); |
2142 return isolate->heap()->ToBoolean(f->IsBuiltin()); | 2149 return isolate->heap()->ToBoolean(f->IsBuiltin()); |
2143 } | 2150 } |
2144 | 2151 |
2145 | 2152 |
2146 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetCode) { | 2153 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetCode) { |
2147 HandleScope scope(isolate); | 2154 HandleScope scope(isolate); |
2148 ASSERT(args.length() == 2); | 2155 ASSERT(args.length() == 2); |
2149 | 2156 |
2150 CONVERT_ARG_CHECKED(JSFunction, target, 0); | 2157 CONVERT_ARG_CHECKED(JSFunction, target, 0); |
2151 Handle<Object> code = args.at<Object>(1); | 2158 Handle<Object> code = args.at<Object>(1); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2228 } | 2235 } |
2229 } | 2236 } |
2230 return isolate->heap()->empty_string(); | 2237 return isolate->heap()->empty_string(); |
2231 } | 2238 } |
2232 | 2239 |
2233 | 2240 |
2234 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringCharCodeAt) { | 2241 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringCharCodeAt) { |
2235 NoHandleAllocation ha; | 2242 NoHandleAllocation ha; |
2236 ASSERT(args.length() == 2); | 2243 ASSERT(args.length() == 2); |
2237 | 2244 |
2238 CONVERT_CHECKED(String, subject, args[0]); | 2245 CONVERT_CHECKED(String, subject, 0); |
2239 Object* index = args[1]; | 2246 Object* index = args[1]; |
2240 RUNTIME_ASSERT(index->IsNumber()); | 2247 RUNTIME_ASSERT(index->IsNumber()); |
2241 | 2248 |
2242 uint32_t i = 0; | 2249 uint32_t i = 0; |
2243 if (index->IsSmi()) { | 2250 if (index->IsSmi()) { |
2244 int value = Smi::cast(index)->value(); | 2251 int value = Smi::cast(index)->value(); |
2245 if (value < 0) return isolate->heap()->nan_value(); | 2252 if (value < 0) return isolate->heap()->nan_value(); |
2246 i = value; | 2253 i = value; |
2247 } else { | 2254 } else { |
2248 ASSERT(index->IsHeapNumber()); | 2255 ASSERT(index->IsHeapNumber()); |
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3205 MemoryChunk::IncrementLiveBytesFromMutator(answer->address(), -delta); | 3212 MemoryChunk::IncrementLiveBytesFromMutator(answer->address(), -delta); |
3206 } | 3213 } |
3207 | 3214 |
3208 return *answer; | 3215 return *answer; |
3209 } | 3216 } |
3210 | 3217 |
3211 | 3218 |
3212 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringReplaceRegExpWithString) { | 3219 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringReplaceRegExpWithString) { |
3213 ASSERT(args.length() == 4); | 3220 ASSERT(args.length() == 4); |
3214 | 3221 |
3215 CONVERT_CHECKED(String, subject, args[0]); | 3222 CONVERT_CHECKED(String, subject, 0); |
3216 if (!subject->IsFlat()) { | 3223 if (!subject->IsFlat()) { |
3217 Object* flat_subject; | 3224 Object* flat_subject; |
3218 { MaybeObject* maybe_flat_subject = subject->TryFlatten(); | 3225 { MaybeObject* maybe_flat_subject = subject->TryFlatten(); |
3219 if (!maybe_flat_subject->ToObject(&flat_subject)) { | 3226 if (!maybe_flat_subject->ToObject(&flat_subject)) { |
3220 return maybe_flat_subject; | 3227 return maybe_flat_subject; |
3221 } | 3228 } |
3222 } | 3229 } |
3223 subject = String::cast(flat_subject); | 3230 subject = String::cast(flat_subject); |
3224 } | 3231 } |
3225 | 3232 |
3226 CONVERT_CHECKED(String, replacement, args[2]); | 3233 CONVERT_CHECKED(String, replacement, 2); |
3227 if (!replacement->IsFlat()) { | 3234 if (!replacement->IsFlat()) { |
3228 Object* flat_replacement; | 3235 Object* flat_replacement; |
3229 { MaybeObject* maybe_flat_replacement = replacement->TryFlatten(); | 3236 { MaybeObject* maybe_flat_replacement = replacement->TryFlatten(); |
3230 if (!maybe_flat_replacement->ToObject(&flat_replacement)) { | 3237 if (!maybe_flat_replacement->ToObject(&flat_replacement)) { |
3231 return maybe_flat_replacement; | 3238 return maybe_flat_replacement; |
3232 } | 3239 } |
3233 } | 3240 } |
3234 replacement = String::cast(flat_replacement); | 3241 replacement = String::cast(flat_replacement); |
3235 } | 3242 } |
3236 | 3243 |
3237 CONVERT_CHECKED(JSRegExp, regexp, args[1]); | 3244 CONVERT_CHECKED(JSRegExp, regexp, 1); |
3238 CONVERT_CHECKED(JSArray, last_match_info, args[3]); | 3245 CONVERT_CHECKED(JSArray, last_match_info, 3); |
3239 | 3246 |
3240 ASSERT(last_match_info->HasFastElements()); | 3247 ASSERT(last_match_info->HasFastElements()); |
3241 | 3248 |
3242 if (replacement->length() == 0) { | 3249 if (replacement->length() == 0) { |
3243 if (subject->HasOnlyAsciiChars()) { | 3250 if (subject->HasOnlyAsciiChars()) { |
3244 return StringReplaceRegExpWithEmptyString<SeqAsciiString>( | 3251 return StringReplaceRegExpWithEmptyString<SeqAsciiString>( |
3245 isolate, subject, regexp, last_match_info); | 3252 isolate, subject, regexp, last_match_info); |
3246 } else { | 3253 } else { |
3247 return StringReplaceRegExpWithEmptyString<SeqTwoByteString>( | 3254 return StringReplaceRegExpWithEmptyString<SeqTwoByteString>( |
3248 isolate, subject, regexp, last_match_info); | 3255 isolate, subject, regexp, last_match_info); |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3490 } | 3497 } |
3491 | 3498 |
3492 return Smi::FromInt(position); | 3499 return Smi::FromInt(position); |
3493 } | 3500 } |
3494 | 3501 |
3495 | 3502 |
3496 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringLocaleCompare) { | 3503 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringLocaleCompare) { |
3497 NoHandleAllocation ha; | 3504 NoHandleAllocation ha; |
3498 ASSERT(args.length() == 2); | 3505 ASSERT(args.length() == 2); |
3499 | 3506 |
3500 CONVERT_CHECKED(String, str1, args[0]); | 3507 CONVERT_CHECKED(String, str1, 0); |
3501 CONVERT_CHECKED(String, str2, args[1]); | 3508 CONVERT_CHECKED(String, str2, 1); |
3502 | 3509 |
3503 if (str1 == str2) return Smi::FromInt(0); // Equal. | 3510 if (str1 == str2) return Smi::FromInt(0); // Equal. |
3504 int str1_length = str1->length(); | 3511 int str1_length = str1->length(); |
3505 int str2_length = str2->length(); | 3512 int str2_length = str2->length(); |
3506 | 3513 |
3507 // Decide trivial cases without flattening. | 3514 // Decide trivial cases without flattening. |
3508 if (str1_length == 0) { | 3515 if (str1_length == 0) { |
3509 if (str2_length == 0) return Smi::FromInt(0); // Equal. | 3516 if (str2_length == 0) return Smi::FromInt(0); // Equal. |
3510 return Smi::FromInt(-str2_length); | 3517 return Smi::FromInt(-str2_length); |
3511 } else { | 3518 } else { |
(...skipping 26 matching lines...) Expand all Loading... | |
3538 } | 3545 } |
3539 | 3546 |
3540 return Smi::FromInt(str1_length - str2_length); | 3547 return Smi::FromInt(str1_length - str2_length); |
3541 } | 3548 } |
3542 | 3549 |
3543 | 3550 |
3544 RUNTIME_FUNCTION(MaybeObject*, Runtime_SubString) { | 3551 RUNTIME_FUNCTION(MaybeObject*, Runtime_SubString) { |
3545 NoHandleAllocation ha; | 3552 NoHandleAllocation ha; |
3546 ASSERT(args.length() == 3); | 3553 ASSERT(args.length() == 3); |
3547 | 3554 |
3548 CONVERT_CHECKED(String, value, args[0]); | 3555 CONVERT_CHECKED(String, value, 0); |
3549 int start, end; | 3556 int start, end; |
3550 // We have a fast integer-only case here to avoid a conversion to double in | 3557 // We have a fast integer-only case here to avoid a conversion to double in |
3551 // the common case where from and to are Smis. | 3558 // the common case where from and to are Smis. |
3552 if (args[1]->IsSmi() && args[2]->IsSmi()) { | 3559 if (args[1]->IsSmi() && args[2]->IsSmi()) { |
3553 CONVERT_SMI_ARG_CHECKED(from_number, 1); | 3560 CONVERT_SMI_ARG_CHECKED(from_number, 1); |
3554 CONVERT_SMI_ARG_CHECKED(to_number, 2); | 3561 CONVERT_SMI_ARG_CHECKED(to_number, 2); |
3555 start = from_number; | 3562 start = from_number; |
3556 end = to_number; | 3563 end = to_number; |
3557 } else { | 3564 } else { |
3558 CONVERT_DOUBLE_ARG_CHECKED(from_number, 1); | 3565 CONVERT_DOUBLE_ARG_CHECKED(from_number, 1); |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4311 // Implements part of 8.12.9 DefineOwnProperty. | 4318 // Implements part of 8.12.9 DefineOwnProperty. |
4312 // There are 3 cases that lead here: | 4319 // There are 3 cases that lead here: |
4313 // Step 4b - define a new accessor property. | 4320 // Step 4b - define a new accessor property. |
4314 // Steps 9c & 12 - replace an existing data property with an accessor property. | 4321 // Steps 9c & 12 - replace an existing data property with an accessor property. |
4315 // Step 12 - update an existing accessor property with an accessor or generic | 4322 // Step 12 - update an existing accessor property with an accessor or generic |
4316 // descriptor. | 4323 // descriptor. |
4317 RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineOrRedefineAccessorProperty) { | 4324 RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineOrRedefineAccessorProperty) { |
4318 ASSERT(args.length() == 5); | 4325 ASSERT(args.length() == 5); |
4319 HandleScope scope(isolate); | 4326 HandleScope scope(isolate); |
4320 CONVERT_ARG_CHECKED(JSObject, obj, 0); | 4327 CONVERT_ARG_CHECKED(JSObject, obj, 0); |
4321 CONVERT_CHECKED(String, name, args[1]); | 4328 CONVERT_CHECKED(String, name, 1); |
4322 CONVERT_CHECKED(Smi, flag_setter, args[2]); | 4329 CONVERT_SMI_ARG_CHECKED(flag_setter, 2); |
4323 Object* fun = args[3]; | 4330 Object* fun = args[3]; |
4324 CONVERT_CHECKED(Smi, flag_attr, args[4]); | 4331 CONVERT_SMI_ARG_CHECKED(unchecked, 4); |
4325 | 4332 |
4326 int unchecked = flag_attr->value(); | |
4327 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); | 4333 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); |
4328 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked); | 4334 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked); |
4329 | 4335 |
4330 RUNTIME_ASSERT(!obj->IsNull()); | 4336 RUNTIME_ASSERT(!obj->IsNull()); |
4331 RUNTIME_ASSERT(fun->IsSpecFunction() || fun->IsUndefined()); | 4337 RUNTIME_ASSERT(fun->IsSpecFunction() || fun->IsUndefined()); |
4332 return obj->DefineAccessor(name, flag_setter->value() == 0, fun, attr); | 4338 return obj->DefineAccessor(name, flag_setter == 0, fun, attr); |
4333 } | 4339 } |
4334 | 4340 |
4335 // Implements part of 8.12.9 DefineOwnProperty. | 4341 // Implements part of 8.12.9 DefineOwnProperty. |
4336 // There are 3 cases that lead here: | 4342 // There are 3 cases that lead here: |
4337 // Step 4a - define a new data property. | 4343 // Step 4a - define a new data property. |
4338 // Steps 9b & 12 - replace an existing accessor property with a data property. | 4344 // Steps 9b & 12 - replace an existing accessor property with a data property. |
4339 // Step 12 - update an existing data property with a data or generic | 4345 // Step 12 - update an existing data property with a data or generic |
4340 // descriptor. | 4346 // descriptor. |
4341 RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineOrRedefineDataProperty) { | 4347 RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineOrRedefineDataProperty) { |
4342 ASSERT(args.length() == 4); | 4348 ASSERT(args.length() == 4); |
4343 HandleScope scope(isolate); | 4349 HandleScope scope(isolate); |
4344 CONVERT_ARG_CHECKED(JSObject, js_object, 0); | 4350 CONVERT_ARG_CHECKED(JSObject, js_object, 0); |
4345 CONVERT_ARG_CHECKED(String, name, 1); | 4351 CONVERT_ARG_CHECKED(String, name, 1); |
4346 Handle<Object> obj_value = args.at<Object>(2); | 4352 Handle<Object> obj_value = args.at<Object>(2); |
4347 CONVERT_CHECKED(Smi, flag, args[3]); | 4353 CONVERT_SMI_ARG_CHECKED(unchecked, 3); |
4348 | 4354 |
4349 int unchecked = flag->value(); | |
4350 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); | 4355 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); |
4351 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked); | 4356 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked); |
4352 | 4357 |
4353 // Check if this is an element. | 4358 // Check if this is an element. |
4354 uint32_t index; | 4359 uint32_t index; |
4355 bool is_element = name->AsArrayIndex(&index); | 4360 bool is_element = name->AsArrayIndex(&index); |
4356 | 4361 |
4357 // Special case for elements if any of the flags might be involved. | 4362 // Special case for elements if any of the flags might be involved. |
4358 // If elements are in fast case we always implicitly assume that: | 4363 // If elements are in fast case we always implicitly assume that: |
4359 // DONT_DELETE: false, DONT_ENUM: false, READ_ONLY: false. | 4364 // DONT_DELETE: false, DONT_ENUM: false, READ_ONLY: false. |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4751 } | 4756 } |
4752 return *object; | 4757 return *object; |
4753 } | 4758 } |
4754 | 4759 |
4755 | 4760 |
4756 // Set a local property, even if it is READ_ONLY. If the property does not | 4761 // Set a local property, even if it is READ_ONLY. If the property does not |
4757 // exist, it will be added with attributes NONE. | 4762 // exist, it will be added with attributes NONE. |
4758 RUNTIME_FUNCTION(MaybeObject*, Runtime_IgnoreAttributesAndSetProperty) { | 4763 RUNTIME_FUNCTION(MaybeObject*, Runtime_IgnoreAttributesAndSetProperty) { |
4759 NoHandleAllocation ha; | 4764 NoHandleAllocation ha; |
4760 RUNTIME_ASSERT(args.length() == 3 || args.length() == 4); | 4765 RUNTIME_ASSERT(args.length() == 3 || args.length() == 4); |
4761 CONVERT_CHECKED(JSObject, object, args[0]); | 4766 CONVERT_CHECKED(JSObject, object, 0); |
4762 CONVERT_CHECKED(String, name, args[1]); | 4767 CONVERT_CHECKED(String, name, 1); |
4763 // Compute attributes. | 4768 // Compute attributes. |
4764 PropertyAttributes attributes = NONE; | 4769 PropertyAttributes attributes = NONE; |
4765 if (args.length() == 4) { | 4770 if (args.length() == 4) { |
4766 CONVERT_CHECKED(Smi, value_obj, args[3]); | 4771 CONVERT_SMI_ARG_CHECKED(unchecked_value, 3); |
4767 int unchecked_value = value_obj->value(); | |
4768 // Only attribute bits should be set. | 4772 // Only attribute bits should be set. |
4769 RUNTIME_ASSERT( | 4773 RUNTIME_ASSERT( |
4770 (unchecked_value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); | 4774 (unchecked_value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); |
4771 attributes = static_cast<PropertyAttributes>(unchecked_value); | 4775 attributes = static_cast<PropertyAttributes>(unchecked_value); |
4772 } | 4776 } |
4773 | 4777 |
4774 return object-> | 4778 return object-> |
4775 SetLocalPropertyIgnoreAttributes(name, args[2], attributes); | 4779 SetLocalPropertyIgnoreAttributes(name, args[2], attributes); |
4776 } | 4780 } |
4777 | 4781 |
4778 | 4782 |
4779 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteProperty) { | 4783 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteProperty) { |
4780 NoHandleAllocation ha; | 4784 NoHandleAllocation ha; |
4781 ASSERT(args.length() == 3); | 4785 ASSERT(args.length() == 3); |
4782 | 4786 |
4783 CONVERT_CHECKED(JSReceiver, object, args[0]); | 4787 CONVERT_CHECKED(JSReceiver, object, 0); |
4784 CONVERT_CHECKED(String, key, args[1]); | 4788 CONVERT_CHECKED(String, key, 1); |
4785 CONVERT_STRICT_MODE_ARG(strict_mode, 2); | 4789 CONVERT_STRICT_MODE_ARG(strict_mode, 2); |
4786 return object->DeleteProperty(key, (strict_mode == kStrictMode) | 4790 return object->DeleteProperty(key, (strict_mode == kStrictMode) |
4787 ? JSReceiver::STRICT_DELETION | 4791 ? JSReceiver::STRICT_DELETION |
4788 : JSReceiver::NORMAL_DELETION); | 4792 : JSReceiver::NORMAL_DELETION); |
4789 } | 4793 } |
4790 | 4794 |
4791 | 4795 |
4792 static Object* HasLocalPropertyImplementation(Isolate* isolate, | 4796 static Object* HasLocalPropertyImplementation(Isolate* isolate, |
4793 Handle<JSObject> object, | 4797 Handle<JSObject> object, |
4794 Handle<String> key) { | 4798 Handle<String> key) { |
4795 if (object->HasLocalProperty(*key)) return isolate->heap()->true_value(); | 4799 if (object->HasLocalProperty(*key)) return isolate->heap()->true_value(); |
4796 // Handle hidden prototypes. If there's a hidden prototype above this thing | 4800 // Handle hidden prototypes. If there's a hidden prototype above this thing |
4797 // then we have to check it for properties, because they are supposed to | 4801 // then we have to check it for properties, because they are supposed to |
4798 // look like they are on this object. | 4802 // look like they are on this object. |
4799 Handle<Object> proto(object->GetPrototype()); | 4803 Handle<Object> proto(object->GetPrototype()); |
4800 if (proto->IsJSObject() && | 4804 if (proto->IsJSObject() && |
4801 Handle<JSObject>::cast(proto)->map()->is_hidden_prototype()) { | 4805 Handle<JSObject>::cast(proto)->map()->is_hidden_prototype()) { |
4802 return HasLocalPropertyImplementation(isolate, | 4806 return HasLocalPropertyImplementation(isolate, |
4803 Handle<JSObject>::cast(proto), | 4807 Handle<JSObject>::cast(proto), |
4804 key); | 4808 key); |
4805 } | 4809 } |
4806 return isolate->heap()->false_value(); | 4810 return isolate->heap()->false_value(); |
4807 } | 4811 } |
4808 | 4812 |
4809 | 4813 |
4810 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasLocalProperty) { | 4814 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasLocalProperty) { |
4811 NoHandleAllocation ha; | 4815 NoHandleAllocation ha; |
4812 ASSERT(args.length() == 2); | 4816 ASSERT(args.length() == 2); |
4813 CONVERT_CHECKED(String, key, args[1]); | 4817 CONVERT_CHECKED(String, key, 1); |
4814 | 4818 |
4815 uint32_t index; | 4819 uint32_t index; |
4816 const bool key_is_array_index = key->AsArrayIndex(&index); | 4820 const bool key_is_array_index = key->AsArrayIndex(&index); |
4817 | 4821 |
4818 Object* obj = args[0]; | 4822 Object* obj = args[0]; |
4819 // Only JS objects can have properties. | 4823 // Only JS objects can have properties. |
4820 if (obj->IsJSObject()) { | 4824 if (obj->IsJSObject()) { |
4821 JSObject* object = JSObject::cast(obj); | 4825 JSObject* object = JSObject::cast(obj); |
4822 // Fast case: either the key is a real named property or it is not | 4826 // Fast case: either the key is a real named property or it is not |
4823 // an array index and there are no interceptors or hidden | 4827 // an array index and there are no interceptors or hidden |
(...skipping 17 matching lines...) Expand all Loading... | |
4841 return isolate->heap()->true_value(); | 4845 return isolate->heap()->true_value(); |
4842 } | 4846 } |
4843 } | 4847 } |
4844 return isolate->heap()->false_value(); | 4848 return isolate->heap()->false_value(); |
4845 } | 4849 } |
4846 | 4850 |
4847 | 4851 |
4848 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasProperty) { | 4852 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasProperty) { |
4849 NoHandleAllocation na; | 4853 NoHandleAllocation na; |
4850 ASSERT(args.length() == 2); | 4854 ASSERT(args.length() == 2); |
4851 CONVERT_CHECKED(JSReceiver, receiver, args[0]); | 4855 CONVERT_CHECKED(JSReceiver, receiver, 0); |
4852 CONVERT_CHECKED(String, key, args[1]); | 4856 CONVERT_CHECKED(String, key, 1); |
4853 | 4857 |
4854 bool result = receiver->HasProperty(key); | 4858 bool result = receiver->HasProperty(key); |
4855 if (isolate->has_pending_exception()) return Failure::Exception(); | 4859 if (isolate->has_pending_exception()) return Failure::Exception(); |
4856 return isolate->heap()->ToBoolean(result); | 4860 return isolate->heap()->ToBoolean(result); |
4857 } | 4861 } |
4858 | 4862 |
4859 | 4863 |
4860 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasElement) { | 4864 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasElement) { |
4861 NoHandleAllocation na; | 4865 NoHandleAllocation na; |
4862 ASSERT(args.length() == 2); | 4866 ASSERT(args.length() == 2); |
4863 CONVERT_CHECKED(JSReceiver, receiver, args[0]); | 4867 CONVERT_CHECKED(JSReceiver, receiver, 0); |
4864 CONVERT_CHECKED(Smi, index, args[1]); | 4868 CONVERT_SMI_ARG_CHECKED(index, 1); |
4865 | 4869 |
4866 bool result = receiver->HasElement(index->value()); | 4870 bool result = receiver->HasElement(index); |
4867 if (isolate->has_pending_exception()) return Failure::Exception(); | 4871 if (isolate->has_pending_exception()) return Failure::Exception(); |
4868 return isolate->heap()->ToBoolean(result); | 4872 return isolate->heap()->ToBoolean(result); |
4869 } | 4873 } |
4870 | 4874 |
4871 | 4875 |
4872 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsPropertyEnumerable) { | 4876 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsPropertyEnumerable) { |
4873 NoHandleAllocation ha; | 4877 NoHandleAllocation ha; |
4874 ASSERT(args.length() == 2); | 4878 ASSERT(args.length() == 2); |
4875 | 4879 |
4876 CONVERT_CHECKED(JSObject, object, args[0]); | 4880 CONVERT_CHECKED(JSObject, object, 0); |
4877 CONVERT_CHECKED(String, key, args[1]); | 4881 CONVERT_CHECKED(String, key, 1); |
4878 | 4882 |
4879 uint32_t index; | 4883 uint32_t index; |
4880 if (key->AsArrayIndex(&index)) { | 4884 if (key->AsArrayIndex(&index)) { |
4881 JSObject::LocalElementType type = object->HasLocalElement(index); | 4885 JSObject::LocalElementType type = object->HasLocalElement(index); |
4882 switch (type) { | 4886 switch (type) { |
4883 case JSObject::UNDEFINED_ELEMENT: | 4887 case JSObject::UNDEFINED_ELEMENT: |
4884 case JSObject::STRING_CHARACTER_ELEMENT: | 4888 case JSObject::STRING_CHARACTER_ELEMENT: |
4885 return isolate->heap()->false_value(); | 4889 return isolate->heap()->false_value(); |
4886 case JSObject::INTERCEPTED_ELEMENT: | 4890 case JSObject::INTERCEPTED_ELEMENT: |
4887 case JSObject::FAST_ELEMENT: | 4891 case JSObject::FAST_ELEMENT: |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4928 | 4932 |
4929 | 4933 |
4930 // Returns either a FixedArray as Runtime_GetPropertyNames, | 4934 // Returns either a FixedArray as Runtime_GetPropertyNames, |
4931 // or, if the given object has an enum cache that contains | 4935 // or, if the given object has an enum cache that contains |
4932 // all enumerable properties of the object and its prototypes | 4936 // all enumerable properties of the object and its prototypes |
4933 // have none, the map of the object. This is used to speed up | 4937 // have none, the map of the object. This is used to speed up |
4934 // the check for deletions during a for-in. | 4938 // the check for deletions during a for-in. |
4935 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNamesFast) { | 4939 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNamesFast) { |
4936 ASSERT(args.length() == 1); | 4940 ASSERT(args.length() == 1); |
4937 | 4941 |
4938 CONVERT_CHECKED(JSReceiver, raw_object, args[0]); | 4942 CONVERT_CHECKED(JSReceiver, raw_object, 0); |
4939 | 4943 |
4940 if (raw_object->IsSimpleEnum()) return raw_object->map(); | 4944 if (raw_object->IsSimpleEnum()) return raw_object->map(); |
4941 | 4945 |
4942 HandleScope scope(isolate); | 4946 HandleScope scope(isolate); |
4943 Handle<JSReceiver> object(raw_object); | 4947 Handle<JSReceiver> object(raw_object); |
4944 bool threw = false; | 4948 bool threw = false; |
4945 Handle<FixedArray> content = | 4949 Handle<FixedArray> content = |
4946 GetKeysInFixedArrayFor(object, INCLUDE_PROTOS, &threw); | 4950 GetKeysInFixedArrayFor(object, INCLUDE_PROTOS, &threw); |
4947 if (threw) return Failure::Exception(); | 4951 if (threw) return Failure::Exception(); |
4948 | 4952 |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5115 if (obj->HasIndexedInterceptor()) { | 5119 if (obj->HasIndexedInterceptor()) { |
5116 v8::Handle<v8::Array> result = GetKeysForIndexedInterceptor(obj, obj); | 5120 v8::Handle<v8::Array> result = GetKeysForIndexedInterceptor(obj, obj); |
5117 if (!result.IsEmpty()) return *v8::Utils::OpenHandle(*result); | 5121 if (!result.IsEmpty()) return *v8::Utils::OpenHandle(*result); |
5118 } | 5122 } |
5119 return isolate->heap()->undefined_value(); | 5123 return isolate->heap()->undefined_value(); |
5120 } | 5124 } |
5121 | 5125 |
5122 | 5126 |
5123 RUNTIME_FUNCTION(MaybeObject*, Runtime_LocalKeys) { | 5127 RUNTIME_FUNCTION(MaybeObject*, Runtime_LocalKeys) { |
5124 ASSERT_EQ(args.length(), 1); | 5128 ASSERT_EQ(args.length(), 1); |
5125 CONVERT_CHECKED(JSObject, raw_object, args[0]); | 5129 CONVERT_CHECKED(JSObject, raw_object, 0); |
5126 HandleScope scope(isolate); | 5130 HandleScope scope(isolate); |
5127 Handle<JSObject> object(raw_object); | 5131 Handle<JSObject> object(raw_object); |
5128 | 5132 |
5129 if (object->IsJSGlobalProxy()) { | 5133 if (object->IsJSGlobalProxy()) { |
5130 // Do access checks before going to the global object. | 5134 // Do access checks before going to the global object. |
5131 if (object->IsAccessCheckNeeded() && | 5135 if (object->IsAccessCheckNeeded() && |
5132 !isolate->MayNamedAccess(*object, isolate->heap()->undefined_value(), | 5136 !isolate->MayNamedAccess(*object, isolate->heap()->undefined_value(), |
5133 v8::ACCESS_KEYS)) { | 5137 v8::ACCESS_KEYS)) { |
5134 isolate->ReportFailedAccessCheck(*object, v8::ACCESS_KEYS); | 5138 isolate->ReportFailedAccessCheck(*object, v8::ACCESS_KEYS); |
5135 return *isolate->factory()->NewJSArray(0); | 5139 return *isolate->factory()->NewJSArray(0); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5307 d = 10 * d + (s[i] - '0'); | 5311 d = 10 * d + (s[i] - '0'); |
5308 } | 5312 } |
5309 | 5313 |
5310 return d; | 5314 return d; |
5311 } | 5315 } |
5312 | 5316 |
5313 | 5317 |
5314 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringToNumber) { | 5318 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringToNumber) { |
5315 NoHandleAllocation ha; | 5319 NoHandleAllocation ha; |
5316 ASSERT(args.length() == 1); | 5320 ASSERT(args.length() == 1); |
5317 CONVERT_CHECKED(String, subject, args[0]); | 5321 CONVERT_CHECKED(String, subject, 0); |
5318 subject->TryFlatten(); | 5322 subject->TryFlatten(); |
5319 | 5323 |
5320 // Fast case: short integer or some sorts of junk values. | 5324 // Fast case: short integer or some sorts of junk values. |
5321 int len = subject->length(); | 5325 int len = subject->length(); |
5322 if (subject->IsSeqAsciiString()) { | 5326 if (subject->IsSeqAsciiString()) { |
5323 if (len == 0) return Smi::FromInt(0); | 5327 if (len == 0) return Smi::FromInt(0); |
5324 | 5328 |
5325 char const* data = SeqAsciiString::cast(subject)->GetChars(); | 5329 char const* data = SeqAsciiString::cast(subject)->GetChars(); |
5326 bool minus = (data[0] == '-'); | 5330 bool minus = (data[0] == '-'); |
5327 int start_pos = (minus ? 1 : 0); | 5331 int start_pos = (minus ? 1 : 0); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5363 // Slower case. | 5367 // Slower case. |
5364 return isolate->heap()->NumberFromDouble( | 5368 return isolate->heap()->NumberFromDouble( |
5365 StringToDouble(isolate->unicode_cache(), subject, ALLOW_HEX)); | 5369 StringToDouble(isolate->unicode_cache(), subject, ALLOW_HEX)); |
5366 } | 5370 } |
5367 | 5371 |
5368 | 5372 |
5369 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringFromCharCodeArray) { | 5373 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringFromCharCodeArray) { |
5370 NoHandleAllocation ha; | 5374 NoHandleAllocation ha; |
5371 ASSERT(args.length() == 1); | 5375 ASSERT(args.length() == 1); |
5372 | 5376 |
5373 CONVERT_CHECKED(JSArray, codes, args[0]); | 5377 CONVERT_CHECKED(JSArray, codes, 0); |
5374 int length = Smi::cast(codes->length())->value(); | 5378 int length = Smi::cast(codes->length())->value(); |
5375 | 5379 |
5376 // Check if the string can be ASCII. | 5380 // Check if the string can be ASCII. |
5377 int i; | 5381 int i; |
5378 for (i = 0; i < length; i++) { | 5382 for (i = 0; i < length; i++) { |
5379 Object* element; | 5383 Object* element; |
5380 { MaybeObject* maybe_element = codes->GetElement(i); | 5384 { MaybeObject* maybe_element = codes->GetElement(i); |
5381 // We probably can't get an exception here, but just in order to enforce | 5385 // We probably can't get an exception here, but just in order to enforce |
5382 // the checking of inputs in the runtime calls we check here. | 5386 // the checking of inputs in the runtime calls we check here. |
5383 if (!maybe_element->ToObject(&element)) return maybe_element; | 5387 if (!maybe_element->ToObject(&element)) return maybe_element; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5443 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 5447 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
5444 }; | 5448 }; |
5445 return kNotEscaped[character] != 0; | 5449 return kNotEscaped[character] != 0; |
5446 } | 5450 } |
5447 | 5451 |
5448 | 5452 |
5449 RUNTIME_FUNCTION(MaybeObject*, Runtime_URIEscape) { | 5453 RUNTIME_FUNCTION(MaybeObject*, Runtime_URIEscape) { |
5450 const char hex_chars[] = "0123456789ABCDEF"; | 5454 const char hex_chars[] = "0123456789ABCDEF"; |
5451 NoHandleAllocation ha; | 5455 NoHandleAllocation ha; |
5452 ASSERT(args.length() == 1); | 5456 ASSERT(args.length() == 1); |
5453 CONVERT_CHECKED(String, source, args[0]); | 5457 CONVERT_CHECKED(String, source, 0); |
5454 | 5458 |
5455 source->TryFlatten(); | 5459 source->TryFlatten(); |
5456 | 5460 |
5457 int escaped_length = 0; | 5461 int escaped_length = 0; |
5458 int length = source->length(); | 5462 int length = source->length(); |
5459 { | 5463 { |
5460 Access<StringInputBuffer> buffer( | 5464 Access<StringInputBuffer> buffer( |
5461 isolate->runtime_state()->string_input_buffer()); | 5465 isolate->runtime_state()->string_input_buffer()); |
5462 buffer->Reset(source); | 5466 buffer->Reset(source); |
5463 while (buffer->has_more()) { | 5467 while (buffer->has_more()) { |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5561 } else { | 5565 } else { |
5562 *step = 1; | 5566 *step = 1; |
5563 return character; | 5567 return character; |
5564 } | 5568 } |
5565 } | 5569 } |
5566 | 5570 |
5567 | 5571 |
5568 RUNTIME_FUNCTION(MaybeObject*, Runtime_URIUnescape) { | 5572 RUNTIME_FUNCTION(MaybeObject*, Runtime_URIUnescape) { |
5569 NoHandleAllocation ha; | 5573 NoHandleAllocation ha; |
5570 ASSERT(args.length() == 1); | 5574 ASSERT(args.length() == 1); |
5571 CONVERT_CHECKED(String, source, args[0]); | 5575 CONVERT_CHECKED(String, source, 0); |
5572 | 5576 |
5573 source->TryFlatten(); | 5577 source->TryFlatten(); |
5574 | 5578 |
5575 bool ascii = true; | 5579 bool ascii = true; |
5576 int length = source->length(); | 5580 int length = source->length(); |
5577 | 5581 |
5578 int unescaped_length = 0; | 5582 int unescaped_length = 0; |
5579 for (int i = 0; i < length; unescaped_length++) { | 5583 for (int i = 0; i < length; unescaped_length++) { |
5580 int step; | 5584 int step; |
5581 if (Unescape(source, i, length, &step) > String::kMaxAsciiCharCode) { | 5585 if (Unescape(source, i, length, &step) > String::kMaxAsciiCharCode) { |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5818 new_string->address() + SeqString::kHeaderSize)); | 5822 new_string->address() + SeqString::kHeaderSize)); |
5819 isolate->heap()->new_space()-> | 5823 isolate->heap()->new_space()-> |
5820 template ShrinkStringAtAllocationBoundary<StringType>( | 5824 template ShrinkStringAtAllocationBoundary<StringType>( |
5821 new_string, final_length); | 5825 new_string, final_length); |
5822 return new_string; | 5826 return new_string; |
5823 } | 5827 } |
5824 | 5828 |
5825 | 5829 |
5826 RUNTIME_FUNCTION(MaybeObject*, Runtime_QuoteJSONString) { | 5830 RUNTIME_FUNCTION(MaybeObject*, Runtime_QuoteJSONString) { |
5827 NoHandleAllocation ha; | 5831 NoHandleAllocation ha; |
5828 CONVERT_CHECKED(String, str, args[0]); | 5832 CONVERT_CHECKED(String, str, 0); |
5829 if (!str->IsFlat()) { | 5833 if (!str->IsFlat()) { |
5830 MaybeObject* try_flatten = str->TryFlatten(); | 5834 MaybeObject* try_flatten = str->TryFlatten(); |
5831 Object* flat; | 5835 Object* flat; |
5832 if (!try_flatten->ToObject(&flat)) { | 5836 if (!try_flatten->ToObject(&flat)) { |
5833 return try_flatten; | 5837 return try_flatten; |
5834 } | 5838 } |
5835 str = String::cast(flat); | 5839 str = String::cast(flat); |
5836 ASSERT(str->IsFlat()); | 5840 ASSERT(str->IsFlat()); |
5837 } | 5841 } |
5838 String::FlatContent flat = str->GetFlatContent(); | 5842 String::FlatContent flat = str->GetFlatContent(); |
5839 ASSERT(flat.IsFlat()); | 5843 ASSERT(flat.IsFlat()); |
5840 if (flat.IsTwoByte()) { | 5844 if (flat.IsTwoByte()) { |
5841 return QuoteJsonString<uc16, SeqTwoByteString, false>(isolate, | 5845 return QuoteJsonString<uc16, SeqTwoByteString, false>(isolate, |
5842 flat.ToUC16Vector()); | 5846 flat.ToUC16Vector()); |
5843 } else { | 5847 } else { |
5844 return QuoteJsonString<char, SeqAsciiString, false>(isolate, | 5848 return QuoteJsonString<char, SeqAsciiString, false>(isolate, |
5845 flat.ToAsciiVector()); | 5849 flat.ToAsciiVector()); |
5846 } | 5850 } |
5847 } | 5851 } |
5848 | 5852 |
5849 | 5853 |
5850 RUNTIME_FUNCTION(MaybeObject*, Runtime_QuoteJSONStringComma) { | 5854 RUNTIME_FUNCTION(MaybeObject*, Runtime_QuoteJSONStringComma) { |
5851 NoHandleAllocation ha; | 5855 NoHandleAllocation ha; |
5852 CONVERT_CHECKED(String, str, args[0]); | 5856 CONVERT_CHECKED(String, str, 0); |
5853 if (!str->IsFlat()) { | 5857 if (!str->IsFlat()) { |
5854 MaybeObject* try_flatten = str->TryFlatten(); | 5858 MaybeObject* try_flatten = str->TryFlatten(); |
5855 Object* flat; | 5859 Object* flat; |
5856 if (!try_flatten->ToObject(&flat)) { | 5860 if (!try_flatten->ToObject(&flat)) { |
5857 return try_flatten; | 5861 return try_flatten; |
5858 } | 5862 } |
5859 str = String::cast(flat); | 5863 str = String::cast(flat); |
5860 ASSERT(str->IsFlat()); | 5864 ASSERT(str->IsFlat()); |
5861 } | 5865 } |
5862 String::FlatContent flat = str->GetFlatContent(); | 5866 String::FlatContent flat = str->GetFlatContent(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5919 isolate->heap()->new_space()-> | 5923 isolate->heap()->new_space()-> |
5920 template ShrinkStringAtAllocationBoundary<StringType>( | 5924 template ShrinkStringAtAllocationBoundary<StringType>( |
5921 new_string, final_length); | 5925 new_string, final_length); |
5922 return new_string; | 5926 return new_string; |
5923 } | 5927 } |
5924 | 5928 |
5925 | 5929 |
5926 RUNTIME_FUNCTION(MaybeObject*, Runtime_QuoteJSONStringArray) { | 5930 RUNTIME_FUNCTION(MaybeObject*, Runtime_QuoteJSONStringArray) { |
5927 NoHandleAllocation ha; | 5931 NoHandleAllocation ha; |
5928 ASSERT(args.length() == 1); | 5932 ASSERT(args.length() == 1); |
5929 CONVERT_CHECKED(JSArray, array, args[0]); | 5933 CONVERT_CHECKED(JSArray, array, 0); |
5930 | 5934 |
5931 if (!array->HasFastElements()) return isolate->heap()->undefined_value(); | 5935 if (!array->HasFastElements()) return isolate->heap()->undefined_value(); |
5932 FixedArray* elements = FixedArray::cast(array->elements()); | 5936 FixedArray* elements = FixedArray::cast(array->elements()); |
5933 int n = elements->length(); | 5937 int n = elements->length(); |
5934 bool ascii = true; | 5938 bool ascii = true; |
5935 int total_length = 0; | 5939 int total_length = 0; |
5936 | 5940 |
5937 for (int i = 0; i < n; i++) { | 5941 for (int i = 0; i < n; i++) { |
5938 Object* elt = elements->get(i); | 5942 Object* elt = elements->get(i); |
5939 if (!elt->IsString()) return isolate->heap()->undefined_value(); | 5943 if (!elt->IsString()) return isolate->heap()->undefined_value(); |
(...skipping 21 matching lines...) Expand all Loading... | |
5961 return QuoteJsonStringArray<uc16, SeqTwoByteString>(isolate, | 5965 return QuoteJsonStringArray<uc16, SeqTwoByteString>(isolate, |
5962 elements, | 5966 elements, |
5963 worst_case_length); | 5967 worst_case_length); |
5964 } | 5968 } |
5965 } | 5969 } |
5966 | 5970 |
5967 | 5971 |
5968 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseInt) { | 5972 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseInt) { |
5969 NoHandleAllocation ha; | 5973 NoHandleAllocation ha; |
5970 | 5974 |
5971 CONVERT_CHECKED(String, s, args[0]); | 5975 CONVERT_CHECKED(String, s, 0); |
5972 CONVERT_SMI_ARG_CHECKED(radix, 1); | 5976 CONVERT_SMI_ARG_CHECKED(radix, 1); |
5973 | 5977 |
5974 s->TryFlatten(); | 5978 s->TryFlatten(); |
5975 | 5979 |
5976 RUNTIME_ASSERT(radix == 0 || (2 <= radix && radix <= 36)); | 5980 RUNTIME_ASSERT(radix == 0 || (2 <= radix && radix <= 36)); |
5977 double value = StringToInt(isolate->unicode_cache(), s, radix); | 5981 double value = StringToInt(isolate->unicode_cache(), s, radix); |
5978 return isolate->heap()->NumberFromDouble(value); | 5982 return isolate->heap()->NumberFromDouble(value); |
5979 } | 5983 } |
5980 | 5984 |
5981 | 5985 |
5982 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseFloat) { | 5986 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseFloat) { |
5983 NoHandleAllocation ha; | 5987 NoHandleAllocation ha; |
5984 CONVERT_CHECKED(String, str, args[0]); | 5988 CONVERT_CHECKED(String, str, 0); |
5985 | 5989 |
5986 // ECMA-262 section 15.1.2.3, empty string is NaN | 5990 // ECMA-262 section 15.1.2.3, empty string is NaN |
5987 double value = StringToDouble(isolate->unicode_cache(), | 5991 double value = StringToDouble(isolate->unicode_cache(), |
5988 str, ALLOW_TRAILING_JUNK, OS::nan_value()); | 5992 str, ALLOW_TRAILING_JUNK, OS::nan_value()); |
5989 | 5993 |
5990 // Create a number object from the value. | 5994 // Create a number object from the value. |
5991 return isolate->heap()->NumberFromDouble(value); | 5995 return isolate->heap()->NumberFromDouble(value); |
5992 } | 5996 } |
5993 | 5997 |
5994 | 5998 |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6223 | 6227 |
6224 } // namespace | 6228 } // namespace |
6225 | 6229 |
6226 | 6230 |
6227 template <typename ConvertTraits> | 6231 template <typename ConvertTraits> |
6228 MUST_USE_RESULT static MaybeObject* ConvertCase( | 6232 MUST_USE_RESULT static MaybeObject* ConvertCase( |
6229 Arguments args, | 6233 Arguments args, |
6230 Isolate* isolate, | 6234 Isolate* isolate, |
6231 unibrow::Mapping<typename ConvertTraits::UnibrowConverter, 128>* mapping) { | 6235 unibrow::Mapping<typename ConvertTraits::UnibrowConverter, 128>* mapping) { |
6232 NoHandleAllocation ha; | 6236 NoHandleAllocation ha; |
6233 CONVERT_CHECKED(String, s, args[0]); | 6237 CONVERT_CHECKED(String, s, 0); |
6234 s = s->TryFlattenGetString(); | 6238 s = s->TryFlattenGetString(); |
6235 | 6239 |
6236 const int length = s->length(); | 6240 const int length = s->length(); |
6237 // Assume that the string is not empty; we need this assumption later | 6241 // Assume that the string is not empty; we need this assumption later |
6238 if (length == 0) return s; | 6242 if (length == 0) return s; |
6239 | 6243 |
6240 // Simpler handling of ASCII strings. | 6244 // Simpler handling of ASCII strings. |
6241 // | 6245 // |
6242 // NOTE: This assumes that the upper/lower case of an ASCII | 6246 // NOTE: This assumes that the upper/lower case of an ASCII |
6243 // character is also ASCII. This is currently the case, but it | 6247 // character is also ASCII. This is currently the case, but it |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6285 | 6289 |
6286 static inline bool IsTrimWhiteSpace(unibrow::uchar c) { | 6290 static inline bool IsTrimWhiteSpace(unibrow::uchar c) { |
6287 return unibrow::WhiteSpace::Is(c) || c == 0x200b || c == 0xfeff; | 6291 return unibrow::WhiteSpace::Is(c) || c == 0x200b || c == 0xfeff; |
6288 } | 6292 } |
6289 | 6293 |
6290 | 6294 |
6291 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringTrim) { | 6295 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringTrim) { |
6292 NoHandleAllocation ha; | 6296 NoHandleAllocation ha; |
6293 ASSERT(args.length() == 3); | 6297 ASSERT(args.length() == 3); |
6294 | 6298 |
6295 CONVERT_CHECKED(String, s, args[0]); | 6299 CONVERT_CHECKED(String, s, 0); |
6296 CONVERT_BOOLEAN_CHECKED(trimLeft, args[1]); | 6300 CONVERT_BOOLEAN_CHECKED(trimLeft, 1); |
6297 CONVERT_BOOLEAN_CHECKED(trimRight, args[2]); | 6301 CONVERT_BOOLEAN_CHECKED(trimRight, 2); |
6298 | 6302 |
6299 s->TryFlatten(); | 6303 s->TryFlatten(); |
6300 int length = s->length(); | 6304 int length = s->length(); |
6301 | 6305 |
6302 int left = 0; | 6306 int left = 0; |
6303 if (trimLeft) { | 6307 if (trimLeft) { |
6304 while (left < length && IsTrimWhiteSpace(s->Get(left))) { | 6308 while (left < length && IsTrimWhiteSpace(s->Get(left))) { |
6305 left++; | 6309 left++; |
6306 } | 6310 } |
6307 } | 6311 } |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6485 } | 6489 } |
6486 #endif | 6490 #endif |
6487 | 6491 |
6488 return *isolate->factory()->NewJSArrayWithElements(elements); | 6492 return *isolate->factory()->NewJSArrayWithElements(elements); |
6489 } | 6493 } |
6490 | 6494 |
6491 | 6495 |
6492 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewStringWrapper) { | 6496 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewStringWrapper) { |
6493 NoHandleAllocation ha; | 6497 NoHandleAllocation ha; |
6494 ASSERT(args.length() == 1); | 6498 ASSERT(args.length() == 1); |
6495 CONVERT_CHECKED(String, value, args[0]); | 6499 CONVERT_CHECKED(String, value, 0); |
6496 return value->ToObject(); | 6500 return value->ToObject(); |
6497 } | 6501 } |
6498 | 6502 |
6499 | 6503 |
6500 bool Runtime::IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch) { | 6504 bool Runtime::IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch) { |
6501 unibrow::uchar chars[unibrow::ToUppercase::kMaxWidth]; | 6505 unibrow::uchar chars[unibrow::ToUppercase::kMaxWidth]; |
6502 int char_length = runtime_state->to_upper_mapping()->get(ch, 0, chars); | 6506 int char_length = runtime_state->to_upper_mapping()->get(ch, 0, chars); |
6503 return char_length == 0; | 6507 return char_length == 0; |
6504 } | 6508 } |
6505 | 6509 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6676 | 6680 |
6677 x = modulo(x, y); | 6681 x = modulo(x, y); |
6678 // NumberFromDouble may return a Smi instead of a Number object | 6682 // NumberFromDouble may return a Smi instead of a Number object |
6679 return isolate->heap()->NumberFromDouble(x); | 6683 return isolate->heap()->NumberFromDouble(x); |
6680 } | 6684 } |
6681 | 6685 |
6682 | 6686 |
6683 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringAdd) { | 6687 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringAdd) { |
6684 NoHandleAllocation ha; | 6688 NoHandleAllocation ha; |
6685 ASSERT(args.length() == 2); | 6689 ASSERT(args.length() == 2); |
6686 CONVERT_CHECKED(String, str1, args[0]); | 6690 CONVERT_CHECKED(String, str1, 0); |
6687 CONVERT_CHECKED(String, str2, args[1]); | 6691 CONVERT_CHECKED(String, str2, 1); |
6688 isolate->counters()->string_add_runtime()->Increment(); | 6692 isolate->counters()->string_add_runtime()->Increment(); |
6689 return isolate->heap()->AllocateConsString(str1, str2); | 6693 return isolate->heap()->AllocateConsString(str1, str2); |
6690 } | 6694 } |
6691 | 6695 |
6692 | 6696 |
6693 template <typename sinkchar> | 6697 template <typename sinkchar> |
6694 static inline void StringBuilderConcatHelper(String* special, | 6698 static inline void StringBuilderConcatHelper(String* special, |
6695 sinkchar* sink, | 6699 sinkchar* sink, |
6696 FixedArray* fixed_array, | 6700 FixedArray* fixed_array, |
6697 int array_length) { | 6701 int array_length) { |
(...skipping 27 matching lines...) Expand all Loading... | |
6725 String::WriteToFlat(string, sink + position, 0, element_length); | 6729 String::WriteToFlat(string, sink + position, 0, element_length); |
6726 position += element_length; | 6730 position += element_length; |
6727 } | 6731 } |
6728 } | 6732 } |
6729 } | 6733 } |
6730 | 6734 |
6731 | 6735 |
6732 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderConcat) { | 6736 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderConcat) { |
6733 NoHandleAllocation ha; | 6737 NoHandleAllocation ha; |
6734 ASSERT(args.length() == 3); | 6738 ASSERT(args.length() == 3); |
6735 CONVERT_CHECKED(JSArray, array, args[0]); | 6739 CONVERT_CHECKED(JSArray, array, 0); |
6736 if (!args[1]->IsSmi()) { | 6740 if (!args[1]->IsSmi()) { |
6737 isolate->context()->mark_out_of_memory(); | 6741 isolate->context()->mark_out_of_memory(); |
6738 return Failure::OutOfMemoryException(); | 6742 return Failure::OutOfMemoryException(); |
6739 } | 6743 } |
6740 int array_length = args.smi_at(1); | 6744 int array_length = args.smi_at(1); |
6741 CONVERT_CHECKED(String, special, args[2]); | 6745 CONVERT_CHECKED(String, special, 2); |
6742 | 6746 |
6743 // This assumption is used by the slice encoding in one or two smis. | 6747 // This assumption is used by the slice encoding in one or two smis. |
6744 ASSERT(Smi::kMaxValue >= String::kMaxLength); | 6748 ASSERT(Smi::kMaxValue >= String::kMaxLength); |
6745 | 6749 |
6746 MaybeObject* maybe_result = array->EnsureCanContainHeapObjectElements(); | 6750 MaybeObject* maybe_result = array->EnsureCanContainHeapObjectElements(); |
6747 if (maybe_result->IsFailure()) return maybe_result; | 6751 if (maybe_result->IsFailure()) return maybe_result; |
6748 | 6752 |
6749 int special_length = special->length(); | 6753 int special_length = special->length(); |
6750 if (!array->HasFastElements()) { | 6754 if (!array->HasFastElements()) { |
6751 return isolate->Throw(isolate->heap()->illegal_argument_symbol()); | 6755 return isolate->Throw(isolate->heap()->illegal_argument_symbol()); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6841 fixed_array, | 6845 fixed_array, |
6842 array_length); | 6846 array_length); |
6843 return answer; | 6847 return answer; |
6844 } | 6848 } |
6845 } | 6849 } |
6846 | 6850 |
6847 | 6851 |
6848 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderJoin) { | 6852 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderJoin) { |
6849 NoHandleAllocation ha; | 6853 NoHandleAllocation ha; |
6850 ASSERT(args.length() == 3); | 6854 ASSERT(args.length() == 3); |
6851 CONVERT_CHECKED(JSArray, array, args[0]); | 6855 CONVERT_CHECKED(JSArray, array, 0); |
6852 if (!args[1]->IsSmi()) { | 6856 if (!args[1]->IsSmi()) { |
6853 isolate->context()->mark_out_of_memory(); | 6857 isolate->context()->mark_out_of_memory(); |
6854 return Failure::OutOfMemoryException(); | 6858 return Failure::OutOfMemoryException(); |
6855 } | 6859 } |
6856 int array_length = args.smi_at(1); | 6860 int array_length = args.smi_at(1); |
6857 CONVERT_CHECKED(String, separator, args[2]); | 6861 CONVERT_CHECKED(String, separator, 2); |
6858 | 6862 |
6859 if (!array->HasFastElements()) { | 6863 if (!array->HasFastElements()) { |
6860 return isolate->Throw(isolate->heap()->illegal_argument_symbol()); | 6864 return isolate->Throw(isolate->heap()->illegal_argument_symbol()); |
6861 } | 6865 } |
6862 FixedArray* fixed_array = FixedArray::cast(array->elements()); | 6866 FixedArray* fixed_array = FixedArray::cast(array->elements()); |
6863 if (fixed_array->length() < array_length) { | 6867 if (fixed_array->length() < array_length) { |
6864 array_length = fixed_array->length(); | 6868 array_length = fixed_array->length(); |
6865 } | 6869 } |
6866 | 6870 |
6867 if (array_length == 0) { | 6871 if (array_length == 0) { |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6965 previous_separator_position++; | 6969 previous_separator_position++; |
6966 } | 6970 } |
6967 } | 6971 } |
6968 ASSERT(cursor <= buffer.length()); | 6972 ASSERT(cursor <= buffer.length()); |
6969 } | 6973 } |
6970 | 6974 |
6971 | 6975 |
6972 RUNTIME_FUNCTION(MaybeObject*, Runtime_SparseJoinWithSeparator) { | 6976 RUNTIME_FUNCTION(MaybeObject*, Runtime_SparseJoinWithSeparator) { |
6973 NoHandleAllocation ha; | 6977 NoHandleAllocation ha; |
6974 ASSERT(args.length() == 3); | 6978 ASSERT(args.length() == 3); |
6975 CONVERT_CHECKED(JSArray, elements_array, args[0]); | 6979 CONVERT_CHECKED(JSArray, elements_array, 0); |
6976 RUNTIME_ASSERT(elements_array->HasFastElements() || | 6980 RUNTIME_ASSERT(elements_array->HasFastElements() || |
6977 elements_array->HasFastSmiOnlyElements()); | 6981 elements_array->HasFastSmiOnlyElements()); |
6978 CONVERT_NUMBER_CHECKED(uint32_t, array_length, Uint32, args[1]); | 6982 CONVERT_NUMBER_CHECKED(uint32_t, array_length, Uint32, args[1]); |
6979 CONVERT_CHECKED(String, separator, args[2]); | 6983 CONVERT_CHECKED(String, separator, 2); |
6980 // elements_array is fast-mode JSarray of alternating positions | 6984 // elements_array is fast-mode JSarray of alternating positions |
6981 // (increasing order) and strings. | 6985 // (increasing order) and strings. |
6982 // array_length is length of original array (used to add separators); | 6986 // array_length is length of original array (used to add separators); |
6983 // separator is string to put between elements. Assumed to be non-empty. | 6987 // separator is string to put between elements. Assumed to be non-empty. |
6984 | 6988 |
6985 // Find total length of join result. | 6989 // Find total length of join result. |
6986 int string_length = 0; | 6990 int string_length = 0; |
6987 bool is_ascii = separator->IsAsciiRepresentation(); | 6991 bool is_ascii = separator->IsAsciiRepresentation(); |
6988 int max_string_length; | 6992 int max_string_length; |
6989 if (is_ascii) { | 6993 if (is_ascii) { |
6990 max_string_length = SeqAsciiString::kMaxLength; | 6994 max_string_length = SeqAsciiString::kMaxLength; |
6991 } else { | 6995 } else { |
6992 max_string_length = SeqTwoByteString::kMaxLength; | 6996 max_string_length = SeqTwoByteString::kMaxLength; |
6993 } | 6997 } |
6994 bool overflow = false; | 6998 bool overflow = false; |
6995 CONVERT_NUMBER_CHECKED(int, elements_length, | 6999 CONVERT_NUMBER_CHECKED(int, elements_length, |
6996 Int32, elements_array->length()); | 7000 Int32, elements_array->length()); |
6997 RUNTIME_ASSERT((elements_length & 1) == 0); // Even length. | 7001 RUNTIME_ASSERT((elements_length & 1) == 0); // Even length. |
6998 FixedArray* elements = FixedArray::cast(elements_array->elements()); | 7002 FixedArray* elements = FixedArray::cast(elements_array->elements()); |
6999 for (int i = 0; i < elements_length; i += 2) { | 7003 for (int i = 0; i < elements_length; i += 2) { |
7000 RUNTIME_ASSERT(elements->get(i)->IsNumber()); | 7004 RUNTIME_ASSERT(elements->get(i)->IsNumber()); |
7001 CONVERT_CHECKED(String, string, elements->get(i + 1)); | 7005 RUNTIME_ASSERT(elements->get(i + 1)->IsString()); |
7006 String* string = String::cast(elements->get(i + 1)); | |
7002 int length = string->length(); | 7007 int length = string->length(); |
7003 if (is_ascii && !string->IsAsciiRepresentation()) { | 7008 if (is_ascii && !string->IsAsciiRepresentation()) { |
7004 is_ascii = false; | 7009 is_ascii = false; |
7005 max_string_length = SeqTwoByteString::kMaxLength; | 7010 max_string_length = SeqTwoByteString::kMaxLength; |
7006 } | 7011 } |
7007 if (length > max_string_length || | 7012 if (length > max_string_length || |
7008 max_string_length - length < string_length) { | 7013 max_string_length - length < string_length) { |
7009 overflow = true; | 7014 overflow = true; |
7010 break; | 7015 break; |
7011 } | 7016 } |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7149 result = Smi::FromInt(NOT_EQUAL); | 7154 result = Smi::FromInt(NOT_EQUAL); |
7150 } | 7155 } |
7151 return result; | 7156 return result; |
7152 } | 7157 } |
7153 | 7158 |
7154 | 7159 |
7155 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringEquals) { | 7160 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringEquals) { |
7156 NoHandleAllocation ha; | 7161 NoHandleAllocation ha; |
7157 ASSERT(args.length() == 2); | 7162 ASSERT(args.length() == 2); |
7158 | 7163 |
7159 CONVERT_CHECKED(String, x, args[0]); | 7164 CONVERT_CHECKED(String, x, 0); |
7160 CONVERT_CHECKED(String, y, args[1]); | 7165 CONVERT_CHECKED(String, y, 1); |
7161 | 7166 |
7162 bool not_equal = !x->Equals(y); | 7167 bool not_equal = !x->Equals(y); |
7163 // This is slightly convoluted because the value that signifies | 7168 // This is slightly convoluted because the value that signifies |
7164 // equality is 0 and inequality is 1 so we have to negate the result | 7169 // equality is 0 and inequality is 1 so we have to negate the result |
7165 // from String::Equals. | 7170 // from String::Equals. |
7166 ASSERT(not_equal == 0 || not_equal == 1); | 7171 ASSERT(not_equal == 0 || not_equal == 1); |
7167 STATIC_CHECK(EQUAL == 0); | 7172 STATIC_CHECK(EQUAL == 0); |
7168 STATIC_CHECK(NOT_EQUAL == 1); | 7173 STATIC_CHECK(NOT_EQUAL == 1); |
7169 return Smi::FromInt(not_equal); | 7174 return Smi::FromInt(not_equal); |
7170 } | 7175 } |
(...skipping 10 matching lines...) Expand all Loading... | |
7181 if (isless(x, y)) return Smi::FromInt(LESS); | 7186 if (isless(x, y)) return Smi::FromInt(LESS); |
7182 return Smi::FromInt(GREATER); | 7187 return Smi::FromInt(GREATER); |
7183 } | 7188 } |
7184 | 7189 |
7185 | 7190 |
7186 // Compare two Smis as if they were converted to strings and then | 7191 // Compare two Smis as if they were converted to strings and then |
7187 // compared lexicographically. | 7192 // compared lexicographically. |
7188 RUNTIME_FUNCTION(MaybeObject*, Runtime_SmiLexicographicCompare) { | 7193 RUNTIME_FUNCTION(MaybeObject*, Runtime_SmiLexicographicCompare) { |
7189 NoHandleAllocation ha; | 7194 NoHandleAllocation ha; |
7190 ASSERT(args.length() == 2); | 7195 ASSERT(args.length() == 2); |
7191 | 7196 CONVERT_SMI_ARG_CHECKED(x_value, 0); |
7192 // Extract the integer values from the Smis. | 7197 CONVERT_SMI_ARG_CHECKED(y_value, 1); |
7193 CONVERT_CHECKED(Smi, x, args[0]); | |
7194 CONVERT_CHECKED(Smi, y, args[1]); | |
7195 int x_value = x->value(); | |
7196 int y_value = y->value(); | |
7197 | 7198 |
7198 // If the integers are equal so are the string representations. | 7199 // If the integers are equal so are the string representations. |
7199 if (x_value == y_value) return Smi::FromInt(EQUAL); | 7200 if (x_value == y_value) return Smi::FromInt(EQUAL); |
7200 | 7201 |
7201 // If one of the integers is zero the normal integer order is the | 7202 // If one of the integers is zero the normal integer order is the |
7202 // same as the lexicographic order of the string representations. | 7203 // same as the lexicographic order of the string representations. |
7203 if (x_value == 0 || y_value == 0) | 7204 if (x_value == 0 || y_value == 0) |
7204 return Smi::FromInt(x_value < y_value ? LESS : GREATER); | 7205 return Smi::FromInt(x_value < y_value ? LESS : GREATER); |
7205 | 7206 |
7206 // If only one of the integers is negative the negative number is | 7207 // If only one of the integers is negative the negative number is |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7326 ASSERT(result == | 7327 ASSERT(result == |
7327 StringInputBufferCompare(Isolate::Current()->runtime_state(), x, y)); | 7328 StringInputBufferCompare(Isolate::Current()->runtime_state(), x, y)); |
7328 return result; | 7329 return result; |
7329 } | 7330 } |
7330 | 7331 |
7331 | 7332 |
7332 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringCompare) { | 7333 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringCompare) { |
7333 NoHandleAllocation ha; | 7334 NoHandleAllocation ha; |
7334 ASSERT(args.length() == 2); | 7335 ASSERT(args.length() == 2); |
7335 | 7336 |
7336 CONVERT_CHECKED(String, x, args[0]); | 7337 CONVERT_CHECKED(String, x, 0); |
7337 CONVERT_CHECKED(String, y, args[1]); | 7338 CONVERT_CHECKED(String, y, 1); |
7338 | 7339 |
7339 isolate->counters()->string_compare_runtime()->Increment(); | 7340 isolate->counters()->string_compare_runtime()->Increment(); |
7340 | 7341 |
7341 // A few fast case tests before we flatten. | 7342 // A few fast case tests before we flatten. |
7342 if (x == y) return Smi::FromInt(EQUAL); | 7343 if (x == y) return Smi::FromInt(EQUAL); |
7343 if (y->length() == 0) { | 7344 if (y->length() == 0) { |
7344 if (x->length() == 0) return Smi::FromInt(EQUAL); | 7345 if (x->length() == 0) return Smi::FromInt(EQUAL); |
7345 return Smi::FromInt(GREATER); | 7346 return Smi::FromInt(GREATER); |
7346 } else if (x->length() == 0) { | 7347 } else if (x->length() == 0) { |
7347 return Smi::FromInt(LESS); | 7348 return Smi::FromInt(LESS); |
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7934 DateYMDFromTimeSlow(date, year, month, day); | 7935 DateYMDFromTimeSlow(date, year, month, day); |
7935 } | 7936 } |
7936 } | 7937 } |
7937 | 7938 |
7938 | 7939 |
7939 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateYMDFromTime) { | 7940 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateYMDFromTime) { |
7940 NoHandleAllocation ha; | 7941 NoHandleAllocation ha; |
7941 ASSERT(args.length() == 2); | 7942 ASSERT(args.length() == 2); |
7942 | 7943 |
7943 CONVERT_DOUBLE_ARG_CHECKED(t, 0); | 7944 CONVERT_DOUBLE_ARG_CHECKED(t, 0); |
7944 CONVERT_CHECKED(JSArray, res_array, args[1]); | 7945 CONVERT_CHECKED(JSArray, res_array, 1); |
7945 | 7946 |
7946 int year, month, day; | 7947 int year, month, day; |
7947 DateYMDFromTime(static_cast<int>(floor(t / 86400000)), year, month, day); | 7948 DateYMDFromTime(static_cast<int>(floor(t / 86400000)), year, month, day); |
7948 | 7949 |
7949 FixedArrayBase* elms_base = FixedArrayBase::cast(res_array->elements()); | 7950 FixedArrayBase* elms_base = FixedArrayBase::cast(res_array->elements()); |
7950 RUNTIME_ASSERT(elms_base->length() == 3); | 7951 RUNTIME_ASSERT(elms_base->length() == 3); |
7951 RUNTIME_ASSERT(res_array->HasFastTypeElements()); | 7952 RUNTIME_ASSERT(res_array->HasFastTypeElements()); |
7952 | 7953 |
7953 MaybeObject* maybe = res_array->EnsureWritableFastElements(); | 7954 MaybeObject* maybe = res_array->EnsureWritableFastElements(); |
7954 if (maybe->IsFailure()) return maybe; | 7955 if (maybe->IsFailure()) return maybe; |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8091 } | 8092 } |
8092 return result; | 8093 return result; |
8093 } | 8094 } |
8094 | 8095 |
8095 | 8096 |
8096 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewClosure) { | 8097 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewClosure) { |
8097 HandleScope scope(isolate); | 8098 HandleScope scope(isolate); |
8098 ASSERT(args.length() == 3); | 8099 ASSERT(args.length() == 3); |
8099 CONVERT_ARG_CHECKED(Context, context, 0); | 8100 CONVERT_ARG_CHECKED(Context, context, 0); |
8100 CONVERT_ARG_CHECKED(SharedFunctionInfo, shared, 1); | 8101 CONVERT_ARG_CHECKED(SharedFunctionInfo, shared, 1); |
8101 CONVERT_BOOLEAN_CHECKED(pretenure, args[2]); | 8102 CONVERT_BOOLEAN_CHECKED(pretenure, 2); |
8102 | 8103 |
8103 // The caller ensures that we pretenure closures that are assigned | 8104 // The caller ensures that we pretenure closures that are assigned |
8104 // directly to properties. | 8105 // directly to properties. |
8105 PretenureFlag pretenure_flag = pretenure ? TENURED : NOT_TENURED; | 8106 PretenureFlag pretenure_flag = pretenure ? TENURED : NOT_TENURED; |
8106 Handle<JSFunction> result = | 8107 Handle<JSFunction> result = |
8107 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, | 8108 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, |
8108 context, | 8109 context, |
8109 pretenure_flag); | 8110 pretenure_flag); |
8110 return *result; | 8111 return *result; |
8111 } | 8112 } |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8747 | 8748 |
8748 RUNTIME_FUNCTION(MaybeObject*, Runtime_CheckIsBootstrapping) { | 8749 RUNTIME_FUNCTION(MaybeObject*, Runtime_CheckIsBootstrapping) { |
8749 RUNTIME_ASSERT(isolate->bootstrapper()->IsActive()); | 8750 RUNTIME_ASSERT(isolate->bootstrapper()->IsActive()); |
8750 return isolate->heap()->undefined_value(); | 8751 return isolate->heap()->undefined_value(); |
8751 } | 8752 } |
8752 | 8753 |
8753 | 8754 |
8754 RUNTIME_FUNCTION(MaybeObject*, Runtime_Call) { | 8755 RUNTIME_FUNCTION(MaybeObject*, Runtime_Call) { |
8755 HandleScope scope(isolate); | 8756 HandleScope scope(isolate); |
8756 ASSERT(args.length() >= 2); | 8757 ASSERT(args.length() >= 2); |
8757 CONVERT_CHECKED(JSReceiver, fun, args[args.length() - 1]); | 8758 int argc = args.length() - 2; |
8759 CONVERT_CHECKED(JSReceiver, fun, argc + 1); | |
8758 Object* receiver = args[0]; | 8760 Object* receiver = args[0]; |
8759 int argc = args.length() - 2; | |
8760 | 8761 |
8761 // If there are too many arguments, allocate argv via malloc. | 8762 // If there are too many arguments, allocate argv via malloc. |
8762 const int argv_small_size = 10; | 8763 const int argv_small_size = 10; |
8763 Handle<Object> argv_small_buffer[argv_small_size]; | 8764 Handle<Object> argv_small_buffer[argv_small_size]; |
8764 SmartArrayPointer<Handle<Object> > argv_large_buffer; | 8765 SmartArrayPointer<Handle<Object> > argv_large_buffer; |
8765 Handle<Object>* argv = argv_small_buffer; | 8766 Handle<Object>* argv = argv_small_buffer; |
8766 if (argc > argv_small_size) { | 8767 if (argc > argv_small_size) { |
8767 argv = new Handle<Object>[argc]; | 8768 argv = new Handle<Object>[argc]; |
8768 if (argv == NULL) return isolate->StackOverflow(); | 8769 if (argv == NULL) return isolate->StackOverflow(); |
8769 argv_large_buffer = SmartArrayPointer<Handle<Object> >(argv); | 8770 argv_large_buffer = SmartArrayPointer<Handle<Object> >(argv); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8835 ASSERT(args.length() == 1); | 8836 ASSERT(args.length() == 1); |
8836 RUNTIME_ASSERT(!args[0]->IsJSFunction()); | 8837 RUNTIME_ASSERT(!args[0]->IsJSFunction()); |
8837 return *Execution::GetConstructorDelegate(args.at<Object>(0)); | 8838 return *Execution::GetConstructorDelegate(args.at<Object>(0)); |
8838 } | 8839 } |
8839 | 8840 |
8840 | 8841 |
8841 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewFunctionContext) { | 8842 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewFunctionContext) { |
8842 NoHandleAllocation ha; | 8843 NoHandleAllocation ha; |
8843 ASSERT(args.length() == 1); | 8844 ASSERT(args.length() == 1); |
8844 | 8845 |
8845 CONVERT_CHECKED(JSFunction, function, args[0]); | 8846 CONVERT_CHECKED(JSFunction, function, 0); |
8846 int length = function->shared()->scope_info()->ContextLength(); | 8847 int length = function->shared()->scope_info()->ContextLength(); |
8847 Object* result; | 8848 Object* result; |
8848 { MaybeObject* maybe_result = | 8849 { MaybeObject* maybe_result = |
8849 isolate->heap()->AllocateFunctionContext(length, function); | 8850 isolate->heap()->AllocateFunctionContext(length, function); |
8850 if (!maybe_result->ToObject(&result)) return maybe_result; | 8851 if (!maybe_result->ToObject(&result)) return maybe_result; |
8851 } | 8852 } |
8852 | 8853 |
8853 isolate->set_context(Context::cast(result)); | 8854 isolate->set_context(Context::cast(result)); |
8854 | 8855 |
8855 return result; // non-failure | 8856 return result; // non-failure |
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9617 return maybe_allocation; | 9618 return maybe_allocation; |
9618 } | 9619 } |
9619 } | 9620 } |
9620 | 9621 |
9621 | 9622 |
9622 // Push an object unto an array of objects if it is not already in the | 9623 // Push an object unto an array of objects if it is not already in the |
9623 // array. Returns true if the element was pushed on the stack and | 9624 // array. Returns true if the element was pushed on the stack and |
9624 // false otherwise. | 9625 // false otherwise. |
9625 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushIfAbsent) { | 9626 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushIfAbsent) { |
9626 ASSERT(args.length() == 2); | 9627 ASSERT(args.length() == 2); |
9627 CONVERT_CHECKED(JSArray, array, args[0]); | 9628 CONVERT_CHECKED(JSArray, array, 0); |
9628 CONVERT_CHECKED(JSObject, element, args[1]); | 9629 CONVERT_CHECKED(JSObject, element, 1); |
9629 RUNTIME_ASSERT(array->HasFastElements() || array->HasFastSmiOnlyElements()); | 9630 RUNTIME_ASSERT(array->HasFastElements() || array->HasFastSmiOnlyElements()); |
9630 int length = Smi::cast(array->length())->value(); | 9631 int length = Smi::cast(array->length())->value(); |
9631 FixedArray* elements = FixedArray::cast(array->elements()); | 9632 FixedArray* elements = FixedArray::cast(array->elements()); |
9632 for (int i = 0; i < length; i++) { | 9633 for (int i = 0; i < length; i++) { |
9633 if (elements->get(i) == element) return isolate->heap()->false_value(); | 9634 if (elements->get(i) == element) return isolate->heap()->false_value(); |
9634 } | 9635 } |
9635 Object* obj; | 9636 Object* obj; |
9636 // Strict not needed. Used for cycle detection in Array join implementation. | 9637 // Strict not needed. Used for cycle detection in Array join implementation. |
9637 { MaybeObject* maybe_obj = | 9638 { MaybeObject* maybe_obj = |
9638 array->SetFastElement(length, element, kNonStrictMode, true); | 9639 array->SetFastElement(length, element, kNonStrictMode, true); |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10204 return *visitor.ToArray(); | 10205 return *visitor.ToArray(); |
10205 } | 10206 } |
10206 | 10207 |
10207 | 10208 |
10208 // This will not allocate (flatten the string), but it may run | 10209 // This will not allocate (flatten the string), but it may run |
10209 // very slowly for very deeply nested ConsStrings. For debugging use only. | 10210 // very slowly for very deeply nested ConsStrings. For debugging use only. |
10210 RUNTIME_FUNCTION(MaybeObject*, Runtime_GlobalPrint) { | 10211 RUNTIME_FUNCTION(MaybeObject*, Runtime_GlobalPrint) { |
10211 NoHandleAllocation ha; | 10212 NoHandleAllocation ha; |
10212 ASSERT(args.length() == 1); | 10213 ASSERT(args.length() == 1); |
10213 | 10214 |
10214 CONVERT_CHECKED(String, string, args[0]); | 10215 CONVERT_CHECKED(String, string, 0); |
10215 StringInputBuffer buffer(string); | 10216 StringInputBuffer buffer(string); |
10216 while (buffer.has_more()) { | 10217 while (buffer.has_more()) { |
10217 uint16_t character = buffer.GetNext(); | 10218 uint16_t character = buffer.GetNext(); |
10218 PrintF("%c", character); | 10219 PrintF("%c", character); |
10219 } | 10220 } |
10220 return string; | 10221 return string; |
10221 } | 10222 } |
10222 | 10223 |
10223 // Moves all own elements of an object, that are below a limit, to positions | 10224 // Moves all own elements of an object, that are below a limit, to positions |
10224 // starting at zero. All undefined values are placed after non-undefined values, | 10225 // starting at zero. All undefined values are placed after non-undefined values, |
10225 // and are followed by non-existing element. Does not change the length | 10226 // and are followed by non-existing element. Does not change the length |
10226 // property. | 10227 // property. |
10227 // Returns the number of non-undefined elements collected. | 10228 // Returns the number of non-undefined elements collected. |
10228 RUNTIME_FUNCTION(MaybeObject*, Runtime_RemoveArrayHoles) { | 10229 RUNTIME_FUNCTION(MaybeObject*, Runtime_RemoveArrayHoles) { |
10229 ASSERT(args.length() == 2); | 10230 ASSERT(args.length() == 2); |
10230 CONVERT_CHECKED(JSObject, object, args[0]); | 10231 CONVERT_CHECKED(JSObject, object, 0); |
10231 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]); | 10232 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]); |
10232 return object->PrepareElementsForSort(limit); | 10233 return object->PrepareElementsForSort(limit); |
10233 } | 10234 } |
10234 | 10235 |
10235 | 10236 |
10236 // Move contents of argument 0 (an array) to argument 1 (an array) | 10237 // Move contents of argument 0 (an array) to argument 1 (an array) |
10237 RUNTIME_FUNCTION(MaybeObject*, Runtime_MoveArrayContents) { | 10238 RUNTIME_FUNCTION(MaybeObject*, Runtime_MoveArrayContents) { |
10238 ASSERT(args.length() == 2); | 10239 ASSERT(args.length() == 2); |
10239 CONVERT_CHECKED(JSArray, from, args[0]); | 10240 CONVERT_CHECKED(JSArray, from, 0); |
10240 CONVERT_CHECKED(JSArray, to, args[1]); | 10241 CONVERT_CHECKED(JSArray, to, 1); |
10241 FixedArrayBase* new_elements = from->elements(); | 10242 FixedArrayBase* new_elements = from->elements(); |
10242 MaybeObject* maybe_new_map; | 10243 MaybeObject* maybe_new_map; |
10243 ElementsKind elements_kind; | 10244 ElementsKind elements_kind; |
10244 if (new_elements->map() == isolate->heap()->fixed_array_map() || | 10245 if (new_elements->map() == isolate->heap()->fixed_array_map() || |
10245 new_elements->map() == isolate->heap()->fixed_cow_array_map()) { | 10246 new_elements->map() == isolate->heap()->fixed_cow_array_map()) { |
10246 elements_kind = FAST_ELEMENTS; | 10247 elements_kind = FAST_ELEMENTS; |
10247 } else if (new_elements->map() == | 10248 } else if (new_elements->map() == |
10248 isolate->heap()->fixed_double_array_map()) { | 10249 isolate->heap()->fixed_double_array_map()) { |
10249 elements_kind = FAST_DOUBLE_ELEMENTS; | 10250 elements_kind = FAST_DOUBLE_ELEMENTS; |
10250 } else { | 10251 } else { |
(...skipping 10 matching lines...) Expand all Loading... | |
10261 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 10262 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
10262 } | 10263 } |
10263 from->set_length(Smi::FromInt(0)); | 10264 from->set_length(Smi::FromInt(0)); |
10264 return to; | 10265 return to; |
10265 } | 10266 } |
10266 | 10267 |
10267 | 10268 |
10268 // How many elements does this object/array have? | 10269 // How many elements does this object/array have? |
10269 RUNTIME_FUNCTION(MaybeObject*, Runtime_EstimateNumberOfElements) { | 10270 RUNTIME_FUNCTION(MaybeObject*, Runtime_EstimateNumberOfElements) { |
10270 ASSERT(args.length() == 1); | 10271 ASSERT(args.length() == 1); |
10271 CONVERT_CHECKED(JSObject, object, args[0]); | 10272 CONVERT_CHECKED(JSObject, object, 0); |
10272 HeapObject* elements = object->elements(); | 10273 HeapObject* elements = object->elements(); |
10273 if (elements->IsDictionary()) { | 10274 if (elements->IsDictionary()) { |
10274 int result = SeededNumberDictionary::cast(elements)->NumberOfElements(); | 10275 int result = SeededNumberDictionary::cast(elements)->NumberOfElements(); |
10275 return Smi::FromInt(result); | 10276 return Smi::FromInt(result); |
10276 } else if (object->IsJSArray()) { | 10277 } else if (object->IsJSArray()) { |
10277 return JSArray::cast(object)->length(); | 10278 return JSArray::cast(object)->length(); |
10278 } else { | 10279 } else { |
10279 return Smi::FromInt(FixedArray::cast(elements)->length()); | 10280 return Smi::FromInt(FixedArray::cast(elements)->length()); |
10280 } | 10281 } |
10281 } | 10282 } |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10361 // DefineAccessor takes an optional final argument which is the | 10362 // DefineAccessor takes an optional final argument which is the |
10362 // property attributes (e.g. DONT_ENUM, DONT_DELETE). IMPORTANT: due | 10363 // property attributes (e.g. DONT_ENUM, DONT_DELETE). IMPORTANT: due |
10363 // to the way accessors are implemented, it is set for both the getter | 10364 // to the way accessors are implemented, it is set for both the getter |
10364 // and setter on the first call to DefineAccessor and ignored on | 10365 // and setter on the first call to DefineAccessor and ignored on |
10365 // subsequent calls. | 10366 // subsequent calls. |
10366 RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineAccessor) { | 10367 RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineAccessor) { |
10367 RUNTIME_ASSERT(args.length() == 4 || args.length() == 5); | 10368 RUNTIME_ASSERT(args.length() == 4 || args.length() == 5); |
10368 // Compute attributes. | 10369 // Compute attributes. |
10369 PropertyAttributes attributes = NONE; | 10370 PropertyAttributes attributes = NONE; |
10370 if (args.length() == 5) { | 10371 if (args.length() == 5) { |
10371 CONVERT_CHECKED(Smi, attrs, args[4]); | 10372 CONVERT_SMI_ARG_CHECKED(value, 4); |
10372 int value = attrs->value(); | |
10373 // Only attribute bits should be set. | 10373 // Only attribute bits should be set. |
10374 ASSERT((value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); | 10374 ASSERT((value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); |
10375 attributes = static_cast<PropertyAttributes>(value); | 10375 attributes = static_cast<PropertyAttributes>(value); |
10376 } | 10376 } |
10377 | 10377 |
10378 CONVERT_CHECKED(JSObject, obj, args[0]); | 10378 CONVERT_CHECKED(JSObject, obj, 0); |
10379 CONVERT_CHECKED(String, name, args[1]); | 10379 CONVERT_CHECKED(String, name, 1); |
10380 CONVERT_CHECKED(Smi, flag, args[2]); | 10380 CONVERT_SMI_ARG_CHECKED(flag, 2); |
10381 CONVERT_CHECKED(JSFunction, fun, args[3]); | 10381 CONVERT_CHECKED(JSFunction, fun, 3); |
10382 return obj->DefineAccessor(name, flag->value() == 0, fun, attributes); | 10382 return obj->DefineAccessor(name, flag == 0, fun, attributes); |
10383 } | 10383 } |
10384 | 10384 |
10385 | 10385 |
10386 RUNTIME_FUNCTION(MaybeObject*, Runtime_LookupAccessor) { | 10386 RUNTIME_FUNCTION(MaybeObject*, Runtime_LookupAccessor) { |
10387 ASSERT(args.length() == 3); | 10387 ASSERT(args.length() == 3); |
10388 CONVERT_CHECKED(JSObject, obj, args[0]); | 10388 CONVERT_CHECKED(JSObject, obj, 0); |
10389 CONVERT_CHECKED(String, name, args[1]); | 10389 CONVERT_CHECKED(String, name, 1); |
10390 CONVERT_CHECKED(Smi, flag, args[2]); | 10390 CONVERT_SMI_ARG_CHECKED(flag, 2); |
10391 return obj->LookupAccessor(name, flag->value() == 0); | 10391 return obj->LookupAccessor(name, flag == 0); |
10392 } | 10392 } |
10393 | 10393 |
10394 | 10394 |
10395 #ifdef ENABLE_DEBUGGER_SUPPORT | 10395 #ifdef ENABLE_DEBUGGER_SUPPORT |
10396 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugBreak) { | 10396 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugBreak) { |
10397 ASSERT(args.length() == 0); | 10397 ASSERT(args.length() == 0); |
10398 return Execution::DebugBreakHelper(); | 10398 return Execution::DebugBreakHelper(); |
10399 } | 10399 } |
10400 | 10400 |
10401 | 10401 |
10402 // Helper functions for wrapping and unwrapping stack frame ids. | 10402 // Helper functions for wrapping and unwrapping stack frame ids. |
10403 static Smi* WrapFrameId(StackFrame::Id id) { | 10403 static Smi* WrapFrameId(StackFrame::Id id) { |
10404 ASSERT(IsAligned(OffsetFrom(id), static_cast<intptr_t>(4))); | 10404 ASSERT(IsAligned(OffsetFrom(id), static_cast<intptr_t>(4))); |
10405 return Smi::FromInt(id >> 2); | 10405 return Smi::FromInt(id >> 2); |
10406 } | 10406 } |
10407 | 10407 |
10408 | 10408 |
10409 static StackFrame::Id UnwrapFrameId(Smi* wrapped) { | 10409 static StackFrame::Id UnwrapFrameId(int wrapped) { |
10410 return static_cast<StackFrame::Id>(wrapped->value() << 2); | 10410 return static_cast<StackFrame::Id>(wrapped << 2); |
10411 } | 10411 } |
10412 | 10412 |
10413 | 10413 |
10414 // Adds a JavaScript function as a debug event listener. | 10414 // Adds a JavaScript function as a debug event listener. |
10415 // args[0]: debug event listener function to set or null or undefined for | 10415 // args[0]: debug event listener function to set or null or undefined for |
10416 // clearing the event listener function | 10416 // clearing the event listener function |
10417 // args[1]: object supplied during callback | 10417 // args[1]: object supplied during callback |
10418 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDebugEventListener) { | 10418 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDebugEventListener) { |
10419 ASSERT(args.length() == 2); | 10419 ASSERT(args.length() == 2); |
10420 RUNTIME_ASSERT(args[0]->IsJSFunction() || | 10420 RUNTIME_ASSERT(args[0]->IsJSFunction() || |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10617 return DebugLookupResultValue(isolate->heap(), *obj, *name, &result, NULL); | 10617 return DebugLookupResultValue(isolate->heap(), *obj, *name, &result, NULL); |
10618 } | 10618 } |
10619 return isolate->heap()->undefined_value(); | 10619 return isolate->heap()->undefined_value(); |
10620 } | 10620 } |
10621 | 10621 |
10622 | 10622 |
10623 // Return the property type calculated from the property details. | 10623 // Return the property type calculated from the property details. |
10624 // args[0]: smi with property details. | 10624 // args[0]: smi with property details. |
10625 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyTypeFromDetails) { | 10625 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyTypeFromDetails) { |
10626 ASSERT(args.length() == 1); | 10626 ASSERT(args.length() == 1); |
10627 CONVERT_CHECKED(Smi, details, args[0]); | 10627 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); |
10628 PropertyType type = PropertyDetails(details).type(); | 10628 return Smi::FromInt(static_cast<int>(details.type())); |
10629 return Smi::FromInt(static_cast<int>(type)); | |
10630 } | 10629 } |
10631 | 10630 |
10632 | 10631 |
10633 // Return the property attribute calculated from the property details. | 10632 // Return the property attribute calculated from the property details. |
10634 // args[0]: smi with property details. | 10633 // args[0]: smi with property details. |
10635 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyAttributesFromDetails) { | 10634 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyAttributesFromDetails) { |
10636 ASSERT(args.length() == 1); | 10635 ASSERT(args.length() == 1); |
10637 CONVERT_CHECKED(Smi, details, args[0]); | 10636 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); |
10638 PropertyAttributes attributes = PropertyDetails(details).attributes(); | 10637 return Smi::FromInt(static_cast<int>(details.attributes())); |
10639 return Smi::FromInt(static_cast<int>(attributes)); | |
10640 } | 10638 } |
10641 | 10639 |
10642 | 10640 |
10643 // Return the property insertion index calculated from the property details. | 10641 // Return the property insertion index calculated from the property details. |
10644 // args[0]: smi with property details. | 10642 // args[0]: smi with property details. |
10645 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyIndexFromDetails) { | 10643 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyIndexFromDetails) { |
10646 ASSERT(args.length() == 1); | 10644 ASSERT(args.length() == 1); |
10647 CONVERT_CHECKED(Smi, details, args[0]); | 10645 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); |
10648 int index = PropertyDetails(details).index(); | 10646 return Smi::FromInt(details.index()); |
10649 return Smi::FromInt(index); | |
10650 } | 10647 } |
10651 | 10648 |
10652 | 10649 |
10653 // Return property value from named interceptor. | 10650 // Return property value from named interceptor. |
10654 // args[0]: object | 10651 // args[0]: object |
10655 // args[1]: property name | 10652 // args[1]: property name |
10656 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugNamedInterceptorPropertyValue) { | 10653 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugNamedInterceptorPropertyValue) { |
10657 HandleScope scope(isolate); | 10654 HandleScope scope(isolate); |
10658 ASSERT(args.length() == 2); | 10655 ASSERT(args.length() == 2); |
10659 CONVERT_ARG_CHECKED(JSObject, obj, 0); | 10656 CONVERT_ARG_CHECKED(JSObject, obj, 0); |
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11600 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScopeCount) { | 11597 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScopeCount) { |
11601 HandleScope scope(isolate); | 11598 HandleScope scope(isolate); |
11602 ASSERT(args.length() == 2); | 11599 ASSERT(args.length() == 2); |
11603 | 11600 |
11604 // Check arguments. | 11601 // Check arguments. |
11605 Object* check; | 11602 Object* check; |
11606 { MaybeObject* maybe_check = Runtime_CheckExecutionState( | 11603 { MaybeObject* maybe_check = Runtime_CheckExecutionState( |
11607 RUNTIME_ARGUMENTS(isolate, args)); | 11604 RUNTIME_ARGUMENTS(isolate, args)); |
11608 if (!maybe_check->ToObject(&check)) return maybe_check; | 11605 if (!maybe_check->ToObject(&check)) return maybe_check; |
11609 } | 11606 } |
11610 CONVERT_CHECKED(Smi, wrapped_id, args[1]); | 11607 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); |
11611 | 11608 |
11612 // Get the frame where the debugging is performed. | 11609 // Get the frame where the debugging is performed. |
11613 StackFrame::Id id = UnwrapFrameId(wrapped_id); | 11610 StackFrame::Id id = UnwrapFrameId(wrapped_id); |
11614 JavaScriptFrameIterator it(isolate, id); | 11611 JavaScriptFrameIterator it(isolate, id); |
11615 JavaScriptFrame* frame = it.frame(); | 11612 JavaScriptFrame* frame = it.frame(); |
11616 | 11613 |
11617 // Count the visible scopes. | 11614 // Count the visible scopes. |
11618 int n = 0; | 11615 int n = 0; |
11619 for (ScopeIterator it(isolate, frame, 0); | 11616 for (ScopeIterator it(isolate, frame, 0); |
11620 !it.Done(); | 11617 !it.Done(); |
(...skipping 21 matching lines...) Expand all Loading... | |
11642 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScopeDetails) { | 11639 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScopeDetails) { |
11643 HandleScope scope(isolate); | 11640 HandleScope scope(isolate); |
11644 ASSERT(args.length() == 4); | 11641 ASSERT(args.length() == 4); |
11645 | 11642 |
11646 // Check arguments. | 11643 // Check arguments. |
11647 Object* check; | 11644 Object* check; |
11648 { MaybeObject* maybe_check = Runtime_CheckExecutionState( | 11645 { MaybeObject* maybe_check = Runtime_CheckExecutionState( |
11649 RUNTIME_ARGUMENTS(isolate, args)); | 11646 RUNTIME_ARGUMENTS(isolate, args)); |
11650 if (!maybe_check->ToObject(&check)) return maybe_check; | 11647 if (!maybe_check->ToObject(&check)) return maybe_check; |
11651 } | 11648 } |
11652 CONVERT_CHECKED(Smi, wrapped_id, args[1]); | 11649 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); |
11653 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); | 11650 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); |
11654 CONVERT_NUMBER_CHECKED(int, index, Int32, args[3]); | 11651 CONVERT_NUMBER_CHECKED(int, index, Int32, args[3]); |
11655 | 11652 |
11656 // Get the frame where the debugging is performed. | 11653 // Get the frame where the debugging is performed. |
11657 StackFrame::Id id = UnwrapFrameId(wrapped_id); | 11654 StackFrame::Id id = UnwrapFrameId(wrapped_id); |
11658 JavaScriptFrameIterator frame_it(isolate, id); | 11655 JavaScriptFrameIterator frame_it(isolate, id); |
11659 JavaScriptFrame* frame = frame_it.frame(); | 11656 JavaScriptFrame* frame = frame_it.frame(); |
11660 | 11657 |
11661 // Find the requested scope. | 11658 // Find the requested scope. |
11662 int n = 0; | 11659 int n = 0; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11782 // Convert to JS array and return. | 11779 // Convert to JS array and return. |
11783 return *isolate->factory()->NewJSArrayWithElements(details); | 11780 return *isolate->factory()->NewJSArrayWithElements(details); |
11784 } | 11781 } |
11785 | 11782 |
11786 | 11783 |
11787 // Sets the disable break state | 11784 // Sets the disable break state |
11788 // args[0]: disable break state | 11785 // args[0]: disable break state |
11789 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDisableBreak) { | 11786 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDisableBreak) { |
11790 HandleScope scope(isolate); | 11787 HandleScope scope(isolate); |
11791 ASSERT(args.length() == 1); | 11788 ASSERT(args.length() == 1); |
11792 CONVERT_BOOLEAN_CHECKED(disable_break, args[0]); | 11789 CONVERT_BOOLEAN_CHECKED(disable_break, 0); |
11793 isolate->debug()->set_disable_break(disable_break); | 11790 isolate->debug()->set_disable_break(disable_break); |
11794 return isolate->heap()->undefined_value(); | 11791 return isolate->heap()->undefined_value(); |
11795 } | 11792 } |
11796 | 11793 |
11797 | 11794 |
11798 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetBreakLocations) { | 11795 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetBreakLocations) { |
11799 HandleScope scope(isolate); | 11796 HandleScope scope(isolate); |
11800 ASSERT(args.length() == 1); | 11797 ASSERT(args.length() == 1); |
11801 | 11798 |
11802 CONVERT_ARG_CHECKED(JSFunction, fun, 0); | 11799 CONVERT_ARG_CHECKED(JSFunction, fun, 0); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11966 } | 11963 } |
11967 | 11964 |
11968 | 11965 |
11969 // Change the state of break on exceptions. | 11966 // Change the state of break on exceptions. |
11970 // args[0]: Enum value indicating whether to affect caught/uncaught exceptions. | 11967 // args[0]: Enum value indicating whether to affect caught/uncaught exceptions. |
11971 // args[1]: Boolean indicating on/off. | 11968 // args[1]: Boolean indicating on/off. |
11972 RUNTIME_FUNCTION(MaybeObject*, Runtime_ChangeBreakOnException) { | 11969 RUNTIME_FUNCTION(MaybeObject*, Runtime_ChangeBreakOnException) { |
11973 HandleScope scope(isolate); | 11970 HandleScope scope(isolate); |
11974 ASSERT(args.length() == 2); | 11971 ASSERT(args.length() == 2); |
11975 RUNTIME_ASSERT(args[0]->IsNumber()); | 11972 RUNTIME_ASSERT(args[0]->IsNumber()); |
11976 CONVERT_BOOLEAN_CHECKED(enable, args[1]); | 11973 CONVERT_BOOLEAN_CHECKED(enable, 1); |
11977 | 11974 |
11978 // If the number doesn't match an enum value, the ChangeBreakOnException | 11975 // If the number doesn't match an enum value, the ChangeBreakOnException |
11979 // function will default to affecting caught exceptions. | 11976 // function will default to affecting caught exceptions. |
11980 ExceptionBreakType type = | 11977 ExceptionBreakType type = |
11981 static_cast<ExceptionBreakType>(NumberToUint32(args[0])); | 11978 static_cast<ExceptionBreakType>(NumberToUint32(args[0])); |
11982 // Update break point state. | 11979 // Update break point state. |
11983 isolate->debug()->ChangeBreakOnException(type, enable); | 11980 isolate->debug()->ChangeBreakOnException(type, enable); |
11984 return isolate->heap()->undefined_value(); | 11981 return isolate->heap()->undefined_value(); |
11985 } | 11982 } |
11986 | 11983 |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12181 // Check the execution state and decode arguments frame and source to be | 12178 // Check the execution state and decode arguments frame and source to be |
12182 // evaluated. | 12179 // evaluated. |
12183 ASSERT(args.length() == 6); | 12180 ASSERT(args.length() == 6); |
12184 Object* check_result; | 12181 Object* check_result; |
12185 { MaybeObject* maybe_check_result = Runtime_CheckExecutionState( | 12182 { MaybeObject* maybe_check_result = Runtime_CheckExecutionState( |
12186 RUNTIME_ARGUMENTS(isolate, args)); | 12183 RUNTIME_ARGUMENTS(isolate, args)); |
12187 if (!maybe_check_result->ToObject(&check_result)) { | 12184 if (!maybe_check_result->ToObject(&check_result)) { |
12188 return maybe_check_result; | 12185 return maybe_check_result; |
12189 } | 12186 } |
12190 } | 12187 } |
12191 CONVERT_CHECKED(Smi, wrapped_id, args[1]); | 12188 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); |
12192 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); | 12189 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); |
12193 CONVERT_ARG_CHECKED(String, source, 3); | 12190 CONVERT_ARG_CHECKED(String, source, 3); |
12194 CONVERT_BOOLEAN_CHECKED(disable_break, args[4]); | 12191 CONVERT_BOOLEAN_CHECKED(disable_break, 4); |
12195 Handle<Object> additional_context(args[5]); | 12192 Handle<Object> additional_context(args[5]); |
12196 | 12193 |
12197 // Handle the processing of break. | 12194 // Handle the processing of break. |
12198 DisableBreak disable_break_save(disable_break); | 12195 DisableBreak disable_break_save(disable_break); |
12199 | 12196 |
12200 // Get the frame where the debugging is performed. | 12197 // Get the frame where the debugging is performed. |
12201 StackFrame::Id id = UnwrapFrameId(wrapped_id); | 12198 StackFrame::Id id = UnwrapFrameId(wrapped_id); |
12202 JavaScriptFrameIterator it(isolate, id); | 12199 JavaScriptFrameIterator it(isolate, id); |
12203 JavaScriptFrame* frame = it.frame(); | 12200 JavaScriptFrame* frame = it.frame(); |
12204 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate); | 12201 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12321 // evaluated. | 12318 // evaluated. |
12322 ASSERT(args.length() == 4); | 12319 ASSERT(args.length() == 4); |
12323 Object* check_result; | 12320 Object* check_result; |
12324 { MaybeObject* maybe_check_result = Runtime_CheckExecutionState( | 12321 { MaybeObject* maybe_check_result = Runtime_CheckExecutionState( |
12325 RUNTIME_ARGUMENTS(isolate, args)); | 12322 RUNTIME_ARGUMENTS(isolate, args)); |
12326 if (!maybe_check_result->ToObject(&check_result)) { | 12323 if (!maybe_check_result->ToObject(&check_result)) { |
12327 return maybe_check_result; | 12324 return maybe_check_result; |
12328 } | 12325 } |
12329 } | 12326 } |
12330 CONVERT_ARG_CHECKED(String, source, 1); | 12327 CONVERT_ARG_CHECKED(String, source, 1); |
12331 CONVERT_BOOLEAN_CHECKED(disable_break, args[2]); | 12328 CONVERT_BOOLEAN_CHECKED(disable_break, 2); |
12332 Handle<Object> additional_context(args[3]); | 12329 Handle<Object> additional_context(args[3]); |
12333 | 12330 |
12334 // Handle the processing of break. | 12331 // Handle the processing of break. |
12335 DisableBreak disable_break_save(disable_break); | 12332 DisableBreak disable_break_save(disable_break); |
12336 | 12333 |
12337 // Enter the top context from before the debugger was invoked. | 12334 // Enter the top context from before the debugger was invoked. |
12338 SaveContext save(isolate); | 12335 SaveContext save(isolate); |
12339 SaveContext* top = &save; | 12336 SaveContext* top = &save; |
12340 while (top != NULL && *top->context() == *isolate->debug()->debug_context()) { | 12337 while (top != NULL && *top->context() == *isolate->debug()->debug_context()) { |
12341 top = top->prev(); | 12338 top = top->prev(); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12494 | 12491 |
12495 // First perform a full GC in order to avoid references from dead objects. | 12492 // First perform a full GC in order to avoid references from dead objects. |
12496 isolate->heap()->CollectAllGarbage(Heap::kMakeHeapIterableMask, | 12493 isolate->heap()->CollectAllGarbage(Heap::kMakeHeapIterableMask, |
12497 "%DebugReferencedBy"); | 12494 "%DebugReferencedBy"); |
12498 // The heap iterator reserves the right to do a GC to make the heap iterable. | 12495 // The heap iterator reserves the right to do a GC to make the heap iterable. |
12499 // Due to the GC above we know it won't need to do that, but it seems cleaner | 12496 // Due to the GC above we know it won't need to do that, but it seems cleaner |
12500 // to get the heap iterator constructed before we start having unprotected | 12497 // to get the heap iterator constructed before we start having unprotected |
12501 // Object* locals that are not protected by handles. | 12498 // Object* locals that are not protected by handles. |
12502 | 12499 |
12503 // Check parameters. | 12500 // Check parameters. |
12504 CONVERT_CHECKED(JSObject, target, args[0]); | 12501 CONVERT_CHECKED(JSObject, target, 0); |
12505 Object* instance_filter = args[1]; | 12502 Object* instance_filter = args[1]; |
12506 RUNTIME_ASSERT(instance_filter->IsUndefined() || | 12503 RUNTIME_ASSERT(instance_filter->IsUndefined() || |
12507 instance_filter->IsJSObject()); | 12504 instance_filter->IsJSObject()); |
12508 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[2]); | 12505 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[2]); |
12509 RUNTIME_ASSERT(max_references >= 0); | 12506 RUNTIME_ASSERT(max_references >= 0); |
12510 | 12507 |
12511 | 12508 |
12512 // Get the constructor function for context extension and arguments array. | 12509 // Get the constructor function for context extension and arguments array. |
12513 JSObject* arguments_boilerplate = | 12510 JSObject* arguments_boilerplate = |
12514 isolate->context()->global_context()->arguments_boilerplate(); | 12511 isolate->context()->global_context()->arguments_boilerplate(); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12582 // args[0]: the constructor to find instances of | 12579 // args[0]: the constructor to find instances of |
12583 // args[1]: the the maximum number of objects to return | 12580 // args[1]: the the maximum number of objects to return |
12584 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugConstructedBy) { | 12581 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugConstructedBy) { |
12585 ASSERT(args.length() == 2); | 12582 ASSERT(args.length() == 2); |
12586 | 12583 |
12587 // First perform a full GC in order to avoid dead objects. | 12584 // First perform a full GC in order to avoid dead objects. |
12588 isolate->heap()->CollectAllGarbage(Heap::kMakeHeapIterableMask, | 12585 isolate->heap()->CollectAllGarbage(Heap::kMakeHeapIterableMask, |
12589 "%DebugConstructedBy"); | 12586 "%DebugConstructedBy"); |
12590 | 12587 |
12591 // Check parameters. | 12588 // Check parameters. |
12592 CONVERT_CHECKED(JSFunction, constructor, args[0]); | 12589 CONVERT_CHECKED(JSFunction, constructor, 0); |
12593 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[1]); | 12590 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[1]); |
12594 RUNTIME_ASSERT(max_references >= 0); | 12591 RUNTIME_ASSERT(max_references >= 0); |
12595 | 12592 |
12596 // Get the number of referencing objects. | 12593 // Get the number of referencing objects. |
12597 int count; | 12594 int count; |
12598 HeapIterator heap_iterator; | 12595 HeapIterator heap_iterator; |
12599 count = DebugConstructedBy(&heap_iterator, | 12596 count = DebugConstructedBy(&heap_iterator, |
12600 constructor, | 12597 constructor, |
12601 max_references, | 12598 max_references, |
12602 NULL, | 12599 NULL, |
(...skipping 23 matching lines...) Expand all Loading... | |
12626 } | 12623 } |
12627 return JSArray::cast(result)->SetContent(instances); | 12624 return JSArray::cast(result)->SetContent(instances); |
12628 } | 12625 } |
12629 | 12626 |
12630 | 12627 |
12631 // Find the effective prototype object as returned by __proto__. | 12628 // Find the effective prototype object as returned by __proto__. |
12632 // args[0]: the object to find the prototype for. | 12629 // args[0]: the object to find the prototype for. |
12633 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetPrototype) { | 12630 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetPrototype) { |
12634 ASSERT(args.length() == 1); | 12631 ASSERT(args.length() == 1); |
12635 | 12632 |
12636 CONVERT_CHECKED(JSObject, obj, args[0]); | 12633 CONVERT_CHECKED(JSObject, obj, 0); |
12637 | 12634 |
12638 // Use the __proto__ accessor. | 12635 // Use the __proto__ accessor. |
12639 return Accessors::ObjectPrototype.getter(obj, NULL); | 12636 return Accessors::ObjectPrototype.getter(obj, NULL); |
12640 } | 12637 } |
12641 | 12638 |
12642 | 12639 |
12643 RUNTIME_FUNCTION(MaybeObject*, Runtime_SystemBreak) { | 12640 RUNTIME_FUNCTION(MaybeObject*, Runtime_SystemBreak) { |
12644 ASSERT(args.length() == 0); | 12641 ASSERT(args.length() == 0); |
12645 CPU::DebugBreak(); | 12642 CPU::DebugBreak(); |
12646 return isolate->heap()->undefined_value(); | 12643 return isolate->heap()->undefined_value(); |
(...skipping 29 matching lines...) Expand all Loading... | |
12676 shared->construct_stub()->PrintLn(); | 12673 shared->construct_stub()->PrintLn(); |
12677 #endif // DEBUG | 12674 #endif // DEBUG |
12678 return isolate->heap()->undefined_value(); | 12675 return isolate->heap()->undefined_value(); |
12679 } | 12676 } |
12680 | 12677 |
12681 | 12678 |
12682 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetInferredName) { | 12679 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetInferredName) { |
12683 NoHandleAllocation ha; | 12680 NoHandleAllocation ha; |
12684 ASSERT(args.length() == 1); | 12681 ASSERT(args.length() == 1); |
12685 | 12682 |
12686 CONVERT_CHECKED(JSFunction, f, args[0]); | 12683 CONVERT_CHECKED(JSFunction, f, 0); |
12687 return f->shared()->inferred_name(); | 12684 return f->shared()->inferred_name(); |
12688 } | 12685 } |
12689 | 12686 |
12690 | 12687 |
12691 static int FindSharedFunctionInfosForScript(HeapIterator* iterator, | 12688 static int FindSharedFunctionInfosForScript(HeapIterator* iterator, |
12692 Script* script, | 12689 Script* script, |
12693 FixedArray* buffer) { | 12690 FixedArray* buffer) { |
12694 AssertNoAllocation no_allocations; | 12691 AssertNoAllocation no_allocations; |
12695 int counter = 0; | 12692 int counter = 0; |
12696 int buffer_size = buffer->length(); | 12693 int buffer_size = buffer->length(); |
(...skipping 16 matching lines...) Expand all Loading... | |
12713 return counter; | 12710 return counter; |
12714 } | 12711 } |
12715 | 12712 |
12716 // For a script finds all SharedFunctionInfo's in the heap that points | 12713 // For a script finds all SharedFunctionInfo's in the heap that points |
12717 // to this script. Returns JSArray of SharedFunctionInfo wrapped | 12714 // to this script. Returns JSArray of SharedFunctionInfo wrapped |
12718 // in OpaqueReferences. | 12715 // in OpaqueReferences. |
12719 RUNTIME_FUNCTION(MaybeObject*, | 12716 RUNTIME_FUNCTION(MaybeObject*, |
12720 Runtime_LiveEditFindSharedFunctionInfosForScript) { | 12717 Runtime_LiveEditFindSharedFunctionInfosForScript) { |
12721 ASSERT(args.length() == 1); | 12718 ASSERT(args.length() == 1); |
12722 HandleScope scope(isolate); | 12719 HandleScope scope(isolate); |
12723 CONVERT_CHECKED(JSValue, script_value, args[0]); | 12720 CONVERT_CHECKED(JSValue, script_value, 0); |
12724 | 12721 |
12725 | 12722 |
12726 Handle<Script> script = Handle<Script>(Script::cast(script_value->value())); | 12723 Handle<Script> script = Handle<Script>(Script::cast(script_value->value())); |
12727 | 12724 |
12728 const int kBufferSize = 32; | 12725 const int kBufferSize = 32; |
12729 | 12726 |
12730 Handle<FixedArray> array; | 12727 Handle<FixedArray> array; |
12731 array = isolate->factory()->NewFixedArray(kBufferSize); | 12728 array = isolate->factory()->NewFixedArray(kBufferSize); |
12732 int number; | 12729 int number; |
12733 { | 12730 { |
(...skipping 25 matching lines...) Expand all Loading... | |
12759 // For a script calculates compilation information about all its functions. | 12756 // For a script calculates compilation information about all its functions. |
12760 // The script source is explicitly specified by the second argument. | 12757 // The script source is explicitly specified by the second argument. |
12761 // The source of the actual script is not used, however it is important that | 12758 // The source of the actual script is not used, however it is important that |
12762 // all generated code keeps references to this particular instance of script. | 12759 // all generated code keeps references to this particular instance of script. |
12763 // Returns a JSArray of compilation infos. The array is ordered so that | 12760 // Returns a JSArray of compilation infos. The array is ordered so that |
12764 // each function with all its descendant is always stored in a continues range | 12761 // each function with all its descendant is always stored in a continues range |
12765 // with the function itself going first. The root function is a script function. | 12762 // with the function itself going first. The root function is a script function. |
12766 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditGatherCompileInfo) { | 12763 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditGatherCompileInfo) { |
12767 ASSERT(args.length() == 2); | 12764 ASSERT(args.length() == 2); |
12768 HandleScope scope(isolate); | 12765 HandleScope scope(isolate); |
12769 CONVERT_CHECKED(JSValue, script, args[0]); | 12766 CONVERT_CHECKED(JSValue, script, 0); |
12770 CONVERT_ARG_CHECKED(String, source, 1); | 12767 CONVERT_ARG_CHECKED(String, source, 1); |
12771 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); | 12768 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); |
12772 | 12769 |
12773 JSArray* result = LiveEdit::GatherCompileInfo(script_handle, source); | 12770 JSArray* result = LiveEdit::GatherCompileInfo(script_handle, source); |
12774 | 12771 |
12775 if (isolate->has_pending_exception()) { | 12772 if (isolate->has_pending_exception()) { |
12776 return Failure::Exception(); | 12773 return Failure::Exception(); |
12777 } | 12774 } |
12778 | 12775 |
12779 return result; | 12776 return result; |
12780 } | 12777 } |
12781 | 12778 |
12782 // Changes the source of the script to a new_source. | 12779 // Changes the source of the script to a new_source. |
12783 // If old_script_name is provided (i.e. is a String), also creates a copy of | 12780 // If old_script_name is provided (i.e. is a String), also creates a copy of |
12784 // the script with its original source and sends notification to debugger. | 12781 // the script with its original source and sends notification to debugger. |
12785 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditReplaceScript) { | 12782 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditReplaceScript) { |
12786 ASSERT(args.length() == 3); | 12783 ASSERT(args.length() == 3); |
12787 HandleScope scope(isolate); | 12784 HandleScope scope(isolate); |
12788 CONVERT_CHECKED(JSValue, original_script_value, args[0]); | 12785 CONVERT_CHECKED(JSValue, original_script_value, 0); |
12789 CONVERT_ARG_CHECKED(String, new_source, 1); | 12786 CONVERT_ARG_CHECKED(String, new_source, 1); |
12790 Handle<Object> old_script_name(args[2], isolate); | 12787 Handle<Object> old_script_name(args[2], isolate); |
12791 | 12788 |
12792 CONVERT_CHECKED(Script, original_script_pointer, | 12789 RUNTIME_ASSERT(original_script_value->value()->IsScript()); |
12793 original_script_value->value()); | 12790 Handle<Script> original_script(Script::cast(original_script_value->value())); |
12794 Handle<Script> original_script(original_script_pointer); | |
12795 | 12791 |
12796 Object* old_script = LiveEdit::ChangeScriptSource(original_script, | 12792 Object* old_script = LiveEdit::ChangeScriptSource(original_script, |
12797 new_source, | 12793 new_source, |
12798 old_script_name); | 12794 old_script_name); |
12799 | 12795 |
12800 if (old_script->IsScript()) { | 12796 if (old_script->IsScript()) { |
12801 Handle<Script> script_handle(Script::cast(old_script)); | 12797 Handle<Script> script_handle(Script::cast(old_script)); |
12802 return *(GetScriptWrapper(script_handle)); | 12798 return *(GetScriptWrapper(script_handle)); |
12803 } else { | 12799 } else { |
12804 return isolate->heap()->null_value(); | 12800 return isolate->heap()->null_value(); |
(...skipping 22 matching lines...) Expand all Loading... | |
12827 // Connects SharedFunctionInfo to another script. | 12823 // Connects SharedFunctionInfo to another script. |
12828 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditFunctionSetScript) { | 12824 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditFunctionSetScript) { |
12829 ASSERT(args.length() == 2); | 12825 ASSERT(args.length() == 2); |
12830 HandleScope scope(isolate); | 12826 HandleScope scope(isolate); |
12831 Handle<Object> function_object(args[0], isolate); | 12827 Handle<Object> function_object(args[0], isolate); |
12832 Handle<Object> script_object(args[1], isolate); | 12828 Handle<Object> script_object(args[1], isolate); |
12833 | 12829 |
12834 if (function_object->IsJSValue()) { | 12830 if (function_object->IsJSValue()) { |
12835 Handle<JSValue> function_wrapper = Handle<JSValue>::cast(function_object); | 12831 Handle<JSValue> function_wrapper = Handle<JSValue>::cast(function_object); |
12836 if (script_object->IsJSValue()) { | 12832 if (script_object->IsJSValue()) { |
12837 CONVERT_CHECKED(Script, script, JSValue::cast(*script_object)->value()); | 12833 RUNTIME_ASSERT(JSValue::cast(*script_object)->value()->IsScript()); |
12834 Script* script = Script::cast(JSValue::cast(*script_object)->value()); | |
12838 script_object = Handle<Object>(script, isolate); | 12835 script_object = Handle<Object>(script, isolate); |
12839 } | 12836 } |
12840 | 12837 |
12841 LiveEdit::SetFunctionScript(function_wrapper, script_object); | 12838 LiveEdit::SetFunctionScript(function_wrapper, script_object); |
12842 } else { | 12839 } else { |
12843 // Just ignore this. We may not have a SharedFunctionInfo for some functions | 12840 // Just ignore this. We may not have a SharedFunctionInfo for some functions |
12844 // and we check it in this function. | 12841 // and we check it in this function. |
12845 } | 12842 } |
12846 | 12843 |
12847 return isolate->heap()->undefined_value(); | 12844 return isolate->heap()->undefined_value(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12881 | 12878 |
12882 | 12879 |
12883 // For array of SharedFunctionInfo's (each wrapped in JSValue) | 12880 // For array of SharedFunctionInfo's (each wrapped in JSValue) |
12884 // checks that none of them have activations on stacks (of any thread). | 12881 // checks that none of them have activations on stacks (of any thread). |
12885 // Returns array of the same length with corresponding results of | 12882 // Returns array of the same length with corresponding results of |
12886 // LiveEdit::FunctionPatchabilityStatus type. | 12883 // LiveEdit::FunctionPatchabilityStatus type. |
12887 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCheckAndDropActivations) { | 12884 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCheckAndDropActivations) { |
12888 ASSERT(args.length() == 2); | 12885 ASSERT(args.length() == 2); |
12889 HandleScope scope(isolate); | 12886 HandleScope scope(isolate); |
12890 CONVERT_ARG_CHECKED(JSArray, shared_array, 0); | 12887 CONVERT_ARG_CHECKED(JSArray, shared_array, 0); |
12891 CONVERT_BOOLEAN_CHECKED(do_drop, args[1]); | 12888 CONVERT_BOOLEAN_CHECKED(do_drop, 1); |
12892 | 12889 |
12893 return *LiveEdit::CheckAndDropActivations(shared_array, do_drop); | 12890 return *LiveEdit::CheckAndDropActivations(shared_array, do_drop); |
12894 } | 12891 } |
12895 | 12892 |
12896 // Compares 2 strings line-by-line, then token-wise and returns diff in form | 12893 // Compares 2 strings line-by-line, then token-wise and returns diff in form |
12897 // of JSArray of triplets (pos1, pos1_end, pos2_end) describing list | 12894 // of JSArray of triplets (pos1, pos1_end, pos2_end) describing list |
12898 // of diff chunks. | 12895 // of diff chunks. |
12899 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCompareStrings) { | 12896 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCompareStrings) { |
12900 ASSERT(args.length() == 2); | 12897 ASSERT(args.length() == 2); |
12901 HandleScope scope(isolate); | 12898 HandleScope scope(isolate); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12942 } | 12939 } |
12943 | 12940 |
12944 | 12941 |
12945 // Calls specified function with or without entering the debugger. | 12942 // Calls specified function with or without entering the debugger. |
12946 // This is used in unit tests to run code as if debugger is entered or simply | 12943 // This is used in unit tests to run code as if debugger is entered or simply |
12947 // to have a stack with C++ frame in the middle. | 12944 // to have a stack with C++ frame in the middle. |
12948 RUNTIME_FUNCTION(MaybeObject*, Runtime_ExecuteInDebugContext) { | 12945 RUNTIME_FUNCTION(MaybeObject*, Runtime_ExecuteInDebugContext) { |
12949 ASSERT(args.length() == 2); | 12946 ASSERT(args.length() == 2); |
12950 HandleScope scope(isolate); | 12947 HandleScope scope(isolate); |
12951 CONVERT_ARG_CHECKED(JSFunction, function, 0); | 12948 CONVERT_ARG_CHECKED(JSFunction, function, 0); |
12952 CONVERT_BOOLEAN_CHECKED(without_debugger, args[1]); | 12949 CONVERT_BOOLEAN_CHECKED(without_debugger, 1); |
12953 | 12950 |
12954 Handle<Object> result; | 12951 Handle<Object> result; |
12955 bool pending_exception; | 12952 bool pending_exception; |
12956 { | 12953 { |
12957 if (without_debugger) { | 12954 if (without_debugger) { |
12958 result = Execution::Call(function, isolate->global(), 0, NULL, | 12955 result = Execution::Call(function, isolate->global(), 0, NULL, |
12959 &pending_exception); | 12956 &pending_exception); |
12960 } else { | 12957 } else { |
12961 EnterDebugger enter_debugger; | 12958 EnterDebugger enter_debugger; |
12962 result = Execution::Call(function, isolate->global(), 0, NULL, | 12959 result = Execution::Call(function, isolate->global(), 0, NULL, |
12963 &pending_exception); | 12960 &pending_exception); |
12964 } | 12961 } |
12965 } | 12962 } |
12966 if (!pending_exception) { | 12963 if (!pending_exception) { |
12967 return *result; | 12964 return *result; |
12968 } else { | 12965 } else { |
12969 return Failure::Exception(); | 12966 return Failure::Exception(); |
12970 } | 12967 } |
12971 } | 12968 } |
12972 | 12969 |
12973 | 12970 |
12974 // Sets a v8 flag. | 12971 // Sets a v8 flag. |
12975 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetFlags) { | 12972 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetFlags) { |
12976 CONVERT_CHECKED(String, arg, args[0]); | 12973 CONVERT_CHECKED(String, arg, 0); |
12977 SmartArrayPointer<char> flags = | 12974 SmartArrayPointer<char> flags = |
12978 arg->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 12975 arg->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
12979 FlagList::SetFlagsFromString(*flags, StrLength(*flags)); | 12976 FlagList::SetFlagsFromString(*flags, StrLength(*flags)); |
12980 return isolate->heap()->undefined_value(); | 12977 return isolate->heap()->undefined_value(); |
12981 } | 12978 } |
12982 | 12979 |
12983 | 12980 |
12984 // Performs a GC. | 12981 // Performs a GC. |
12985 // Presently, it only does a full GC. | 12982 // Presently, it only does a full GC. |
12986 RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectGarbage) { | 12983 RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectGarbage) { |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13250 | 13247 |
13251 | 13248 |
13252 // Get the script object from script data. NOTE: Regarding performance | 13249 // Get the script object from script data. NOTE: Regarding performance |
13253 // see the NOTE for GetScriptFromScriptData. | 13250 // see the NOTE for GetScriptFromScriptData. |
13254 // args[0]: script data for the script to find the source for | 13251 // args[0]: script data for the script to find the source for |
13255 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScript) { | 13252 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScript) { |
13256 HandleScope scope(isolate); | 13253 HandleScope scope(isolate); |
13257 | 13254 |
13258 ASSERT(args.length() == 1); | 13255 ASSERT(args.length() == 1); |
13259 | 13256 |
13260 CONVERT_CHECKED(String, script_name, args[0]); | 13257 CONVERT_CHECKED(String, script_name, 0); |
13261 | 13258 |
13262 // Find the requested script. | 13259 // Find the requested script. |
13263 Handle<Object> result = | 13260 Handle<Object> result = |
13264 Runtime_GetScriptFromScriptName(Handle<String>(script_name)); | 13261 Runtime_GetScriptFromScriptName(Handle<String>(script_name)); |
13265 return *result; | 13262 return *result; |
13266 } | 13263 } |
13267 | 13264 |
13268 | 13265 |
13269 // Determines whether the given stack frame should be displayed in | 13266 // Determines whether the given stack frame should be displayed in |
13270 // a stack trace. The caller is the error constructor that asked | 13267 // a stack trace. The caller is the error constructor that asked |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13390 reinterpret_cast<char*>(args[0]) + args.smi_at(1)); | 13387 reinterpret_cast<char*>(args[0]) + args.smi_at(1)); |
13391 isolate->PrintStack(); | 13388 isolate->PrintStack(); |
13392 OS::Abort(); | 13389 OS::Abort(); |
13393 UNREACHABLE(); | 13390 UNREACHABLE(); |
13394 return NULL; | 13391 return NULL; |
13395 } | 13392 } |
13396 | 13393 |
13397 | 13394 |
13398 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFromCache) { | 13395 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFromCache) { |
13399 // This is only called from codegen, so checks might be more lax. | 13396 // This is only called from codegen, so checks might be more lax. |
13400 CONVERT_CHECKED(JSFunctionResultCache, cache, args[0]); | 13397 CONVERT_CHECKED(JSFunctionResultCache, cache, 0); |
13401 Object* key = args[1]; | 13398 Object* key = args[1]; |
13402 | 13399 |
13403 int finger_index = cache->finger_index(); | 13400 int finger_index = cache->finger_index(); |
13404 Object* o = cache->get(finger_index); | 13401 Object* o = cache->get(finger_index); |
13405 if (o == key) { | 13402 if (o == key) { |
13406 // The fastest case: hit the same place again. | 13403 // The fastest case: hit the same place again. |
13407 return cache->get(finger_index + 1); | 13404 return cache->get(finger_index + 1); |
13408 } | 13405 } |
13409 | 13406 |
13410 for (int i = finger_index - 2; | 13407 for (int i = finger_index - 2; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13500 arguments, | 13497 arguments, |
13501 0, | 13498 0, |
13502 0, | 13499 0, |
13503 isolate->factory()->undefined_value(), | 13500 isolate->factory()->undefined_value(), |
13504 isolate->factory()->undefined_value(), | 13501 isolate->factory()->undefined_value(), |
13505 isolate->factory()->undefined_value()); | 13502 isolate->factory()->undefined_value()); |
13506 } | 13503 } |
13507 | 13504 |
13508 | 13505 |
13509 RUNTIME_FUNCTION(MaybeObject*, Runtime_MessageGetType) { | 13506 RUNTIME_FUNCTION(MaybeObject*, Runtime_MessageGetType) { |
13510 CONVERT_CHECKED(JSMessageObject, message, args[0]); | 13507 CONVERT_CHECKED(JSMessageObject, message, 0); |
13511 return message->type(); | 13508 return message->type(); |
13512 } | 13509 } |
13513 | 13510 |
13514 | 13511 |
13515 RUNTIME_FUNCTION(MaybeObject*, Runtime_MessageGetArguments) { | 13512 RUNTIME_FUNCTION(MaybeObject*, Runtime_MessageGetArguments) { |
13516 CONVERT_CHECKED(JSMessageObject, message, args[0]); | 13513 CONVERT_CHECKED(JSMessageObject, message, 0); |
13517 return message->arguments(); | 13514 return message->arguments(); |
13518 } | 13515 } |
13519 | 13516 |
13520 | 13517 |
13521 RUNTIME_FUNCTION(MaybeObject*, Runtime_MessageGetStartPosition) { | 13518 RUNTIME_FUNCTION(MaybeObject*, Runtime_MessageGetStartPosition) { |
13522 CONVERT_CHECKED(JSMessageObject, message, args[0]); | 13519 CONVERT_CHECKED(JSMessageObject, message, 0); |
13523 return Smi::FromInt(message->start_position()); | 13520 return Smi::FromInt(message->start_position()); |
13524 } | 13521 } |
13525 | 13522 |
13526 | 13523 |
13527 RUNTIME_FUNCTION(MaybeObject*, Runtime_MessageGetScript) { | 13524 RUNTIME_FUNCTION(MaybeObject*, Runtime_MessageGetScript) { |
13528 CONVERT_CHECKED(JSMessageObject, message, args[0]); | 13525 CONVERT_CHECKED(JSMessageObject, message, 0); |
13529 return message->script(); | 13526 return message->script(); |
13530 } | 13527 } |
13531 | 13528 |
13532 | 13529 |
13533 #ifdef DEBUG | 13530 #ifdef DEBUG |
13534 // ListNatives is ONLY used by the fuzz-natives.js in debug mode | 13531 // ListNatives is ONLY used by the fuzz-natives.js in debug mode |
13535 // Exclude the code in release mode. | 13532 // Exclude the code in release mode. |
13536 RUNTIME_FUNCTION(MaybeObject*, Runtime_ListNatives) { | 13533 RUNTIME_FUNCTION(MaybeObject*, Runtime_ListNatives) { |
13537 ASSERT(args.length() == 0); | 13534 ASSERT(args.length() == 0); |
13538 HandleScope scope; | 13535 HandleScope scope; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13572 #undef ADD_ENTRY | 13569 #undef ADD_ENTRY |
13573 ASSERT_EQ(index, entry_count); | 13570 ASSERT_EQ(index, entry_count); |
13574 Handle<JSArray> result = factory->NewJSArrayWithElements(elements); | 13571 Handle<JSArray> result = factory->NewJSArrayWithElements(elements); |
13575 return *result; | 13572 return *result; |
13576 } | 13573 } |
13577 #endif | 13574 #endif |
13578 | 13575 |
13579 | 13576 |
13580 RUNTIME_FUNCTION(MaybeObject*, Runtime_Log) { | 13577 RUNTIME_FUNCTION(MaybeObject*, Runtime_Log) { |
13581 ASSERT(args.length() == 2); | 13578 ASSERT(args.length() == 2); |
13582 CONVERT_CHECKED(String, format, args[0]); | 13579 CONVERT_CHECKED(String, format, 0); |
13583 CONVERT_CHECKED(JSArray, elms, args[1]); | 13580 CONVERT_CHECKED(JSArray, elms, 1); |
13584 String::FlatContent format_content = format->GetFlatContent(); | 13581 String::FlatContent format_content = format->GetFlatContent(); |
13585 RUNTIME_ASSERT(format_content.IsAscii()); | 13582 RUNTIME_ASSERT(format_content.IsAscii()); |
13586 Vector<const char> chars = format_content.ToAsciiVector(); | 13583 Vector<const char> chars = format_content.ToAsciiVector(); |
13587 LOGGER->LogRuntime(chars, elms); | 13584 LOGGER->LogRuntime(chars, elms); |
13588 return isolate->heap()->undefined_value(); | 13585 return isolate->heap()->undefined_value(); |
13589 } | 13586 } |
13590 | 13587 |
13591 | 13588 |
13592 RUNTIME_FUNCTION(MaybeObject*, Runtime_IS_VAR) { | 13589 RUNTIME_FUNCTION(MaybeObject*, Runtime_IS_VAR) { |
13593 UNREACHABLE(); // implemented as macro in the parser | 13590 UNREACHABLE(); // implemented as macro in the parser |
13594 return NULL; | 13591 return NULL; |
13595 } | 13592 } |
13596 | 13593 |
13597 | 13594 |
13598 #define ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(Name) \ | 13595 #define ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(Name) \ |
13599 RUNTIME_FUNCTION(MaybeObject*, Runtime_Has##Name) { \ | 13596 RUNTIME_FUNCTION(MaybeObject*, Runtime_Has##Name) { \ |
13600 CONVERT_CHECKED(JSObject, obj, args[0]); \ | 13597 CONVERT_CHECKED(JSObject, obj, 0); \ |
13601 return isolate->heap()->ToBoolean(obj->Has##Name()); \ | 13598 return isolate->heap()->ToBoolean(obj->Has##Name()); \ |
13602 } | 13599 } |
13603 | 13600 |
13604 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastSmiOnlyElements) | 13601 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastSmiOnlyElements) |
13605 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastElements) | 13602 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastElements) |
13606 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastDoubleElements) | 13603 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastDoubleElements) |
13607 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(DictionaryElements) | 13604 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(DictionaryElements) |
13608 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalPixelElements) | 13605 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalPixelElements) |
13609 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalArrayElements) | 13606 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalArrayElements) |
13610 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalByteElements) | 13607 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalByteElements) |
13611 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalUnsignedByteElements) | 13608 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalUnsignedByteElements) |
13612 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalShortElements) | 13609 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalShortElements) |
13613 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalUnsignedShortElements) | 13610 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalUnsignedShortElements) |
13614 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalIntElements) | 13611 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalIntElements) |
13615 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalUnsignedIntElements) | 13612 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalUnsignedIntElements) |
13616 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalFloatElements) | 13613 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalFloatElements) |
13617 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalDoubleElements) | 13614 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalDoubleElements) |
13618 | 13615 |
13619 #undef ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION | 13616 #undef ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION |
13620 | 13617 |
13621 | 13618 |
13622 RUNTIME_FUNCTION(MaybeObject*, Runtime_HaveSameMap) { | 13619 RUNTIME_FUNCTION(MaybeObject*, Runtime_HaveSameMap) { |
13623 ASSERT(args.length() == 2); | 13620 ASSERT(args.length() == 2); |
13624 CONVERT_CHECKED(JSObject, obj1, args[0]); | 13621 CONVERT_CHECKED(JSObject, obj1, 0); |
13625 CONVERT_CHECKED(JSObject, obj2, args[1]); | 13622 CONVERT_CHECKED(JSObject, obj2, 1); |
13626 return isolate->heap()->ToBoolean(obj1->map() == obj2->map()); | 13623 return isolate->heap()->ToBoolean(obj1->map() == obj2->map()); |
13627 } | 13624 } |
13628 | 13625 |
13629 // ---------------------------------------------------------------------------- | 13626 // ---------------------------------------------------------------------------- |
13630 // Implementation of Runtime | 13627 // Implementation of Runtime |
13631 | 13628 |
13632 #define F(name, number_of_args, result_size) \ | 13629 #define F(name, number_of_args, result_size) \ |
13633 { Runtime::k##name, Runtime::RUNTIME, #name, \ | 13630 { Runtime::k##name, Runtime::RUNTIME, #name, \ |
13634 FUNCTION_ADDR(Runtime_##name), number_of_args, result_size }, | 13631 FUNCTION_ADDR(Runtime_##name), number_of_args, result_size }, |
13635 | 13632 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13704 // Handle last resort GC and make sure to allow future allocations | 13701 // Handle last resort GC and make sure to allow future allocations |
13705 // to grow the heap without causing GCs (if possible). | 13702 // to grow the heap without causing GCs (if possible). |
13706 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13703 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13707 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13704 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
13708 "Runtime::PerformGC"); | 13705 "Runtime::PerformGC"); |
13709 } | 13706 } |
13710 } | 13707 } |
13711 | 13708 |
13712 | 13709 |
13713 } } // namespace v8::internal | 13710 } } // namespace v8::internal |
OLD | NEW |