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

Side by Side Diff: src/js/v8natives.js

Issue 1427743011: [proxies] Remove "fix" functionality, add (still unused) target property. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Test Created 5 years, 1 month 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
« no previous file with comments | « src/js/proxy.js ('k') | src/objects.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 (function(global, utils) { 5 (function(global, utils) {
6 6
7 %CheckIsBootstrapping(); 7 %CheckIsBootstrapping();
8 8
9 // ---------------------------------------------------------------------------- 9 // ----------------------------------------------------------------------------
10 // Imports 10 // Imports
(...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 } 1109 }
1110 for (var i = 0; i < names.length; i++) { 1110 for (var i = 0; i < names.length; i++) {
1111 DefineOwnProperty(obj, names[i], descriptors[i], true); 1111 DefineOwnProperty(obj, names[i], descriptors[i], true);
1112 } 1112 }
1113 return obj; 1113 return obj;
1114 } 1114 }
1115 return %ObjectDefineProperties(obj, properties); 1115 return %ObjectDefineProperties(obj, properties);
1116 } 1116 }
1117 1117
1118 1118
1119 // Harmony proxies.
1120 function ProxyFix(obj) {
1121 var handler = %GetHandler(obj);
1122 var props = CallTrap0(handler, "fix", UNDEFINED);
1123 if (IS_UNDEFINED(props)) {
1124 throw MakeTypeError(kProxyHandlerReturned, handler, "undefined", "fix");
1125 }
1126
1127 if (%IsJSFunctionProxy(obj)) {
1128 var callTrap = %GetCallTrap(obj);
1129 var constructTrap = %GetConstructTrap(obj);
1130 var code = ProxyDelegateCallAndConstruct(callTrap, constructTrap);
1131 %Fix(obj); // becomes a regular function
1132 %SetCode(obj, code);
1133 // TODO(rossberg): What about length and other properties? Not specified.
1134 // We just put in some half-reasonable defaults for now.
1135 var prototype = new GlobalObject();
1136 ObjectDefineProperty(prototype, "constructor",
1137 {value: obj, writable: true, enumerable: false, configurable: true});
1138 // TODO(v8:1530): defineProperty does not handle prototype and length.
1139 %FunctionSetPrototype(obj, prototype);
1140 obj.length = 0;
1141 } else {
1142 %Fix(obj);
1143 }
1144 ObjectDefineProperties(obj, props);
1145 }
1146
1147
1148 // ES5 section 15.2.3.8. 1119 // ES5 section 15.2.3.8.
1149 function ObjectSealJS(obj) { 1120 function ObjectSealJS(obj) {
1150 if (!IS_SPEC_OBJECT(obj)) return obj; 1121 if (!IS_SPEC_OBJECT(obj)) return obj;
1151 var isProxy = %_IsJSProxy(obj); 1122 var isProxy = %_IsJSProxy(obj);
1152 if (isProxy || %HasSloppyArgumentsElements(obj) || %IsObserved(obj)) { 1123 if (isProxy || %HasSloppyArgumentsElements(obj) || %IsObserved(obj)) {
1153 if (isProxy) { 1124 // TODO(neis): For proxies, must call preventExtensions trap first.
1154 ProxyFix(obj);
1155 }
1156 var names = OwnPropertyKeys(obj); 1125 var names = OwnPropertyKeys(obj);
1157 for (var i = 0; i < names.length; i++) { 1126 for (var i = 0; i < names.length; i++) {
1158 var name = names[i]; 1127 var name = names[i];
1159 var desc = GetOwnPropertyJS(obj, name); 1128 var desc = GetOwnPropertyJS(obj, name);
1160 if (desc.isConfigurable()) { 1129 if (desc.isConfigurable()) {
1161 desc.setConfigurable(false); 1130 desc.setConfigurable(false);
1162 DefineOwnProperty(obj, name, desc, true); 1131 DefineOwnProperty(obj, name, desc, true);
1163 } 1132 }
1164 } 1133 }
1165 %PreventExtensions(obj); 1134 %PreventExtensions(obj);
1166 } else { 1135 } else {
1167 // TODO(adamk): Is it worth going to this fast path if the 1136 // TODO(adamk): Is it worth going to this fast path if the
1168 // object's properties are already in dictionary mode? 1137 // object's properties are already in dictionary mode?
1169 %ObjectSeal(obj); 1138 %ObjectSeal(obj);
1170 } 1139 }
1171 return obj; 1140 return obj;
1172 } 1141 }
1173 1142
1174 1143
1175 // ES5 section 15.2.3.9. 1144 // ES5 section 15.2.3.9.
1176 function ObjectFreezeJS(obj) { 1145 function ObjectFreezeJS(obj) {
1177 if (!IS_SPEC_OBJECT(obj)) return obj; 1146 if (!IS_SPEC_OBJECT(obj)) return obj;
1178 var isProxy = %_IsJSProxy(obj); 1147 var isProxy = %_IsJSProxy(obj);
1179 // TODO(conradw): Investigate modifying the fast path to accommodate strong 1148 // TODO(conradw): Investigate modifying the fast path to accommodate strong
1180 // objects. 1149 // objects.
1181 if (isProxy || %HasSloppyArgumentsElements(obj) || %IsObserved(obj) || 1150 if (isProxy || %HasSloppyArgumentsElements(obj) || %IsObserved(obj) ||
1182 IS_STRONG(obj)) { 1151 IS_STRONG(obj)) {
1183 if (isProxy) { 1152 // TODO(neis): For proxies, must call preventExtensions trap first.
1184 ProxyFix(obj);
1185 }
1186 var names = OwnPropertyKeys(obj); 1153 var names = OwnPropertyKeys(obj);
1187 for (var i = 0; i < names.length; i++) { 1154 for (var i = 0; i < names.length; i++) {
1188 var name = names[i]; 1155 var name = names[i];
1189 var desc = GetOwnPropertyJS(obj, name); 1156 var desc = GetOwnPropertyJS(obj, name);
1190 if (desc.isWritable() || desc.isConfigurable()) { 1157 if (desc.isWritable() || desc.isConfigurable()) {
1191 if (IsDataDescriptor(desc)) desc.setWritable(false); 1158 if (IsDataDescriptor(desc)) desc.setWritable(false);
1192 desc.setConfigurable(false); 1159 desc.setConfigurable(false);
1193 DefineOwnProperty(obj, name, desc, true); 1160 DefineOwnProperty(obj, name, desc, true);
1194 } 1161 }
1195 } 1162 }
1196 %PreventExtensions(obj); 1163 %PreventExtensions(obj);
1197 } else { 1164 } else {
1198 // TODO(adamk): Is it worth going to this fast path if the 1165 // TODO(adamk): Is it worth going to this fast path if the
1199 // object's properties are already in dictionary mode? 1166 // object's properties are already in dictionary mode?
1200 %ObjectFreeze(obj); 1167 %ObjectFreeze(obj);
1201 } 1168 }
1202 return obj; 1169 return obj;
1203 } 1170 }
1204 1171
1205 1172
1206 // ES5 section 15.2.3.10 1173 // ES5 section 15.2.3.10
1207 function ObjectPreventExtension(obj) { 1174 function ObjectPreventExtension(obj) {
1208 if (!IS_SPEC_OBJECT(obj)) return obj; 1175 if (!IS_SPEC_OBJECT(obj)) return obj;
1209 if (%_IsJSProxy(obj)) { 1176 return %PreventExtensions(obj);
1210 ProxyFix(obj);
1211 }
1212 %PreventExtensions(obj);
1213 return obj;
1214 } 1177 }
1215 1178
1216 1179
1217 // ES5 section 15.2.3.11 1180 // ES5 section 15.2.3.11
1218 function ObjectIsSealed(obj) { 1181 function ObjectIsSealed(obj) {
1219 if (!IS_SPEC_OBJECT(obj)) return true; 1182 if (!IS_SPEC_OBJECT(obj)) return true;
1220 if (%_IsJSProxy(obj)) { 1183 if (%_IsJSProxy(obj)) {
1221 return false; 1184 return false; // TODO(neis): Must call isExtensible trap and ownKeys trap.
1222 } 1185 }
1223 if (%IsExtensible(obj)) { 1186 if (%IsExtensible(obj)) {
1224 return false; 1187 return false;
1225 } 1188 }
1226 var names = OwnPropertyKeys(obj); 1189 var names = OwnPropertyKeys(obj);
1227 for (var i = 0; i < names.length; i++) { 1190 for (var i = 0; i < names.length; i++) {
1228 var name = names[i]; 1191 var name = names[i];
1229 var desc = GetOwnPropertyJS(obj, name); 1192 var desc = GetOwnPropertyJS(obj, name);
1230 if (desc.isConfigurable()) { 1193 if (desc.isConfigurable()) {
1231 return false; 1194 return false;
1232 } 1195 }
1233 } 1196 }
1234 return true; 1197 return true;
1235 } 1198 }
1236 1199
1237 1200
1238 // ES5 section 15.2.3.12 1201 // ES5 section 15.2.3.12
1239 function ObjectIsFrozen(obj) { 1202 function ObjectIsFrozen(obj) {
1240 if (!IS_SPEC_OBJECT(obj)) return true; 1203 if (!IS_SPEC_OBJECT(obj)) return true;
1241 if (%_IsJSProxy(obj)) { 1204 if (%_IsJSProxy(obj)) {
1242 return false; 1205 return false; // TODO(neis): Must call isExtensible trap and ownKeys trap.
1243 } 1206 }
1244 if (%IsExtensible(obj)) { 1207 if (%IsExtensible(obj)) {
1245 return false; 1208 return false;
1246 } 1209 }
1247 var names = OwnPropertyKeys(obj); 1210 var names = OwnPropertyKeys(obj);
1248 for (var i = 0; i < names.length; i++) { 1211 for (var i = 0; i < names.length; i++) {
1249 var name = names[i]; 1212 var name = names[i];
1250 var desc = GetOwnPropertyJS(obj, name); 1213 var desc = GetOwnPropertyJS(obj, name);
1251 if (IsDataDescriptor(desc) && desc.isWritable()) return false; 1214 if (IsDataDescriptor(desc) && desc.isWritable()) return false;
1252 if (desc.isConfigurable()) return false; 1215 if (desc.isConfigurable()) return false;
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
1848 1811
1849 %InstallToContext([ 1812 %InstallToContext([
1850 "global_eval_fun", GlobalEval, 1813 "global_eval_fun", GlobalEval,
1851 "object_value_of", ObjectValueOf, 1814 "object_value_of", ObjectValueOf,
1852 "object_to_string", ObjectToString, 1815 "object_to_string", ObjectToString,
1853 "object_get_own_property_descriptor", ObjectGetOwnPropertyDescriptor, 1816 "object_get_own_property_descriptor", ObjectGetOwnPropertyDescriptor,
1854 "to_complete_property_descriptor", ToCompletePropertyDescriptor, 1817 "to_complete_property_descriptor", ToCompletePropertyDescriptor,
1855 ]); 1818 ]);
1856 1819
1857 }) 1820 })
OLDNEW
« no previous file with comments | « src/js/proxy.js ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698