OLD | NEW |
---|---|
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 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
451 MaybeObject* CallICBase::LoadFunction(State state, | 451 MaybeObject* CallICBase::LoadFunction(State state, |
452 Code::ExtraICState extra_ic_state, | 452 Code::ExtraICState extra_ic_state, |
453 Handle<Object> object, | 453 Handle<Object> object, |
454 Handle<String> name) { | 454 Handle<String> name) { |
455 // If the object is undefined or null it's illegal to try to get any | 455 // If the object is undefined or null it's illegal to try to get any |
456 // of its properties; throw a TypeError in that case. | 456 // of its properties; throw a TypeError in that case. |
457 if (object->IsUndefined() || object->IsNull()) { | 457 if (object->IsUndefined() || object->IsNull()) { |
458 return TypeError("non_object_property_call", object, name); | 458 return TypeError("non_object_property_call", object, name); |
459 } | 459 } |
460 | 460 |
461 if (object->IsString() || object->IsNumber() || object->IsBoolean()) { | |
462 ReceiverToObject(object); | |
463 } | |
464 | |
465 // Check if the name is trivially convertible to an index and get | 461 // Check if the name is trivially convertible to an index and get |
466 // the element if so. | 462 // the element if so. |
467 uint32_t index; | 463 uint32_t index; |
468 if (name->AsArrayIndex(&index)) { | 464 // TODO(mmaly): One cannot hang number-indexed functions off of values, right? |
Martin Maly
2011/02/16 04:56:17
I couldn't come up with a way where value could ac
Mads Ager (chromium)
2011/02/16 10:43:54
I think that is because we have a bug here. I thin
Martin Maly
2011/02/17 05:25:55
Done.
| |
465 if (object->IsJSObject() && name->AsArrayIndex(&index)) { | |
469 Object* result; | 466 Object* result; |
470 { MaybeObject* maybe_result = object->GetElement(index); | 467 { MaybeObject* maybe_result = object->GetElement(index); |
471 if (!maybe_result->ToObject(&result)) return maybe_result; | 468 if (!maybe_result->ToObject(&result)) return maybe_result; |
472 } | 469 } |
473 | 470 |
474 if (result->IsJSFunction()) return result; | 471 if (result->IsJSFunction()) return result; |
475 | 472 |
476 // Try to find a suitable function delegate for the object at hand. | 473 // Try to find a suitable function delegate for the object at hand. |
477 result = TryCallAsFunction(result); | 474 result = TryCallAsFunction(result); |
478 if (result->IsJSFunction()) return result; | 475 if (result->IsJSFunction()) return result; |
479 | 476 |
480 // Otherwise, it will fail in the lookup step. | 477 // Otherwise, it will fail in the lookup step. |
481 } | 478 } |
482 | 479 |
483 // Lookup the property in the object. | 480 // Lookup the property in the object. |
484 LookupResult lookup; | 481 LookupResult lookup; |
485 LookupForRead(*object, *name, &lookup); | 482 LookupForRead(*object, *name, &lookup); |
486 | 483 |
487 if (!lookup.IsProperty()) { | 484 if (!lookup.IsProperty()) { |
488 // If the object does not have the requested property, check which | 485 // If the object does not have the requested property, check which |
489 // exception we need to throw. | 486 // exception we need to throw. |
490 if (IsContextual(object)) { | 487 if (IsContextual(object)) { |
491 return ReferenceError("not_defined", name); | 488 return ReferenceError("not_defined", name); |
492 } | 489 } |
490 // TODO(mmaly): Should we do ToObject here? | |
Mads Ager (chromium)
2011/02/16 10:43:54
Nope, there is no change to this code and it makes
Martin Maly
2011/02/17 05:25:55
Done.
| |
493 return TypeError("undefined_method", object, name); | 491 return TypeError("undefined_method", object, name); |
494 } | 492 } |
495 | 493 |
496 // Lookup is valid: Update inline cache and stub cache. | 494 // Lookup is valid: Update inline cache and stub cache. |
497 if (FLAG_use_ic) { | 495 if (FLAG_use_ic) { |
498 UpdateCaches(&lookup, state, extra_ic_state, object, name); | 496 UpdateCaches(&lookup, state, extra_ic_state, object, name); |
499 } | 497 } |
500 | 498 |
501 // Get the property. | 499 // Get the property. |
502 PropertyAttributes attr; | 500 PropertyAttributes attr; |
503 Object* result; | 501 Object* result; |
504 { MaybeObject* maybe_result = | 502 { MaybeObject* maybe_result = |
505 object->GetProperty(*object, &lookup, *name, &attr); | 503 object->GetProperty(*object, &lookup, *name, &attr); |
506 if (!maybe_result->ToObject(&result)) return maybe_result; | 504 if (!maybe_result->ToObject(&result)) return maybe_result; |
507 } | 505 } |
506 | |
507 // For non-strict mode functions, make receiver an object. | |
508 if ((!result->IsJSFunction() || | |
509 !JSFunction::cast(result)->shared()->strict_mode()) && | |
510 (object->IsString() || object->IsNumber() || object->IsBoolean())) { | |
511 ReceiverToObject(object); | |
Vitaly Repeshko
2011/02/16 11:52:12
1. Since this is now done after UpdateCaches, plea
Martin Maly
2011/02/17 05:25:55
Done and done. for the builtin change I ran full t
| |
512 } | |
513 | |
508 if (lookup.type() == INTERCEPTOR) { | 514 if (lookup.type() == INTERCEPTOR) { |
509 // If the object does not have the requested property, check which | 515 // If the object does not have the requested property, check which |
510 // exception we need to throw. | 516 // exception we need to throw. |
511 if (attr == ABSENT) { | 517 if (attr == ABSENT) { |
512 if (IsContextual(object)) { | 518 if (IsContextual(object)) { |
513 return ReferenceError("not_defined", name); | 519 return ReferenceError("not_defined", name); |
514 } | 520 } |
515 return TypeError("undefined_method", object, name); | 521 return TypeError("undefined_method", object, name); |
516 } | 522 } |
517 } | 523 } |
(...skipping 1768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2286 #undef ADDR | 2292 #undef ADDR |
2287 }; | 2293 }; |
2288 | 2294 |
2289 | 2295 |
2290 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 2296 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
2291 return IC_utilities[id]; | 2297 return IC_utilities[id]; |
2292 } | 2298 } |
2293 | 2299 |
2294 | 2300 |
2295 } } // namespace v8::internal | 2301 } } // namespace v8::internal |
OLD | NEW |