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

Side by Side Diff: src/ic.cc

Issue 14850006: Use mutable heapnumbers to store doubles in fields. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Ported to ARM and x64 Created 7 years, 7 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/ic.h ('k') | src/json-parser.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 // 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 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 if (!lookup->IsProperty()) { 1234 if (!lookup->IsProperty()) {
1235 // Nonexistent property. The result is undefined. 1235 // Nonexistent property. The result is undefined.
1236 return isolate()->stub_cache()->ComputeLoadNonexistent(name, receiver); 1236 return isolate()->stub_cache()->ComputeLoadNonexistent(name, receiver);
1237 } 1237 }
1238 1238
1239 // Compute monomorphic stub. 1239 // Compute monomorphic stub.
1240 Handle<JSObject> holder(lookup->holder()); 1240 Handle<JSObject> holder(lookup->holder());
1241 switch (lookup->type()) { 1241 switch (lookup->type()) {
1242 case FIELD: 1242 case FIELD:
1243 return isolate()->stub_cache()->ComputeLoadField( 1243 return isolate()->stub_cache()->ComputeLoadField(
1244 name, receiver, holder, lookup->GetFieldIndex()); 1244 name, receiver, holder,
1245 lookup->GetFieldIndex(), lookup->representation());
1245 case CONSTANT_FUNCTION: { 1246 case CONSTANT_FUNCTION: {
1246 Handle<JSFunction> constant(lookup->GetConstantFunction()); 1247 Handle<JSFunction> constant(lookup->GetConstantFunction());
1247 return isolate()->stub_cache()->ComputeLoadConstant( 1248 return isolate()->stub_cache()->ComputeLoadConstant(
1248 name, receiver, holder, constant); 1249 name, receiver, holder, constant);
1249 } 1250 }
1250 case NORMAL: 1251 case NORMAL:
1251 if (holder->IsGlobalObject()) { 1252 if (holder->IsGlobalObject()) {
1252 Handle<GlobalObject> global = Handle<GlobalObject>::cast(holder); 1253 Handle<GlobalObject> global = Handle<GlobalObject>::cast(holder);
1253 Handle<JSGlobalPropertyCell> cell( 1254 Handle<JSGlobalPropertyCell> cell(
1254 global->GetPropertyCell(lookup), isolate()); 1255 global->GetPropertyCell(lookup), isolate());
(...skipping 21 matching lines...) Expand all
1276 if (!getter->IsJSFunction()) break; 1277 if (!getter->IsJSFunction()) break;
1277 if (holder->IsGlobalObject()) break; 1278 if (holder->IsGlobalObject()) break;
1278 if (!holder->HasFastProperties()) break; 1279 if (!holder->HasFastProperties()) break;
1279 return isolate()->stub_cache()->ComputeLoadViaGetter( 1280 return isolate()->stub_cache()->ComputeLoadViaGetter(
1280 name, receiver, holder, Handle<JSFunction>::cast(getter)); 1281 name, receiver, holder, Handle<JSFunction>::cast(getter));
1281 } else if (receiver->IsJSArray() && 1282 } else if (receiver->IsJSArray() &&
1282 name->Equals(isolate()->heap()->length_string())) { 1283 name->Equals(isolate()->heap()->length_string())) {
1283 PropertyIndex lengthIndex = 1284 PropertyIndex lengthIndex =
1284 PropertyIndex::NewHeaderIndex(JSArray::kLengthOffset / kPointerSize); 1285 PropertyIndex::NewHeaderIndex(JSArray::kLengthOffset / kPointerSize);
1285 return isolate()->stub_cache()->ComputeLoadField( 1286 return isolate()->stub_cache()->ComputeLoadField(
1286 name, receiver, holder, lengthIndex); 1287 name, receiver, holder, lengthIndex, Representation::Tagged());
1287 } 1288 }
1288 // TODO(dcarney): Handle correctly. 1289 // TODO(dcarney): Handle correctly.
1289 if (callback->IsDeclaredAccessorInfo()) break; 1290 if (callback->IsDeclaredAccessorInfo()) break;
1290 ASSERT(callback->IsForeign()); 1291 ASSERT(callback->IsForeign());
1291 // No IC support for old-style native accessors. 1292 // No IC support for old-style native accessors.
1292 break; 1293 break;
1293 } 1294 }
1294 case INTERCEPTOR: 1295 case INTERCEPTOR:
1295 ASSERT(HasInterceptorGetter(*holder)); 1296 ASSERT(HasInterceptorGetter(*holder));
1296 return isolate()->stub_cache()->ComputeLoadInterceptor( 1297 return isolate()->stub_cache()->ComputeLoadInterceptor(
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 Handle<JSObject> receiver, 1444 Handle<JSObject> receiver,
1444 Handle<String> name) { 1445 Handle<String> name) {
1445 // Bail out if we didn't find a result. 1446 // Bail out if we didn't find a result.
1446 if (!lookup->IsProperty()) return Handle<Code>::null(); 1447 if (!lookup->IsProperty()) return Handle<Code>::null();
1447 1448
1448 // Compute a monomorphic stub. 1449 // Compute a monomorphic stub.
1449 Handle<JSObject> holder(lookup->holder(), isolate()); 1450 Handle<JSObject> holder(lookup->holder(), isolate());
1450 switch (lookup->type()) { 1451 switch (lookup->type()) {
1451 case FIELD: 1452 case FIELD:
1452 return isolate()->stub_cache()->ComputeKeyedLoadField( 1453 return isolate()->stub_cache()->ComputeKeyedLoadField(
1453 name, receiver, holder, lookup->GetFieldIndex()); 1454 name, receiver, holder,
1455 lookup->GetFieldIndex(), lookup->representation());
1454 case CONSTANT_FUNCTION: { 1456 case CONSTANT_FUNCTION: {
1455 Handle<JSFunction> constant(lookup->GetConstantFunction(), isolate()); 1457 Handle<JSFunction> constant(lookup->GetConstantFunction(), isolate());
1456 return isolate()->stub_cache()->ComputeKeyedLoadConstant( 1458 return isolate()->stub_cache()->ComputeKeyedLoadConstant(
1457 name, receiver, holder, constant); 1459 name, receiver, holder, constant);
1458 } 1460 }
1459 case CALLBACKS: { 1461 case CALLBACKS: {
1460 Handle<Object> callback_object(lookup->GetCallbackObject(), isolate()); 1462 Handle<Object> callback_object(lookup->GetCallbackObject(), isolate());
1461 // TODO(dcarney): Handle DeclaredAccessorInfo correctly. 1463 // TODO(dcarney): Handle DeclaredAccessorInfo correctly.
1462 if (!callback_object->IsExecutableAccessorInfo()) break; 1464 if (!callback_object->IsExecutableAccessorInfo()) break;
1463 Handle<ExecutableAccessorInfo> callback = 1465 Handle<ExecutableAccessorInfo> callback =
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after
2253 2255
2254 // Check the object has run out out property space. 2256 // Check the object has run out out property space.
2255 ASSERT(object->HasFastProperties()); 2257 ASSERT(object->HasFastProperties());
2256 ASSERT(object->map()->unused_property_fields() == 0); 2258 ASSERT(object->map()->unused_property_fields() == 0);
2257 2259
2258 // Expand the properties array. 2260 // Expand the properties array.
2259 FixedArray* old_storage = object->properties(); 2261 FixedArray* old_storage = object->properties();
2260 int new_unused = transition->unused_property_fields(); 2262 int new_unused = transition->unused_property_fields();
2261 int new_size = old_storage->length() + new_unused + 1; 2263 int new_size = old_storage->length() + new_unused + 1;
2262 Object* result; 2264 Object* result;
2263 { MaybeObject* maybe_result = old_storage->CopySize(new_size); 2265 MaybeObject* maybe_result = old_storage->CopySize(new_size);
2264 if (!maybe_result->ToObject(&result)) return maybe_result; 2266 if (!maybe_result->ToObject(&result)) return maybe_result;
2267
2268 FixedArray* new_storage = FixedArray::cast(result);
2269
2270 Object* to_store = value;
2271
2272 if (FLAG_track_double_fields) {
2273 DescriptorArray* descriptors = transition->instance_descriptors();
2274 PropertyDetails details = descriptors->GetDetails(transition->LastAdded());
2275 if (details.representation().IsDouble()) {
2276 MaybeObject* maybe_storage =
2277 isolate->heap()->AllocateHeapNumber(value->Number());
2278 if (!maybe_storage->To(&to_store)) return maybe_storage;
2279 }
2265 } 2280 }
2266 FixedArray* new_storage = FixedArray::cast(result); 2281
2267 new_storage->set(old_storage->length(), value); 2282 new_storage->set(old_storage->length(), to_store);
2268 2283
2269 // Set the new property value and do the map transition. 2284 // Set the new property value and do the map transition.
2270 object->set_properties(new_storage); 2285 object->set_properties(new_storage);
2271 object->set_map(transition); 2286 object->set_map(transition);
2272 2287
2273 // Return the stored value. 2288 // Return the stored value.
2274 return value; 2289 return value;
2275 } 2290 }
2276 2291
2277 2292
(...skipping 21 matching lines...) Expand all
2299 Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state(); 2314 Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state();
2300 return ic.Store(state, 2315 return ic.Store(state,
2301 Code::GetStrictMode(extra_ic_state), 2316 Code::GetStrictMode(extra_ic_state),
2302 args.at<Object>(0), 2317 args.at<Object>(0),
2303 args.at<Object>(1), 2318 args.at<Object>(1),
2304 args.at<Object>(2), 2319 args.at<Object>(2),
2305 MISS); 2320 MISS);
2306 } 2321 }
2307 2322
2308 2323
2324 RUNTIME_FUNCTION(MaybeObject*, StoreIC_Slow) {
2325 NoHandleAllocation na(isolate);
2326 ASSERT(args.length() == 3);
2327 StoreIC ic(IC::NO_EXTRA_FRAME, isolate);
2328 Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state();
2329 Handle<Object> object = args.at<Object>(0);
2330 Handle<Object> key = args.at<Object>(1);
2331 Handle<Object> value = args.at<Object>(2);
2332 StrictModeFlag strict_mode = Code::GetStrictMode(extra_ic_state);
2333 return Runtime::SetObjectProperty(isolate,
2334 object,
2335 key,
2336 value,
2337 NONE,
2338 strict_mode);
2339 }
2340
2341
2309 RUNTIME_FUNCTION(MaybeObject*, KeyedStoreIC_Slow) { 2342 RUNTIME_FUNCTION(MaybeObject*, KeyedStoreIC_Slow) {
2310 NoHandleAllocation na(isolate); 2343 NoHandleAllocation na(isolate);
2311 ASSERT(args.length() == 3); 2344 ASSERT(args.length() == 3);
2312 KeyedStoreIC ic(IC::NO_EXTRA_FRAME, isolate); 2345 KeyedStoreIC ic(IC::NO_EXTRA_FRAME, isolate);
2313 Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state(); 2346 Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state();
2314 Handle<Object> object = args.at<Object>(0); 2347 Handle<Object> object = args.at<Object>(0);
2315 Handle<Object> key = args.at<Object>(1); 2348 Handle<Object> key = args.at<Object>(1);
2316 Handle<Object> value = args.at<Object>(2); 2349 Handle<Object> value = args.at<Object>(2);
2317 StrictModeFlag strict_mode = Code::GetStrictMode(extra_ic_state); 2350 StrictModeFlag strict_mode = Code::GetStrictMode(extra_ic_state);
2318 return Runtime::SetObjectProperty(isolate, 2351 return Runtime::SetObjectProperty(isolate,
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
2974 #undef ADDR 3007 #undef ADDR
2975 }; 3008 };
2976 3009
2977 3010
2978 Address IC::AddressFromUtilityId(IC::UtilityId id) { 3011 Address IC::AddressFromUtilityId(IC::UtilityId id) {
2979 return IC_utilities[id]; 3012 return IC_utilities[id];
2980 } 3013 }
2981 3014
2982 3015
2983 } } // namespace v8::internal 3016 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ic.h ('k') | src/json-parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698