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

Side by Side Diff: src/runtime.cc

Issue 7584005: Revert "Fix a bug in scope analysis." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/runtime.h ('k') | src/v8natives.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 isolate->heap()->ToBoolean(obj->IsJSProxy()); 618 return obj->IsJSProxy()
619 ? isolate->heap()->true_value() : isolate->heap()->false_value();
619 } 620 }
620 621
621 622
622 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetHandler) { 623 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetHandler) {
623 ASSERT(args.length() == 1); 624 ASSERT(args.length() == 1);
624 CONVERT_CHECKED(JSProxy, proxy, args[0]); 625 CONVERT_CHECKED(JSProxy, proxy, args[0]);
625 return proxy->handler(); 626 return proxy->handler();
626 } 627 }
627 628
628 629
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 1031
1031 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsExtensible) { 1032 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsExtensible) {
1032 ASSERT(args.length() == 1); 1033 ASSERT(args.length() == 1);
1033 CONVERT_CHECKED(JSObject, obj, args[0]); 1034 CONVERT_CHECKED(JSObject, obj, args[0]);
1034 if (obj->IsJSGlobalProxy()) { 1035 if (obj->IsJSGlobalProxy()) {
1035 Object* proto = obj->GetPrototype(); 1036 Object* proto = obj->GetPrototype();
1036 if (proto->IsNull()) return isolate->heap()->false_value(); 1037 if (proto->IsNull()) return isolate->heap()->false_value();
1037 ASSERT(proto->IsJSGlobalObject()); 1038 ASSERT(proto->IsJSGlobalObject());
1038 obj = JSObject::cast(proto); 1039 obj = JSObject::cast(proto);
1039 } 1040 }
1040 return isolate->heap()->ToBoolean(obj->map()->is_extensible()); 1041 return obj->map()->is_extensible() ? isolate->heap()->true_value()
1042 : isolate->heap()->false_value();
1041 } 1043 }
1042 1044
1043 1045
1044 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpCompile) { 1046 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpCompile) {
1045 HandleScope scope(isolate); 1047 HandleScope scope(isolate);
1046 ASSERT(args.length() == 3); 1048 ASSERT(args.length() == 3);
1047 CONVERT_ARG_CHECKED(JSRegExp, re, 0); 1049 CONVERT_ARG_CHECKED(JSRegExp, re, 0);
1048 CONVERT_ARG_CHECKED(String, pattern, 1); 1050 CONVERT_ARG_CHECKED(String, pattern, 1);
1049 CONVERT_ARG_CHECKED(String, flags, 2); 1051 CONVERT_ARG_CHECKED(String, flags, 2);
1050 Handle<Object> result = RegExpImpl::Compile(re, pattern, flags); 1052 Handle<Object> result = RegExpImpl::Compile(re, pattern, flags);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 if (needs_access_checks) { 1098 if (needs_access_checks) {
1097 // Copy map so it won't interfere constructor's initial map. 1099 // Copy map so it won't interfere constructor's initial map.
1098 Object* new_map; 1100 Object* new_map;
1099 { MaybeObject* maybe_new_map = old_map->CopyDropTransitions(); 1101 { MaybeObject* maybe_new_map = old_map->CopyDropTransitions();
1100 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map; 1102 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map;
1101 } 1103 }
1102 1104
1103 Map::cast(new_map)->set_is_access_check_needed(false); 1105 Map::cast(new_map)->set_is_access_check_needed(false);
1104 object->set_map(Map::cast(new_map)); 1106 object->set_map(Map::cast(new_map));
1105 } 1107 }
1106 return isolate->heap()->ToBoolean(needs_access_checks); 1108 return needs_access_checks ? isolate->heap()->true_value()
1109 : isolate->heap()->false_value();
1107 } 1110 }
1108 1111
1109 1112
1110 RUNTIME_FUNCTION(MaybeObject*, Runtime_EnableAccessChecks) { 1113 RUNTIME_FUNCTION(MaybeObject*, Runtime_EnableAccessChecks) {
1111 ASSERT(args.length() == 1); 1114 ASSERT(args.length() == 1);
1112 CONVERT_CHECKED(HeapObject, object, args[0]); 1115 CONVERT_CHECKED(HeapObject, object, args[0]);
1113 Map* old_map = object->map(); 1116 Map* old_map = object->map();
1114 if (!old_map->is_access_check_needed()) { 1117 if (!old_map->is_access_check_needed()) {
1115 // Copy map so it won't interfere constructor's initial map. 1118 // Copy map so it won't interfere constructor's initial map.
1116 Object* new_map; 1119 Object* new_map;
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
1907 NoHandleAllocation ha; 1910 NoHandleAllocation ha;
1908 ASSERT(args.length() == 2); 1911 ASSERT(args.length() == 2);
1909 1912
1910 CONVERT_CHECKED(JSFunction, f, args[0]); 1913 CONVERT_CHECKED(JSFunction, f, args[0]);
1911 CONVERT_CHECKED(String, name, args[1]); 1914 CONVERT_CHECKED(String, name, args[1]);
1912 f->shared()->set_name(name); 1915 f->shared()->set_name(name);
1913 return isolate->heap()->undefined_value(); 1916 return isolate->heap()->undefined_value();
1914 } 1917 }
1915 1918
1916 1919
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
1935 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetBound) { 1920 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetBound) {
1936 HandleScope scope(isolate); 1921 HandleScope scope(isolate);
1937 ASSERT(args.length() == 1); 1922 ASSERT(args.length() == 1);
1938 1923
1939 CONVERT_CHECKED(JSFunction, fun, args[0]); 1924 CONVERT_CHECKED(JSFunction, fun, args[0]);
1940 fun->shared()->set_bound(true); 1925 fun->shared()->set_bound(true);
1941 return isolate->heap()->undefined_value(); 1926 return isolate->heap()->undefined_value();
1942 } 1927 }
1943 1928
1944 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionRemovePrototype) { 1929 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionRemovePrototype) {
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
2105 } 2090 }
2106 return function; 2091 return function;
2107 } 2092 }
2108 2093
2109 2094
2110 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsAPIFunction) { 2095 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsAPIFunction) {
2111 NoHandleAllocation ha; 2096 NoHandleAllocation ha;
2112 ASSERT(args.length() == 1); 2097 ASSERT(args.length() == 1);
2113 2098
2114 CONVERT_CHECKED(JSFunction, f, args[0]); 2099 CONVERT_CHECKED(JSFunction, f, args[0]);
2115 return isolate->heap()->ToBoolean(f->shared()->IsApiFunction()); 2100 return f->shared()->IsApiFunction() ? isolate->heap()->true_value()
2101 : isolate->heap()->false_value();
2116 } 2102 }
2117 2103
2118 2104
2119 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsBuiltin) { 2105 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsBuiltin) {
2120 NoHandleAllocation ha; 2106 NoHandleAllocation ha;
2121 ASSERT(args.length() == 1); 2107 ASSERT(args.length() == 1);
2122 2108
2123 CONVERT_CHECKED(JSFunction, f, args[0]); 2109 CONVERT_CHECKED(JSFunction, f, args[0]);
2124 return isolate->heap()->ToBoolean(f->IsBuiltin()); 2110 return f->IsBuiltin() ? isolate->heap()->true_value() :
2111 isolate->heap()->false_value();
2125 } 2112 }
2126 2113
2127 2114
2128 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetCode) { 2115 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetCode) {
2129 HandleScope scope(isolate); 2116 HandleScope scope(isolate);
2130 ASSERT(args.length() == 2); 2117 ASSERT(args.length() == 2);
2131 2118
2132 CONVERT_ARG_CHECKED(JSFunction, target, 0); 2119 CONVERT_ARG_CHECKED(JSFunction, target, 0);
2133 Handle<Object> code = args.at<Object>(1); 2120 Handle<Object> code = args.at<Object>(1);
2134 2121
(...skipping 7851 matching lines...) Expand 10 before | Expand all | Expand 10 after
9986 9973
9987 // If the callback object is a fixed array then it contains JavaScript 9974 // If the callback object is a fixed array then it contains JavaScript
9988 // getter and/or setter. 9975 // getter and/or setter.
9989 bool hasJavaScriptAccessors = result_type == CALLBACKS && 9976 bool hasJavaScriptAccessors = result_type == CALLBACKS &&
9990 result_callback_obj->IsFixedArray(); 9977 result_callback_obj->IsFixedArray();
9991 Handle<FixedArray> details = 9978 Handle<FixedArray> details =
9992 isolate->factory()->NewFixedArray(hasJavaScriptAccessors ? 5 : 2); 9979 isolate->factory()->NewFixedArray(hasJavaScriptAccessors ? 5 : 2);
9993 details->set(0, *value); 9980 details->set(0, *value);
9994 details->set(1, property_details); 9981 details->set(1, property_details);
9995 if (hasJavaScriptAccessors) { 9982 if (hasJavaScriptAccessors) {
9996 details->set(2, isolate->heap()->ToBoolean(caught_exception)); 9983 details->set(2,
9984 caught_exception ? isolate->heap()->true_value()
9985 : isolate->heap()->false_value());
9997 details->set(3, FixedArray::cast(*result_callback_obj)->get(0)); 9986 details->set(3, FixedArray::cast(*result_callback_obj)->get(0));
9998 details->set(4, FixedArray::cast(*result_callback_obj)->get(1)); 9987 details->set(4, FixedArray::cast(*result_callback_obj)->get(1));
9999 } 9988 }
10000 9989
10001 return *isolate->factory()->NewJSArrayWithElements(details); 9990 return *isolate->factory()->NewJSArrayWithElements(details);
10002 } 9991 }
10003 if (i < length - 1) { 9992 if (i < length - 1) {
10004 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); 9993 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype()));
10005 } 9994 }
10006 } 9995 }
(...skipping 2162 matching lines...) Expand 10 before | Expand all | Expand 10 after
12169 return isolate->heap()->undefined_value(); 12158 return isolate->heap()->undefined_value();
12170 #endif 12159 #endif
12171 } 12160 }
12172 12161
12173 12162
12174 // Deletes the specified live object list. 12163 // Deletes the specified live object list.
12175 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteLOL) { 12164 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteLOL) {
12176 #ifdef LIVE_OBJECT_LIST 12165 #ifdef LIVE_OBJECT_LIST
12177 CONVERT_SMI_ARG_CHECKED(id, 0); 12166 CONVERT_SMI_ARG_CHECKED(id, 0);
12178 bool success = LiveObjectList::Delete(id); 12167 bool success = LiveObjectList::Delete(id);
12179 return isolate->heap()->ToBoolean(success); 12168 return success ? isolate->heap()->true_value() :
12169 isolate->heap()->false_value();
12180 #else 12170 #else
12181 return isolate->heap()->undefined_value(); 12171 return isolate->heap()->undefined_value();
12182 #endif 12172 #endif
12183 } 12173 }
12184 12174
12185 12175
12186 // Generates the response to a debugger request for a dump of the objects 12176 // Generates the response to a debugger request for a dump of the objects
12187 // contained in the difference between the captured live object lists 12177 // contained in the difference between the captured live object lists
12188 // specified by id1 and id2. 12178 // specified by id1 and id2.
12189 // If id1 is 0 (i.e. not a valid lol), then the whole of lol id2 will be 12179 // 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
12833 } else { 12823 } else {
12834 // Handle last resort GC and make sure to allow future allocations 12824 // Handle last resort GC and make sure to allow future allocations
12835 // to grow the heap without causing GCs (if possible). 12825 // to grow the heap without causing GCs (if possible).
12836 isolate->counters()->gc_last_resort_from_js()->Increment(); 12826 isolate->counters()->gc_last_resort_from_js()->Increment();
12837 isolate->heap()->CollectAllGarbage(false); 12827 isolate->heap()->CollectAllGarbage(false);
12838 } 12828 }
12839 } 12829 }
12840 12830
12841 12831
12842 } } // namespace v8::internal 12832 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | src/v8natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698