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

Side by Side Diff: src/ic.cc

Issue 149521: Try to work around http://crbug.com/16276 until we can... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 5 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 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 20 matching lines...) Expand all
31 #include "api.h" 31 #include "api.h"
32 #include "arguments.h" 32 #include "arguments.h"
33 #include "execution.h" 33 #include "execution.h"
34 #include "ic-inl.h" 34 #include "ic-inl.h"
35 #include "runtime.h" 35 #include "runtime.h"
36 #include "stub-cache.h" 36 #include "stub-cache.h"
37 37
38 namespace v8 { 38 namespace v8 {
39 namespace internal { 39 namespace internal {
40 40
41 // Temporary helper for working around http://crbug.com/16276. If we
42 // allow 'the hole value' to leak into the IC code, it may lead to
43 // crashes, but this should not happen and we should track down the
44 // cause of it.
45 static inline Handle<Object> UnholeForBug16276(Handle<Object> object) {
46 if (!object->IsTheHole()) return object;
47 ASSERT(false); // This should not happen.
48 return Factory::undefined_value();
49 }
50
51
41 #ifdef DEBUG 52 #ifdef DEBUG
42 static char TransitionMarkFromState(IC::State state) { 53 static char TransitionMarkFromState(IC::State state) {
43 switch (state) { 54 switch (state) {
44 case UNINITIALIZED: return '0'; 55 case UNINITIALIZED: return '0';
45 case PREMONOMORPHIC: return 'P'; 56 case PREMONOMORPHIC: return 'P';
46 case MONOMORPHIC: return '1'; 57 case MONOMORPHIC: return '1';
47 case MONOMORPHIC_PROTOTYPE_FAILURE: return '^'; 58 case MONOMORPHIC_PROTOTYPE_FAILURE: return '^';
48 case MEGAMORPHIC: return 'N'; 59 case MEGAMORPHIC: return 'N';
49 60
50 // We never see the debugger states here, because the state is 61 // We never see the debugger states here, because the state is
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 frame->SetExpression(index, *target); 325 frame->SetExpression(index, *target);
315 } 326 }
316 327
317 return *delegate; 328 return *delegate;
318 } 329 }
319 330
320 331
321 Object* CallIC::LoadFunction(State state, 332 Object* CallIC::LoadFunction(State state,
322 Handle<Object> object, 333 Handle<Object> object,
323 Handle<String> name) { 334 Handle<String> name) {
335 object = UnholeForBug16276(object);
336
324 // If the object is undefined or null it's illegal to try to get any 337 // If the object is undefined or null it's illegal to try to get any
325 // of its properties; throw a TypeError in that case. 338 // of its properties; throw a TypeError in that case.
326 if (object->IsUndefined() || object->IsNull()) { 339 if (object->IsUndefined() || object->IsNull()) {
327 return TypeError("non_object_property_call", object, name); 340 return TypeError("non_object_property_call", object, name);
328 } 341 }
329 342
330 Object* result = Heap::the_hole_value();
331
332 // Check if the name is trivially convertible to an index and get 343 // Check if the name is trivially convertible to an index and get
333 // the element if so. 344 // the element if so.
334 uint32_t index; 345 uint32_t index;
335 if (name->AsArrayIndex(&index)) { 346 if (name->AsArrayIndex(&index)) {
336 result = object->GetElement(index); 347 Object* result = object->GetElement(index);
337 if (result->IsJSFunction()) return result; 348 if (result->IsJSFunction()) return result;
338 349
339 // Try to find a suitable function delegate for the object at hand. 350 // Try to find a suitable function delegate for the object at hand.
340 result = TryCallAsFunction(result); 351 result = TryCallAsFunction(result);
341 if (result->IsJSFunction()) return result; 352 if (result->IsJSFunction()) return result;
342 353
343 // Otherwise, it will fail in the lookup step. 354 // Otherwise, it will fail in the lookup step.
344 } 355 }
345 356
346 // Lookup the property in the object. 357 // Lookup the property in the object.
347 LookupResult lookup; 358 LookupResult lookup;
348 LookupForRead(*object, *name, &lookup); 359 LookupForRead(*object, *name, &lookup);
349 360
350 if (!lookup.IsValid()) { 361 if (!lookup.IsValid()) {
351 // If the object does not have the requested property, check which 362 // If the object does not have the requested property, check which
352 // exception we need to throw. 363 // exception we need to throw.
353 if (is_contextual()) { 364 if (is_contextual()) {
354 return ReferenceError("not_defined", name); 365 return ReferenceError("not_defined", name);
355 } 366 }
356 return TypeError("undefined_method", object, name); 367 return TypeError("undefined_method", object, name);
357 } 368 }
358 369
359 // Lookup is valid: Update inline cache and stub cache. 370 // Lookup is valid: Update inline cache and stub cache.
360 if (FLAG_use_ic && lookup.IsLoaded()) { 371 if (FLAG_use_ic && lookup.IsLoaded()) {
361 UpdateCaches(&lookup, state, object, name); 372 UpdateCaches(&lookup, state, object, name);
362 } 373 }
363 374
364 // Get the property. 375 // Get the property.
365 PropertyAttributes attr; 376 PropertyAttributes attr;
366 result = object->GetProperty(*object, &lookup, *name, &attr); 377 Object* result = object->GetProperty(*object, &lookup, *name, &attr);
367 if (result->IsFailure()) return result; 378 if (result->IsFailure()) return result;
368 if (lookup.type() == INTERCEPTOR) { 379 if (lookup.type() == INTERCEPTOR) {
369 // If the object does not have the requested property, check which 380 // If the object does not have the requested property, check which
370 // exception we need to throw. 381 // exception we need to throw.
371 if (attr == ABSENT) { 382 if (attr == ABSENT) {
372 if (is_contextual()) { 383 if (is_contextual()) {
373 return ReferenceError("not_defined", name); 384 return ReferenceError("not_defined", name);
374 } 385 }
375 return TypeError("undefined_method", object, name); 386 return TypeError("undefined_method", object, name);
376 } 387 }
377 } 388 }
378 389
379 ASSERT(result != Heap::the_hole_value()); 390 ASSERT(!result->IsTheHole());
380 391
381 if (result->IsJSFunction()) { 392 if (result->IsJSFunction()) {
382 // Check if there is an optimized (builtin) version of the function. 393 // Check if there is an optimized (builtin) version of the function.
383 // Ignored this will degrade performance for Array.prototype.{push,pop}. 394 // Ignored this will degrade performance for Array.prototype.{push,pop}.
384 // Please note we only return the optimized function iff 395 // Please note we only return the optimized function iff
385 // the JSObject has FastElements. 396 // the JSObject has FastElements.
386 if (object->IsJSObject() && JSObject::cast(*object)->HasFastElements()) { 397 if (object->IsJSObject() && JSObject::cast(*object)->HasFastElements()) {
387 Object* opt = Top::LookupSpecialFunction(JSObject::cast(*object), 398 Object* opt = Top::LookupSpecialFunction(JSObject::cast(*object),
388 lookup.holder(), 399 lookup.holder(),
389 JSFunction::cast(result)); 400 JSFunction::cast(result));
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 set_target(Code::cast(code)); 511 set_target(Code::cast(code));
501 } 512 }
502 513
503 #ifdef DEBUG 514 #ifdef DEBUG
504 TraceIC("CallIC", name, state, target(), in_loop ? " (in-loop)" : ""); 515 TraceIC("CallIC", name, state, target(), in_loop ? " (in-loop)" : "");
505 #endif 516 #endif
506 } 517 }
507 518
508 519
509 Object* LoadIC::Load(State state, Handle<Object> object, Handle<String> name) { 520 Object* LoadIC::Load(State state, Handle<Object> object, Handle<String> name) {
521 object = UnholeForBug16276(object);
522
510 // If the object is undefined or null it's illegal to try to get any 523 // If the object is undefined or null it's illegal to try to get any
511 // of its properties; throw a TypeError in that case. 524 // of its properties; throw a TypeError in that case.
512 if (object->IsUndefined() || object->IsNull()) { 525 if (object->IsUndefined() || object->IsNull()) {
513 return TypeError("non_object_property_load", object, name); 526 return TypeError("non_object_property_load", object, name);
514 } 527 }
515 528
516 if (FLAG_use_ic) { 529 if (FLAG_use_ic) {
517 // Use specialized code for getting the length of strings and 530 // Use specialized code for getting the length of strings and
518 // string wrapper objects. The length property of string wrapper 531 // string wrapper objects. The length property of string wrapper
519 // objects is read-only and therefore always returns the length of 532 // objects is read-only and therefore always returns the length of
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 725
713 #ifdef DEBUG 726 #ifdef DEBUG
714 TraceIC("LoadIC", name, state, target()); 727 TraceIC("LoadIC", name, state, target());
715 #endif 728 #endif
716 } 729 }
717 730
718 731
719 Object* KeyedLoadIC::Load(State state, 732 Object* KeyedLoadIC::Load(State state,
720 Handle<Object> object, 733 Handle<Object> object,
721 Handle<Object> key) { 734 Handle<Object> key) {
735 object = UnholeForBug16276(object);
736
722 if (key->IsSymbol()) { 737 if (key->IsSymbol()) {
723 Handle<String> name = Handle<String>::cast(key); 738 Handle<String> name = Handle<String>::cast(key);
724 739
725 // If the object is undefined or null it's illegal to try to get any 740 // If the object is undefined or null it's illegal to try to get any
726 // of its properties; throw a TypeError in that case. 741 // of its properties; throw a TypeError in that case.
727 if (object->IsUndefined() || object->IsNull()) { 742 if (object->IsUndefined() || object->IsNull()) {
728 return TypeError("non_object_property_load", object, name); 743 return TypeError("non_object_property_load", object, name);
729 } 744 }
730 745
731 if (FLAG_use_ic) { 746 if (FLAG_use_ic) {
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 } 952 }
938 953
939 return true; 954 return true;
940 } 955 }
941 956
942 957
943 Object* StoreIC::Store(State state, 958 Object* StoreIC::Store(State state,
944 Handle<Object> object, 959 Handle<Object> object,
945 Handle<String> name, 960 Handle<String> name,
946 Handle<Object> value) { 961 Handle<Object> value) {
962 object = UnholeForBug16276(object);
963
947 // If the object is undefined or null it's illegal to try to set any 964 // If the object is undefined or null it's illegal to try to set any
948 // properties on it; throw a TypeError in that case. 965 // properties on it; throw a TypeError in that case.
949 if (object->IsUndefined() || object->IsNull()) { 966 if (object->IsUndefined() || object->IsNull()) {
950 return TypeError("non_object_property_store", object, name); 967 return TypeError("non_object_property_store", object, name);
951 } 968 }
952 969
953 // Ignore stores where the receiver is not a JSObject. 970 // Ignore stores where the receiver is not a JSObject.
954 if (!object->IsJSObject()) return *value; 971 if (!object->IsJSObject()) return *value;
955 Handle<JSObject> receiver = Handle<JSObject>::cast(object); 972 Handle<JSObject> receiver = Handle<JSObject>::cast(object);
956 973
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 #ifdef DEBUG 1072 #ifdef DEBUG
1056 TraceIC("StoreIC", name, state, target()); 1073 TraceIC("StoreIC", name, state, target());
1057 #endif 1074 #endif
1058 } 1075 }
1059 1076
1060 1077
1061 Object* KeyedStoreIC::Store(State state, 1078 Object* KeyedStoreIC::Store(State state,
1062 Handle<Object> object, 1079 Handle<Object> object,
1063 Handle<Object> key, 1080 Handle<Object> key,
1064 Handle<Object> value) { 1081 Handle<Object> value) {
1082 object = UnholeForBug16276(object);
1083
1065 if (key->IsSymbol()) { 1084 if (key->IsSymbol()) {
1066 Handle<String> name = Handle<String>::cast(key); 1085 Handle<String> name = Handle<String>::cast(key);
1067 1086
1068 // If the object is undefined or null it's illegal to try to set any 1087 // If the object is undefined or null it's illegal to try to set
1069 // properties on it; throw a TypeError in that case. 1088 // any properties on it; throw a TypeError in that case.
1070 if (object->IsUndefined() || object->IsNull()) { 1089 if (object->IsUndefined() || object->IsNull()) {
1071 return TypeError("non_object_property_store", object, name); 1090 return TypeError("non_object_property_store", object, name);
1072 } 1091 }
1073 1092
1074 // Ignore stores where the receiver is not a JSObject. 1093 // Ignore stores where the receiver is not a JSObject.
1075 if (!object->IsJSObject()) return *value; 1094 if (!object->IsJSObject()) return *value;
1076 Handle<JSObject> receiver = Handle<JSObject>::cast(object); 1095 Handle<JSObject> receiver = Handle<JSObject>::cast(object);
1077 1096
1078 // Check if the given name is an array index. 1097 // Check if the given name is an array index.
1079 uint32_t index; 1098 uint32_t index;
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
1356 #undef ADDR 1375 #undef ADDR
1357 }; 1376 };
1358 1377
1359 1378
1360 Address IC::AddressFromUtilityId(IC::UtilityId id) { 1379 Address IC::AddressFromUtilityId(IC::UtilityId id) {
1361 return IC_utilities[id]; 1380 return IC_utilities[id];
1362 } 1381 }
1363 1382
1364 1383
1365 } } // namespace v8::internal 1384 } } // 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