OLD | NEW |
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/runtime/runtime.h" | 5 #include "src/runtime/runtime.h" |
6 | 6 |
| 7 #include "src/contexts.h" |
7 #include "src/handles-inl.h" | 8 #include "src/handles-inl.h" |
8 #include "src/heap/heap.h" | 9 #include "src/heap/heap.h" |
9 #include "src/isolate.h" | 10 #include "src/isolate.h" |
10 #include "src/runtime/runtime-utils.h" | 11 #include "src/runtime/runtime-utils.h" |
11 | 12 |
12 namespace v8 { | 13 namespace v8 { |
13 namespace internal { | 14 namespace internal { |
14 | 15 |
15 // Header of runtime functions. | 16 // Header of runtime functions. |
16 #define F(name, number_of_args, result_size) \ | 17 #define F(name, number_of_args, result_size) \ |
17 Object* Runtime_##name(int args_length, Object** args_object, \ | 18 Object* Runtime_##name(int args_length, Object** args_object, \ |
18 Isolate* isolate); | 19 Isolate* isolate); |
19 FOR_EACH_INTRINSIC_RETURN_OBJECT(F) | 20 FOR_EACH_INTRINSIC_RETURN_OBJECT(F) |
20 #undef F | 21 #undef F |
21 | 22 |
22 #define P(name, number_of_args, result_size) \ | 23 #define P(name, number_of_args, result_size) \ |
23 ObjectPair Runtime_##name(int args_length, Object** args_object, \ | 24 ObjectPair Runtime_##name(int args_length, Object** args_object, \ |
24 Isolate* isolate); | 25 Isolate* isolate); |
25 FOR_EACH_INTRINSIC_RETURN_PAIR(P) | 26 FOR_EACH_INTRINSIC_RETURN_PAIR(P) |
26 #undef P | 27 #undef P |
27 | 28 |
28 | 29 |
29 #define F(name, number_of_args, result_size) \ | 30 #define F(name, number_of_args, result_size) \ |
30 { \ | 31 { \ |
31 Runtime::k##name, Runtime::RUNTIME, #name, FUNCTION_ADDR(Runtime_##name), \ | 32 Runtime::k##name, Runtime::RUNTIME, #name, \ |
32 number_of_args, result_size \ | 33 {FUNCTION_ADDR(Runtime_##name)}, number_of_args, result_size \ |
33 } \ | 34 } \ |
34 , | 35 , |
35 | 36 |
36 | 37 |
37 #define I(name, number_of_args, result_size) \ | 38 #define I(name, number_of_args, result_size) \ |
38 { \ | 39 { \ |
39 Runtime::kInline##name, Runtime::INLINE, "_" #name, \ | 40 Runtime::kInline##name, Runtime::INLINE, "_" #name, \ |
40 FUNCTION_ADDR(Runtime_##name), number_of_args, result_size \ | 41 {FUNCTION_ADDR(Runtime_##name)}, number_of_args, result_size \ |
41 } \ | 42 } \ |
42 , | 43 , |
43 | 44 |
| 45 #define C(index, type, name) \ |
| 46 { \ |
| 47 Runtime::kContext_##name, Runtime::CONTEXT, #name, \ |
| 48 {reinterpret_cast<Address>(Context::index)}, -1, 0 \ |
| 49 } \ |
| 50 , |
44 | 51 |
45 static const Runtime::Function kIntrinsicFunctions[] = { | 52 static const Runtime::Function kIntrinsicFunctions[] = { |
46 FOR_EACH_INTRINSIC(F) FOR_EACH_INTRINSIC(I)}; | 53 FOR_EACH_INTRINSIC(F) |
| 54 FOR_EACH_INTRINSIC(I) |
| 55 NATIVE_CONTEXT_IMPORTED_FIELDS(C) |
| 56 }; |
47 | 57 |
| 58 #undef C |
48 #undef I | 59 #undef I |
49 #undef F | 60 #undef F |
50 | 61 |
51 | 62 |
52 void Runtime::InitializeIntrinsicFunctionNames(Isolate* isolate, | 63 void Runtime::InitializeIntrinsicFunctionNames(Isolate* isolate, |
53 Handle<NameDictionary> dict) { | 64 Handle<NameDictionary> dict) { |
54 DCHECK(dict->NumberOfElements() == 0); | 65 DCHECK(dict->NumberOfElements() == 0); |
55 HandleScope scope(isolate); | 66 HandleScope scope(isolate); |
56 for (int i = 0; i < kNumFunctions; ++i) { | 67 for (int i = 0; i < kNumFunctions; ++i) { |
57 const char* name = kIntrinsicFunctions[i].name; | 68 const char* name = kIntrinsicFunctions[i].name; |
(...skipping 14 matching lines...) Expand all Loading... |
72 Object* smi_index = heap->intrinsic_function_names()->ValueAt(entry); | 83 Object* smi_index = heap->intrinsic_function_names()->ValueAt(entry); |
73 int function_index = Smi::cast(smi_index)->value(); | 84 int function_index = Smi::cast(smi_index)->value(); |
74 return &(kIntrinsicFunctions[function_index]); | 85 return &(kIntrinsicFunctions[function_index]); |
75 } | 86 } |
76 return NULL; | 87 return NULL; |
77 } | 88 } |
78 | 89 |
79 | 90 |
80 const Runtime::Function* Runtime::FunctionForEntry(Address entry) { | 91 const Runtime::Function* Runtime::FunctionForEntry(Address entry) { |
81 for (size_t i = 0; i < arraysize(kIntrinsicFunctions); ++i) { | 92 for (size_t i = 0; i < arraysize(kIntrinsicFunctions); ++i) { |
82 if (entry == kIntrinsicFunctions[i].entry) { | 93 if (kIntrinsicFunctions[i].intrinsic_type == RUNTIME && |
| 94 entry == kIntrinsicFunctions[i].entry) { |
83 return &(kIntrinsicFunctions[i]); | 95 return &(kIntrinsicFunctions[i]); |
84 } | 96 } |
85 } | 97 } |
86 return NULL; | 98 return NULL; |
87 } | 99 } |
88 | 100 |
89 | 101 |
90 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { | 102 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { |
91 return &(kIntrinsicFunctions[static_cast<int>(id)]); | 103 return &(kIntrinsicFunctions[static_cast<int>(id)]); |
92 } | 104 } |
93 | 105 |
94 | 106 |
95 std::ostream& operator<<(std::ostream& os, Runtime::FunctionId id) { | 107 std::ostream& operator<<(std::ostream& os, Runtime::FunctionId id) { |
96 return os << Runtime::FunctionForId(id)->name; | 108 return os << Runtime::FunctionForId(id)->name; |
97 } | 109 } |
98 | 110 |
99 } // namespace internal | 111 } // namespace internal |
100 } // namespace v8 | 112 } // namespace v8 |
OLD | NEW |