| 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/code-stubs.h" | 7 #include "src/code-stubs.h" |
| 8 #include "src/compiler.h" | 8 #include "src/compiler.h" |
| 9 #include "src/parser.h" |
| 9 #include "src/zone.h" | 10 #include "src/zone.h" |
| 10 | 11 |
| 11 #include "src/compiler/common-operator.h" | 12 #include "src/compiler/common-operator.h" |
| 12 #include "src/compiler/graph.h" | 13 #include "src/compiler/graph.h" |
| 13 #include "src/compiler/linkage.h" | 14 #include "src/compiler/linkage.h" |
| 14 #include "src/compiler/machine-operator.h" | 15 #include "src/compiler/machine-operator.h" |
| 15 #include "src/compiler/node.h" | 16 #include "src/compiler/node.h" |
| 16 #include "src/compiler/operator.h" | 17 #include "src/compiler/operator.h" |
| 17 #include "src/compiler/pipeline.h" | 18 #include "src/compiler/pipeline.h" |
| 18 #include "src/compiler/schedule.h" | 19 #include "src/compiler/schedule.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 35 Handle<SharedFunctionInfo> shared_function = Compiler::CompileScript( | 36 Handle<SharedFunctionInfo> shared_function = Compiler::CompileScript( |
| 36 source_code, Handle<String>(), 0, 0, false, false, Handle<Object>(), | 37 source_code, Handle<String>(), 0, 0, false, false, Handle<Object>(), |
| 37 Handle<Context>(isolate->native_context()), NULL, NULL, | 38 Handle<Context>(isolate->native_context()), NULL, NULL, |
| 38 v8::ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE, false); | 39 v8::ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE, false); |
| 39 return isolate->factory()->NewFunctionFromSharedFunctionInfo( | 40 return isolate->factory()->NewFunctionFromSharedFunctionInfo( |
| 40 shared_function, isolate->native_context()); | 41 shared_function, isolate->native_context()); |
| 41 } | 42 } |
| 42 | 43 |
| 43 | 44 |
| 44 TEST(TestLinkageCreate) { | 45 TEST(TestLinkageCreate) { |
| 45 InitializedHandleScope handles; | 46 HandleAndZoneScope handles; |
| 46 Handle<JSFunction> function = Compile("a + b"); | 47 Handle<JSFunction> function = Compile("a + b"); |
| 47 CompilationInfoWithZone info(function); | 48 ParseInfo parse_info(handles.main_zone(), function); |
| 49 CompilationInfo info(&parse_info); |
| 48 CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info); | 50 CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info); |
| 49 CHECK(descriptor); | 51 CHECK(descriptor); |
| 50 } | 52 } |
| 51 | 53 |
| 52 | 54 |
| 53 TEST(TestLinkageJSFunctionIncoming) { | 55 TEST(TestLinkageJSFunctionIncoming) { |
| 54 InitializedHandleScope handles; | |
| 55 | |
| 56 const char* sources[] = {"(function() { })", "(function(a) { })", | 56 const char* sources[] = {"(function() { })", "(function(a) { })", |
| 57 "(function(a,b) { })", "(function(a,b,c) { })"}; | 57 "(function(a,b) { })", "(function(a,b,c) { })"}; |
| 58 | 58 |
| 59 for (int i = 0; i < 3; i++) { | 59 for (int i = 0; i < 3; i++) { |
| 60 i::HandleScope handles(CcTest::i_isolate()); | 60 HandleAndZoneScope handles; |
| 61 Handle<JSFunction> function = v8::Utils::OpenHandle( | 61 Handle<JSFunction> function = v8::Utils::OpenHandle( |
| 62 *v8::Handle<v8::Function>::Cast(CompileRun(sources[i]))); | 62 *v8::Handle<v8::Function>::Cast(CompileRun(sources[i]))); |
| 63 CompilationInfoWithZone info(function); | 63 ParseInfo parse_info(handles.main_zone(), function); |
| 64 CompilationInfo info(&parse_info); |
| 64 CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info); | 65 CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info); |
| 65 CHECK(descriptor); | 66 CHECK(descriptor); |
| 66 | 67 |
| 67 CHECK_EQ(1 + i, static_cast<int>(descriptor->JSParameterCount())); | 68 CHECK_EQ(1 + i, static_cast<int>(descriptor->JSParameterCount())); |
| 68 CHECK_EQ(1, static_cast<int>(descriptor->ReturnCount())); | 69 CHECK_EQ(1, static_cast<int>(descriptor->ReturnCount())); |
| 69 CHECK_EQ(Operator::kNoProperties, descriptor->properties()); | 70 CHECK_EQ(Operator::kNoProperties, descriptor->properties()); |
| 70 CHECK_EQ(true, descriptor->IsJSFunctionCall()); | 71 CHECK_EQ(true, descriptor->IsJSFunctionCall()); |
| 71 } | 72 } |
| 72 } | 73 } |
| 73 | 74 |
| 74 | 75 |
| 75 TEST(TestLinkageCodeStubIncoming) { | 76 TEST(TestLinkageCodeStubIncoming) { |
| 76 Isolate* isolate = CcTest::InitIsolateOnce(); | 77 Isolate* isolate = CcTest::InitIsolateOnce(); |
| 77 Zone zone; | 78 Zone zone; |
| 78 ToNumberStub stub(isolate); | 79 ToNumberStub stub(isolate); |
| 79 CompilationInfo info(&stub, isolate, &zone); | 80 CompilationInfo info(&stub, isolate, &zone); |
| 80 CallDescriptor* descriptor = Linkage::ComputeIncoming(&zone, &info); | 81 CallDescriptor* descriptor = Linkage::ComputeIncoming(&zone, &info); |
| 81 CHECK(descriptor); | 82 CHECK(descriptor); |
| 82 CHECK_EQ(1, static_cast<int>(descriptor->JSParameterCount())); | 83 CHECK_EQ(1, static_cast<int>(descriptor->JSParameterCount())); |
| 83 CHECK_EQ(1, static_cast<int>(descriptor->ReturnCount())); | 84 CHECK_EQ(1, static_cast<int>(descriptor->ReturnCount())); |
| 84 CHECK_EQ(Operator::kNoProperties, descriptor->properties()); | 85 CHECK_EQ(Operator::kNoProperties, descriptor->properties()); |
| 85 CHECK_EQ(false, descriptor->IsJSFunctionCall()); | 86 CHECK_EQ(false, descriptor->IsJSFunctionCall()); |
| 86 } | 87 } |
| 87 | 88 |
| 88 | 89 |
| 89 TEST(TestLinkageJSCall) { | 90 TEST(TestLinkageJSCall) { |
| 90 HandleAndZoneScope handles; | 91 HandleAndZoneScope handles; |
| 91 Handle<JSFunction> function = Compile("a + c"); | 92 Handle<JSFunction> function = Compile("a + c"); |
| 92 CompilationInfoWithZone info(function); | 93 ParseInfo parse_info(handles.main_zone(), function); |
| 94 CompilationInfo info(&parse_info); |
| 93 | 95 |
| 94 for (int i = 0; i < 32; i++) { | 96 for (int i = 0; i < 32; i++) { |
| 95 CallDescriptor* descriptor = Linkage::GetJSCallDescriptor( | 97 CallDescriptor* descriptor = Linkage::GetJSCallDescriptor( |
| 96 info.zone(), false, i, CallDescriptor::kNoFlags); | 98 info.zone(), false, i, CallDescriptor::kNoFlags); |
| 97 CHECK(descriptor); | 99 CHECK(descriptor); |
| 98 CHECK_EQ(i, static_cast<int>(descriptor->JSParameterCount())); | 100 CHECK_EQ(i, static_cast<int>(descriptor->JSParameterCount())); |
| 99 CHECK_EQ(1, static_cast<int>(descriptor->ReturnCount())); | 101 CHECK_EQ(1, static_cast<int>(descriptor->ReturnCount())); |
| 100 CHECK_EQ(Operator::kNoProperties, descriptor->properties()); | 102 CHECK_EQ(Operator::kNoProperties, descriptor->properties()); |
| 101 CHECK_EQ(true, descriptor->IsJSFunctionCall()); | 103 CHECK_EQ(true, descriptor->IsJSFunctionCall()); |
| 102 } | 104 } |
| 103 } | 105 } |
| 104 | 106 |
| 105 | 107 |
| 106 TEST(TestLinkageRuntimeCall) { | 108 TEST(TestLinkageRuntimeCall) { |
| 107 // TODO(titzer): test linkage creation for outgoing runtime calls. | 109 // TODO(titzer): test linkage creation for outgoing runtime calls. |
| 108 } | 110 } |
| 109 | 111 |
| 110 | 112 |
| 111 TEST(TestLinkageStubCall) { | 113 TEST(TestLinkageStubCall) { |
| 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 | 117 |
| 116 #endif // V8_TURBOFAN_TARGET | 118 #endif // V8_TURBOFAN_TARGET |
| OLD | NEW |