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

Side by Side Diff: src/runtime.cc

Issue 218783003: Replace uses of set_map by MigrateToMap. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 2030 matching lines...) Expand 10 before | Expand all | Expand 10 after
2041 if (type == FUNCTION_TEMPLATE_INFO_TYPE) { 2041 if (type == FUNCTION_TEMPLATE_INFO_TYPE) {
2042 RUNTIME_ASSERT(offset < FunctionTemplateInfo::kSize); 2042 RUNTIME_ASSERT(offset < FunctionTemplateInfo::kSize);
2043 } else { 2043 } else {
2044 RUNTIME_ASSERT(offset < ObjectTemplateInfo::kSize); 2044 RUNTIME_ASSERT(offset < ObjectTemplateInfo::kSize);
2045 } 2045 }
2046 return *HeapObject::RawField(templ, offset); 2046 return *HeapObject::RawField(templ, offset);
2047 } 2047 }
2048 2048
2049 2049
2050 RUNTIME_FUNCTION(MaybeObject*, Runtime_DisableAccessChecks) { 2050 RUNTIME_FUNCTION(MaybeObject*, Runtime_DisableAccessChecks) {
2051 SealHandleScope shs(isolate); 2051 HandleScope scope(isolate);
2052 ASSERT(args.length() == 1); 2052 ASSERT(args.length() == 1);
2053 CONVERT_ARG_CHECKED(HeapObject, object, 0); 2053 CONVERT_ARG_HANDLE_CHECKED(HeapObject, object, 0);
2054 Map* old_map = object->map(); 2054 Handle<Map> old_map(object->map());
2055 bool needs_access_checks = old_map->is_access_check_needed(); 2055 bool needs_access_checks = old_map->is_access_check_needed();
2056 if (needs_access_checks) { 2056 if (needs_access_checks) {
2057 // Copy map so it won't interfere constructor's initial map. 2057 // Copy map so it won't interfere constructor's initial map.
2058 Map* new_map; 2058 Handle<Map> new_map = Map::Copy(old_map);
2059 MaybeObject* maybe_new_map = old_map->Copy();
2060 if (!maybe_new_map->To(&new_map)) return maybe_new_map;
2061
2062 new_map->set_is_access_check_needed(false); 2059 new_map->set_is_access_check_needed(false);
2063 object->set_map(new_map); 2060 if (object->IsJSObject()) {
2061 JSObject::MigrateToMap(Handle<JSObject>::cast(object), new_map);
2062 } else {
2063 object->set_map(*new_map);
2064 }
2064 } 2065 }
2065 return isolate->heap()->ToBoolean(needs_access_checks); 2066 return isolate->heap()->ToBoolean(needs_access_checks);
2066 } 2067 }
2067 2068
2068 2069
2069 RUNTIME_FUNCTION(MaybeObject*, Runtime_EnableAccessChecks) { 2070 RUNTIME_FUNCTION(MaybeObject*, Runtime_EnableAccessChecks) {
2070 SealHandleScope shs(isolate); 2071 HandleScope scope(isolate);
2071 ASSERT(args.length() == 1); 2072 ASSERT(args.length() == 1);
2072 CONVERT_ARG_CHECKED(HeapObject, object, 0); 2073 CONVERT_ARG_HANDLE_CHECKED(HeapObject, object, 0);
2073 Map* old_map = object->map(); 2074 Handle<Map> old_map(object->map());
2074 if (!old_map->is_access_check_needed()) { 2075 if (!old_map->is_access_check_needed()) {
2075 // Copy map so it won't interfere constructor's initial map. 2076 // Copy map so it won't interfere constructor's initial map.
2076 Map* new_map; 2077 Handle<Map> new_map = Map::Copy(old_map);
2077 MaybeObject* maybe_new_map = old_map->Copy();
2078 if (!maybe_new_map->To(&new_map)) return maybe_new_map;
2079
2080 new_map->set_is_access_check_needed(true); 2078 new_map->set_is_access_check_needed(true);
2081 object->set_map(new_map); 2079 if (object->IsJSObject()) {
2080 JSObject::MigrateToMap(Handle<JSObject>::cast(object), new_map);
2081 } else {
2082 object->set_map(*new_map);
2083 }
2082 } 2084 }
2083 return isolate->heap()->undefined_value(); 2085 return isolate->heap()->undefined_value();
2084 } 2086 }
2085 2087
2086 2088
2087 // Transform getter or setter into something DefineAccessor can handle. 2089 // Transform getter or setter into something DefineAccessor can handle.
2088 static Handle<Object> InstantiateAccessorComponent(Isolate* isolate, 2090 static Handle<Object> InstantiateAccessorComponent(Isolate* isolate,
2089 Handle<Object> component) { 2091 Handle<Object> component) {
2090 if (component->IsUndefined()) return isolate->factory()->null_value(); 2092 if (component->IsUndefined()) return isolate->factory()->null_value();
2091 Handle<FunctionTemplateInfo> info = 2093 Handle<FunctionTemplateInfo> info =
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after
2938 2940
2939 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); 2941 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0);
2940 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); 2942 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1);
2941 ASSERT(fun->should_have_prototype()); 2943 ASSERT(fun->should_have_prototype());
2942 Accessors::FunctionSetPrototype(fun, value); 2944 Accessors::FunctionSetPrototype(fun, value);
2943 return args[0]; // return TOS 2945 return args[0]; // return TOS
2944 } 2946 }
2945 2947
2946 2948
2947 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetReadOnlyPrototype) { 2949 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetReadOnlyPrototype) {
2948 SealHandleScope shs(isolate); 2950 HandleScope shs(isolate);
2949 RUNTIME_ASSERT(args.length() == 1); 2951 RUNTIME_ASSERT(args.length() == 1);
2950 CONVERT_ARG_CHECKED(JSFunction, function, 0); 2952 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
2951 2953
2952 String* name = isolate->heap()->prototype_string(); 2954 String* name = isolate->heap()->prototype_string();
2953 2955
2954 if (function->HasFastProperties()) { 2956 if (function->HasFastProperties()) {
2955 // Construct a new field descriptor with updated attributes. 2957 // Construct a new field descriptor with updated attributes.
2956 DescriptorArray* instance_desc = function->map()->instance_descriptors(); 2958 DescriptorArray* instance_desc = function->map()->instance_descriptors();
2957 2959
2958 int index = instance_desc->SearchWithCache(name, function->map()); 2960 int index = instance_desc->SearchWithCache(name, function->map());
2959 ASSERT(index != DescriptorArray::kNotFound); 2961 ASSERT(index != DescriptorArray::kNotFound);
2960 PropertyDetails details = instance_desc->GetDetails(index); 2962 PropertyDetails details = instance_desc->GetDetails(index);
2961 2963
2962 CallbacksDescriptor new_desc(name, 2964 CallbacksDescriptor new_desc(name,
2963 instance_desc->GetValue(index), 2965 instance_desc->GetValue(index),
2964 static_cast<PropertyAttributes>(details.attributes() | READ_ONLY)); 2966 static_cast<PropertyAttributes>(details.attributes() | READ_ONLY));
2965 2967
2966 // Create a new map featuring the new field descriptors array. 2968 // Create a new map featuring the new field descriptors array.
2967 Map* new_map; 2969 Map* new_map;
2968 MaybeObject* maybe_map = 2970 MaybeObject* maybe_map =
2969 function->map()->CopyReplaceDescriptor( 2971 function->map()->CopyReplaceDescriptor(
Igor Sheludko 2014/03/31 12:52:43 Does it make sense to make a handlified wrapper fo
2970 instance_desc, &new_desc, index, OMIT_TRANSITION); 2972 instance_desc, &new_desc, index, OMIT_TRANSITION);
2971 if (!maybe_map->To(&new_map)) return maybe_map; 2973 if (!maybe_map->To(&new_map)) return maybe_map;
2972 2974
2973 function->set_map(new_map); 2975 JSObject::MigrateToMap(function, handle(new_map));
2974 } else { // Dictionary properties. 2976 } else { // Dictionary properties.
2975 // Directly manipulate the property details. 2977 // Directly manipulate the property details.
2978 DisallowHeapAllocation no_gc;
2976 int entry = function->property_dictionary()->FindEntry(name); 2979 int entry = function->property_dictionary()->FindEntry(name);
2977 ASSERT(entry != NameDictionary::kNotFound); 2980 ASSERT(entry != NameDictionary::kNotFound);
2978 PropertyDetails details = function->property_dictionary()->DetailsAt(entry); 2981 PropertyDetails details = function->property_dictionary()->DetailsAt(entry);
2979 PropertyDetails new_details( 2982 PropertyDetails new_details(
2980 static_cast<PropertyAttributes>(details.attributes() | READ_ONLY), 2983 static_cast<PropertyAttributes>(details.attributes() | READ_ONLY),
2981 details.type(), 2984 details.type(),
2982 details.dictionary_index()); 2985 details.dictionary_index());
2983 function->property_dictionary()->DetailsAtPut(entry, new_details); 2986 function->property_dictionary()->DetailsAtPut(entry, new_details);
2984 } 2987 }
2985 return function; 2988 return *function;
2986 } 2989 }
2987 2990
2988 2991
2989 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsAPIFunction) { 2992 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsAPIFunction) {
2990 SealHandleScope shs(isolate); 2993 SealHandleScope shs(isolate);
2991 ASSERT(args.length() == 1); 2994 ASSERT(args.length() == 1);
2992 2995
2993 CONVERT_ARG_CHECKED(JSFunction, f, 0); 2996 CONVERT_ARG_CHECKED(JSFunction, f, 0);
2994 return isolate->heap()->ToBoolean(f->shared()->IsApiFunction()); 2997 return isolate->heap()->ToBoolean(f->shared()->IsApiFunction());
2995 } 2998 }
(...skipping 12152 matching lines...) Expand 10 before | Expand all | Expand 10 after
15148 } 15151 }
15149 } 15152 }
15150 15153
15151 15154
15152 void Runtime::OutOfMemory() { 15155 void Runtime::OutOfMemory() {
15153 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); 15156 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true);
15154 UNREACHABLE(); 15157 UNREACHABLE();
15155 } 15158 }
15156 15159
15157 } } // namespace v8::internal 15160 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698