OLD | NEW |
---|---|
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 10 matching lines...) Expand all Loading... | |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #include "v8.h" | 28 #include "v8.h" |
29 #include "accessors.h" | 29 #include "accessors.h" |
30 | 30 |
31 #include "compiler.h" | |
31 #include "contexts.h" | 32 #include "contexts.h" |
32 #include "deoptimizer.h" | 33 #include "deoptimizer.h" |
33 #include "execution.h" | 34 #include "execution.h" |
34 #include "factory.h" | 35 #include "factory.h" |
35 #include "frames-inl.h" | 36 #include "frames-inl.h" |
36 #include "isolate.h" | 37 #include "isolate.h" |
37 #include "list-inl.h" | 38 #include "list-inl.h" |
38 #include "property-details.h" | 39 #include "property-details.h" |
39 | 40 |
40 namespace v8 { | 41 namespace v8 { |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
641 void*) { | 642 void*) { |
642 JSFunction* function = FindInstanceOf<JSFunction>(isolate, object); | 643 JSFunction* function = FindInstanceOf<JSFunction>(isolate, object); |
643 if (function == NULL) return Smi::FromInt(0); | 644 if (function == NULL) return Smi::FromInt(0); |
644 // Check if already compiled. | 645 // Check if already compiled. |
645 if (function->shared()->is_compiled()) { | 646 if (function->shared()->is_compiled()) { |
646 return Smi::FromInt(function->shared()->length()); | 647 return Smi::FromInt(function->shared()->length()); |
647 } | 648 } |
648 // If the function isn't compiled yet, the length is not computed correctly | 649 // If the function isn't compiled yet, the length is not computed correctly |
649 // yet. Compile it now and return the right length. | 650 // yet. Compile it now and return the right length. |
650 HandleScope scope(isolate); | 651 HandleScope scope(isolate); |
651 Handle<JSFunction> handle(function); | 652 Handle<JSFunction> function_handle(function); |
652 if (JSFunction::CompileLazy(handle, KEEP_EXCEPTION)) { | 653 if (!Compiler::EnsureCompiled(function_handle, KEEP_EXCEPTION)) { |
titzer
2013/12/09 14:49:28
Not sure why you negated this condition, can you s
Yang
2013/12/10 11:22:04
Done.
| |
653 return Smi::FromInt(handle->shared()->length()); | 654 return Failure::Exception(); |
654 } | 655 } |
655 return Failure::Exception(); | 656 return Smi::FromInt(function_handle->shared()->length()); |
656 } | 657 } |
657 | 658 |
658 | 659 |
659 const AccessorDescriptor Accessors::FunctionLength = { | 660 const AccessorDescriptor Accessors::FunctionLength = { |
660 FunctionGetLength, | 661 FunctionGetLength, |
661 ReadOnlySetAccessor, | 662 ReadOnlySetAccessor, |
662 0 | 663 0 |
663 }; | 664 }; |
664 | 665 |
665 | 666 |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
968 info->set_data(Smi::FromInt(index)); | 969 info->set_data(Smi::FromInt(index)); |
969 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); | 970 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); |
970 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); | 971 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); |
971 info->set_getter(*getter); | 972 info->set_getter(*getter); |
972 if (!(attributes & ReadOnly)) info->set_setter(*setter); | 973 if (!(attributes & ReadOnly)) info->set_setter(*setter); |
973 return info; | 974 return info; |
974 } | 975 } |
975 | 976 |
976 | 977 |
977 } } // namespace v8::internal | 978 } } // namespace v8::internal |
OLD | NEW |