Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1454)

Side by Side Diff: src/builtins.cc

Issue 2090723005: [builtins] New frame type for exits to C++ builtins (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add missing condition in SafeStackFrameIter::frame() Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/builtins.h ('k') | src/code-stubs.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/builtins.h" 5 #include "src/builtins.h"
6 6
7 #include "src/api-arguments.h" 7 #include "src/api-arguments.h"
8 #include "src/api-natives.h" 8 #include "src/api-natives.h"
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/base/ieee754.h" 10 #include "src/base/ieee754.h"
(...skipping 5699 matching lines...) Expand 10 before | Expand all | Expand 10 after
5710 5710
5711 Builtins::Builtins() : initialized_(false) { 5711 Builtins::Builtins() : initialized_(false) {
5712 memset(builtins_, 0, sizeof(builtins_[0]) * builtin_count); 5712 memset(builtins_, 0, sizeof(builtins_[0]) * builtin_count);
5713 memset(names_, 0, sizeof(names_[0]) * builtin_count); 5713 memset(names_, 0, sizeof(names_[0]) * builtin_count);
5714 } 5714 }
5715 5715
5716 5716
5717 Builtins::~Builtins() { 5717 Builtins::~Builtins() {
5718 } 5718 }
5719 5719
5720 #define DEF_ENUM_C(name) FUNCTION_ADDR(Builtin_##name), 5720 #define DEF_ENUM_C(name, ignore) FUNCTION_ADDR(Builtin_##name),
5721 Address const Builtins::c_functions_[cfunction_count] = { 5721 Address const Builtins::c_functions_[cfunction_count] = {
5722 BUILTIN_LIST_C(DEF_ENUM_C) 5722 BUILTIN_LIST_C(DEF_ENUM_C)
5723 }; 5723 };
5724 #undef DEF_ENUM_C 5724 #undef DEF_ENUM_C
5725 5725
5726 5726
5727 struct BuiltinDesc { 5727 struct BuiltinDesc {
5728 Handle<Code> (*builder)(Isolate*, struct BuiltinDesc const*); 5728 Handle<Code> (*builder)(Isolate*, struct BuiltinDesc const*);
5729 byte* generator; 5729 byte* generator;
5730 byte* c_code; 5730 byte* c_code;
5731 const char* s_name; // name is only used for generating log information. 5731 const char* s_name; // name is only used for generating log information.
5732 int name; 5732 int name;
5733 Code::Flags flags; 5733 Code::Flags flags;
5734 Builtins::ExitFrameType exit_frame_type;
5734 int argc; 5735 int argc;
5735 }; 5736 };
5736 5737
5737 #define BUILTIN_FUNCTION_TABLE_INIT { V8_ONCE_INIT, {} } 5738 #define BUILTIN_FUNCTION_TABLE_INIT { V8_ONCE_INIT, {} }
5738 5739
5739 class BuiltinFunctionTable { 5740 class BuiltinFunctionTable {
5740 public: 5741 public:
5741 BuiltinDesc* functions() { 5742 BuiltinDesc* functions() {
5742 base::CallOnce(&once_, &Builtins::InitBuiltinFunctionTable); 5743 base::CallOnce(&once_, &Builtins::InitBuiltinFunctionTable);
5743 return functions_; 5744 return functions_;
(...skipping 24 matching lines...) Expand all
5768 const size_t buffer_size = 8 * KB; 5769 const size_t buffer_size = 8 * KB;
5769 #endif 5770 #endif
5770 union { 5771 union {
5771 int force_alignment; 5772 int force_alignment;
5772 byte buffer[buffer_size]; // NOLINT(runtime/arrays) 5773 byte buffer[buffer_size]; // NOLINT(runtime/arrays)
5773 } u; 5774 } u;
5774 5775
5775 MacroAssembler masm(isolate, u.buffer, sizeof(u.buffer), 5776 MacroAssembler masm(isolate, u.buffer, sizeof(u.buffer),
5776 CodeObjectRequired::kYes); 5777 CodeObjectRequired::kYes);
5777 // Generate the code/adaptor. 5778 // Generate the code/adaptor.
5778 typedef void (*Generator)(MacroAssembler*, int); 5779 typedef void (*Generator)(MacroAssembler*, int, Builtins::ExitFrameType);
5779 Generator g = FUNCTION_CAST<Generator>(builtin_desc->generator); 5780 Generator g = FUNCTION_CAST<Generator>(builtin_desc->generator);
5780 // We pass all arguments to the generator, but it may not use all of 5781 // We pass all arguments to the generator, but it may not use all of
5781 // them. This works because the first arguments are on top of the 5782 // them. This works because the first arguments are on top of the
5782 // stack. 5783 // stack.
5783 DCHECK(!masm.has_frame()); 5784 DCHECK(!masm.has_frame());
5784 g(&masm, builtin_desc->name); 5785 g(&masm, builtin_desc->name, builtin_desc->exit_frame_type);
5785 // Move the code into the object heap. 5786 // Move the code into the object heap.
5786 CodeDesc desc; 5787 CodeDesc desc;
5787 masm.GetCode(&desc); 5788 masm.GetCode(&desc);
5788 Code::Flags flags = builtin_desc->flags; 5789 Code::Flags flags = builtin_desc->flags;
5789 return isolate->factory()->NewCode(desc, flags, masm.CodeObject()); 5790 return isolate->factory()->NewCode(desc, flags, masm.CodeObject());
5790 } 5791 }
5791 5792
5792 // Builder for builtins implemented in TurboFan with JS linkage. 5793 // Builder for builtins implemented in TurboFan with JS linkage.
5793 Handle<Code> CodeStubAssemblerBuilderJS(Isolate* isolate, 5794 Handle<Code> CodeStubAssemblerBuilderJS(Isolate* isolate,
5794 BuiltinDesc const* builtin_desc) { 5795 BuiltinDesc const* builtin_desc) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
5828 // within the lexical scope of Builtins:: and within a context where 5829 // within the lexical scope of Builtins:: and within a context where
5829 // Code::Flags names a non-abstract type. 5830 // Code::Flags names a non-abstract type.
5830 void Builtins::InitBuiltinFunctionTable() { 5831 void Builtins::InitBuiltinFunctionTable() {
5831 BuiltinDesc* functions = builtin_function_table.functions_; 5832 BuiltinDesc* functions = builtin_function_table.functions_;
5832 functions[builtin_count].builder = nullptr; 5833 functions[builtin_count].builder = nullptr;
5833 functions[builtin_count].generator = nullptr; 5834 functions[builtin_count].generator = nullptr;
5834 functions[builtin_count].c_code = nullptr; 5835 functions[builtin_count].c_code = nullptr;
5835 functions[builtin_count].s_name = nullptr; 5836 functions[builtin_count].s_name = nullptr;
5836 functions[builtin_count].name = builtin_count; 5837 functions[builtin_count].name = builtin_count;
5837 functions[builtin_count].flags = static_cast<Code::Flags>(0); 5838 functions[builtin_count].flags = static_cast<Code::Flags>(0);
5839 functions[builtin_count].exit_frame_type = EXIT;
5838 functions[builtin_count].argc = 0; 5840 functions[builtin_count].argc = 0;
5839 5841
5840 #define DEF_FUNCTION_PTR_C(aname) \ 5842 #define DEF_FUNCTION_PTR_C(aname, aexit_frame_type) \
5841 functions->builder = &MacroAssemblerBuilder; \ 5843 functions->builder = &MacroAssemblerBuilder; \
5842 functions->generator = FUNCTION_ADDR(Generate_Adaptor); \ 5844 functions->generator = FUNCTION_ADDR(Generate_Adaptor); \
5843 functions->c_code = FUNCTION_ADDR(Builtin_##aname); \ 5845 functions->c_code = FUNCTION_ADDR(Builtin_##aname); \
5844 functions->s_name = #aname; \ 5846 functions->s_name = #aname; \
5845 functions->name = c_##aname; \ 5847 functions->name = c_##aname; \
5846 functions->flags = Code::ComputeFlags(Code::BUILTIN); \ 5848 functions->flags = Code::ComputeFlags(Code::BUILTIN); \
5849 functions->exit_frame_type = aexit_frame_type; \
5847 functions->argc = 0; \ 5850 functions->argc = 0; \
5848 ++functions; 5851 ++functions;
5849 5852
5850 #define DEF_FUNCTION_PTR_A(aname, kind, extra) \ 5853 #define DEF_FUNCTION_PTR_A(aname, kind, extra) \
5851 functions->builder = &MacroAssemblerBuilder; \ 5854 functions->builder = &MacroAssemblerBuilder; \
5852 functions->generator = FUNCTION_ADDR(Generate_##aname); \ 5855 functions->generator = FUNCTION_ADDR(Generate_##aname); \
5853 functions->c_code = NULL; \ 5856 functions->c_code = NULL; \
5854 functions->s_name = #aname; \ 5857 functions->s_name = #aname; \
5855 functions->name = k##aname; \ 5858 functions->name = k##aname; \
5856 functions->flags = Code::ComputeFlags(Code::kind, extra); \ 5859 functions->flags = Code::ComputeFlags(Code::kind, extra); \
5860 functions->exit_frame_type = EXIT; \
5857 functions->argc = 0; \ 5861 functions->argc = 0; \
5858 ++functions; 5862 ++functions;
5859 5863
5860 #define DEF_FUNCTION_PTR_T(aname, aargc) \ 5864 #define DEF_FUNCTION_PTR_T(aname, aargc) \
5861 functions->builder = &CodeStubAssemblerBuilderJS; \ 5865 functions->builder = &CodeStubAssemblerBuilderJS; \
5862 functions->generator = FUNCTION_ADDR(Generate_##aname); \ 5866 functions->generator = FUNCTION_ADDR(Generate_##aname); \
5863 functions->c_code = NULL; \ 5867 functions->c_code = NULL; \
5864 functions->s_name = #aname; \ 5868 functions->s_name = #aname; \
5865 functions->name = k##aname; \ 5869 functions->name = k##aname; \
5866 functions->flags = Code::ComputeFlags(Code::BUILTIN); \ 5870 functions->flags = Code::ComputeFlags(Code::BUILTIN); \
5871 functions->exit_frame_type = EXIT; \
5867 functions->argc = aargc; \ 5872 functions->argc = aargc; \
5868 ++functions; 5873 ++functions;
5869 5874
5870 #define DEF_FUNCTION_PTR_S(aname, kind, extra, interface_descriptor) \ 5875 #define DEF_FUNCTION_PTR_S(aname, kind, extra, interface_descriptor) \
5871 functions->builder = &CodeStubAssemblerBuilderCS; \ 5876 functions->builder = &CodeStubAssemblerBuilderCS; \
5872 functions->generator = FUNCTION_ADDR(Generate_##aname); \ 5877 functions->generator = FUNCTION_ADDR(Generate_##aname); \
5873 functions->c_code = NULL; \ 5878 functions->c_code = NULL; \
5874 functions->s_name = #aname; \ 5879 functions->s_name = #aname; \
5875 functions->name = k##aname; \ 5880 functions->name = k##aname; \
5876 functions->flags = Code::ComputeFlags(Code::kind, extra); \ 5881 functions->flags = Code::ComputeFlags(Code::kind, extra); \
5882 functions->exit_frame_type = EXIT; \
5877 functions->argc = CallDescriptors::interface_descriptor; \ 5883 functions->argc = CallDescriptors::interface_descriptor; \
5878 ++functions; 5884 ++functions;
5879 5885
5880 #define DEF_FUNCTION_PTR_H(aname, kind) \ 5886 #define DEF_FUNCTION_PTR_H(aname, kind) \
5881 functions->builder = &MacroAssemblerBuilder; \ 5887 functions->builder = &MacroAssemblerBuilder; \
5882 functions->generator = FUNCTION_ADDR(Generate_##aname); \ 5888 functions->generator = FUNCTION_ADDR(Generate_##aname); \
5883 functions->c_code = NULL; \ 5889 functions->c_code = NULL; \
5884 functions->s_name = #aname; \ 5890 functions->s_name = #aname; \
5885 functions->name = k##aname; \ 5891 functions->name = k##aname; \
5886 functions->flags = Code::ComputeHandlerFlags(Code::kind); \ 5892 functions->flags = Code::ComputeHandlerFlags(Code::kind); \
5893 functions->exit_frame_type = EXIT; \
5887 functions->argc = 0; \ 5894 functions->argc = 0; \
5888 ++functions; 5895 ++functions;
5889 5896
5890 BUILTIN_LIST_C(DEF_FUNCTION_PTR_C) 5897 BUILTIN_LIST_C(DEF_FUNCTION_PTR_C)
5891 BUILTIN_LIST_A(DEF_FUNCTION_PTR_A) 5898 BUILTIN_LIST_A(DEF_FUNCTION_PTR_A)
5892 BUILTIN_LIST_T(DEF_FUNCTION_PTR_T) 5899 BUILTIN_LIST_T(DEF_FUNCTION_PTR_T)
5893 BUILTIN_LIST_S(DEF_FUNCTION_PTR_S) 5900 BUILTIN_LIST_S(DEF_FUNCTION_PTR_S)
5894 BUILTIN_LIST_H(DEF_FUNCTION_PTR_H) 5901 BUILTIN_LIST_H(DEF_FUNCTION_PTR_H)
5895 BUILTIN_LIST_DEBUG_A(DEF_FUNCTION_PTR_A) 5902 BUILTIN_LIST_DEBUG_A(DEF_FUNCTION_PTR_A)
5896 5903
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
6210 a->Bind(&u32); 6217 a->Bind(&u32);
6211 a->AtomicStore(MachineRepresentation::kWord32, backing_store, 6218 a->AtomicStore(MachineRepresentation::kWord32, backing_store,
6212 a->WordShl(index_word, 2), value_word32); 6219 a->WordShl(index_word, 2), value_word32);
6213 a->Return(value_integer); 6220 a->Return(value_integer);
6214 6221
6215 // This shouldn't happen, we've already validated the type. 6222 // This shouldn't happen, we've already validated the type.
6216 a->Bind(&other); 6223 a->Bind(&other);
6217 a->Return(a->Int32Constant(0)); 6224 a->Return(a->Int32Constant(0));
6218 } 6225 }
6219 6226
6220 #define DEFINE_BUILTIN_ACCESSOR_C(name) \ 6227 #define DEFINE_BUILTIN_ACCESSOR_C(name, ignore) \
6221 Handle<Code> Builtins::name() { \ 6228 Handle<Code> Builtins::name() { \
6222 Code** code_address = reinterpret_cast<Code**>(builtin_address(k##name)); \ 6229 Code** code_address = reinterpret_cast<Code**>(builtin_address(k##name)); \
6223 return Handle<Code>(code_address); \ 6230 return Handle<Code>(code_address); \
6224 } 6231 }
6225 #define DEFINE_BUILTIN_ACCESSOR_A(name, kind, extra) \ 6232 #define DEFINE_BUILTIN_ACCESSOR_A(name, kind, extra) \
6226 Handle<Code> Builtins::name() { \ 6233 Handle<Code> Builtins::name() { \
6227 Code** code_address = reinterpret_cast<Code**>(builtin_address(k##name)); \ 6234 Code** code_address = reinterpret_cast<Code**>(builtin_address(k##name)); \
6228 return Handle<Code>(code_address); \ 6235 return Handle<Code>(code_address); \
6229 } 6236 }
6230 #define DEFINE_BUILTIN_ACCESSOR_T(name, argc) \ 6237 #define DEFINE_BUILTIN_ACCESSOR_T(name, argc) \
(...skipping 19 matching lines...) Expand all
6250 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) 6257 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H)
6251 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) 6258 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A)
6252 #undef DEFINE_BUILTIN_ACCESSOR_C 6259 #undef DEFINE_BUILTIN_ACCESSOR_C
6253 #undef DEFINE_BUILTIN_ACCESSOR_A 6260 #undef DEFINE_BUILTIN_ACCESSOR_A
6254 #undef DEFINE_BUILTIN_ACCESSOR_T 6261 #undef DEFINE_BUILTIN_ACCESSOR_T
6255 #undef DEFINE_BUILTIN_ACCESSOR_S 6262 #undef DEFINE_BUILTIN_ACCESSOR_S
6256 #undef DEFINE_BUILTIN_ACCESSOR_H 6263 #undef DEFINE_BUILTIN_ACCESSOR_H
6257 6264
6258 } // namespace internal 6265 } // namespace internal
6259 } // namespace v8 6266 } // namespace v8
OLDNEW
« no previous file with comments | « src/builtins.h ('k') | src/code-stubs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698