зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1406041: Add a fast-path for wasm code segment lookup; r=luke
MozReview-Commit-ID: L6LXvOOaNKs --HG-- extra : rebase_source : c6efebdeba448366dd6f8adf740cbc167edadbbd extra : amend_source : 07625d42aaadf3dc2e13176a66ad09bd7d705ea0
This commit is contained in:
Родитель
70a600450d
Коммит
6d0c96ad81
|
@ -11,9 +11,7 @@ function f() {
|
|||
Float32Array,
|
||||
Float64Array ])
|
||||
{
|
||||
for (var len of [ 3, 30, 300, 3000 ]) {
|
||||
// TODO: disabled before follow-up in bug 1406041
|
||||
//for (var len of [ 3, 30, 300, 3000, 30000 ]) {
|
||||
for (var len of [ 3, 30, 300, 3000, 30000 ]) {
|
||||
var arr = new ctor(len);
|
||||
for (var i = 0; i < arr.length; i++)
|
||||
assertEq(arr[i], 0, "index " + i + " of " + ctor.name + " len " + len);
|
||||
|
|
|
@ -1565,6 +1565,9 @@ Simulator::startWasmInterrupt(JitActivation* activation)
|
|||
void
|
||||
Simulator::handleWasmInterrupt()
|
||||
{
|
||||
if (!wasm::CodeExists)
|
||||
return;
|
||||
|
||||
uint8_t* pc = (uint8_t*)get_pc();
|
||||
uint8_t* fp = (uint8_t*)get_register(r11);
|
||||
|
||||
|
@ -1589,6 +1592,8 @@ Simulator::handleWasmInterrupt()
|
|||
bool
|
||||
Simulator::handleWasmFault(int32_t addr, unsigned numBytes)
|
||||
{
|
||||
if (!wasm::CodeExists)
|
||||
return false;
|
||||
if (!cx_->activation() || !cx_->activation()->isJit())
|
||||
return false;
|
||||
JitActivation* act = cx_->activation()->asJit();
|
||||
|
|
|
@ -1637,6 +1637,9 @@ Simulator::startInterrupt(JitActivation* activation)
|
|||
void
|
||||
Simulator::handleWasmInterrupt()
|
||||
{
|
||||
if (!wasm::CodeExists)
|
||||
return;
|
||||
|
||||
void* pc = (void*)get_pc();
|
||||
void* fp = (void*)getRegister(Register::fp);
|
||||
|
||||
|
@ -1663,6 +1666,9 @@ Simulator::handleWasmInterrupt()
|
|||
bool
|
||||
Simulator::handleWasmFault(int32_t addr, unsigned numBytes)
|
||||
{
|
||||
if (!wasm::CodeExists)
|
||||
return false;
|
||||
|
||||
JSContext* cx = TlsContext.get();
|
||||
if (!cx->activation() || !cx->activation()->isJit())
|
||||
return false;
|
||||
|
|
|
@ -38,6 +38,8 @@ using mozilla::BinarySearchIf;
|
|||
|
||||
typedef Vector<const CodeSegment*, 0, SystemAllocPolicy> CodeSegmentVector;
|
||||
|
||||
Atomic<bool> wasm::CodeExists(false);
|
||||
|
||||
class ProcessCodeSegmentMap
|
||||
{
|
||||
// Since writes (insertions or removals) can happen on any background
|
||||
|
@ -134,6 +136,8 @@ class ProcessCodeSegmentMap
|
|||
if (!mutableCodeSegments_->insert(mutableCodeSegments_->begin() + index, cs))
|
||||
return false;
|
||||
|
||||
CodeExists = true;
|
||||
|
||||
swapAndWait();
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -163,6 +167,9 @@ class ProcessCodeSegmentMap
|
|||
|
||||
mutableCodeSegments_->erase(mutableCodeSegments_->begin() + index);
|
||||
|
||||
if (!mutableCodeSegments_->length())
|
||||
CodeExists = false;
|
||||
|
||||
swapAndWait();
|
||||
|
||||
#ifdef DEBUG
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
#ifndef wasm_process_h
|
||||
#define wasm_process_h
|
||||
|
||||
#include "mozilla/Atomics.h"
|
||||
|
||||
namespace js {
|
||||
namespace wasm {
|
||||
|
||||
|
@ -35,6 +37,11 @@ LookupCodeSegment(const void* pc);
|
|||
const Code*
|
||||
LookupCode(const void* pc);
|
||||
|
||||
// A bool member that can be used as a very fast lookup to know if there is any
|
||||
// code segment at all.
|
||||
|
||||
extern mozilla::Atomic<bool> CodeExists;
|
||||
|
||||
// These methods allow to (un)register CodeSegments so they can be looked up
|
||||
// via pc in the methods described above.
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче