OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 const Smi* kConstructMarker = Smi::FromInt(StackFrame::CONSTRUCT); | 161 const Smi* kConstructMarker = Smi::FromInt(StackFrame::CONSTRUCT); |
162 Object* marker = Memory::Object_at(caller_fp + kMarkerOffset); | 162 Object* marker = Memory::Object_at(caller_fp + kMarkerOffset); |
163 bool result = (marker == kConstructMarker); | 163 bool result = (marker == kConstructMarker); |
164 ASSERT_EQ(result, reference_result); | 164 ASSERT_EQ(result, reference_result); |
165 return result; | 165 return result; |
166 } | 166 } |
167 | 167 |
168 // ---------------------------------------------------------------------------- | 168 // ---------------------------------------------------------------------------- |
169 | 169 |
170 | 170 |
171 Handle<Code> Builtins::GetCode(JavaScript id, bool* resolved) { | |
172 Code* code = Builtins::builtin(Builtins::Illegal); | |
173 *resolved = false; | |
174 | |
175 if (Top::context() != NULL) { | |
176 Object* object = Top::builtins()->javascript_builtin(id); | |
177 if (object->IsJSFunction()) { | |
178 Handle<SharedFunctionInfo> shared(JSFunction::cast(object)->shared()); | |
179 // Make sure the number of parameters match the formal parameter count. | |
180 ASSERT(shared->formal_parameter_count() == | |
181 Builtins::GetArgumentsCount(id)); | |
182 if (EnsureCompiled(shared, CLEAR_EXCEPTION)) { | |
183 code = shared->code(); | |
184 *resolved = true; | |
185 } | |
186 } | |
187 } | |
188 | |
189 return Handle<Code>(code); | |
190 } | |
191 | |
192 | |
193 BUILTIN(Illegal) { | 171 BUILTIN(Illegal) { |
194 UNREACHABLE(); | 172 UNREACHABLE(); |
195 return Heap::undefined_value(); // Make compiler happy. | 173 return Heap::undefined_value(); // Make compiler happy. |
196 } | 174 } |
197 | 175 |
198 | 176 |
199 BUILTIN(EmptyFunction) { | 177 BUILTIN(EmptyFunction) { |
200 return Heap::undefined_value(); | 178 return Heap::undefined_value(); |
201 } | 179 } |
202 | 180 |
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 Object* code; | 831 Object* code; |
854 { | 832 { |
855 // During startup it's OK to always allocate and defer GC to later. | 833 // During startup it's OK to always allocate and defer GC to later. |
856 // This simplifies things because we don't need to retry. | 834 // This simplifies things because we don't need to retry. |
857 AlwaysAllocateScope __scope__; | 835 AlwaysAllocateScope __scope__; |
858 code = Heap::CreateCode(desc, NULL, flags, masm.CodeObject()); | 836 code = Heap::CreateCode(desc, NULL, flags, masm.CodeObject()); |
859 if (code->IsFailure()) { | 837 if (code->IsFailure()) { |
860 v8::internal::V8::FatalProcessOutOfMemory("CreateCode"); | 838 v8::internal::V8::FatalProcessOutOfMemory("CreateCode"); |
861 } | 839 } |
862 } | 840 } |
863 // Add any unresolved jumps or calls to the fixup list in the | |
864 // bootstrapper. | |
865 Bootstrapper::AddFixup(Code::cast(code), &masm); | |
866 // Log the event and add the code to the builtins array. | 841 // Log the event and add the code to the builtins array. |
867 LOG(CodeCreateEvent(Logger::BUILTIN_TAG, | 842 LOG(CodeCreateEvent(Logger::BUILTIN_TAG, |
868 Code::cast(code), functions[i].s_name)); | 843 Code::cast(code), functions[i].s_name)); |
869 builtins_[i] = code; | 844 builtins_[i] = code; |
870 #ifdef ENABLE_DISASSEMBLER | 845 #ifdef ENABLE_DISASSEMBLER |
871 if (FLAG_print_builtin_code) { | 846 if (FLAG_print_builtin_code) { |
872 PrintF("Builtin: %s\n", functions[i].s_name); | 847 PrintF("Builtin: %s\n", functions[i].s_name); |
873 Code::cast(code)->Disassemble(functions[i].s_name); | 848 Code::cast(code)->Disassemble(functions[i].s_name); |
874 PrintF("\n"); | 849 PrintF("\n"); |
875 } | 850 } |
(...skipping 27 matching lines...) Expand all Loading... |
903 if (entry->contains(pc)) { | 878 if (entry->contains(pc)) { |
904 return names_[i]; | 879 return names_[i]; |
905 } | 880 } |
906 } | 881 } |
907 } | 882 } |
908 return NULL; | 883 return NULL; |
909 } | 884 } |
910 | 885 |
911 | 886 |
912 } } // namespace v8::internal | 887 } } // namespace v8::internal |
OLD | NEW |