OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 MaybeObject* Accessors::FunctionGetLength(Object* object, void*) { | 520 MaybeObject* Accessors::FunctionGetLength(Object* object, void*) { |
521 bool found_it = false; | 521 bool found_it = false; |
522 JSFunction* function = FindInPrototypeChain<JSFunction>(object, &found_it); | 522 JSFunction* function = FindInPrototypeChain<JSFunction>(object, &found_it); |
523 if (!found_it) return Smi::FromInt(0); | 523 if (!found_it) return Smi::FromInt(0); |
524 // Check if already compiled. | 524 // Check if already compiled. |
525 if (!function->shared()->is_compiled()) { | 525 if (!function->shared()->is_compiled()) { |
526 // If the function isn't compiled yet, the length is not computed | 526 // If the function isn't compiled yet, the length is not computed |
527 // correctly yet. Compile it now and return the right length. | 527 // correctly yet. Compile it now and return the right length. |
528 HandleScope scope; | 528 HandleScope scope; |
529 Handle<JSFunction> handle(function); | 529 Handle<JSFunction> handle(function); |
530 if (!CompileLazy(handle, KEEP_EXCEPTION)) return Failure::Exception(); | 530 if (!JSFunction::CompileLazy(handle, KEEP_EXCEPTION)) { |
| 531 return Failure::Exception(); |
| 532 } |
531 return Smi::FromInt(handle->shared()->length()); | 533 return Smi::FromInt(handle->shared()->length()); |
532 } else { | 534 } else { |
533 return Smi::FromInt(function->shared()->length()); | 535 return Smi::FromInt(function->shared()->length()); |
534 } | 536 } |
535 } | 537 } |
536 | 538 |
537 | 539 |
538 const AccessorDescriptor Accessors::FunctionLength = { | 540 const AccessorDescriptor Accessors::FunctionLength = { |
539 FunctionGetLength, | 541 FunctionGetLength, |
540 ReadOnlySetAccessor, | 542 ReadOnlySetAccessor, |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 if (caller == NULL) return isolate->heap()->null_value(); | 754 if (caller == NULL) return isolate->heap()->null_value(); |
753 } while (caller->shared()->is_toplevel()); | 755 } while (caller->shared()->is_toplevel()); |
754 | 756 |
755 // If caller is a built-in function and caller's caller is also built-in, | 757 // If caller is a built-in function and caller's caller is also built-in, |
756 // use that instead. | 758 // use that instead. |
757 JSFunction* potential_caller = caller; | 759 JSFunction* potential_caller = caller; |
758 while (potential_caller != NULL && potential_caller->IsBuiltin()) { | 760 while (potential_caller != NULL && potential_caller->IsBuiltin()) { |
759 caller = potential_caller; | 761 caller = potential_caller; |
760 potential_caller = it.next(); | 762 potential_caller = it.next(); |
761 } | 763 } |
762 | 764 // If caller is bound, return null. This is compatible with JSC, and |
| 765 // allows us to make bound functions use the strict function map |
| 766 // and its associated throwing caller and arguments. |
| 767 if (caller->shared()->bound()) { |
| 768 return isolate->heap()->null_value(); |
| 769 } |
763 return CheckNonStrictCallerOrThrow(isolate, caller); | 770 return CheckNonStrictCallerOrThrow(isolate, caller); |
764 } | 771 } |
765 | 772 |
766 | 773 |
767 const AccessorDescriptor Accessors::FunctionCaller = { | 774 const AccessorDescriptor Accessors::FunctionCaller = { |
768 FunctionGetCaller, | 775 FunctionGetCaller, |
769 ReadOnlySetAccessor, | 776 ReadOnlySetAccessor, |
770 0 | 777 0 |
771 }; | 778 }; |
772 | 779 |
(...skipping 22 matching lines...) Expand all Loading... |
795 } | 802 } |
796 | 803 |
797 | 804 |
798 const AccessorDescriptor Accessors::ObjectPrototype = { | 805 const AccessorDescriptor Accessors::ObjectPrototype = { |
799 ObjectGetPrototype, | 806 ObjectGetPrototype, |
800 ObjectSetPrototype, | 807 ObjectSetPrototype, |
801 0 | 808 0 |
802 }; | 809 }; |
803 | 810 |
804 } } // namespace v8::internal | 811 } } // namespace v8::internal |
OLD | NEW |