| 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 13 matching lines...) Expand all Loading... |
| 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 | 29 |
| 30 #include "api.h" | 30 #include "api.h" |
| 31 #include "arguments.h" | 31 #include "arguments.h" |
| 32 #include "bootstrapper.h" | 32 #include "bootstrapper.h" |
| 33 #include "builtins.h" | 33 #include "builtins.h" |
| 34 #include "gdb-jit.h" |
| 34 #include "ic-inl.h" | 35 #include "ic-inl.h" |
| 35 #include "vm-state-inl.h" | 36 #include "vm-state-inl.h" |
| 36 | 37 |
| 37 namespace v8 { | 38 namespace v8 { |
| 38 namespace internal { | 39 namespace internal { |
| 39 | 40 |
| 40 namespace { | 41 namespace { |
| 41 | 42 |
| 42 // Arguments object passed to C++ builtins. | 43 // Arguments object passed to C++ builtins. |
| 43 template <BuiltinExtraArguments extra_args> | 44 template <BuiltinExtraArguments extra_args> |
| (...skipping 1499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1543 typedef void (*Generator)(MacroAssembler*, int, BuiltinExtraArguments); | 1544 typedef void (*Generator)(MacroAssembler*, int, BuiltinExtraArguments); |
| 1544 Generator g = FUNCTION_CAST<Generator>(functions[i].generator); | 1545 Generator g = FUNCTION_CAST<Generator>(functions[i].generator); |
| 1545 // We pass all arguments to the generator, but it may not use all of | 1546 // We pass all arguments to the generator, but it may not use all of |
| 1546 // them. This works because the first arguments are on top of the | 1547 // them. This works because the first arguments are on top of the |
| 1547 // stack. | 1548 // stack. |
| 1548 g(&masm, functions[i].name, functions[i].extra_args); | 1549 g(&masm, functions[i].name, functions[i].extra_args); |
| 1549 // Move the code into the object heap. | 1550 // Move the code into the object heap. |
| 1550 CodeDesc desc; | 1551 CodeDesc desc; |
| 1551 masm.GetCode(&desc); | 1552 masm.GetCode(&desc); |
| 1552 Code::Flags flags = functions[i].flags; | 1553 Code::Flags flags = functions[i].flags; |
| 1553 Object* code = 0; | 1554 Object* code = NULL; |
| 1554 { | 1555 { |
| 1555 // During startup it's OK to always allocate and defer GC to later. | 1556 // During startup it's OK to always allocate and defer GC to later. |
| 1556 // This simplifies things because we don't need to retry. | 1557 // This simplifies things because we don't need to retry. |
| 1557 AlwaysAllocateScope __scope__; | 1558 AlwaysAllocateScope __scope__; |
| 1558 { MaybeObject* maybe_code = | 1559 { MaybeObject* maybe_code = |
| 1559 Heap::CreateCode(desc, flags, masm.CodeObject()); | 1560 Heap::CreateCode(desc, flags, masm.CodeObject()); |
| 1560 if (!maybe_code->ToObject(&code)) { | 1561 if (!maybe_code->ToObject(&code)) { |
| 1561 v8::internal::V8::FatalProcessOutOfMemory("CreateCode"); | 1562 v8::internal::V8::FatalProcessOutOfMemory("CreateCode"); |
| 1562 } | 1563 } |
| 1563 } | 1564 } |
| 1564 } | 1565 } |
| 1565 // Log the event and add the code to the builtins array. | 1566 // Log the event and add the code to the builtins array. |
| 1566 PROFILE(CodeCreateEvent(Logger::BUILTIN_TAG, | 1567 PROFILE(CodeCreateEvent(Logger::BUILTIN_TAG, |
| 1567 Code::cast(code), functions[i].s_name)); | 1568 Code::cast(code), |
| 1569 functions[i].s_name)); |
| 1570 GDBJIT(AddCode(GDBJITInterface::BUILTIN, |
| 1571 functions[i].s_name, |
| 1572 Code::cast(code))); |
| 1568 builtins_[i] = code; | 1573 builtins_[i] = code; |
| 1569 #ifdef ENABLE_DISASSEMBLER | 1574 #ifdef ENABLE_DISASSEMBLER |
| 1570 if (FLAG_print_builtin_code) { | 1575 if (FLAG_print_builtin_code) { |
| 1571 PrintF("Builtin: %s\n", functions[i].s_name); | 1576 PrintF("Builtin: %s\n", functions[i].s_name); |
| 1572 Code::cast(code)->Disassemble(functions[i].s_name); | 1577 Code::cast(code)->Disassemble(functions[i].s_name); |
| 1573 PrintF("\n"); | 1578 PrintF("\n"); |
| 1574 } | 1579 } |
| 1575 #endif | 1580 #endif |
| 1576 } else { | 1581 } else { |
| 1577 // Deserializing. The values will be filled in during IterateBuiltins. | 1582 // Deserializing. The values will be filled in during IterateBuiltins. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1602 if (entry->contains(pc)) { | 1607 if (entry->contains(pc)) { |
| 1603 return names_[i]; | 1608 return names_[i]; |
| 1604 } | 1609 } |
| 1605 } | 1610 } |
| 1606 } | 1611 } |
| 1607 return NULL; | 1612 return NULL; |
| 1608 } | 1613 } |
| 1609 | 1614 |
| 1610 | 1615 |
| 1611 } } // namespace v8::internal | 1616 } } // namespace v8::internal |
| OLD | NEW |