OLD | NEW |
---|---|
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/compiler.h" | 5 #include "vm/compiler.h" |
6 | 6 |
7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
8 | 8 |
9 #include "vm/ast_printer.h" | 9 #include "vm/ast_printer.h" |
10 #include "vm/block_scheduler.h" | 10 #include "vm/block_scheduler.h" |
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
850 RawError* Compiler::CompileAllFunctions(const Class& cls) { | 850 RawError* Compiler::CompileAllFunctions(const Class& cls) { |
851 Error& error = Error::Handle(); | 851 Error& error = Error::Handle(); |
852 Array& functions = Array::Handle(cls.functions()); | 852 Array& functions = Array::Handle(cls.functions()); |
853 Function& func = Function::Handle(); | 853 Function& func = Function::Handle(); |
854 // Class dynamic lives in the vm isolate. Its array fields cannot be set to | 854 // Class dynamic lives in the vm isolate. Its array fields cannot be set to |
855 // an empty array. | 855 // an empty array. |
856 if (functions.IsNull()) { | 856 if (functions.IsNull()) { |
857 ASSERT(cls.IsDynamicClass()); | 857 ASSERT(cls.IsDynamicClass()); |
858 return error.raw(); | 858 return error.raw(); |
859 } | 859 } |
860 // Compile all the regular functions. | |
860 for (int i = 0; i < functions.Length(); i++) { | 861 for (int i = 0; i < functions.Length(); i++) { |
861 func ^= functions.At(i); | 862 func ^= functions.At(i); |
862 ASSERT(!func.IsNull()); | 863 ASSERT(!func.IsNull()); |
863 if (!func.HasCode() && | 864 if (!func.HasCode() && |
864 !func.is_abstract() && | 865 !func.is_abstract() && |
865 !func.IsRedirectingFactory()) { | 866 !func.IsRedirectingFactory()) { |
866 error = CompileFunction(func); | 867 error = CompileFunction(func); |
867 if (!error.IsNull()) { | 868 if (!error.IsNull()) { |
868 return error.raw(); | 869 return error.raw(); |
869 } | 870 } |
870 } | 871 } |
871 } | 872 } |
873 // Inner functions get added to the closures array. As part of compilation | |
874 // more closures can be added to the end of the array. Compile all the | |
875 // closures until we have reached the end of the "worklist". | |
876 GrowableObjectArray& closures = | |
877 GrowableObjectArray::Handle(cls.closures()); | |
878 if (!closures.IsNull()) { | |
879 for (int i = 0; i < closures.Length(); i++) { | |
880 func ^= closures.At(i); | |
881 if (!func.HasCode() && | |
882 !func.is_abstract() && | |
883 !func.IsRedirectingFactory()) { | |
hausner
2013/10/04 16:06:23
Can we really have abstract functions or redirecti
Ivan Posva
2013/10/04 20:50:02
Copy & Pasterr.
| |
884 error = CompileFunction(func); | |
885 if (!error.IsNull()) { | |
886 return error.raw(); | |
887 } | |
888 } | |
889 } | |
890 } | |
872 return error.raw(); | 891 return error.raw(); |
873 } | 892 } |
874 | 893 |
875 | 894 |
876 RawObject* Compiler::ExecuteOnce(SequenceNode* fragment) { | 895 RawObject* Compiler::ExecuteOnce(SequenceNode* fragment) { |
877 Isolate* isolate = Isolate::Current(); | 896 Isolate* isolate = Isolate::Current(); |
878 LongJump* base = isolate->long_jump_base(); | 897 LongJump* base = isolate->long_jump_base(); |
879 LongJump jump; | 898 LongJump jump; |
880 isolate->set_long_jump_base(&jump); | 899 isolate->set_long_jump_base(&jump); |
881 if (setjmp(*jump.Set()) == 0) { | 900 if (setjmp(*jump.Set()) == 0) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
926 Object::Handle(isolate->object_store()->sticky_error()); | 945 Object::Handle(isolate->object_store()->sticky_error()); |
927 isolate->object_store()->clear_sticky_error(); | 946 isolate->object_store()->clear_sticky_error(); |
928 isolate->set_long_jump_base(base); | 947 isolate->set_long_jump_base(base); |
929 return result.raw(); | 948 return result.raw(); |
930 } | 949 } |
931 UNREACHABLE(); | 950 UNREACHABLE(); |
932 return Object::null(); | 951 return Object::null(); |
933 } | 952 } |
934 | 953 |
935 } // namespace dart | 954 } // namespace dart |
OLD | NEW |