OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/code-stubs.h" | 5 #include "src/code-stubs.h" |
6 #include "src/compiler.h" | 6 #include "src/compiler.h" |
7 #include "src/parsing/parser.h" | 7 #include "src/parsing/parser.h" |
8 #include "src/zone.h" | 8 #include "src/zone.h" |
9 | 9 |
10 #include "src/compiler/common-operator.h" | 10 #include "src/compiler/common-operator.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 return isolate->factory()->NewFunctionFromSharedFunctionInfo( | 37 return isolate->factory()->NewFunctionFromSharedFunctionInfo( |
38 shared_function, isolate->native_context()); | 38 shared_function, isolate->native_context()); |
39 } | 39 } |
40 | 40 |
41 | 41 |
42 TEST(TestLinkageCreate) { | 42 TEST(TestLinkageCreate) { |
43 HandleAndZoneScope handles; | 43 HandleAndZoneScope handles; |
44 Handle<JSFunction> function = Compile("a + b"); | 44 Handle<JSFunction> function = Compile("a + b"); |
45 ParseInfo parse_info(handles.main_zone(), function); | 45 ParseInfo parse_info(handles.main_zone(), function); |
46 CompilationInfo info(&parse_info); | 46 CompilationInfo info(&parse_info); |
47 CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info); | 47 const CallDescriptor* descriptor = |
| 48 Linkage::ComputeIncoming(info.zone(), &info); |
48 CHECK(descriptor); | 49 CHECK(descriptor); |
49 } | 50 } |
50 | 51 |
51 | 52 |
52 TEST(TestLinkageJSFunctionIncoming) { | 53 TEST(TestLinkageJSFunctionIncoming) { |
53 const char* sources[] = {"(function() { })", "(function(a) { })", | 54 const char* sources[] = {"(function() { })", "(function(a) { })", |
54 "(function(a,b) { })", "(function(a,b,c) { })"}; | 55 "(function(a,b) { })", "(function(a,b,c) { })"}; |
55 | 56 |
56 for (int i = 0; i < 3; i++) { | 57 for (int i = 0; i < 3; i++) { |
57 HandleAndZoneScope handles; | 58 HandleAndZoneScope handles; |
58 Handle<JSFunction> function = | 59 Handle<JSFunction> function = |
59 Handle<JSFunction>::cast(v8::Utils::OpenHandle( | 60 Handle<JSFunction>::cast(v8::Utils::OpenHandle( |
60 *v8::Local<v8::Function>::Cast(CompileRun(sources[i])))); | 61 *v8::Local<v8::Function>::Cast(CompileRun(sources[i])))); |
61 ParseInfo parse_info(handles.main_zone(), function); | 62 ParseInfo parse_info(handles.main_zone(), function); |
62 CompilationInfo info(&parse_info); | 63 CompilationInfo info(&parse_info); |
63 CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info); | 64 const CallDescriptor* descriptor = |
| 65 Linkage::ComputeIncoming(info.zone(), &info); |
64 CHECK(descriptor); | 66 CHECK(descriptor); |
65 | 67 |
66 CHECK_EQ(1 + i, static_cast<int>(descriptor->JSParameterCount())); | 68 CHECK_EQ(1 + i, static_cast<int>(descriptor->JSParameterCount())); |
67 CHECK_EQ(1, static_cast<int>(descriptor->ReturnCount())); | 69 CHECK_EQ(1, static_cast<int>(descriptor->ReturnCount())); |
68 CHECK_EQ(Operator::kNoProperties, descriptor->properties()); | 70 CHECK_EQ(Operator::kNoProperties, descriptor->properties()); |
69 CHECK_EQ(true, descriptor->IsJSFunctionCall()); | 71 CHECK_EQ(true, descriptor->IsJSFunctionCall()); |
70 } | 72 } |
71 } | 73 } |
72 | 74 |
73 | 75 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 CHECK_EQ(0, static_cast<int>(descriptor->StackParameterCount())); | 110 CHECK_EQ(0, static_cast<int>(descriptor->StackParameterCount())); |
109 CHECK_EQ(1, static_cast<int>(descriptor->ReturnCount())); | 111 CHECK_EQ(1, static_cast<int>(descriptor->ReturnCount())); |
110 CHECK_EQ(Operator::kNoProperties, descriptor->properties()); | 112 CHECK_EQ(Operator::kNoProperties, descriptor->properties()); |
111 CHECK_EQ(false, descriptor->IsJSFunctionCall()); | 113 CHECK_EQ(false, descriptor->IsJSFunctionCall()); |
112 // TODO(titzer): test linkage creation for outgoing stub calls. | 114 // TODO(titzer): test linkage creation for outgoing stub calls. |
113 } | 115 } |
114 | 116 |
115 } // namespace compiler | 117 } // namespace compiler |
116 } // namespace internal | 118 } // namespace internal |
117 } // namespace v8 | 119 } // namespace v8 |
OLD | NEW |