OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 Object* prototype = args[1]; | 608 Object* prototype = args[1]; |
609 Object* used_prototype = | 609 Object* used_prototype = |
610 prototype->IsJSReceiver() ? prototype : isolate->heap()->null_value(); | 610 prototype->IsJSReceiver() ? prototype : isolate->heap()->null_value(); |
611 return isolate->heap()->AllocateJSProxy(handler, used_prototype); | 611 return isolate->heap()->AllocateJSProxy(handler, used_prototype); |
612 } | 612 } |
613 | 613 |
614 | 614 |
615 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsJSProxy) { | 615 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsJSProxy) { |
616 ASSERT(args.length() == 1); | 616 ASSERT(args.length() == 1); |
617 Object* obj = args[0]; | 617 Object* obj = args[0]; |
618 return obj->IsJSProxy() | 618 return isolate->heap()->ToBoolean(obj->IsJSProxy()); |
619 ? isolate->heap()->true_value() : isolate->heap()->false_value(); | |
620 } | 619 } |
621 | 620 |
622 | 621 |
623 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetHandler) { | 622 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetHandler) { |
624 ASSERT(args.length() == 1); | 623 ASSERT(args.length() == 1); |
625 CONVERT_CHECKED(JSProxy, proxy, args[0]); | 624 CONVERT_CHECKED(JSProxy, proxy, args[0]); |
626 return proxy->handler(); | 625 return proxy->handler(); |
627 } | 626 } |
628 | 627 |
629 | 628 |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 | 1030 |
1032 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsExtensible) { | 1031 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsExtensible) { |
1033 ASSERT(args.length() == 1); | 1032 ASSERT(args.length() == 1); |
1034 CONVERT_CHECKED(JSObject, obj, args[0]); | 1033 CONVERT_CHECKED(JSObject, obj, args[0]); |
1035 if (obj->IsJSGlobalProxy()) { | 1034 if (obj->IsJSGlobalProxy()) { |
1036 Object* proto = obj->GetPrototype(); | 1035 Object* proto = obj->GetPrototype(); |
1037 if (proto->IsNull()) return isolate->heap()->false_value(); | 1036 if (proto->IsNull()) return isolate->heap()->false_value(); |
1038 ASSERT(proto->IsJSGlobalObject()); | 1037 ASSERT(proto->IsJSGlobalObject()); |
1039 obj = JSObject::cast(proto); | 1038 obj = JSObject::cast(proto); |
1040 } | 1039 } |
1041 return obj->map()->is_extensible() ? isolate->heap()->true_value() | 1040 return isolate->heap()->ToBoolean(obj->map()->is_extensible()); |
1042 : isolate->heap()->false_value(); | |
1043 } | 1041 } |
1044 | 1042 |
1045 | 1043 |
1046 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpCompile) { | 1044 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpCompile) { |
1047 HandleScope scope(isolate); | 1045 HandleScope scope(isolate); |
1048 ASSERT(args.length() == 3); | 1046 ASSERT(args.length() == 3); |
1049 CONVERT_ARG_CHECKED(JSRegExp, re, 0); | 1047 CONVERT_ARG_CHECKED(JSRegExp, re, 0); |
1050 CONVERT_ARG_CHECKED(String, pattern, 1); | 1048 CONVERT_ARG_CHECKED(String, pattern, 1); |
1051 CONVERT_ARG_CHECKED(String, flags, 2); | 1049 CONVERT_ARG_CHECKED(String, flags, 2); |
1052 Handle<Object> result = RegExpImpl::Compile(re, pattern, flags); | 1050 Handle<Object> result = RegExpImpl::Compile(re, pattern, flags); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1098 if (needs_access_checks) { | 1096 if (needs_access_checks) { |
1099 // Copy map so it won't interfere constructor's initial map. | 1097 // Copy map so it won't interfere constructor's initial map. |
1100 Object* new_map; | 1098 Object* new_map; |
1101 { MaybeObject* maybe_new_map = old_map->CopyDropTransitions(); | 1099 { MaybeObject* maybe_new_map = old_map->CopyDropTransitions(); |
1102 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map; | 1100 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map; |
1103 } | 1101 } |
1104 | 1102 |
1105 Map::cast(new_map)->set_is_access_check_needed(false); | 1103 Map::cast(new_map)->set_is_access_check_needed(false); |
1106 object->set_map(Map::cast(new_map)); | 1104 object->set_map(Map::cast(new_map)); |
1107 } | 1105 } |
1108 return needs_access_checks ? isolate->heap()->true_value() | 1106 return isolate->heap()->ToBoolean(needs_access_checks); |
1109 : isolate->heap()->false_value(); | |
1110 } | 1107 } |
1111 | 1108 |
1112 | 1109 |
1113 RUNTIME_FUNCTION(MaybeObject*, Runtime_EnableAccessChecks) { | 1110 RUNTIME_FUNCTION(MaybeObject*, Runtime_EnableAccessChecks) { |
1114 ASSERT(args.length() == 1); | 1111 ASSERT(args.length() == 1); |
1115 CONVERT_CHECKED(HeapObject, object, args[0]); | 1112 CONVERT_CHECKED(HeapObject, object, args[0]); |
1116 Map* old_map = object->map(); | 1113 Map* old_map = object->map(); |
1117 if (!old_map->is_access_check_needed()) { | 1114 if (!old_map->is_access_check_needed()) { |
1118 // Copy map so it won't interfere constructor's initial map. | 1115 // Copy map so it won't interfere constructor's initial map. |
1119 Object* new_map; | 1116 Object* new_map; |
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1910 NoHandleAllocation ha; | 1907 NoHandleAllocation ha; |
1911 ASSERT(args.length() == 2); | 1908 ASSERT(args.length() == 2); |
1912 | 1909 |
1913 CONVERT_CHECKED(JSFunction, f, args[0]); | 1910 CONVERT_CHECKED(JSFunction, f, args[0]); |
1914 CONVERT_CHECKED(String, name, args[1]); | 1911 CONVERT_CHECKED(String, name, args[1]); |
1915 f->shared()->set_name(name); | 1912 f->shared()->set_name(name); |
1916 return isolate->heap()->undefined_value(); | 1913 return isolate->heap()->undefined_value(); |
1917 } | 1914 } |
1918 | 1915 |
1919 | 1916 |
| 1917 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionNameShouldPrintAsAnonymous) { |
| 1918 NoHandleAllocation ha; |
| 1919 ASSERT(args.length() == 1); |
| 1920 CONVERT_CHECKED(JSFunction, f, args[0]); |
| 1921 return isolate->heap()->ToBoolean( |
| 1922 f->shared()->name_should_print_as_anonymous()); |
| 1923 } |
| 1924 |
| 1925 |
| 1926 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionMarkNameShouldPrintAsAnonymous) { |
| 1927 NoHandleAllocation ha; |
| 1928 ASSERT(args.length() == 1); |
| 1929 CONVERT_CHECKED(JSFunction, f, args[0]); |
| 1930 f->shared()->set_name_should_print_as_anonymous(true); |
| 1931 return isolate->heap()->undefined_value(); |
| 1932 } |
| 1933 |
| 1934 |
1920 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetBound) { | 1935 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetBound) { |
1921 HandleScope scope(isolate); | 1936 HandleScope scope(isolate); |
1922 ASSERT(args.length() == 1); | 1937 ASSERT(args.length() == 1); |
1923 | 1938 |
1924 CONVERT_CHECKED(JSFunction, fun, args[0]); | 1939 CONVERT_CHECKED(JSFunction, fun, args[0]); |
1925 fun->shared()->set_bound(true); | 1940 fun->shared()->set_bound(true); |
1926 return isolate->heap()->undefined_value(); | 1941 return isolate->heap()->undefined_value(); |
1927 } | 1942 } |
1928 | 1943 |
1929 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionRemovePrototype) { | 1944 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionRemovePrototype) { |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2090 } | 2105 } |
2091 return function; | 2106 return function; |
2092 } | 2107 } |
2093 | 2108 |
2094 | 2109 |
2095 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsAPIFunction) { | 2110 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsAPIFunction) { |
2096 NoHandleAllocation ha; | 2111 NoHandleAllocation ha; |
2097 ASSERT(args.length() == 1); | 2112 ASSERT(args.length() == 1); |
2098 | 2113 |
2099 CONVERT_CHECKED(JSFunction, f, args[0]); | 2114 CONVERT_CHECKED(JSFunction, f, args[0]); |
2100 return f->shared()->IsApiFunction() ? isolate->heap()->true_value() | 2115 return isolate->heap()->ToBoolean(f->shared()->IsApiFunction()); |
2101 : isolate->heap()->false_value(); | |
2102 } | 2116 } |
2103 | 2117 |
2104 | 2118 |
2105 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsBuiltin) { | 2119 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsBuiltin) { |
2106 NoHandleAllocation ha; | 2120 NoHandleAllocation ha; |
2107 ASSERT(args.length() == 1); | 2121 ASSERT(args.length() == 1); |
2108 | 2122 |
2109 CONVERT_CHECKED(JSFunction, f, args[0]); | 2123 CONVERT_CHECKED(JSFunction, f, args[0]); |
2110 return f->IsBuiltin() ? isolate->heap()->true_value() : | 2124 return isolate->heap()->ToBoolean(f->IsBuiltin()); |
2111 isolate->heap()->false_value(); | |
2112 } | 2125 } |
2113 | 2126 |
2114 | 2127 |
2115 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetCode) { | 2128 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetCode) { |
2116 HandleScope scope(isolate); | 2129 HandleScope scope(isolate); |
2117 ASSERT(args.length() == 2); | 2130 ASSERT(args.length() == 2); |
2118 | 2131 |
2119 CONVERT_ARG_CHECKED(JSFunction, target, 0); | 2132 CONVERT_ARG_CHECKED(JSFunction, target, 0); |
2120 Handle<Object> code = args.at<Object>(1); | 2133 Handle<Object> code = args.at<Object>(1); |
2121 | 2134 |
(...skipping 7851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9973 | 9986 |
9974 // If the callback object is a fixed array then it contains JavaScript | 9987 // If the callback object is a fixed array then it contains JavaScript |
9975 // getter and/or setter. | 9988 // getter and/or setter. |
9976 bool hasJavaScriptAccessors = result_type == CALLBACKS && | 9989 bool hasJavaScriptAccessors = result_type == CALLBACKS && |
9977 result_callback_obj->IsFixedArray(); | 9990 result_callback_obj->IsFixedArray(); |
9978 Handle<FixedArray> details = | 9991 Handle<FixedArray> details = |
9979 isolate->factory()->NewFixedArray(hasJavaScriptAccessors ? 5 : 2); | 9992 isolate->factory()->NewFixedArray(hasJavaScriptAccessors ? 5 : 2); |
9980 details->set(0, *value); | 9993 details->set(0, *value); |
9981 details->set(1, property_details); | 9994 details->set(1, property_details); |
9982 if (hasJavaScriptAccessors) { | 9995 if (hasJavaScriptAccessors) { |
9983 details->set(2, | 9996 details->set(2, isolate->heap()->ToBoolean(caught_exception)); |
9984 caught_exception ? isolate->heap()->true_value() | |
9985 : isolate->heap()->false_value()); | |
9986 details->set(3, FixedArray::cast(*result_callback_obj)->get(0)); | 9997 details->set(3, FixedArray::cast(*result_callback_obj)->get(0)); |
9987 details->set(4, FixedArray::cast(*result_callback_obj)->get(1)); | 9998 details->set(4, FixedArray::cast(*result_callback_obj)->get(1)); |
9988 } | 9999 } |
9989 | 10000 |
9990 return *isolate->factory()->NewJSArrayWithElements(details); | 10001 return *isolate->factory()->NewJSArrayWithElements(details); |
9991 } | 10002 } |
9992 if (i < length - 1) { | 10003 if (i < length - 1) { |
9993 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); | 10004 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); |
9994 } | 10005 } |
9995 } | 10006 } |
(...skipping 2166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12162 return isolate->heap()->undefined_value(); | 12173 return isolate->heap()->undefined_value(); |
12163 #endif | 12174 #endif |
12164 } | 12175 } |
12165 | 12176 |
12166 | 12177 |
12167 // Deletes the specified live object list. | 12178 // Deletes the specified live object list. |
12168 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteLOL) { | 12179 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteLOL) { |
12169 #ifdef LIVE_OBJECT_LIST | 12180 #ifdef LIVE_OBJECT_LIST |
12170 CONVERT_SMI_ARG_CHECKED(id, 0); | 12181 CONVERT_SMI_ARG_CHECKED(id, 0); |
12171 bool success = LiveObjectList::Delete(id); | 12182 bool success = LiveObjectList::Delete(id); |
12172 return success ? isolate->heap()->true_value() : | 12183 return isolate->heap()->ToBoolean(success); |
12173 isolate->heap()->false_value(); | |
12174 #else | 12184 #else |
12175 return isolate->heap()->undefined_value(); | 12185 return isolate->heap()->undefined_value(); |
12176 #endif | 12186 #endif |
12177 } | 12187 } |
12178 | 12188 |
12179 | 12189 |
12180 // Generates the response to a debugger request for a dump of the objects | 12190 // Generates the response to a debugger request for a dump of the objects |
12181 // contained in the difference between the captured live object lists | 12191 // contained in the difference between the captured live object lists |
12182 // specified by id1 and id2. | 12192 // specified by id1 and id2. |
12183 // If id1 is 0 (i.e. not a valid lol), then the whole of lol id2 will be | 12193 // If id1 is 0 (i.e. not a valid lol), then the whole of lol id2 will be |
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12827 } else { | 12837 } else { |
12828 // Handle last resort GC and make sure to allow future allocations | 12838 // Handle last resort GC and make sure to allow future allocations |
12829 // to grow the heap without causing GCs (if possible). | 12839 // to grow the heap without causing GCs (if possible). |
12830 isolate->counters()->gc_last_resort_from_js()->Increment(); | 12840 isolate->counters()->gc_last_resort_from_js()->Increment(); |
12831 isolate->heap()->CollectAllGarbage(false); | 12841 isolate->heap()->CollectAllGarbage(false); |
12832 } | 12842 } |
12833 } | 12843 } |
12834 | 12844 |
12835 | 12845 |
12836 } } // namespace v8::internal | 12846 } } // namespace v8::internal |
OLD | NEW |