| 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 25 matching lines...) Expand all Loading... |
| 36 v8::ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE, false); | 36 v8::ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE, false); |
| 37 return isolate->factory()->NewFunctionFromSharedFunctionInfo( | 37 return isolate->factory()->NewFunctionFromSharedFunctionInfo( |
| 38 shared, isolate->native_context()); | 38 shared, 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, function); |
| 47 CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info); | 47 CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info); |
| 48 CHECK(descriptor); | 48 CHECK(descriptor); |
| 49 } | 49 } |
| 50 | 50 |
| 51 | 51 |
| 52 TEST(TestLinkageJSFunctionIncoming) { | 52 TEST(TestLinkageJSFunctionIncoming) { |
| 53 const char* sources[] = {"(function() { })", "(function(a) { })", | 53 const char* sources[] = {"(function() { })", "(function(a) { })", |
| 54 "(function(a,b) { })", "(function(a,b,c) { })"}; | 54 "(function(a,b) { })", "(function(a,b,c) { })"}; |
| 55 | 55 |
| 56 for (int i = 0; i < 3; i++) { | 56 for (int i = 0; i < 3; i++) { |
| 57 HandleAndZoneScope handles; | 57 HandleAndZoneScope handles; |
| 58 Handle<JSFunction> function = | 58 Handle<JSFunction> function = |
| 59 Handle<JSFunction>::cast(v8::Utils::OpenHandle( | 59 Handle<JSFunction>::cast(v8::Utils::OpenHandle( |
| 60 *v8::Local<v8::Function>::Cast(CompileRun(sources[i])))); | 60 *v8::Local<v8::Function>::Cast(CompileRun(sources[i])))); |
| 61 ParseInfo parse_info(handles.main_zone(), function); | 61 ParseInfo parse_info(handles.main_zone(), function); |
| 62 CompilationInfo info(&parse_info); | 62 CompilationInfo info(&parse_info, function); |
| 63 CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info); | 63 CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info); |
| 64 CHECK(descriptor); | 64 CHECK(descriptor); |
| 65 | 65 |
| 66 CHECK_EQ(1 + i, static_cast<int>(descriptor->JSParameterCount())); | 66 CHECK_EQ(1 + i, static_cast<int>(descriptor->JSParameterCount())); |
| 67 CHECK_EQ(1, static_cast<int>(descriptor->ReturnCount())); | 67 CHECK_EQ(1, static_cast<int>(descriptor->ReturnCount())); |
| 68 CHECK_EQ(Operator::kNoProperties, descriptor->properties()); | 68 CHECK_EQ(Operator::kNoProperties, descriptor->properties()); |
| 69 CHECK_EQ(true, descriptor->IsJSFunctionCall()); | 69 CHECK_EQ(true, descriptor->IsJSFunctionCall()); |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 | 72 |
| 73 | 73 |
| 74 TEST(TestLinkageJSCall) { | 74 TEST(TestLinkageJSCall) { |
| 75 HandleAndZoneScope handles; | 75 HandleAndZoneScope handles; |
| 76 Handle<JSFunction> function = Compile("a + c"); | 76 Handle<JSFunction> function = Compile("a + c"); |
| 77 ParseInfo parse_info(handles.main_zone(), function); | 77 ParseInfo parse_info(handles.main_zone(), function); |
| 78 CompilationInfo info(&parse_info); | 78 CompilationInfo info(&parse_info, function); |
| 79 | 79 |
| 80 for (int i = 0; i < 32; i++) { | 80 for (int i = 0; i < 32; i++) { |
| 81 CallDescriptor* descriptor = Linkage::GetJSCallDescriptor( | 81 CallDescriptor* descriptor = Linkage::GetJSCallDescriptor( |
| 82 info.zone(), false, i, CallDescriptor::kNoFlags); | 82 info.zone(), false, i, CallDescriptor::kNoFlags); |
| 83 CHECK(descriptor); | 83 CHECK(descriptor); |
| 84 CHECK_EQ(i, static_cast<int>(descriptor->JSParameterCount())); | 84 CHECK_EQ(i, static_cast<int>(descriptor->JSParameterCount())); |
| 85 CHECK_EQ(1, static_cast<int>(descriptor->ReturnCount())); | 85 CHECK_EQ(1, static_cast<int>(descriptor->ReturnCount())); |
| 86 CHECK_EQ(Operator::kNoProperties, descriptor->properties()); | 86 CHECK_EQ(Operator::kNoProperties, descriptor->properties()); |
| 87 CHECK_EQ(true, descriptor->IsJSFunctionCall()); | 87 CHECK_EQ(true, descriptor->IsJSFunctionCall()); |
| 88 } | 88 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 108 CHECK_EQ(0, static_cast<int>(descriptor->StackParameterCount())); | 108 CHECK_EQ(0, static_cast<int>(descriptor->StackParameterCount())); |
| 109 CHECK_EQ(1, static_cast<int>(descriptor->ReturnCount())); | 109 CHECK_EQ(1, static_cast<int>(descriptor->ReturnCount())); |
| 110 CHECK_EQ(Operator::kNoProperties, descriptor->properties()); | 110 CHECK_EQ(Operator::kNoProperties, descriptor->properties()); |
| 111 CHECK_EQ(false, descriptor->IsJSFunctionCall()); | 111 CHECK_EQ(false, descriptor->IsJSFunctionCall()); |
| 112 // TODO(titzer): test linkage creation for outgoing stub calls. | 112 // TODO(titzer): test linkage creation for outgoing stub calls. |
| 113 } | 113 } |
| 114 | 114 |
| 115 } // namespace compiler | 115 } // namespace compiler |
| 116 } // namespace internal | 116 } // namespace internal |
| 117 } // namespace v8 | 117 } // namespace v8 |
| OLD | NEW |