| OLD | NEW | 
|---|
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 <stdint.h> | 5 #include <stdint.h> | 
| 6 #include <stdio.h> | 6 #include <stdio.h> | 
| 7 #include <stdlib.h> | 7 #include <stdlib.h> | 
| 8 #include <string.h> | 8 #include <string.h> | 
| 9 | 9 | 
| 10 #include "src/wasm/wasm-macro-gen.h" | 10 #include "src/wasm/wasm-macro-gen.h" | 
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 49 | 49 | 
| 50 | 50 | 
| 51 uint32_t AddJsFunction(TestingModule* module, FunctionSig* sig, | 51 uint32_t AddJsFunction(TestingModule* module, FunctionSig* sig, | 
| 52                        const char* source) { | 52                        const char* source) { | 
| 53   Handle<JSFunction> jsfunc = Handle<JSFunction>::cast(v8::Utils::OpenHandle( | 53   Handle<JSFunction> jsfunc = Handle<JSFunction>::cast(v8::Utils::OpenHandle( | 
| 54       *v8::Local<v8::Function>::Cast(CompileRun(source)))); | 54       *v8::Local<v8::Function>::Cast(CompileRun(source)))); | 
| 55   module->AddFunction(sig, Handle<Code>::null()); | 55   module->AddFunction(sig, Handle<Code>::null()); | 
| 56   uint32_t index = static_cast<uint32_t>(module->module->functions->size() - 1); | 56   uint32_t index = static_cast<uint32_t>(module->module->functions->size() - 1); | 
| 57   Isolate* isolate = CcTest::InitIsolateOnce(); | 57   Isolate* isolate = CcTest::InitIsolateOnce(); | 
| 58   Handle<Code> code = CompileWasmToJSWrapper(isolate, module, jsfunc, index); | 58   Handle<Code> code = CompileWasmToJSWrapper(isolate, module, jsfunc, index); | 
| 59   module->function_code->at(index) = code; | 59   module->instance->function_code->at(index) = code; | 
| 60   return index; | 60   return index; | 
| 61 } | 61 } | 
| 62 | 62 | 
| 63 | 63 | 
| 64 uint32_t AddJSSelector(TestingModule* module, FunctionSig* sig, int which) { | 64 uint32_t AddJSSelector(TestingModule* module, FunctionSig* sig, int which) { | 
| 65   const int kMaxParams = 8; | 65   const int kMaxParams = 8; | 
| 66   static const char* formals[kMaxParams] = { | 66   static const char* formals[kMaxParams] = { | 
| 67       "",        "a",         "a,b",         "a,b,c", | 67       "",        "a",         "a,b",         "a,b,c", | 
| 68       "a,b,c,d", "a,b,c,d,e", "a,b,c,d,e,f", "a,b,c,d,e,f,g", | 68       "a,b,c,d", "a,b,c,d,e", "a,b,c,d,e,f", "a,b,c,d,e,f,g", | 
| 69   }; | 69   }; | 
| 70   CHECK_LT(which, static_cast<int>(sig->parameter_count())); | 70   CHECK_LT(which, static_cast<int>(sig->parameter_count())); | 
| 71   CHECK_LT(static_cast<int>(sig->parameter_count()), kMaxParams); | 71   CHECK_LT(static_cast<int>(sig->parameter_count()), kMaxParams); | 
| 72 | 72 | 
| 73   i::EmbeddedVector<char, 256> source; | 73   i::EmbeddedVector<char, 256> source; | 
| 74   char param = 'a' + which; | 74   char param = 'a' + which; | 
| 75   SNPrintF(source, "(function(%s) { return %c; })", | 75   SNPrintF(source, "(function(%s) { return %c; })", | 
| 76            formals[sig->parameter_count()], param); | 76            formals[sig->parameter_count()], param); | 
| 77 | 77 | 
| 78   return AddJsFunction(module, sig, source.start()); | 78   return AddJsFunction(module, sig, source.start()); | 
| 79 } | 79 } | 
| 80 | 80 | 
| 81 | 81 | 
| 82 Handle<JSFunction> WrapCode(ModuleEnv* module, uint32_t index) { | 82 Handle<JSFunction> WrapCode(ModuleEnv* module, uint32_t index) { | 
| 83   Isolate* isolate = module->module->shared_isolate; | 83   Isolate* isolate = module->module->shared_isolate; | 
| 84   // Wrap the code so it can be called as a JS function. | 84   // Wrap the code so it can be called as a JS function. | 
| 85   Handle<String> name = isolate->factory()->NewStringFromStaticChars("main"); | 85   Handle<String> name = isolate->factory()->NewStringFromStaticChars("main"); | 
| 86   Handle<JSObject> module_object = Handle<JSObject>(0, isolate); | 86   Handle<JSObject> module_object = Handle<JSObject>(0, isolate); | 
| 87   Handle<Code> code = module->function_code->at(index); | 87   Handle<Code> code = module->instance->function_code->at(index); | 
| 88   WasmJs::InstallWasmFunctionMap(isolate, isolate->native_context()); | 88   WasmJs::InstallWasmFunctionMap(isolate, isolate->native_context()); | 
| 89   return compiler::CompileJSToWasmWrapper(isolate, module, name, code, | 89   return compiler::CompileJSToWasmWrapper(isolate, module, name, code, | 
| 90                                           module_object, index); | 90                                           module_object, index); | 
| 91 } | 91 } | 
| 92 | 92 | 
| 93 | 93 | 
| 94 void EXPECT_CALL(double expected, Handle<JSFunction> jsfunc, | 94 void EXPECT_CALL(double expected, Handle<JSFunction> jsfunc, | 
| 95                  Handle<Object>* buffer, int count) { | 95                  Handle<Object>* buffer, int count) { | 
| 96   Isolate* isolate = jsfunc->GetIsolate(); | 96   Isolate* isolate = jsfunc->GetIsolate(); | 
| 97   Handle<Object> global(isolate->context()->global_object(), isolate); | 97   Handle<Object> global(isolate->context()->global_object(), isolate); | 
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 421   RunJSSelectAlignTest(1, 2); | 421   RunJSSelectAlignTest(1, 2); | 
| 422   RunJSSelectAlignTest(1, 3); | 422   RunJSSelectAlignTest(1, 3); | 
| 423 } | 423 } | 
| 424 | 424 | 
| 425 | 425 | 
| 426 TEST(Run_JSSelectAlign_3) { | 426 TEST(Run_JSSelectAlign_3) { | 
| 427   RunJSSelectAlignTest(3, 3); | 427   RunJSSelectAlignTest(3, 3); | 
| 428   RunJSSelectAlignTest(3, 4); | 428   RunJSSelectAlignTest(3, 4); | 
| 429 } | 429 } | 
| 430 #endif | 430 #endif | 
| OLD | NEW | 
|---|