| 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/compiler.h" | 7 #include "src/compiler.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 27 matching lines...) Expand all Loading... |
| 38 v8::ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE); | 38 v8::ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE); |
| 39 return isolate->factory()->NewFunctionFromSharedFunctionInfo( | 39 return isolate->factory()->NewFunctionFromSharedFunctionInfo( |
| 40 shared_function, isolate->native_context()); | 40 shared_function, isolate->native_context()); |
| 41 } | 41 } |
| 42 | 42 |
| 43 | 43 |
| 44 TEST(TestLinkageCreate) { | 44 TEST(TestLinkageCreate) { |
| 45 InitializedHandleScope handles; | 45 InitializedHandleScope handles; |
| 46 Handle<JSFunction> function = Compile("a + b"); | 46 Handle<JSFunction> function = Compile("a + b"); |
| 47 CompilationInfoWithZone info(function); | 47 CompilationInfoWithZone info(function); |
| 48 Linkage linkage(&info); | 48 Linkage linkage(info.zone(), &info); |
| 49 } | 49 } |
| 50 | 50 |
| 51 | 51 |
| 52 TEST(TestLinkageJSFunctionIncoming) { | 52 TEST(TestLinkageJSFunctionIncoming) { |
| 53 InitializedHandleScope handles; | 53 InitializedHandleScope handles; |
| 54 | 54 |
| 55 const char* sources[] = {"(function() { })", "(function(a) { })", | 55 const char* sources[] = {"(function() { })", "(function(a) { })", |
| 56 "(function(a,b) { })", "(function(a,b,c) { })"}; | 56 "(function(a,b) { })", "(function(a,b,c) { })"}; |
| 57 | 57 |
| 58 for (int i = 0; i < 3; i++) { | 58 for (int i = 0; i < 3; i++) { |
| 59 i::HandleScope handles(CcTest::i_isolate()); | 59 i::HandleScope handles(CcTest::i_isolate()); |
| 60 Handle<JSFunction> function = v8::Utils::OpenHandle( | 60 Handle<JSFunction> function = v8::Utils::OpenHandle( |
| 61 *v8::Handle<v8::Function>::Cast(CompileRun(sources[i]))); | 61 *v8::Handle<v8::Function>::Cast(CompileRun(sources[i]))); |
| 62 CompilationInfoWithZone info(function); | 62 CompilationInfoWithZone info(function); |
| 63 Linkage linkage(&info); | 63 Linkage linkage(info.zone(), &info); |
| 64 | 64 |
| 65 CallDescriptor* descriptor = linkage.GetIncomingDescriptor(); | 65 CallDescriptor* descriptor = linkage.GetIncomingDescriptor(); |
| 66 CHECK_NE(NULL, descriptor); | 66 CHECK_NE(NULL, descriptor); |
| 67 | 67 |
| 68 CHECK_EQ(1 + i, descriptor->JSParameterCount()); | 68 CHECK_EQ(1 + i, descriptor->JSParameterCount()); |
| 69 CHECK_EQ(1, descriptor->ReturnCount()); | 69 CHECK_EQ(1, descriptor->ReturnCount()); |
| 70 CHECK_EQ(Operator::kNoProperties, descriptor->properties()); | 70 CHECK_EQ(Operator::kNoProperties, descriptor->properties()); |
| 71 CHECK_EQ(true, descriptor->IsJSFunctionCall()); | 71 CHECK_EQ(true, descriptor->IsJSFunctionCall()); |
| 72 } | 72 } |
| 73 } | 73 } |
| 74 | 74 |
| 75 | 75 |
| 76 TEST(TestLinkageCodeStubIncoming) { | 76 TEST(TestLinkageCodeStubIncoming) { |
| 77 Isolate* isolate = CcTest::InitIsolateOnce(); | 77 Isolate* isolate = CcTest::InitIsolateOnce(); |
| 78 CompilationInfoWithZone info(static_cast<HydrogenCodeStub*>(NULL), isolate); | 78 CompilationInfoWithZone info(static_cast<HydrogenCodeStub*>(NULL), isolate); |
| 79 Linkage linkage(&info); | 79 Linkage linkage(info.zone(), &info); |
| 80 // TODO(titzer): test linkage creation with a bonafide code stub. | 80 // TODO(titzer): test linkage creation with a bonafide code stub. |
| 81 // this just checks current behavior. | 81 // this just checks current behavior. |
| 82 CHECK_EQ(NULL, linkage.GetIncomingDescriptor()); | 82 CHECK_EQ(NULL, linkage.GetIncomingDescriptor()); |
| 83 } | 83 } |
| 84 | 84 |
| 85 | 85 |
| 86 TEST(TestLinkageJSCall) { | 86 TEST(TestLinkageJSCall) { |
| 87 HandleAndZoneScope handles; | 87 HandleAndZoneScope handles; |
| 88 Handle<JSFunction> function = Compile("a + c"); | 88 Handle<JSFunction> function = Compile("a + c"); |
| 89 CompilationInfoWithZone info(function); | 89 CompilationInfoWithZone info(function); |
| 90 Linkage linkage(&info); | 90 Linkage linkage(info.zone(), &info); |
| 91 | 91 |
| 92 for (int i = 0; i < 32; i++) { | 92 for (int i = 0; i < 32; i++) { |
| 93 CallDescriptor* descriptor = linkage.GetJSCallDescriptor(i); | 93 CallDescriptor* descriptor = linkage.GetJSCallDescriptor(i); |
| 94 CHECK_NE(NULL, descriptor); | 94 CHECK_NE(NULL, descriptor); |
| 95 CHECK_EQ(i, descriptor->JSParameterCount()); | 95 CHECK_EQ(i, descriptor->JSParameterCount()); |
| 96 CHECK_EQ(1, descriptor->ReturnCount()); | 96 CHECK_EQ(1, descriptor->ReturnCount()); |
| 97 CHECK_EQ(Operator::kNoProperties, descriptor->properties()); | 97 CHECK_EQ(Operator::kNoProperties, descriptor->properties()); |
| 98 CHECK_EQ(true, descriptor->IsJSFunctionCall()); | 98 CHECK_EQ(true, descriptor->IsJSFunctionCall()); |
| 99 } | 99 } |
| 100 } | 100 } |
| 101 | 101 |
| 102 | 102 |
| 103 TEST(TestLinkageRuntimeCall) { | 103 TEST(TestLinkageRuntimeCall) { |
| 104 // TODO(titzer): test linkage creation for outgoing runtime calls. | 104 // TODO(titzer): test linkage creation for outgoing runtime calls. |
| 105 } | 105 } |
| 106 | 106 |
| 107 | 107 |
| 108 TEST(TestLinkageStubCall) { | 108 TEST(TestLinkageStubCall) { |
| 109 // TODO(titzer): test linkage creation for outgoing stub calls. | 109 // TODO(titzer): test linkage creation for outgoing stub calls. |
| 110 } | 110 } |
| 111 | 111 |
| 112 | 112 |
| 113 #endif // V8_TURBOFAN_TARGET | 113 #endif // V8_TURBOFAN_TARGET |
| OLD | NEW |