| 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-factory.h" | 5 #include "src/code-factory.h" | 
| 6 #include "src/code-stubs.h" | 6 #include "src/code-stubs.h" | 
| 7 #include "src/compilation-info.h" | 7 #include "src/compilation-info.h" | 
| 8 #include "src/compiler.h" | 8 #include "src/compiler.h" | 
| 9 #include "src/compiler/common-operator.h" | 9 #include "src/compiler/common-operator.h" | 
| 10 #include "src/compiler/graph.h" | 10 #include "src/compiler/graph.h" | 
| (...skipping 26 matching lines...) Expand all  Loading... | 
| 37       v8::ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE); | 37       v8::ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE); | 
| 38   return isolate->factory()->NewFunctionFromSharedFunctionInfo( | 38   return isolate->factory()->NewFunctionFromSharedFunctionInfo( | 
| 39       shared, isolate->native_context()); | 39       shared, isolate->native_context()); | 
| 40 } | 40 } | 
| 41 | 41 | 
| 42 | 42 | 
| 43 TEST(TestLinkageCreate) { | 43 TEST(TestLinkageCreate) { | 
| 44   HandleAndZoneScope handles; | 44   HandleAndZoneScope handles; | 
| 45   Handle<JSFunction> function = Compile("a + b"); | 45   Handle<JSFunction> function = Compile("a + b"); | 
| 46   ParseInfo parse_info(handle(function->shared())); | 46   ParseInfo parse_info(handle(function->shared())); | 
| 47   CompilationInfo info(&parse_info, function); | 47   Zone compile_zone(function->GetIsolate()->allocator(), ZONE_NAME); | 
|  | 48   CompilationInfo info(&compile_zone, &parse_info, function); | 
| 48   CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info); | 49   CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info); | 
| 49   CHECK(descriptor); | 50   CHECK(descriptor); | 
| 50 } | 51 } | 
| 51 | 52 | 
| 52 | 53 | 
| 53 TEST(TestLinkageJSFunctionIncoming) { | 54 TEST(TestLinkageJSFunctionIncoming) { | 
| 54   const char* sources[] = {"(function() { })", "(function(a) { })", | 55   const char* sources[] = {"(function() { })", "(function(a) { })", | 
| 55                            "(function(a,b) { })", "(function(a,b,c) { })"}; | 56                            "(function(a,b) { })", "(function(a,b,c) { })"}; | 
| 56 | 57 | 
| 57   for (int i = 0; i < 3; i++) { | 58   for (int i = 0; i < 3; i++) { | 
| 58     HandleAndZoneScope handles; | 59     HandleAndZoneScope handles; | 
| 59     Handle<JSFunction> function = | 60     Handle<JSFunction> function = | 
| 60         Handle<JSFunction>::cast(v8::Utils::OpenHandle( | 61         Handle<JSFunction>::cast(v8::Utils::OpenHandle( | 
| 61             *v8::Local<v8::Function>::Cast(CompileRun(sources[i])))); | 62             *v8::Local<v8::Function>::Cast(CompileRun(sources[i])))); | 
| 62     ParseInfo parse_info(handle(function->shared())); | 63     ParseInfo parse_info(handle(function->shared())); | 
| 63     CompilationInfo info(&parse_info, function); | 64     Zone compile_zone(function->GetIsolate()->allocator(), ZONE_NAME); | 
|  | 65     CompilationInfo info(&compile_zone, &parse_info, function); | 
| 64     CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info); | 66     CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info); | 
| 65     CHECK(descriptor); | 67     CHECK(descriptor); | 
| 66 | 68 | 
| 67     CHECK_EQ(1 + i, static_cast<int>(descriptor->JSParameterCount())); | 69     CHECK_EQ(1 + i, static_cast<int>(descriptor->JSParameterCount())); | 
| 68     CHECK_EQ(1, static_cast<int>(descriptor->ReturnCount())); | 70     CHECK_EQ(1, static_cast<int>(descriptor->ReturnCount())); | 
| 69     CHECK_EQ(Operator::kNoProperties, descriptor->properties()); | 71     CHECK_EQ(Operator::kNoProperties, descriptor->properties()); | 
| 70     CHECK_EQ(true, descriptor->IsJSFunctionCall()); | 72     CHECK_EQ(true, descriptor->IsJSFunctionCall()); | 
| 71   } | 73   } | 
| 72 } | 74 } | 
| 73 | 75 | 
| 74 | 76 | 
| 75 TEST(TestLinkageJSCall) { | 77 TEST(TestLinkageJSCall) { | 
| 76   HandleAndZoneScope handles; | 78   HandleAndZoneScope handles; | 
| 77   Handle<JSFunction> function = Compile("a + c"); | 79   Handle<JSFunction> function = Compile("a + c"); | 
| 78   ParseInfo parse_info(handle(function->shared())); | 80   ParseInfo parse_info(handle(function->shared())); | 
| 79   CompilationInfo info(&parse_info, function); | 81   Zone compile_zone(function->GetIsolate()->allocator(), ZONE_NAME); | 
|  | 82   CompilationInfo info(&compile_zone, &parse_info, function); | 
| 80 | 83 | 
| 81   for (int i = 0; i < 32; i++) { | 84   for (int i = 0; i < 32; i++) { | 
| 82     CallDescriptor* descriptor = Linkage::GetJSCallDescriptor( | 85     CallDescriptor* descriptor = Linkage::GetJSCallDescriptor( | 
| 83         info.zone(), false, i, CallDescriptor::kNoFlags); | 86         info.zone(), false, i, CallDescriptor::kNoFlags); | 
| 84     CHECK(descriptor); | 87     CHECK(descriptor); | 
| 85     CHECK_EQ(i, static_cast<int>(descriptor->JSParameterCount())); | 88     CHECK_EQ(i, static_cast<int>(descriptor->JSParameterCount())); | 
| 86     CHECK_EQ(1, static_cast<int>(descriptor->ReturnCount())); | 89     CHECK_EQ(1, static_cast<int>(descriptor->ReturnCount())); | 
| 87     CHECK_EQ(Operator::kNoProperties, descriptor->properties()); | 90     CHECK_EQ(Operator::kNoProperties, descriptor->properties()); | 
| 88     CHECK_EQ(true, descriptor->IsJSFunctionCall()); | 91     CHECK_EQ(true, descriptor->IsJSFunctionCall()); | 
| 89   } | 92   } | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
| 108   CHECK_EQ(0, static_cast<int>(descriptor->StackParameterCount())); | 111   CHECK_EQ(0, static_cast<int>(descriptor->StackParameterCount())); | 
| 109   CHECK_EQ(1, static_cast<int>(descriptor->ReturnCount())); | 112   CHECK_EQ(1, static_cast<int>(descriptor->ReturnCount())); | 
| 110   CHECK_EQ(Operator::kNoProperties, descriptor->properties()); | 113   CHECK_EQ(Operator::kNoProperties, descriptor->properties()); | 
| 111   CHECK_EQ(false, descriptor->IsJSFunctionCall()); | 114   CHECK_EQ(false, descriptor->IsJSFunctionCall()); | 
| 112   // TODO(titzer): test linkage creation for outgoing stub calls. | 115   // TODO(titzer): test linkage creation for outgoing stub calls. | 
| 113 } | 116 } | 
| 114 | 117 | 
| 115 }  // namespace compiler | 118 }  // namespace compiler | 
| 116 }  // namespace internal | 119 }  // namespace internal | 
| 117 }  // namespace v8 | 120 }  // namespace v8 | 
| OLD | NEW | 
|---|