1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- 2 * vim: set ts=8 sts=4 et sw=4 tw=99: 3 * 4 * Copyright 2016 Mozilla Foundation 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 #ifndef asmjs_wasm_baseline_compile_h 20 #define asmjs_wasm_baseline_compile_h 21 22 #include "wasm/WasmGenerator.h" 23 24 namespace js { 25 namespace wasm { 26 27 // Return whether BaselineCompileFunction can generate code on the current 28 // device. Note: asm.js is also currently not supported due to Atomics and SIMD. 29 bool BaselineCanCompile(); 30 31 // Generate adequate code quickly. 32 MOZ_MUST_USE bool BaselineCompileFunctions(const ModuleEnvironment& env, 33 LifoAlloc& lifo, 34 const FuncCompileInputVector& inputs, 35 CompiledCode* code, 36 UniqueChars* error); 37 38 class BaseLocalIter { 39 private: 40 using ConstValTypeRange = mozilla::Range<const ValType>; 41 42 const ValTypeVector& locals_; 43 size_t argsLength_; 44 ConstValTypeRange argsRange_; // range struct cache for ABIArgIter 45 jit::ABIArgIter<ConstValTypeRange> argsIter_; 46 size_t index_; 47 int32_t localSize_; 48 int32_t reservedSize_; 49 int32_t frameOffset_; 50 jit::MIRType mirType_; 51 bool done_; 52 53 void settle(); 54 int32_t pushLocal(size_t nbytes); 55 56 public: 57 BaseLocalIter(const ValTypeVector& locals, size_t argsLength, 58 bool debugEnabled); 59 void operator++(int); done()60 bool done() const { return done_; } 61 mirType()62 jit::MIRType mirType() const { 63 MOZ_ASSERT(!done_); 64 return mirType_; 65 } frameOffset()66 int32_t frameOffset() const { 67 MOZ_ASSERT(!done_); 68 return frameOffset_; 69 } index()70 size_t index() const { 71 MOZ_ASSERT(!done_); 72 return index_; 73 } currentLocalSize()74 int32_t currentLocalSize() const { return localSize_; } reservedSize()75 int32_t reservedSize() const { return reservedSize_; } 76 77 #ifdef DEBUG isArg()78 bool isArg() const { 79 MOZ_ASSERT(!done_); 80 return !argsIter_.done(); 81 } 82 #endif 83 }; 84 85 } // namespace wasm 86 } // namespace js 87 88 #endif // asmjs_wasm_baseline_compile_h 89