Merge mozilla-inbound to mozilla-central. a=merge

This commit is contained in:
Andreea Pavel 2019-03-22 18:44:45 +02:00
Родитель ca2f9536a8 cc4fab743c
Коммит 34af4f6a20
126 изменённых файлов: 1400 добавлений и 1131 удалений

Просмотреть файл

@ -285,6 +285,8 @@ var gSync = {
document.documentElement.removeAttribute("fxa_avatar_badged");
}
this.enableSendTabIfValidTab();
const anchor = document.getElementById("fxa-toolbar-menu-button");
if (anchor.getAttribute("open") == "true") {
PanelUI.hide();
@ -340,6 +342,18 @@ var gSync = {
mainWindowEl.setAttribute("fxastatus", stateValue);
},
enableSendTabIfValidTab() {
// All tabs selected must be sendable for the Send Tab button to be enabled
// on the FxA menu.
let canSendAllURIs = gBrowser.selectedTabs.every(t => this.isSendableURI(t.linkedBrowser.currentURI.spec));
if (canSendAllURIs) {
document.getElementById("PanelUI-fxa-menu-sendtab-button").removeAttribute("disabled");
} else {
document.getElementById("PanelUI-fxa-menu-sendtab-button").setAttribute("disabled", true);
}
},
updatePanelPopup(state) {
let defaultLabel = this.appMenuStatus.getAttribute("defaultlabel");
// The localization string is for the signed in text, but it's the default text as well

Просмотреть файл

@ -57,6 +57,9 @@
# define ASSERT_UNLESS_FUZZING(...) MOZ_ASSERT(false, __VA_ARGS__)
#endif
#define LS_LOG_TEST() MOZ_LOG_TEST(GetLocalStorageLogger(), LogLevel::Info)
#define LS_LOG(_args) MOZ_LOG(GetLocalStorageLogger(), LogLevel::Info, _args)
#if defined(MOZ_WIDGET_ANDROID)
# define LS_MOBILE
#endif
@ -2159,6 +2162,10 @@ class LSRequestBase : public DatastoreOperationBase,
virtual void Cleanup() {}
void LogState();
virtual void LogNestedState() {}
private:
void SendReadyMessage();
@ -2172,9 +2179,9 @@ class LSRequestBase : public DatastoreOperationBase,
// IPDL methods.
void ActorDestroy(ActorDestroyReason aWhy) override;
mozilla::ipc::IPCResult RecvCancel() override;
private:
mozilla::ipc::IPCResult RecvCancel() final;
mozilla::ipc::IPCResult RecvFinish() final;
};
@ -2231,6 +2238,7 @@ class PrepareDatastoreOp : public LSRequestBase, public OpenDirectoryListener {
nsCOMPtr<nsIEventTarget> mMainEventTarget;
RefPtr<PrepareDatastoreOp> mDelayedOp;
RefPtr<DirectoryLock> mPendingDirectoryLock;
RefPtr<DirectoryLock> mDirectoryLock;
RefPtr<Connection> mConnection;
RefPtr<Datastore> mDatastore;
@ -2339,13 +2347,13 @@ class PrepareDatastoreOp : public LSRequestBase, public OpenDirectoryListener {
void CleanupMetadata();
void LogNestedState() override;
NS_DECL_ISUPPORTS_INHERITED
// IPDL overrides.
void ActorDestroy(ActorDestroyReason aWhy) override;
mozilla::ipc::IPCResult RecvCancel() final;
// OpenDirectoryListener overrides.
void DirectoryLockAcquired(DirectoryLock* aLock) override;
@ -2742,8 +2750,6 @@ StaticAutoPtr<ArchivedOriginHashtable> gArchivedOrigins;
// Can only be touched on the Quota Manager I/O thread.
bool gInitializedShadowStorage = false;
LazyLogModule gLogger("LocalStorage");
bool IsOnConnectionThread() {
MOZ_ASSERT(gConnectionThread);
return gConnectionThread->IsOnConnectionThread();
@ -5628,6 +5634,61 @@ void LSRequestBase::Dispatch() {
nsresult LSRequestBase::NestedRun() { return NS_OK; }
void LSRequestBase::LogState() {
AssertIsOnOwningThread();
if (!LS_LOG_TEST()) {
return;
}
LS_LOG(("LSRequestBase [%p]", this));
nsCString state;
switch (mState) {
case State::Initial:
state.AssignLiteral("Initial");
break;
case State::Opening:
state.AssignLiteral("Opening");
break;
case State::Nesting:
state.AssignLiteral("Nesting");
break;
case State::SendingReadyMessage:
state.AssignLiteral("SendingReadyMessage");
break;
case State::WaitingForFinish:
state.AssignLiteral("WaitingForFinish");
break;
case State::SendingResults:
state.AssignLiteral("SendingResults");
break;
case State::Completed:
state.AssignLiteral("Completed");
break;
default:
MOZ_CRASH("Bad state!");
}
LS_LOG((" mState: %s", state.get()));
switch (mState) {
case State::Nesting:
LogNestedState();
break;
default:;
}
}
void LSRequestBase::SendReadyMessage() {
AssertIsOnOwningThread();
MOZ_ASSERT(mState == State::SendingReadyMessage);
@ -5726,46 +5787,7 @@ void LSRequestBase::ActorDestroy(ActorDestroyReason aWhy) {
mozilla::ipc::IPCResult LSRequestBase::RecvCancel() {
AssertIsOnOwningThread();
if (MOZ_LOG_TEST(gLogger, LogLevel::Info)) {
MOZ_LOG(gLogger, LogLevel::Info, ("LSRequestBase::RecvCancel"));
nsCString state;
switch (mState) {
case State::Initial:
state.AssignLiteral("Initial");
break;
case State::Opening:
state.AssignLiteral("Opening");
break;
case State::Nesting:
state.AssignLiteral("Nesting");
break;
case State::SendingReadyMessage:
state.AssignLiteral("SendingReadyMessage");
break;
case State::WaitingForFinish:
state.AssignLiteral("WaitingForFinish");
break;
case State::SendingResults:
state.AssignLiteral("SendingResults");
break;
case State::Completed:
state.AssignLiteral("Completed");
break;
default:
MOZ_CRASH("Bad state!");
}
MOZ_LOG(gLogger, LogLevel::Info, (" mState: %s", state.get()));
}
LogState();
const char* crashOnCancel = PR_GetEnv("LSNG_CRASH_ON_CANCEL");
if (crashOnCancel) {
@ -6066,9 +6088,16 @@ nsresult PrepareDatastoreOp::OpenDirectory() {
MOZ_ASSERT(QuotaManager::Get());
mNestedState = NestedState::DirectoryOpenPending;
QuotaManager::Get()->OpenDirectory(PERSISTENCE_TYPE_DEFAULT, mGroup, mOrigin,
mozilla::dom::quota::Client::LS,
/* aExclusive */ false, this);
RefPtr<DirectoryLock> pendingDirectoryLock =
QuotaManager::Get()->CreateDirectoryLock(PERSISTENCE_TYPE_DEFAULT, mGroup,
mOrigin,
mozilla::dom::quota::Client::LS,
/* aExclusive */ false, this);
MOZ_ASSERT(pendingDirectoryLock);
if (mNestedState == NestedState::DirectoryOpenPending) {
mPendingDirectoryLock = pendingDirectoryLock.forget();
}
mRequestedDirectoryLock = true;
@ -6719,6 +6748,90 @@ void PrepareDatastoreOp::CleanupMetadata() {
}
}
void PrepareDatastoreOp::LogNestedState() {
AssertIsOnOwningThread();
nsCString nestedState;
switch (mNestedState) {
case NestedState::BeforeNesting:
nestedState.AssignLiteral("BeforeNesting");
break;
case NestedState::CheckExistingOperations:
nestedState.AssignLiteral("CheckExistingOperations");
break;
case NestedState::CheckClosingDatastore:
nestedState.AssignLiteral("CheckClosingDatastore");
break;
case NestedState::PreparationPending:
nestedState.AssignLiteral("PreparationPending");
break;
case NestedState::QuotaManagerPending:
nestedState.AssignLiteral("QuotaManagerPending");
break;
case NestedState::DirectoryOpenPending:
nestedState.AssignLiteral("DirectoryOpenPending");
break;
case NestedState::DatabaseWorkOpen:
nestedState.AssignLiteral("DatabaseWorkOpen");
break;
case NestedState::BeginLoadData:
nestedState.AssignLiteral("BeginLoadData");
break;
case NestedState::DatabaseWorkLoadData:
nestedState.AssignLiteral("DatabaseWorkLoadData");
break;
case NestedState::AfterNesting:
nestedState.AssignLiteral("AfterNesting");
break;
default:
MOZ_CRASH("Bad state!");
}
LS_LOG((" mNestedState: %s", nestedState.get()));
switch (mNestedState) {
case NestedState::CheckClosingDatastore: {
for (uint32_t index = gPrepareDatastoreOps->Length(); index > 0;
index--) {
PrepareDatastoreOp* existingOp = (*gPrepareDatastoreOps)[index - 1];
if (existingOp->mDelayedOp == this) {
LS_LOG((" mDelayedBy: [%p]", existingOp));
existingOp->LogState();
break;
}
}
break;
}
case NestedState::DirectoryOpenPending: {
MOZ_ASSERT(mPendingDirectoryLock);
LS_LOG((" mPendingDirectoryLock: [%p]", mPendingDirectoryLock.get()));
mPendingDirectoryLock->LogState();
break;
}
default:;
}
}
NS_IMPL_ISUPPORTS_INHERITED0(PrepareDatastoreOp, LSRequestBase)
void PrepareDatastoreOp::ActorDestroy(ActorDestroyReason aWhy) {
@ -6731,71 +6844,14 @@ void PrepareDatastoreOp::ActorDestroy(ActorDestroyReason aWhy) {
}
}
mozilla::ipc::IPCResult PrepareDatastoreOp::RecvCancel() {
AssertIsOnOwningThread();
if (MOZ_LOG_TEST(gLogger, LogLevel::Info)) {
MOZ_LOG(gLogger, LogLevel::Info, ("PrepareDatastoreOp::RecvCancel"));
nsCString nestedState;
switch (mNestedState) {
case NestedState::BeforeNesting:
nestedState.AssignLiteral("BeforeNesting");
break;
case NestedState::CheckExistingOperations:
nestedState.AssignLiteral("CheckExistingOperations");
break;
case NestedState::CheckClosingDatastore:
nestedState.AssignLiteral("CheckClosingDatastore");
break;
case NestedState::PreparationPending:
nestedState.AssignLiteral("PreparationPending");
break;
case NestedState::QuotaManagerPending:
nestedState.AssignLiteral("QuotaManagerPending");
break;
case NestedState::DirectoryOpenPending:
nestedState.AssignLiteral("DirectoryOpenPending");
break;
case NestedState::DatabaseWorkOpen:
nestedState.AssignLiteral("DatabaseWorkOpen");
break;
case NestedState::BeginLoadData:
nestedState.AssignLiteral("BeginLoadData");
break;
case NestedState::DatabaseWorkLoadData:
nestedState.AssignLiteral("DatabaseWorkLoadData");
break;
case NestedState::AfterNesting:
nestedState.AssignLiteral("AfterNesting");
break;
default:
MOZ_CRASH("Bad state!");
}
MOZ_LOG(gLogger, LogLevel::Info, (" mNestedState: %s", nestedState.get()));
}
return LSRequestBase::RecvCancel();
}
void PrepareDatastoreOp::DirectoryLockAcquired(DirectoryLock* aLock) {
AssertIsOnOwningThread();
MOZ_ASSERT(mState == State::Nesting);
MOZ_ASSERT(mNestedState == NestedState::DirectoryOpenPending);
MOZ_ASSERT(!mDirectoryLock);
mPendingDirectoryLock = nullptr;
if (NS_WARN_IF(QuotaClient::IsShuttingDownOnBackgroundThread()) ||
!MayProceed()) {
MaybeSetFailureCode(NS_ERROR_FAILURE);
@ -6816,6 +6872,8 @@ void PrepareDatastoreOp::DirectoryLockFailed() {
MOZ_ASSERT(mNestedState == NestedState::DirectoryOpenPending);
MOZ_ASSERT(!mDirectoryLock);
mPendingDirectoryLock = nullptr;
MaybeSetFailureCode(NS_ERROR_FAILURE);
FinishNesting();

Просмотреть файл

@ -18,6 +18,7 @@ namespace {
StaticMutex gNextGenLocalStorageMutex;
Atomic<int32_t> gNextGenLocalStorageEnabled(-1);
LazyLogModule gLogger("LocalStorage");
} // namespace
@ -133,5 +134,7 @@ nsresult GenerateOriginKey2(const PrincipalInfo& aPrincipalInfo,
return NS_OK;
}
LogModule* GetLocalStorageLogger() { return gLogger; }
} // namespace dom
} // namespace mozilla

Просмотреть файл

@ -186,6 +186,8 @@
namespace mozilla {
class LogModule;
namespace ipc {
class PrincipalInfo;
@ -238,6 +240,8 @@ nsresult GenerateOriginKey2(const mozilla::ipc::PrincipalInfo& aPrincipalInfo,
nsACString& aOriginAttrSuffix,
nsACString& aOriginKey);
LogModule* GetLocalStorageLogger();
} // namespace dom
} // namespace mozilla

Просмотреть файл

@ -91,6 +91,9 @@
# define ASSERT_UNLESS_FUZZING(...) MOZ_ASSERT(false, __VA_ARGS__)
#endif
#define QM_LOG_TEST() MOZ_LOG_TEST(GetQuotaManagerLogger(), LogLevel::Info)
#define QM_LOG(_args) MOZ_LOG(GetQuotaManagerLogger(), LogLevel::Info, _args)
#define UNKNOWN_FILE_WARNING(_leafName) \
QM_WARNING("Something (%s) in the directory that doesn't belong!", \
NS_ConvertUTF16toUTF8(_leafName).get())
@ -417,6 +420,8 @@ class DirectoryLockImpl final : public DirectoryLock {
NS_INLINE_DECL_REFCOUNTING(DirectoryLockImpl, override)
void LogState() override;
private:
~DirectoryLockImpl();
};
@ -2345,6 +2350,66 @@ void DirectoryLockImpl::NotifyOpenListener() {
mQuotaManager->RemovePendingDirectoryLock(this);
}
void DirectoryLockImpl::LogState() {
AssertIsOnOwningThread();
if (!QM_LOG_TEST()) {
return;
}
QM_LOG(("DirectoryLockImpl [%p]", this));
nsCString persistenceType;
if (mPersistenceType.IsNull()) {
persistenceType.AssignLiteral("null");
} else {
PersistenceTypeToText(mPersistenceType.Value(), persistenceType);
}
QM_LOG((" mPersistenceType: %s", persistenceType.get()));
QM_LOG((" mGroup: %s", mGroup.get()));
nsCString originScope;
if (mOriginScope.IsOrigin()) {
originScope.AssignLiteral("origin:");
originScope.Append(mOriginScope.GetOrigin());
} else if (mOriginScope.IsPrefix()) {
originScope.AssignLiteral("prefix:");
originScope.Append(mOriginScope.GetOriginNoSuffix());
} else if (mOriginScope.IsPattern()) {
originScope.AssignLiteral("pattern:");
// Can't call GetJSONPattern since it only works on the main thread.
} else {
MOZ_ASSERT(mOriginScope.IsNull());
originScope.AssignLiteral("null");
}
QM_LOG((" mOriginScope: %s", originScope.get()));
nsString clientType;
if (mClientType.IsNull()) {
clientType.AssignLiteral("null");
} else {
Client::TypeToText(mClientType.Value(), clientType);
}
QM_LOG((" mClientType: %s", NS_ConvertUTF16toUTF8(clientType).get()));
nsCString blockedOnString;
for (auto blockedOn : mBlockedOn) {
blockedOnString.Append(nsPrintfCString(" [%p]", blockedOn));
}
QM_LOG((" mBlockedOn:%s", blockedOnString.get()));
QM_LOG((" mExclusive: %d", mExclusive));
QM_LOG((" mInternal: %d", mInternal));
QM_LOG((" mInvalidated: %d", mInvalidated));
for (auto blockedOn : mBlockedOn) {
blockedOn->LogState();
}
}
QuotaManager::Observer* QuotaManager::Observer::sInstance = nullptr;
// static
@ -5015,6 +5080,21 @@ nsresult QuotaManager::EnsureStorageIsInitialized() {
return NS_OK;
}
already_AddRefed<DirectoryLock> QuotaManager::CreateDirectoryLock(
PersistenceType aPersistenceType, const nsACString& aGroup,
const nsACString& aOrigin, Client::Type aClientType, bool aExclusive,
OpenDirectoryListener* aOpenListener) {
AssertIsOnOwningThread();
RefPtr<DirectoryLockImpl> lock = CreateDirectoryLock(
Nullable<PersistenceType>(aPersistenceType), aGroup,
OriginScope::FromOrigin(aOrigin), Nullable<Client::Type>(aClientType),
aExclusive, false, aOpenListener);
MOZ_ASSERT(lock);
return lock.forget();
}
void QuotaManager::OpenDirectory(PersistenceType aPersistenceType,
const nsACString& aGroup,
const nsACString& aOrigin,
@ -5022,10 +5102,9 @@ void QuotaManager::OpenDirectory(PersistenceType aPersistenceType,
OpenDirectoryListener* aOpenListener) {
AssertIsOnOwningThread();
RefPtr<DirectoryLockImpl> lock = CreateDirectoryLock(
Nullable<PersistenceType>(aPersistenceType), aGroup,
OriginScope::FromOrigin(aOrigin), Nullable<Client::Type>(aClientType),
aExclusive, false, aOpenListener);
RefPtr<DirectoryLock> lock =
CreateDirectoryLock(aPersistenceType, aGroup, aOrigin, aClientType,
aExclusive, aOpenListener);
MOZ_ASSERT(lock);
}

Просмотреть файл

@ -6,11 +6,23 @@
#include "QuotaCommon.h"
BEGIN_QUOTA_NAMESPACE
namespace mozilla {
namespace dom {
namespace quota {
namespace {
LazyLogModule gLogger("QuotaManager");
} // namespace
#ifdef NIGHTLY_BUILD
NS_NAMED_LITERAL_CSTRING(kInternalError, "internal");
NS_NAMED_LITERAL_CSTRING(kExternalError, "external");
#endif
END_QUOTA_NAMESPACE
LogModule* GetQuotaManagerLogger() { return gLogger; }
} // namespace quota
} // namespace dom
} // namespace mozilla

Просмотреть файл

@ -72,7 +72,12 @@
class nsIEventTarget;
BEGIN_QUOTA_NAMESPACE
namespace mozilla {
class LogModule;
namespace dom {
namespace quota {
// Telemetry keys to indicate types of errors.
#ifdef NIGHTLY_BUILD
@ -113,6 +118,10 @@ bool IsOnIOThread();
void ReportInternalError(const char* aFile, uint32_t aLine, const char* aStr);
END_QUOTA_NAMESPACE
LogModule* GetQuotaManagerLogger();
} // namespace quota
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_quota_quotacommon_h__

Просмотреть файл

@ -61,6 +61,9 @@ class NS_NO_VTABLE RefCountedObject {
class DirectoryLock : public RefCountedObject {
friend class DirectoryLockImpl;
public:
virtual void LogState() = 0;
private:
DirectoryLock() {}
@ -210,6 +213,11 @@ class QuotaManager final : public BackgroundThreadObject {
int64_t* aTimestamp,
bool* aPersisted);
already_AddRefed<DirectoryLock> CreateDirectoryLock(
PersistenceType aPersistenceType, const nsACString& aGroup,
const nsACString& aOrigin, Client::Type aClientType, bool aExclusive,
OpenDirectoryListener* aOpenListener);
// This is the main entry point into the QuotaManager API.
// Any storage API implementation (quota client) that participates in
// centralized quota and storage handling should call this method to get

Просмотреть файл

@ -4078,10 +4078,9 @@ static MOZ_ALWAYS_INLINE ArrayObject* NewArray(
}
AutoSetNewObjectMetadata metadata(cx);
RootedArrayObject arr(
cx, ArrayObject::createArray(
cx, allocKind, GetInitialHeap(newKind, &ArrayObject::class_),
shape, group, length, metadata));
RootedArrayObject arr(cx, ArrayObject::createArray(
cx, allocKind, GetInitialHeap(newKind, group),
shape, group, length, metadata));
if (!arr) {
return nullptr;
}
@ -4169,7 +4168,7 @@ ArrayObject* js::NewDenseFullyAllocatedArrayWithTemplate(
RootedObjectGroup group(cx, templateObject->group());
RootedShape shape(cx, templateObject->as<ArrayObject>().lastProperty());
gc::InitialHeap heap = GetInitialHeap(GenericObject, &ArrayObject::class_);
gc::InitialHeap heap = GetInitialHeap(GenericObject, group);
Rooted<ArrayObject*> arr(
cx, ArrayObject::createArray(cx, allocKind, heap, shape, group, length,
metadata));
@ -4187,10 +4186,11 @@ ArrayObject* js::NewDenseFullyAllocatedArrayWithTemplate(
}
ArrayObject* js::NewDenseCopyOnWriteArray(JSContext* cx,
HandleArrayObject templateObject,
gc::InitialHeap heap) {
HandleArrayObject templateObject) {
MOZ_ASSERT(!gc::IsInsideNursery(templateObject));
gc::InitialHeap heap = GetInitialHeap(GenericObject, templateObject->group());
ArrayObject* arr =
ArrayObject::createCopyOnWriteArray(cx, heap, templateObject);
if (!arr) {

Просмотреть файл

@ -79,8 +79,7 @@ extern ArrayObject* NewDenseFullyAllocatedArrayWithTemplate(
// Create a dense array with the same copy-on-write elements as another object.
extern ArrayObject* NewDenseCopyOnWriteArray(JSContext* cx,
HandleArrayObject templateObject,
gc::InitialHeap heap);
HandleArrayObject templateObject);
extern ArrayObject* NewFullyAllocatedArrayTryUseGroup(
JSContext* cx, HandleObjectGroup group, size_t length,

Просмотреть файл

@ -1552,8 +1552,7 @@ static MOZ_MUST_USE JSObject* ReadableStreamCreateReadResult(
// Step 4: Let obj be ObjectCreate(prototype).
NativeObject* obj;
JS_TRY_VAR_OR_RETURN_NULL(
cx, obj,
NativeObject::createWithTemplate(cx, gc::DefaultHeap, templateObject));
cx, obj, NativeObject::createWithTemplate(cx, templateObject));
// Step 5: Perform CreateDataProperty(obj, "value", value).
obj->setSlot(Realm::IterResultObjectValueSlot, value);

Просмотреть файл

@ -0,0 +1,10 @@
"use strict";
function __f_276() {
this.getNameReallyHard = () => eval("eval('(() => this.name)()')")
}
for (var __v_1377 = 0; __v_1377 < 10000; __v_1377++) {
var __v_1378 = new __f_276();
try {
__v_1376[__getRandomProperty()];
} catch (e) {}
__v_1378.getNameReallyHard()}

Просмотреть файл

@ -177,7 +177,7 @@ var RMWOperation =
(func $ld (param i32) (result ${type})
(${type}.atomic.load${view} ${address}))
(func (export "ld") (param i32) (result i32)
(${type}.eq (call $ld (get_local 0)) ${operand})))`);
(${type}.eq (call $ld (local.get 0)) ${operand})))`);
let mod = new WebAssembly.Module(bin);
let mem = new WebAssembly.Memory({initial: 1, maximum: 1, shared: true});
let ins = new WebAssembly.Instance(mod, {"": {memory: mem}});
@ -204,7 +204,7 @@ var RMWOperation =
(func $_f (param i32) (result ${type})
(${type}.atomic.rmw${view}.${op} ${address} ${operand}))
(func (export "f") (param i32) (result i32)
(${type}.eq (call $_f (get_local 0)) (${type}.const ${expected}))))`);
(${type}.eq (call $_f (local.get 0)) (${type}.const ${expected}))))`);
let mod = new WebAssembly.Module(bin);
let mem = new WebAssembly.Memory({initial: 1, maximum: 1, shared: true});
let ins = new WebAssembly.Instance(mod, {"": {memory: mem}});
@ -230,7 +230,7 @@ var RMWOperation =
(func $_f (param i32) (result ${type})
(${type}.atomic.rmw${view}.cmpxchg ${address} ${operand1} ${operand2}))
(func (export "f") (param i32) (result i32)
(${type}.eq (call $_f (get_local 0)) (${type}.const ${expected}))))`);
(${type}.eq (call $_f (local.get 0)) (${type}.const ${expected}))))`);
let mod = new WebAssembly.Module(bin);
let mem = new WebAssembly.Memory({initial: 1, maximum: 1, shared: true});
let ins = new WebAssembly.Instance(mod, {"": {memory: mem}});
@ -256,7 +256,7 @@ var RMWOperation =
for ( let [TA, view] of variations )
{
for ( let addr of [`(i32.const ${LOC * TA.BYTES_PER_ELEMENT})`,
`(get_local 0)`] )
`(local.get 0)`] )
{
for ( let [initial, operand] of [[0x12, 0x37]] )
{
@ -369,9 +369,9 @@ var BoundsAndAlignment =
`(module
(memory 1 1 shared)
(func $0 (param i32) (result ${type})
(${type}.atomic.load${ext} offset=${offset} (get_local 0)))
(${type}.atomic.load${ext} offset=${offset} (local.get 0)))
(func (export "f") (param i32)
(drop (call $0 (get_local 0)))))
(drop (call $0 (local.get 0)))))
`).exports.f;
},
@ -380,7 +380,7 @@ var BoundsAndAlignment =
`(module
(memory 1 1 shared)
(func (export "f") (param i32)
(drop (${type}.atomic.load${ext} offset=${offset} (get_local 0)))))
(drop (${type}.atomic.load${ext} offset=${offset} (local.get 0)))))
`).exports.f;
},
@ -389,7 +389,7 @@ var BoundsAndAlignment =
`(module
(memory 1 1 shared)
(func (export "f") (param i32)
(${type}.atomic.store${ext} offset=${offset} (get_local 0) (${type}.const 37))))
(${type}.atomic.store${ext} offset=${offset} (local.get 0) (${type}.const 37))))
`).exports.f;
},
@ -398,9 +398,9 @@ var BoundsAndAlignment =
`(module
(memory 1 1 shared)
(func $0 (param i32) (result ${type})
(${type}.atomic.rmw${ext}.${op} offset=${offset} (get_local 0) (${type}.const 37)))
(${type}.atomic.rmw${ext}.${op} offset=${offset} (local.get 0) (${type}.const 37)))
(func (export "f") (param i32)
(drop (call $0 (get_local 0)))))
(drop (call $0 (local.get 0)))))
`).exports.f;
},
@ -409,7 +409,7 @@ var BoundsAndAlignment =
`(module
(memory 1 1 shared)
(func (export "f") (param i32)
(drop (${type}.atomic.rmw${ext}.${op} offset=${offset} (get_local 0) (${type}.const 37)))))
(drop (${type}.atomic.rmw${ext}.${op} offset=${offset} (local.get 0) (${type}.const 37)))))
`).exports.f;
},
@ -418,9 +418,9 @@ var BoundsAndAlignment =
`(module
(memory 1 1 shared)
(func $0 (param i32) (result ${type})
(${type}.atomic.rmw${ext}.cmpxchg offset=${offset} (get_local 0) (${type}.const 37) (${type}.const 42)))
(${type}.atomic.rmw${ext}.cmpxchg offset=${offset} (local.get 0) (${type}.const 37) (${type}.const 42)))
(func (export "f") (param i32)
(drop (call $0 (get_local 0)))))
(drop (call $0 (local.get 0)))))
`).exports.f;
},
@ -471,31 +471,31 @@ BoundsAndAlignment.run();
assertErrorMessage(() => wasmEvalText(`(module (memory 1 1 shared)
(func (param i32) (result i32)
(i32.atomic.wait (get_local 0) (i32.const 1) (i64.const -1)))
(i32.atomic.wait (local.get 0) (i32.const 1) (i64.const -1)))
(export "" 0))`).exports[""](65536),
RuntimeError, oob);
assertErrorMessage(() => wasmEvalText(`(module (memory 1 1 shared)
(func (param i32) (result i32)
(i64.atomic.wait (get_local 0) (i64.const 1) (i64.const -1)))
(i64.atomic.wait (local.get 0) (i64.const 1) (i64.const -1)))
(export "" 0))`).exports[""](65536),
RuntimeError, oob);
assertErrorMessage(() => wasmEvalText(`(module (memory 1 1 shared)
(func (param i32) (result i32)
(i32.atomic.wait (get_local 0) (i32.const 1) (i64.const -1)))
(i32.atomic.wait (local.get 0) (i32.const 1) (i64.const -1)))
(export "" 0))`).exports[""](65501),
RuntimeError, unaligned);
assertErrorMessage(() => wasmEvalText(`(module (memory 1 1 shared)
(func (param i32) (result i32)
(i64.atomic.wait (get_local 0) (i64.const 1) (i64.const -1)))
(i64.atomic.wait (local.get 0) (i64.const 1) (i64.const -1)))
(export "" 0))`).exports[""](65501),
RuntimeError, unaligned);
assertErrorMessage(() => wasmEvalText(`(module (memory 1 1 shared)
(func (param i32) (result i32)
(atomic.notify (get_local 0) (i32.const 1)))
(atomic.notify (local.get 0) (i32.const 1)))
(export "" 0))`).exports[""](65536),
RuntimeError, oob);
@ -503,7 +503,7 @@ assertErrorMessage(() => wasmEvalText(`(module (memory 1 1 shared)
for (let addr of [1,2,3,5,6,7]) {
assertErrorMessage(() => wasmEvalText(`(module (memory 1 1 shared)
(func (export "f") (param i32) (result i32)
(atomic.notify (get_local 0) (i32.const 1))))`).exports.f(addr),
(atomic.notify (local.get 0) (i32.const 1))))`).exports.f(addr),
RuntimeError, unaligned);
}

Просмотреть файл

@ -156,10 +156,10 @@ function makeModule(id) {
let BARRIER = "(i32.const 0)";
let barrier = `
;; Barrier
(set_local $barrierValue (i32.add (get_local $barrierValue) (i32.const ${NUMAGENTS})))
(local.set $barrierValue (i32.add (local.get $barrierValue) (i32.const ${NUMAGENTS})))
(drop (i32.atomic.rmw.add ${BARRIER} (i32.const 1)))
(loop $c1
(if (i32.lt_s (i32.atomic.load ${BARRIER}) (get_local $barrierValue))
(if (i32.lt_s (i32.atomic.load ${BARRIER}) (local.get $barrierValue))
(br $c1)))
;; End barrier
`;
@ -200,9 +200,9 @@ function makeModule(id) {
(func ${name} (param $barrierValue i32) (result i32)
(local $n i32)
(local $tmp ${prefix})
(set_local $n (i32.const ${ITERATIONS}))
(local.set $n (i32.const ${ITERATIONS}))
(loop $outer
(if (get_local $n)
(if (local.get $n)
(block
${isMaster ? `;; Init
(${prefix}.atomic.store${tag} ${loc} (${prefix}.const ${distribute(initial)}))` : ``}
@ -216,11 +216,11 @@ ${(() => {
// we would avoid fences in that case.
if (op.match(/cmpxchg/)) {
s += `(loop $doit
(set_local $tmp (${prefix}.atomic.load${tag} ${loc}))
(local.set $tmp (${prefix}.atomic.load${tag} ${loc}))
(br_if $doit (i32.eqz
(${prefix}.eq
(get_local $tmp)
(${op} ${loc} (get_local $tmp) (${prefix}.or (get_local $tmp) ${bitval}))))))
(local.get $tmp)
(${op} ${loc} (local.get $tmp) (${prefix}.or (local.get $tmp) ${bitval}))))))
`;
} else {
s += `(drop (${op} ${loc} ${bitval}))
@ -232,9 +232,9 @@ ${(() => {
(loop $wait_done
(br_if $wait_done (${prefix}.ne (${prefix}.atomic.load${tag} ${loc}) (${prefix}.const ${distribute(expected)}))))
${barrier}
(set_local $n (i32.sub (get_local $n) (i32.const 1)))
(local.set $n (i32.sub (local.get $n) (i32.const 1)))
(br $outer))))
(get_local $barrierValue))`;
(local.get $barrierValue))`;
}
const ADDLOC = "(i32.const 256)";
@ -303,33 +303,33 @@ ${(() => {
(func (export "test")
(local $barrierValue i32)
(call $print (i32.const ${10 + id}))
(set_local $barrierValue (call $test_add8 (get_local $barrierValue)))
(set_local $barrierValue (call $test_sub8 (get_local $barrierValue)))
(set_local $barrierValue (call $test_and8 (get_local $barrierValue)))
(set_local $barrierValue (call $test_or8 (get_local $barrierValue)))
(set_local $barrierValue (call $test_xor8 (get_local $barrierValue)))
(set_local $barrierValue (call $test_cmpxchg8 (get_local $barrierValue)))
(local.set $barrierValue (call $test_add8 (local.get $barrierValue)))
(local.set $barrierValue (call $test_sub8 (local.get $barrierValue)))
(local.set $barrierValue (call $test_and8 (local.get $barrierValue)))
(local.set $barrierValue (call $test_or8 (local.get $barrierValue)))
(local.set $barrierValue (call $test_xor8 (local.get $barrierValue)))
(local.set $barrierValue (call $test_cmpxchg8 (local.get $barrierValue)))
(call $print (i32.const ${20 + id}))
(set_local $barrierValue (call $test_add16 (get_local $barrierValue)))
(set_local $barrierValue (call $test_sub16 (get_local $barrierValue)))
(set_local $barrierValue (call $test_and16 (get_local $barrierValue)))
(set_local $barrierValue (call $test_or16 (get_local $barrierValue)))
(set_local $barrierValue (call $test_xor16 (get_local $barrierValue)))
(set_local $barrierValue (call $test_cmpxchg16 (get_local $barrierValue)))
(local.set $barrierValue (call $test_add16 (local.get $barrierValue)))
(local.set $barrierValue (call $test_sub16 (local.get $barrierValue)))
(local.set $barrierValue (call $test_and16 (local.get $barrierValue)))
(local.set $barrierValue (call $test_or16 (local.get $barrierValue)))
(local.set $barrierValue (call $test_xor16 (local.get $barrierValue)))
(local.set $barrierValue (call $test_cmpxchg16 (local.get $barrierValue)))
(call $print (i32.const ${30 + id}))
(set_local $barrierValue (call $test_add (get_local $barrierValue)))
(set_local $barrierValue (call $test_sub (get_local $barrierValue)))
(set_local $barrierValue (call $test_and (get_local $barrierValue)))
(set_local $barrierValue (call $test_or (get_local $barrierValue)))
(set_local $barrierValue (call $test_xor (get_local $barrierValue)))
(set_local $barrierValue (call $test_cmpxchg (get_local $barrierValue)))
(local.set $barrierValue (call $test_add (local.get $barrierValue)))
(local.set $barrierValue (call $test_sub (local.get $barrierValue)))
(local.set $barrierValue (call $test_and (local.get $barrierValue)))
(local.set $barrierValue (call $test_or (local.get $barrierValue)))
(local.set $barrierValue (call $test_xor (local.get $barrierValue)))
(local.set $barrierValue (call $test_cmpxchg (local.get $barrierValue)))
(call $print (i32.const ${40 + id}))
(set_local $barrierValue (call $test_add64 (get_local $barrierValue)))
(set_local $barrierValue (call $test_sub64 (get_local $barrierValue)))
(set_local $barrierValue (call $test_and64 (get_local $barrierValue)))
(set_local $barrierValue (call $test_or64 (get_local $barrierValue)))
(set_local $barrierValue (call $test_xor64 (get_local $barrierValue)))
(set_local $barrierValue (call $test_cmpxchg64 (get_local $barrierValue)))
(local.set $barrierValue (call $test_add64 (local.get $barrierValue)))
(local.set $barrierValue (call $test_sub64 (local.get $barrierValue)))
(local.set $barrierValue (call $test_and64 (local.get $barrierValue)))
(local.set $barrierValue (call $test_or64 (local.get $barrierValue)))
(local.set $barrierValue (call $test_xor64 (local.get $barrierValue)))
(local.set $barrierValue (call $test_cmpxchg64 (local.get $barrierValue)))
))
`;
}

Просмотреть файл

@ -15,12 +15,12 @@ function testEqzBrIf(value, type, untaken, taken, expected) {
(func (result i32)
(local ${type})
(local i32)
(set_local 0 (${type}.const ${value}))
(set_local 1 (i32.const ${taken}))
(local.set 0 (${type}.const ${value}))
(local.set 1 (i32.const ${taken}))
(block $b
(br_if $b (${type}.eqz (get_local 0)))
(set_local 1 (i32.const ${untaken})))
(get_local 1))
(br_if $b (${type}.eqz (local.get 0)))
(local.set 1 (i32.const ${untaken})))
(local.get 1))
(export "f" 0))`).exports["f"];
assertEq(f(), expected);
}
@ -33,11 +33,11 @@ function testCmpBrIf(value, type, untaken, taken, expected) {
(func (result i32)
(local ${type})
(local i32)
(set_local 1 (i32.const ${taken}))
(local.set 1 (i32.const ${taken}))
(block $b
(br_if $b (${type}.eq (get_local 0) (${type}.const ${value})))
(set_local 1 (i32.const ${untaken})))
(get_local 1))
(br_if $b (${type}.eq (local.get 0) (${type}.const ${value})))
(local.set 1 (i32.const ${untaken})))
(local.get 1))
(export "f" 0))`).exports["f"];
assertEq(f(), expected);
}
@ -49,10 +49,10 @@ function testEqzSelect(value, type, iftrue, iffalse, expected) {
var f = wasmEvalText(`(module
(func (result i32)
(local ${type})
(set_local 0 (${type}.const ${value}))
(local.set 0 (${type}.const ${value}))
(select (i32.const ${iftrue})
(i32.const ${iffalse})
(${type}.eqz (get_local 0))))
(${type}.eqz (local.get 0))))
(export "f" 0))`).exports["f"];
assertEq(f(), expected);
}
@ -66,7 +66,7 @@ function testCmpSelect(value, type, iftrue, iffalse, expected) {
(local ${type})
(select (i32.const ${iftrue})
(i32.const ${iffalse})
(${type}.eq (get_local 0) (${type}.const ${value}))))
(${type}.eq (local.get 0) (${type}.const ${value}))))
(export "f" 0))`).exports["f"];
assertEq(f(), expected);
}
@ -79,11 +79,11 @@ function testEqzIf(value, type, trueBranch, falseBranch, expected) {
(func (result i32)
(local ${type})
(local i32)
(set_local 0 (${type}.const ${value}))
(if (${type}.eqz (get_local 0))
(set_local 1 (i32.const ${trueBranch}))
(set_local 1 (i32.const ${falseBranch})))
(get_local 1))
(local.set 0 (${type}.const ${value}))
(if (${type}.eqz (local.get 0))
(local.set 1 (i32.const ${trueBranch}))
(local.set 1 (i32.const ${falseBranch})))
(local.get 1))
(export "f" 0))`).exports["f"];
assertEq(f(), expected);
}
@ -96,10 +96,10 @@ function testCmpIf(value, type, trueBranch, falseBranch, expected) {
(func (result i32)
(local ${type})
(local i32)
(if (${type}.eq (get_local 0) (${type}.const ${value}))
(set_local 1 (i32.const ${trueBranch}))
(set_local 1 (i32.const ${falseBranch})))
(get_local 1))
(if (${type}.eq (local.get 0) (${type}.const ${value}))
(local.set 1 (i32.const ${trueBranch}))
(local.set 1 (i32.const ${falseBranch})))
(local.get 1))
(export "f" 0))`).exports["f"];
assertEq(f(), expected);
}

Просмотреть файл

@ -82,7 +82,7 @@ wasmFullPassI64('(module (func $run (param i64) (result i64) (local.get 0)))',
'0x123400007fffffff',
{},
'(i64.const 0x123400007fffffff)');
wasmFullPassI64('(module (func $run (param i64) (result i64) (i64.add (get_local 0) (i64.const 1))))',
wasmFullPassI64('(module (func $run (param i64) (result i64) (i64.add (local.get 0) (i64.const 1))))',
'0x1234000100000000',
{},
'(i64.const 0x12340000ffffffff)');
@ -175,41 +175,41 @@ assertEq(new Uint8Array(buf)[65535], 'c'.charCodeAt(0));
// ----------------------------------------------------------------------------
// locals
assertEq(wasmEvalText('(module (func (param i32) (result i32) (get_local 0)) (export "" 0))').exports[""](), 0);
assertEq(wasmEvalText('(module (func (param i32) (result i32) (get_local 0)) (export "" 0))').exports[""](42), 42);
assertEq(wasmEvalText('(module (func (param i32) (param i32) (result i32) (get_local 0)) (export "" 0))').exports[""](42, 43), 42);
assertEq(wasmEvalText('(module (func (param i32) (param i32) (result i32) (get_local 1)) (export "" 0))').exports[""](42, 43), 43);
assertEq(wasmEvalText('(module (func (param i32) (result i32) (local.get 0)) (export "" 0))').exports[""](), 0);
assertEq(wasmEvalText('(module (func (param i32) (result i32) (local.get 0)) (export "" 0))').exports[""](42), 42);
assertEq(wasmEvalText('(module (func (param i32) (param i32) (result i32) (local.get 0)) (export "" 0))').exports[""](42, 43), 42);
assertEq(wasmEvalText('(module (func (param i32) (param i32) (result i32) (local.get 1)) (export "" 0))').exports[""](42, 43), 43);
wasmFailValidateText('(module (func (get_local 0)))', /local.get index out of range/);
wasmFailValidateText('(module (func (result f32) (local i32) (get_local 0)))', mismatchError("i32", "f32"));
wasmFailValidateText('(module (func (result i32) (local f32) (get_local 0)))', mismatchError("f32", "i32"));
wasmFailValidateText('(module (func (result f32) (param i32) (local f32) (get_local 0)))', mismatchError("i32", "f32"));
wasmFailValidateText('(module (func (result i32) (param i32) (local f32) (get_local 1)))', mismatchError("f32", "i32"));
wasmFailValidateText('(module (func (local.get 0)))', /local.get index out of range/);
wasmFailValidateText('(module (func (result f32) (local i32) (local.get 0)))', mismatchError("i32", "f32"));
wasmFailValidateText('(module (func (result i32) (local f32) (local.get 0)))', mismatchError("f32", "i32"));
wasmFailValidateText('(module (func (result f32) (param i32) (local f32) (local.get 0)))', mismatchError("i32", "f32"));
wasmFailValidateText('(module (func (result i32) (param i32) (local f32) (local.get 1)))', mismatchError("f32", "i32"));
wasmValidateText('(module (func (local i32)))');
wasmValidateText('(module (func (local i32) (local f32)))');
wasmFullPass('(module (func (result i32) (local i32) (get_local 0)) (export "run" 0))', 0);
wasmFullPass('(module (func (result i32) (param i32) (local f32) (get_local 0)) (export "run" 0))', 0);
wasmFullPass('(module (func (result f32) (param i32) (local f32) (get_local 1)) (export "run" 0))', 0);
wasmFullPass('(module (func (result i32) (local i32) (local.get 0)) (export "run" 0))', 0);
wasmFullPass('(module (func (result i32) (param i32) (local f32) (local.get 0)) (export "run" 0))', 0);
wasmFullPass('(module (func (result f32) (param i32) (local f32) (local.get 1)) (export "run" 0))', 0);
wasmFailValidateText('(module (func (local.set 0 (i32.const 0))))', /local.set index out of range/);
wasmFailValidateText('(module (func (local f32) (set_local 0 (i32.const 0))))', mismatchError("i32", "f32"));
wasmFailValidateText('(module (func (local f32) (set_local 0 (nop))))', emptyStackError);
wasmFailValidateText('(module (func (local i32) (local f32) (set_local 0 (get_local 1))))', mismatchError("f32", "i32"));
wasmFailValidateText('(module (func (local i32) (local f32) (set_local 1 (get_local 0))))', mismatchError("i32", "f32"));
wasmFailValidateText('(module (func (local f32) (local.set 0 (i32.const 0))))', mismatchError("i32", "f32"));
wasmFailValidateText('(module (func (local f32) (local.set 0 (nop))))', emptyStackError);
wasmFailValidateText('(module (func (local i32) (local f32) (local.set 0 (local.get 1))))', mismatchError("f32", "i32"));
wasmFailValidateText('(module (func (local i32) (local f32) (local.set 1 (local.get 0))))', mismatchError("i32", "f32"));
wasmValidateText('(module (func (local i32) (set_local 0 (i32.const 0))))');
wasmValidateText('(module (func (local i32) (local f32) (set_local 0 (get_local 0))))');
wasmValidateText('(module (func (local i32) (local f32) (set_local 1 (get_local 1))))');
wasmValidateText('(module (func (local i32) (local.set 0 (i32.const 0))))');
wasmValidateText('(module (func (local i32) (local f32) (local.set 0 (local.get 0))))');
wasmValidateText('(module (func (local i32) (local f32) (local.set 1 (local.get 1))))');
wasmFullPass('(module (func (result i32) (local i32) (tee_local 0 (i32.const 42))) (export "run" 0))', 42);
wasmFullPass('(module (func (result i32) (local i32) (tee_local 0 (get_local 0))) (export "run" 0))', 0);
wasmFullPass('(module (func (result i32) (local i32) (tee_local 0 (local.get 0))) (export "run" 0))', 0);
wasmFullPass('(module (func (param $a i32) (result i32) (get_local $a)) (export "run" 0))', 0);
wasmFullPass('(module (func (param $a i32) (local $b i32) (result i32) (block i32 (set_local $b (get_local $a)) (get_local $b))) (export "run" 0))', 42, {}, 42);
wasmFullPass('(module (func (param $a i32) (result i32) (local.get $a)) (export "run" 0))', 0);
wasmFullPass('(module (func (param $a i32) (local $b i32) (result i32) (block i32 (local.set $b (local.get $a)) (local.get $b))) (export "run" 0))', 42, {}, 42);
wasmValidateText('(module (func (local i32) (local $a f32) (set_local 0 (i32.const 1)) (set_local $a (f32.const nan))))');
wasmValidateText('(module (func (local i32) (local $a f32) (local.set 0 (i32.const 1)) (local.set $a (f32.const nan))))');
// ----------------------------------------------------------------------------
// blocks
@ -218,7 +218,7 @@ wasmFullPass('(module (func (block )) (export "run" 0))', undefined);
wasmFailValidateText('(module (func (result i32) (block )))', emptyStackError);
wasmFailValidateText('(module (func (result i32) (block (block ))))', emptyStackError);
wasmFailValidateText('(module (func (local i32) (set_local 0 (block ))))', emptyStackError);
wasmFailValidateText('(module (func (local i32) (local.set 0 (block ))))', emptyStackError);
wasmFullPass('(module (func (block (block ))) (export "run" 0))', undefined);
wasmFullPass('(module (func (result i32) (block i32 (i32.const 42))) (export "run" 0))', 42);
@ -226,9 +226,9 @@ wasmFullPass('(module (func (result i32) (block i32 (block i32 (i32.const 42))))
wasmFailValidateText('(module (func (result f32) (block i32 (i32.const 0))))', mismatchError("i32", "f32"));
wasmFullPass('(module (func (result i32) (block i32 (drop (i32.const 13)) (block i32 (i32.const 42)))) (export "run" 0))', 42);
wasmFailValidateText('(module (func (result f32) (param f32) (block i32 (drop (get_local 0)) (i32.const 0))))', mismatchError("i32", "f32"));
wasmFailValidateText('(module (func (result f32) (param f32) (block i32 (drop (local.get 0)) (i32.const 0))))', mismatchError("i32", "f32"));
wasmFullPass('(module (func (result i32) (local i32) (set_local 0 (i32.const 42)) (get_local 0)) (export "run" 0))', 42);
wasmFullPass('(module (func (result i32) (local i32) (local.set 0 (i32.const 42)) (local.get 0)) (export "run" 0))', 42);
// ----------------------------------------------------------------------------
// calls
@ -261,7 +261,7 @@ function checkF32CallImport(v) {
wasmFullPass('(module (import "" "a" (result f32)) (func (result f32) (call 0)) (export "run" 1))',
Math.fround(v),
{"":{a:()=>{ return v; }}});
wasmFullPass('(module (import "" "a" (param f32)) (func (param f32) (call 0 (get_local 0))) (export "run" 1))',
wasmFullPass('(module (import "" "a" (param f32)) (func (param f32) (call 0 (local.get 0))) (export "run" 1))',
undefined,
{"":{a:x=>{ assertEq(Math.fround(v), x); }}},
v);
@ -307,14 +307,14 @@ var {v2i, i2i, i2v} = wasmEvalText(`(module
(type (func (param i32)))
(func (type 0) (i32.const 13))
(func (type 0) (i32.const 42))
(func (type 1) (i32.add (get_local 0) (i32.const 1)))
(func (type 1) (i32.add (get_local 0) (i32.const 2)))
(func (type 1) (i32.add (get_local 0) (i32.const 3)))
(func (type 1) (i32.add (get_local 0) (i32.const 4)))
(func (type 1) (i32.add (local.get 0) (i32.const 1)))
(func (type 1) (i32.add (local.get 0) (i32.const 2)))
(func (type 1) (i32.add (local.get 0) (i32.const 3)))
(func (type 1) (i32.add (local.get 0) (i32.const 4)))
(table funcref (elem 0 1 2 3 4 5))
(func (param i32) (result i32) (call_indirect 0 (get_local 0)))
(func (param i32) (param i32) (result i32) (call_indirect 1 (get_local 1) (get_local 0)))
(func (param i32) (call_indirect 2 (i32.const 0) (get_local 0)))
(func (param i32) (result i32) (call_indirect 0 (local.get 0)))
(func (param i32) (param i32) (result i32) (call_indirect 1 (local.get 1) (local.get 0)))
(func (param i32) (call_indirect 2 (i32.const 0) (local.get 0)))
(export "v2i" 6)
(export "i2i" 7)
(export "i2v" 8)
@ -412,7 +412,7 @@ var f = wasmEvalText(`
(select
(call 0)
(call 1)
(get_local 0)
(local.get 0)
)
)
(export "" 2)
@ -493,7 +493,7 @@ function testSelect(type, trueVal, falseVal) {
(select
(${type}.const ${trueVal})
(${type}.const ${falseVal})
(get_local 0)
(local.get 0)
)
)
(export "" 0)
@ -510,7 +510,7 @@ function testSelect(type, trueVal, falseVal) {
(select
(${type}.const ${trueVal})
(${type}.const ${falseVal})
(get_local 0)
(local.get 0)
)
)
(export "run" 0)
@ -537,7 +537,7 @@ wasmAssert(`
(select
(i64.const 0xc0010ff08badf00d)
(i64.const 0x12345678deadc0de)
(get_local 0)
(local.get 0)
)
)
(export "" 0)

Просмотреть файл

@ -67,12 +67,12 @@ function loadTwiceModule(type, ext, offset, align) {
(drop (${type}.load${ext}
offset=${offset}
${align != 0 ? 'align=' + align : ''}
(get_local 0)
(local.get 0)
))
(${type}.load${ext}
offset=${offset}
${align != 0 ? 'align=' + align : ''}
(get_local 1)
(local.get 1)
)
) (export "" 0))`
).exports[""];
@ -89,12 +89,12 @@ function loadTwiceSameBasePlusConstModule(type, ext, offset, align, addConst) {
(drop (${type}.load${ext}
offset=${offset}
${align != 0 ? 'align=' + align : ''}
(get_local 0)
(local.get 0)
))
(${type}.load${ext}
offset=${offset}
${align != 0 ? 'align=' + align : ''}
(i32.add (get_local 0) (i32.const ${addConst}))
(i32.add (local.get 0) (i32.const ${addConst}))
)
) (export "" 0))`
).exports[""];
@ -111,12 +111,12 @@ function loadTwiceSameBasePlusNonConstModule(type, ext, offset, align) {
(drop (${type}.load${ext}
offset=${offset}
${align != 0 ? 'align=' + align : ''}
(get_local 0)
(local.get 0)
))
(${type}.load${ext}
offset=${offset}
${align != 0 ? 'align=' + align : ''}
(i32.add (get_local 0) (get_local 1))
(i32.add (local.get 0) (local.get 1))
)
) (export "" 0))`
).exports[""];

Просмотреть файл

@ -22,20 +22,20 @@ function unary(name) {
(elem (i32.const 0) $f32 $f64)
(func (export "f32") (param f32) (result f32)
get_local 0
local.get 0
call $f32
)
(func (export "f32_t") (param f32) (result f32)
get_local 0
local.get 0
i32.const 0
call_indirect $f_f
)
(func (export "f64") (param f64) (result f64)
get_local 0
local.get 0
call $f64
)
(func (export "f64_t") (param f64) (result f64)
get_local 0
local.get 0
i32.const 1
call_indirect $d_d
)
@ -71,24 +71,24 @@ function binary(name) {
(elem (i32.const 0) $f32 $f64)
(func (export "f32") (param f32) (param f32) (result f32)
get_local 0
get_local 1
local.get 0
local.get 1
call $f32
)
(func (export "f32_t") (param f32) (param f32) (result f32)
get_local 0
get_local 1
local.get 0
local.get 1
i32.const 0
call_indirect $ff_f
)
(func (export "f64") (param f64) (param f64) (result f64)
get_local 0
get_local 1
local.get 0
local.get 1
call $f64
)
(func (export "f64_t") (param f64) (param f64) (result f64)
get_local 0
get_local 1
local.get 0
local.get 1
i32.const 1
call_indirect $dd_d
)

Просмотреть файл

@ -37,7 +37,7 @@ function testCached(code, imports, test) {
testCached(`(module
(func $test (param i64) (result f64)
get_local 0
local.get 0
f64.convert_u/i64
)
(func (export "run") (result i32)
@ -68,7 +68,7 @@ testCached(
(func $t4 (type $T) (i32.const 40))
(table funcref (elem $t1 $t2 $t3 $t4))
(func (export "run") (param i32) (result i32)
(call_indirect $T (get_local 0))))`,
(call_indirect $T (local.get 0))))`,
{'':{ t1() { return 10 }, t2() { return 20 } }},
i => {
assertEq(i.exports.run(0), 10);

Просмотреть файл

@ -1,6 +1,6 @@
// Ensures that the postorder allows us to have very deep expression trees.
var expr = '(get_local 0)';
var expr = '(local.get 0)';
for (var i = 1000; i --> 0; ) {
expr = `(f32.neg ${expr})`;

Просмотреть файл

@ -4,23 +4,23 @@ const RuntimeError = WebAssembly.RuntimeError;
// if
// Condition is an int32
wasmFailValidateText('(module (func (local f32) (if (get_local 0) (i32.const 1))))', mismatchError("f32", "i32"));
wasmFailValidateText('(module (func (local f32) (if (get_local 0) (i32.const 1) (i32.const 0))))', mismatchError("f32", "i32"));
wasmFailValidateText('(module (func (local f64) (if (get_local 0) (i32.const 1) (i32.const 0))))', mismatchError("f64", "i32"));
wasmEvalText('(module (func (local i32) (if (get_local 0) (nop))) (export "" 0))');
wasmEvalText('(module (func (local i32) (if (get_local 0) (nop) (nop))) (export "" 0))');
wasmFailValidateText('(module (func (local f32) (if (local.get 0) (i32.const 1))))', mismatchError("f32", "i32"));
wasmFailValidateText('(module (func (local f32) (if (local.get 0) (i32.const 1) (i32.const 0))))', mismatchError("f32", "i32"));
wasmFailValidateText('(module (func (local f64) (if (local.get 0) (i32.const 1) (i32.const 0))))', mismatchError("f64", "i32"));
wasmEvalText('(module (func (local i32) (if (local.get 0) (nop))) (export "" 0))');
wasmEvalText('(module (func (local i32) (if (local.get 0) (nop) (nop))) (export "" 0))');
// Expression values types are consistent
wasmFailValidateText('(module (func (result i32) (local f32) (if f32 (i32.const 42) (get_local 0) (i32.const 0))))', mismatchError("i32", "f32"));
wasmFailValidateText('(module (func (result i32) (local f64) (if i32 (i32.const 42) (i32.const 0) (get_local 0))))', mismatchError("f64", "i32"));
wasmFailValidateText('(module (func (result i32) (local f32) (if f32 (i32.const 42) (local.get 0) (i32.const 0))))', mismatchError("i32", "f32"));
wasmFailValidateText('(module (func (result i32) (local f64) (if i32 (i32.const 42) (i32.const 0) (local.get 0))))', mismatchError("f64", "i32"));
assertEq(wasmEvalText('(module (func (result i32) (if i32 (i32.const 42) (i32.const 1) (i32.const 2))) (export "" 0))').exports[""](), 1);
assertEq(wasmEvalText('(module (func (result i32) (if i32 (i32.const 0) (i32.const 1) (i32.const 2))) (export "" 0))').exports[""](), 2);
// Even if we don't yield, sub expressions types still have to match.
wasmFailValidateText('(module (func (param f32) (if i32 (i32.const 42) (i32.const 1) (get_local 0))) (export "" 0))', mismatchError('f32', 'i32'));
wasmFailValidateText('(module (func (param f32) (if i32 (i32.const 42) (i32.const 1) (local.get 0))) (export "" 0))', mismatchError('f32', 'i32'));
wasmFailValidateText('(module (func (if i32 (i32.const 42) (i32.const 1) (i32.const 0))) (export "" 0))', /unused values not explicitly dropped by end of block/);
wasmFullPass('(module (func (drop (if i32 (i32.const 42) (i32.const 1) (i32.const 0)))) (export "run" 0))', undefined);
wasmFullPass('(module (func (param f32) (if (i32.const 42) (drop (i32.const 1)) (drop (get_local 0)))) (export "run" 0))', undefined, {}, 13.37);
wasmFullPass('(module (func (param f32) (if (i32.const 42) (drop (i32.const 1)) (drop (local.get 0)))) (export "run" 0))', undefined, {}, 13.37);
// Sub-expression values are returned
wasmFullPass(`(module
@ -295,7 +295,7 @@ wasmFullPass('(module (func (block $l (br_if $l (i32.const 1)))) (export "run" 0
var isNonZero = wasmEvalText(`(module (func (result i32) (param i32)
(block
(br_if 0 (get_local 0))
(br_if 0 (local.get 0))
(return (i32.const 0))
)
(return (i32.const 1))
@ -312,8 +312,8 @@ wasmFailValidateText('(module (func (result i32) (br 0 (f32.const 42))))', misma
wasmFailValidateText('(module (func (result i32) (block (br 0))))', emptyStackError);
wasmFailValidateText('(module (func (result i32) (block f32 (br 0 (f32.const 42)))))', mismatchError("f32", "i32"));
wasmFailValidateText(`(module (func (result i32) (param i32) (block (if i32 (get_local 0) (br 0 (i32.const 42))))) (export "" 0))`, /if without else with a result value/);
wasmFailValidateText(`(module (func (result i32) (param i32) (block i32 (if (get_local 0) (drop (i32.const 42))) (br 0 (f32.const 42)))) (export "" 0))`, mismatchError("f32", "i32"));
wasmFailValidateText(`(module (func (result i32) (param i32) (block (if i32 (local.get 0) (br 0 (i32.const 42))))) (export "" 0))`, /if without else with a result value/);
wasmFailValidateText(`(module (func (result i32) (param i32) (block i32 (if (local.get 0) (drop (i32.const 42))) (br 0 (f32.const 42)))) (export "" 0))`, mismatchError("f32", "i32"));
wasmFullPass('(module (func (result i32) (br 0 (i32.const 42)) (i32.const 13)) (export "run" 0))', 42);
wasmFullPass('(module (func (result i32) (block i32 (br 0 (i32.const 42)) (i32.const 13))) (export "run" 0))', 42);
@ -321,57 +321,57 @@ wasmFullPass('(module (func (result i32) (block i32 (br 0 (i32.const 42)) (i32.c
wasmFailValidateText('(module (func) (func (block i32 (br 0 (call 0)) (i32.const 13))) (export "" 0))', emptyStackError);
wasmFailValidateText('(module (func) (func (block i32 (br_if 0 (call 0) (i32.const 1)) (i32.const 13))) (export "" 0))', emptyStackError);
var f = wasmEvalText(`(module (func (result i32) (param i32) (block i32 (if (get_local 0) (drop (i32.const 42))) (i32.const 43))) (export "" 0))`).exports[""];
var f = wasmEvalText(`(module (func (result i32) (param i32) (block i32 (if (local.get 0) (drop (i32.const 42))) (i32.const 43))) (export "" 0))`).exports[""];
assertEq(f(0), 43);
assertEq(f(1), 43);
wasmFailValidateText(`(module (func (result i32) (param i32) (block i32 (if i32 (get_local 0) (br 0 (i32.const 42))) (i32.const 43))) (export "" 0))`, /if without else with a result value/);
wasmFailValidateText(`(module (func (result i32) (param i32) (block i32 (if i32 (local.get 0) (br 0 (i32.const 42))) (i32.const 43))) (export "" 0))`, /if without else with a result value/);
var f = wasmEvalText(`(module (func (result i32) (param i32) (block i32 (if (get_local 0) (br 1 (i32.const 42))) (i32.const 43))) (export "" 0))`).exports[""];
var f = wasmEvalText(`(module (func (result i32) (param i32) (block i32 (if (local.get 0) (br 1 (i32.const 42))) (i32.const 43))) (export "" 0))`).exports[""];
assertEq(f(0), 43);
assertEq(f(1), 42);
wasmFailValidateText(`(module (func (result i32) (param i32) (block (br_if 0 (i32.const 42) (get_local 0)) (i32.const 43))) (export "" 0))`, /unused values not explicitly dropped by end of block/);
wasmFailValidateText(`(module (func (result i32) (param i32) (block (br_if 0 (i32.const 42) (local.get 0)) (i32.const 43))) (export "" 0))`, /unused values not explicitly dropped by end of block/);
var f = wasmEvalText(`(module (func (result i32) (param i32) (block i32 (drop (br_if 0 (i32.const 42) (get_local 0))) (i32.const 43))) (export "" 0))`).exports[""];
var f = wasmEvalText(`(module (func (result i32) (param i32) (block i32 (drop (br_if 0 (i32.const 42) (local.get 0))) (i32.const 43))) (export "" 0))`).exports[""];
assertEq(f(0), 43);
assertEq(f(1), 42);
var f = wasmEvalText(`(module (func (result i32) (param i32) (block i32 (if (get_local 0) (drop (i32.const 42))) (br 0 (i32.const 43)))) (export "" 0))`).exports[""];
var f = wasmEvalText(`(module (func (result i32) (param i32) (block i32 (if (local.get 0) (drop (i32.const 42))) (br 0 (i32.const 43)))) (export "" 0))`).exports[""];
assertEq(f(0), 43);
assertEq(f(1), 43);
wasmFailValidateText(`(module (func (result i32) (param i32) (block i32 (if i32 (get_local 0) (br 0 (i32.const 42))) (br 0 (i32.const 43)))) (export "" 0))`, /if without else with a result value/);
wasmFailValidateText(`(module (func (result i32) (param i32) (block i32 (if i32 (local.get 0) (br 0 (i32.const 42))) (br 0 (i32.const 43)))) (export "" 0))`, /if without else with a result value/);
var f = wasmEvalText(`(module (func (result i32) (param i32) (if (get_local 0) (br 1 (i32.const 42))) (br 0 (i32.const 43))) (export "" 0))`).exports[""];
var f = wasmEvalText(`(module (func (result i32) (param i32) (if (local.get 0) (br 1 (i32.const 42))) (br 0 (i32.const 43))) (export "" 0))`).exports[""];
assertEq(f(0), 43);
assertEq(f(1), 42);
var f = wasmEvalText(`(module (func (result i32) (param i32) (block i32 (if (get_local 0) (br 1 (i32.const 42))) (br 0 (i32.const 43)))) (export "" 0))`).exports[""];
var f = wasmEvalText(`(module (func (result i32) (param i32) (block i32 (if (local.get 0) (br 1 (i32.const 42))) (br 0 (i32.const 43)))) (export "" 0))`).exports[""];
assertEq(f(0), 43);
assertEq(f(1), 42);
var f = wasmEvalText(`(module (func (result i32) (param i32) (br_if 0 (i32.const 42) (get_local 0)) (br 0 (i32.const 43))) (export "" 0))`).exports[""];
var f = wasmEvalText(`(module (func (result i32) (param i32) (br_if 0 (i32.const 42) (local.get 0)) (br 0 (i32.const 43))) (export "" 0))`).exports[""];
assertEq(f(0), 43);
assertEq(f(1), 42);
var f = wasmEvalText(`(module (func (result i32) (param i32) (block i32 (br_if 0 (i32.const 42) (get_local 0)) (br 0 (i32.const 43)))) (export "" 0))`).exports[""];
var f = wasmEvalText(`(module (func (result i32) (param i32) (block i32 (br_if 0 (i32.const 42) (local.get 0)) (br 0 (i32.const 43)))) (export "" 0))`).exports[""];
assertEq(f(0), 43);
assertEq(f(1), 42);
var f = wasmEvalText(`(module (func (param i32) (result i32) (i32.add (i32.const 1) (block i32 (if (get_local 0) (drop (i32.const 99))) (i32.const -1)))) (export "" 0))`).exports[""];
var f = wasmEvalText(`(module (func (param i32) (result i32) (i32.add (i32.const 1) (block i32 (if (local.get 0) (drop (i32.const 99))) (i32.const -1)))) (export "" 0))`).exports[""];
assertEq(f(0), 0);
assertEq(f(1), 0);
wasmFailValidateText(`(module (func (param i32) (result i32) (i32.add (i32.const 1) (block i32 (if i32 (get_local 0) (br 0 (i32.const 99))) (i32.const -1)))) (export "" 0))`, /if without else with a result value/);
wasmFailValidateText(`(module (func (param i32) (result i32) (i32.add (i32.const 1) (block i32 (if i32 (local.get 0) (br 0 (i32.const 99))) (i32.const -1)))) (export "" 0))`, /if without else with a result value/);
var f = wasmEvalText(`(module (func (param i32) (result i32) (i32.add (i32.const 1) (block i32 (if (get_local 0) (br 1 (i32.const 99))) (i32.const -1)))) (export "" 0))`).exports[""];
var f = wasmEvalText(`(module (func (param i32) (result i32) (i32.add (i32.const 1) (block i32 (if (local.get 0) (br 1 (i32.const 99))) (i32.const -1)))) (export "" 0))`).exports[""];
assertEq(f(0), 0);
assertEq(f(1), 100);
wasmFailValidateText(`(module (func (param i32) (result i32) (i32.add (i32.const 1) (block (br_if 0 (i32.const 99) (get_local 0)) (i32.const -1)))) (export "" 0))`, /unused values not explicitly dropped by end of block/);
wasmFailValidateText(`(module (func (param i32) (result i32) (i32.add (i32.const 1) (block (br_if 0 (i32.const 99) (local.get 0)) (i32.const -1)))) (export "" 0))`, /unused values not explicitly dropped by end of block/);
var f = wasmEvalText(`(module (func (param i32) (result i32) (i32.add (i32.const 1) (block i32 (drop (br_if 0 (i32.const 99) (get_local 0))) (i32.const -1)))) (export "" 0))`).exports[""];
var f = wasmEvalText(`(module (func (param i32) (result i32) (i32.add (i32.const 1) (block i32 (drop (br_if 0 (i32.const 99) (local.get 0))) (i32.const -1)))) (export "" 0))`).exports[""];
assertEq(f(0), 0);
assertEq(f(1), 100);
@ -395,11 +395,11 @@ var f = wasmEvalText(`(module
(param i32) (result i32)
(block $outer
(if
(get_local 0)
(local.get 0)
(block (call 0 (i32.const 13)) (br $outer))
)
(if
(i32.eqz (get_local 0))
(i32.eqz (local.get 0))
(block (call 1 (i32.const 37)) (br $outer))
)
)
@ -412,16 +412,16 @@ assertEq(f(1), 42);
assertEq(called, 0);
// br/br_if and loop
wasmFullPass(`(module (func (param i32) (result i32) (loop $out $in i32 (br $out (get_local 0)))) (export "run" 0))`, 1, {}, 1);
wasmFullPass(`(module (func (param i32) (result i32) (loop $in i32 (br 1 (get_local 0)))) (export "run" 0))`, 1, {}, 1);
wasmFullPass(`(module (func (param i32) (result i32) (block $out i32 (loop $in i32 (br $out (get_local 0))))) (export "run" 0))`, 1, {}, 1);
wasmFullPass(`(module (func (param i32) (result i32) (loop $out $in i32 (br $out (local.get 0)))) (export "run" 0))`, 1, {}, 1);
wasmFullPass(`(module (func (param i32) (result i32) (loop $in i32 (br 1 (local.get 0)))) (export "run" 0))`, 1, {}, 1);
wasmFullPass(`(module (func (param i32) (result i32) (block $out i32 (loop $in i32 (br $out (local.get 0))))) (export "run" 0))`, 1, {}, 1);
wasmFailValidateText(`(module (func (param i32) (result i32)
(loop $out $in
(if (get_local 0) (br $in (i32.const 1)))
(if (get_local 0) (br $in (f32.const 2)))
(if (get_local 0) (br $in (f64.const 3)))
(if (get_local 0) (br $in))
(if (local.get 0) (br $in (i32.const 1)))
(if (local.get 0) (br $in (f32.const 2)))
(if (local.get 0) (br $in (f64.const 3)))
(if (local.get 0) (br $in))
(i32.const 7)
)
) (export "" 0))`, /unused values not explicitly dropped by end of block/);
@ -432,10 +432,10 @@ wasmFullPass(`(module
(local i32)
(block $out i32
(loop $in i32
(set_local 0 (i32.add (get_local 0) (i32.const 1)))
(local.set 0 (i32.add (local.get 0) (i32.const 1)))
(if
(i32.ge_s (get_local 0) (i32.const 7))
(br $out (get_local 0))
(i32.ge_s (local.get 0) (i32.const 7))
(br $out (local.get 0))
)
(br $in)
)
@ -449,8 +449,8 @@ wasmFullPass(`(module
(local i32)
(block $out i32
(loop $in i32
(set_local 0 (i32.add (get_local 0) (i32.const 1)))
(br_if $out (get_local 0) (i32.ge_s (get_local 0) (i32.const 7)))
(local.set 0 (i32.add (local.get 0) (i32.const 1)))
(br_if $out (local.get 0) (i32.ge_s (local.get 0) (i32.const 7)))
(br $in)
)
)
@ -477,13 +477,13 @@ wasmFullPass(`(module (func (result i32) (local i32)
(loop
$break $continue
(if
(i32.gt_u (get_local 0) (i32.const 5))
(i32.gt_u (local.get 0) (i32.const 5))
(br $break)
)
(set_local 0 (i32.add (get_local 0) (i32.const 1)))
(local.set 0 (i32.add (local.get 0) (i32.const 1)))
(br $continue)
)
(return (get_local 0))
(return (local.get 0))
) (export "run" 0))`, 6);
wasmFullPass(`(module (func (result i32) (local i32)
@ -492,14 +492,14 @@ wasmFullPass(`(module (func (result i32) (local i32)
(loop
$continue
(if
(i32.gt_u (get_local 0) (i32.const 5))
(i32.gt_u (local.get 0) (i32.const 5))
(br $break)
)
(set_local 0 (i32.add (get_local 0) (i32.const 1)))
(local.set 0 (i32.add (local.get 0) (i32.const 1)))
(br $continue)
)
)
(return (get_local 0))
(return (local.get 0))
) (export "run" 0))`, 6);
wasmFullPass(`(module (func (result i32) (local i32)
@ -507,12 +507,12 @@ wasmFullPass(`(module (func (result i32) (local i32)
$break $continue
(br_if
$break
(i32.gt_u (get_local 0) (i32.const 5))
(i32.gt_u (local.get 0) (i32.const 5))
)
(set_local 0 (i32.add (get_local 0) (i32.const 1)))
(local.set 0 (i32.add (local.get 0) (i32.const 1)))
(br $continue)
)
(return (get_local 0))
(return (local.get 0))
) (export "run" 0))`, 6);
wasmFullPass(`(module (func (result i32) (local i32)
@ -522,25 +522,25 @@ wasmFullPass(`(module (func (result i32) (local i32)
$continue
(br_if
$break
(i32.gt_u (get_local 0) (i32.const 5))
(i32.gt_u (local.get 0) (i32.const 5))
)
(set_local 0 (i32.add (get_local 0) (i32.const 1)))
(local.set 0 (i32.add (local.get 0) (i32.const 1)))
(br $continue)
)
)
(return (get_local 0))
(return (local.get 0))
) (export "run" 0))`, 6);
wasmFullPass(`(module (func (result i32) (local i32)
(loop
$break $continue
(set_local 0 (i32.add (get_local 0) (i32.const 1)))
(local.set 0 (i32.add (local.get 0) (i32.const 1)))
(br_if
$continue
(i32.le_u (get_local 0) (i32.const 5))
(i32.le_u (local.get 0) (i32.const 5))
)
)
(return (get_local 0))
(return (local.get 0))
) (export "run" 0))`, 6);
wasmFullPass(`(module (func (result i32) (local i32)
@ -548,14 +548,14 @@ wasmFullPass(`(module (func (result i32) (local i32)
$break
(loop
$continue
(set_local 0 (i32.add (get_local 0) (i32.const 1)))
(local.set 0 (i32.add (local.get 0) (i32.const 1)))
(br_if
$continue
(i32.le_u (get_local 0) (i32.const 5))
(i32.le_u (local.get 0) (i32.const 5))
)
)
)
(return (get_local 0))
(return (local.get 0))
) (export "run" 0))`, 6);
wasmFullPass(`(module (func (result i32) (local i32)
@ -563,15 +563,15 @@ wasmFullPass(`(module (func (result i32) (local i32)
$break $continue
(br_if
$break
(i32.gt_u (get_local 0) (i32.const 5))
(i32.gt_u (local.get 0) (i32.const 5))
)
(set_local 0 (i32.add (get_local 0) (i32.const 1)))
(local.set 0 (i32.add (local.get 0) (i32.const 1)))
(loop
(br $continue)
)
(return (i32.const 42))
)
(return (get_local 0))
(return (local.get 0))
) (export "run" 0))`, 6);
wasmFullPass(`(module (func (result i32) (local i32)
@ -581,31 +581,31 @@ wasmFullPass(`(module (func (result i32) (local i32)
$continue
(br_if
$break
(i32.gt_u (get_local 0) (i32.const 5))
(i32.gt_u (local.get 0) (i32.const 5))
)
(set_local 0 (i32.add (get_local 0) (i32.const 1)))
(local.set 0 (i32.add (local.get 0) (i32.const 1)))
(loop
(br $continue)
)
(return (i32.const 42))
)
)
(return (get_local 0))
(return (local.get 0))
) (export "run" 0))`, 6);
wasmFullPass(`(module (func (result i32) (local i32)
(loop
$break $continue
(set_local 0 (i32.add (get_local 0) (i32.const 1)))
(local.set 0 (i32.add (local.get 0) (i32.const 1)))
(loop
(br_if
$continue
(i32.le_u (get_local 0) (i32.const 5))
(i32.le_u (local.get 0) (i32.const 5))
)
)
(br $break)
)
(return (get_local 0))
(return (local.get 0))
) (export "run" 0))`, 6);
wasmFullPass(`(module (func (result i32) (local i32)
@ -613,17 +613,17 @@ wasmFullPass(`(module (func (result i32) (local i32)
$break
(loop
$continue
(set_local 0 (i32.add (get_local 0) (i32.const 1)))
(local.set 0 (i32.add (local.get 0) (i32.const 1)))
(loop
(br_if
$continue
(i32.le_u (get_local 0) (i32.const 5))
(i32.le_u (local.get 0) (i32.const 5))
)
)
(br $break)
)
)
(return (get_local 0))
(return (local.get 0))
) (export "run" 0))`, 6);
// ----------------------------------------------------------------------------
@ -641,7 +641,7 @@ wasmFailValidateText('(module (func (loop (br_table 0 (f32.const 0)))))', mismat
wasmFullPass(`(module (func (result i32) (param i32)
(block $default
(br_table $default (get_local 0))
(br_table $default (local.get 0))
(return (i32.const 0))
)
(return (i32.const 1))
@ -658,7 +658,7 @@ wasmFullPass(`(module (func (result i32) (param i32)
wasmFullPass(`(module (func (result i32) (param i32)
(block $outer
(block $inner
(br_table $inner (get_local 0))
(br_table $inner (local.get 0))
(return (i32.const 0))
)
(return (i32.const 1))
@ -671,7 +671,7 @@ var f = wasmEvalText(`(module (func (result i32) (param i32)
(block $1
(block $2
(block $default
(br_table $0 $1 $2 $default (get_local 0))
(br_table $0 $1 $2 $default (local.get 0))
)
(return (i32.const -1))
)
@ -711,11 +711,11 @@ var f = wasmEvalText(`(module (func (param i32) (result i32)
(block $1 i32
(drop (block $0 i32
(drop (block $default i32
(br_table $0 $1 $default (get_local 0) (get_local 0))
(br_table $0 $1 $default (local.get 0) (local.get 0))
))
(tee_local 0 (i32.mul (i32.const 2) (get_local 0)))
(tee_local 0 (i32.mul (i32.const 2) (local.get 0)))
))
(tee_local 0 (i32.add (i32.const 4) (get_local 0)))
(tee_local 0 (i32.add (i32.const 4) (local.get 0)))
)
(i32.const 1)
)

Просмотреть файл

@ -2,7 +2,7 @@ function testConversion0(resultType, opcode, paramType, op, expect) {
if (resultType === 'i64') {
wasmFullPassI64(`(module
(func $run (param ${paramType}) (result ${resultType})
(${opcode} (get_local 0))
(${opcode} (local.get 0))
)
)`, expect, {}, `${paramType}.const ${op}`);
@ -15,7 +15,7 @@ function testConversion0(resultType, opcode, paramType, op, expect) {
} else if (paramType === 'i64') {
wasmFullPass(`(module
(func $f (param ${paramType}) (result ${resultType})
(${opcode} (get_local 0))
(${opcode} (local.get 0))
)
(func (export "run") (result ${resultType})
i64.const ${op}
@ -25,7 +25,7 @@ function testConversion0(resultType, opcode, paramType, op, expect) {
} else {
wasmFullPass(`(module
(func (param ${paramType}) (result ${resultType})
(${opcode} (get_local 0)))
(${opcode} (local.get 0)))
(export "run" 0)
)`, expect, {}, op);
}
@ -33,14 +33,14 @@ function testConversion0(resultType, opcode, paramType, op, expect) {
for (var bad of ['i32', 'f32', 'f64', 'i64']) {
if (bad !== resultType) {
wasmFailValidateText(
`(module (func (param ${paramType}) (result ${bad}) (${opcode} (get_local 0))))`,
`(module (func (param ${paramType}) (result ${bad}) (${opcode} (local.get 0))))`,
mismatchError(resultType, bad)
);
}
if (bad !== paramType) {
wasmFailValidateText(
`(module (func (param ${bad}) (result ${resultType}) (${opcode} (get_local 0))))`,
`(module (func (param ${bad}) (result ${resultType}) (${opcode} (local.get 0))))`,
mismatchError(bad, paramType)
);
}
@ -60,11 +60,11 @@ function testTrap(resultType, opcode, paramType, op) {
(func
(param ${paramType})
(result ${resultType})
(${resultType}.${opcode}/${paramType} (get_local 0))
(${resultType}.${opcode}/${paramType} (local.get 0))
)
(func
(param ${paramType})
get_local 0
local.get 0
call 0
drop
)
@ -367,4 +367,4 @@ testConversion('f64', 'promote', 'f32', 40.1, 40.099998474121094);
// Non-canonical NaNs.
wasmFullPass('(module (func (result i32) (i32.reinterpret/f32 (f32.demote/f64 (f64.const -nan:0x4444444444444)))) (export "run" 0))', -0x1dddde);
wasmFullPass('(module (func (result i32) (local i64) (set_local 0 (i64.reinterpret/f64 (f64.promote/f32 (f32.const -nan:0x222222)))) (i32.xor (i32.wrap/i64 (get_local 0)) (i32.wrap/i64 (i64.shr_u (get_local 0) (i64.const 32))))) (export "run" 0))', -0x4003bbbc);
wasmFullPass('(module (func (result i32) (local i64) (local.set 0 (i64.reinterpret/f64 (f64.promote/f32 (f32.const -nan:0x222222)))) (i32.xor (i32.wrap/i64 (local.get 0)) (i32.wrap/i64 (i64.shr_u (local.get 0) (i64.const 32))))) (export "run" 0))', -0x4003bbbc);

Просмотреть файл

@ -2,8 +2,8 @@ for (let type of ['i32', 'f32', 'f64']) {
assertEq(wasmEvalText(`
(module
(func $test (result ${type}) (param $p ${type}) (param $p2 ${type})
get_local $p
get_local $p2
local.get $p
local.get $p2
(block)
drop
)
@ -15,10 +15,10 @@ for (let type of ['i32', 'f32', 'f64']) {
assertEq(wasmEvalText(`
(module
(func $test (result i32) (param $p i32) (param $p2 f32) (param $p3 f64) (param $p4 i32)
get_local $p
get_local $p2
get_local $p3
get_local $p4
local.get $p
local.get $p2
local.get $p3
local.get $p4
(block)
drop
(block)
@ -33,8 +33,8 @@ assertEq(wasmEvalText(`
wasmAssert(`
(module
(func $test (result i64) (param $p i64) (param $p2 i64)
get_local $p
get_local $p2
local.get $p
local.get $p2
(block)
drop
)

Просмотреть файл

@ -70,12 +70,12 @@ function testAccess(opcode, text, width, type, msg) {
}
function testLoad(opcode, optext, width, type, msg) {
var text = `(module (memory 1) (func (export "") (param i32) (drop (${optext} (get_local 0)))))`;
var text = `(module (memory 1) (func (export "") (param i32) (drop (${optext} (local.get 0)))))`;
testAccess(opcode, text, width, type, msg);
}
function testStore(opcode, optext, consttext, width, type, msg) {
var text = `(module (memory 1) (func (export "") (param i32) (${optext} (get_local 0) (${consttext}.const 0))))`;
var text = `(module (memory 1) (func (export "") (param i32) (${optext} (local.get 0) (${consttext}.const 0))))`;
testAccess(opcode, text, width, type, msg);
}

Просмотреть файл

@ -3,16 +3,16 @@
assertEq(wasmEvalText(`(module
(func $fac-opt (param i32) (result i32)
(local i32)
(set_local 1 (i32.const 1))
(local.set 1 (i32.const 1))
(block
(br_if 0 (i32.lt_s (get_local 0) (i32.const 2)))
(br_if 0 (i32.lt_s (local.get 0) (i32.const 2)))
(loop
(set_local 1 (i32.mul (get_local 1) (get_local 0)))
(set_local 0 (i32.add (get_local 0) (i32.const -1)))
(br_if 0 (i32.gt_s (get_local 0) (i32.const 1)))
(local.set 1 (i32.mul (local.get 1) (local.get 0)))
(local.set 0 (i32.add (local.get 0) (i32.const -1)))
(br_if 0 (i32.gt_s (local.get 0) (i32.const 1)))
)
)
(get_local 1)
(local.get 1)
)
(export "" 0)

Просмотреть файл

@ -35,7 +35,7 @@ function makeLoadStore(numBallast, ty, offset) {
(i32.store (i32.const 8) (i32.add (i32.load (i32.const 8)) (i32.const 1)))
(${ty}.load (i32.const 8))`)}
(${ty}.store (i32.const 0) (${ty}.load offset=${offset} (get_local $p)))
(${ty}.store (i32.const 0) (${ty}.load offset=${offset} (local.get $p)))
${ballast(() => `
${ty}.store`)}
@ -51,12 +51,12 @@ function makeLoadStore(numBallast, ty, offset) {
(i32.store (i32.const 8) (i32.add (i32.load (i32.const 8)) (i32.const 1)))
(${ty}.load (i32.const 8))`)}
(set_local $tmp (${ty}.add (get_local $v) (${ty}.load (i32.const 16))))
(${ty}.store offset=${offset} (get_local $p) (get_local $tmp))
(local.set $tmp (${ty}.add (local.get $v) (${ty}.load (i32.const 16))))
(${ty}.store offset=${offset} (local.get $p) (local.get $tmp))
${ballast(() => `
${ty}.store`)}
(${ty}.store (i32.const 8) (get_local $v)))`;
(${ty}.store (i32.const 8) (local.get $v)))`;
return `${loadtxt}
${storetxt}`;

Просмотреть файл

@ -12,21 +12,21 @@ wasmFullPass('(module (func (result f64) (f64.const -9223372036854775808)) (expo
wasmFullPass('(module (func (result f64) (f64.const 1797693134862315708145274e284)) (export "run" 0))', 1797693134862315708145274e284);
function testUnary(type, opcode, op, expect) {
wasmFullPass('(module (func (param ' + type + ') (result ' + type + ') (' + type + '.' + opcode + ' (get_local 0))) (export "run" 0))',
wasmFullPass('(module (func (param ' + type + ') (result ' + type + ') (' + type + '.' + opcode + ' (local.get 0))) (export "run" 0))',
expect,
{},
op);
}
function testBinary(type, opcode, lhs, rhs, expect) {
wasmFullPass('(module (func (param ' + type + ') (param ' + type + ') (result ' + type + ') (' + type + '.' + opcode + ' (get_local 0) (get_local 1))) (export "run" 0))',
wasmFullPass('(module (func (param ' + type + ') (param ' + type + ') (result ' + type + ') (' + type + '.' + opcode + ' (local.get 0) (local.get 1))) (export "run" 0))',
expect,
{},
lhs, rhs);
}
function testComparison(type, opcode, lhs, rhs, expect) {
wasmFullPass('(module (func (param ' + type + ') (param ' + type + ') (result i32) (' + type + '.' + opcode + ' (get_local 0) (get_local 1))) (export "run" 0))',
wasmFullPass('(module (func (param ' + type + ') (param ' + type + ') (result i32) (' + type + '.' + opcode + ' (local.get 0) (local.get 1))) (export "run" 0))',
expect,
{},
lhs, rhs);
@ -78,26 +78,26 @@ testComparison('f64', 'le', 40, 40, 1);
testComparison('f64', 'gt', 40, 40, 0);
testComparison('f64', 'ge', 40, 40, 1);
wasmFailValidateText('(module (func (param i32) (result f32) (f32.sqrt (get_local 0))))', mismatchError("i32", "f32"));
wasmFailValidateText('(module (func (param f32) (result i32) (f32.sqrt (get_local 0))))', mismatchError("f32", "i32"));
wasmFailValidateText('(module (func (param i32) (result i32) (f32.sqrt (get_local 0))))', mismatchError("i32", "f32"));
wasmFailValidateText('(module (func (param i32) (result f64) (f64.sqrt (get_local 0))))', mismatchError("i32", "f64"));
wasmFailValidateText('(module (func (param f64) (result i32) (f64.sqrt (get_local 0))))', mismatchError("f64", "i32"));
wasmFailValidateText('(module (func (param i32) (result i32) (f64.sqrt (get_local 0))))', mismatchError("i32", "f64"));
wasmFailValidateText('(module (func (param i32) (result f32) (f32.sqrt (local.get 0))))', mismatchError("i32", "f32"));
wasmFailValidateText('(module (func (param f32) (result i32) (f32.sqrt (local.get 0))))', mismatchError("f32", "i32"));
wasmFailValidateText('(module (func (param i32) (result i32) (f32.sqrt (local.get 0))))', mismatchError("i32", "f32"));
wasmFailValidateText('(module (func (param i32) (result f64) (f64.sqrt (local.get 0))))', mismatchError("i32", "f64"));
wasmFailValidateText('(module (func (param f64) (result i32) (f64.sqrt (local.get 0))))', mismatchError("f64", "i32"));
wasmFailValidateText('(module (func (param i32) (result i32) (f64.sqrt (local.get 0))))', mismatchError("i32", "f64"));
wasmFailValidateText('(module (func (f32.sqrt (nop))))', /popping value from empty stack/);
wasmFailValidateText('(module (func (param i32) (param f32) (result f32) (f32.add (get_local 0) (get_local 1))))', mismatchError("i32", "f32"));
wasmFailValidateText('(module (func (param f32) (param i32) (result f32) (f32.add (get_local 0) (get_local 1))))', mismatchError("i32", "f32"));
wasmFailValidateText('(module (func (param f32) (param f32) (result i32) (f32.add (get_local 0) (get_local 1))))', mismatchError("f32", "i32"));
wasmFailValidateText('(module (func (param i32) (param i32) (result i32) (f32.add (get_local 0) (get_local 1))))', mismatchError("i32", "f32"));
wasmFailValidateText('(module (func (param i32) (param f64) (result f64) (f64.add (get_local 0) (get_local 1))))', mismatchError("i32", "f64"));
wasmFailValidateText('(module (func (param f64) (param i32) (result f64) (f64.add (get_local 0) (get_local 1))))', mismatchError("i32", "f64"));
wasmFailValidateText('(module (func (param f64) (param f64) (result i32) (f64.add (get_local 0) (get_local 1))))', mismatchError("f64", "i32"));
wasmFailValidateText('(module (func (param i32) (param i32) (result i32) (f64.add (get_local 0) (get_local 1))))', mismatchError("i32", "f64"));
wasmFailValidateText('(module (func (param i32) (param f32) (result f32) (f32.add (local.get 0) (local.get 1))))', mismatchError("i32", "f32"));
wasmFailValidateText('(module (func (param f32) (param i32) (result f32) (f32.add (local.get 0) (local.get 1))))', mismatchError("i32", "f32"));
wasmFailValidateText('(module (func (param f32) (param f32) (result i32) (f32.add (local.get 0) (local.get 1))))', mismatchError("f32", "i32"));
wasmFailValidateText('(module (func (param i32) (param i32) (result i32) (f32.add (local.get 0) (local.get 1))))', mismatchError("i32", "f32"));
wasmFailValidateText('(module (func (param i32) (param f64) (result f64) (f64.add (local.get 0) (local.get 1))))', mismatchError("i32", "f64"));
wasmFailValidateText('(module (func (param f64) (param i32) (result f64) (f64.add (local.get 0) (local.get 1))))', mismatchError("i32", "f64"));
wasmFailValidateText('(module (func (param f64) (param f64) (result i32) (f64.add (local.get 0) (local.get 1))))', mismatchError("f64", "i32"));
wasmFailValidateText('(module (func (param i32) (param i32) (result i32) (f64.add (local.get 0) (local.get 1))))', mismatchError("i32", "f64"));
wasmFailValidateText('(module (func (param i32) (param f32) (result f32) (f32.eq (get_local 0) (get_local 1))))', mismatchError("i32", "f32"));
wasmFailValidateText('(module (func (param f32) (param i32) (result f32) (f32.eq (get_local 0) (get_local 1))))', mismatchError("i32", "f32"));
wasmFailValidateText('(module (func (param f32) (param f32) (result f32) (f32.eq (get_local 0) (get_local 1))))', mismatchError("i32", "f32"));
wasmFailValidateText('(module (func (param i32) (param f64) (result f64) (f64.eq (get_local 0) (get_local 1))))', mismatchError("i32", "f64"));
wasmFailValidateText('(module (func (param f64) (param i32) (result f64) (f64.eq (get_local 0) (get_local 1))))', mismatchError("i32", "f64"));
wasmFailValidateText('(module (func (param f64) (param f64) (result f64) (f64.eq (get_local 0) (get_local 1))))', mismatchError("i32", "f64"));
wasmFailValidateText('(module (func (param i32) (param f32) (result f32) (f32.eq (local.get 0) (local.get 1))))', mismatchError("i32", "f32"));
wasmFailValidateText('(module (func (param f32) (param i32) (result f32) (f32.eq (local.get 0) (local.get 1))))', mismatchError("i32", "f32"));
wasmFailValidateText('(module (func (param f32) (param f32) (result f32) (f32.eq (local.get 0) (local.get 1))))', mismatchError("i32", "f32"));
wasmFailValidateText('(module (func (param i32) (param f64) (result f64) (f64.eq (local.get 0) (local.get 1))))', mismatchError("i32", "f64"));
wasmFailValidateText('(module (func (param f64) (param i32) (result f64) (f64.eq (local.get 0) (local.get 1))))', mismatchError("i32", "f64"));
wasmFailValidateText('(module (func (param f64) (param f64) (result f64) (f64.eq (local.get 0) (local.get 1))))', mismatchError("i32", "f64"));

Просмотреть файл

@ -1,5 +1,5 @@
wasmFullPass(`(module
(func $test (result i32) (param i32) (param i32) (i32.add (get_local 0) (get_local 1)))
(func $test (result i32) (param i32) (param i32) (i32.add (local.get 0) (local.get 1)))
(func $run (result i32) (call $test (i32.const 1) (i32.const ${Math.pow(2, 31) - 1})))
(export "run" $run)
)`, -Math.pow(2, 31));
@ -23,7 +23,7 @@ wasmFullPass(`
(module
(import "env" "a" (global $a i32))
(import "env" "b" (func $b (param i32) (result i32)))
(func (export "run") (param $0 i32) (result i32) get_local 0 call $b)
(func (export "run") (param $0 i32) (result i32) local.get 0 call $b)
)`, 43, { env: { a: 1337, b: x => x+1 } }, 42);
// Global section.
@ -31,16 +31,16 @@ wasmFullPass(`(module
(import $imported "globals" "x" (global i32))
(global $mut_local (mut i32) (i32.const 0))
(global $imm_local i32 (i32.const 37))
(global $imm_local_2 i32 (get_global 0))
(global $imm_local_2 i32 (global.get 0))
(func $get (result i32)
i32.const 13
set_global $mut_local
get_global $imported
get_global $mut_local
global.set $mut_local
global.get $imported
global.get $mut_local
i32.add
get_global $imm_local
global.get $imm_local
i32.add
get_global $imm_local_2
global.get $imm_local_2
i32.add
)
(export "run" $get)
@ -79,7 +79,7 @@ wasmFullPass(`(module
(elem (i32.const 0) $baz $bar)
(elem (i32.const 2) $foo)
(func (export "run") (param i32) (result i32)
get_local 0
local.get 0
call_indirect $t
)
)`, 3, {}, 0);
@ -95,7 +95,7 @@ wasmFullPass(`(module
(elem (i32.const 0) $baz $bar)
(elem (i32.const 2) $foo)
(func (export "run") (param i32) (result i32)
get_local 0
local.get 0
call_indirect $t
)
)`, 3, {"":{table}}, 0);
@ -104,14 +104,14 @@ wasmFullPass(`(module
wasmFullPass(`(module
(global $g (mut i32) (i32.const 0))
(func $start
get_global $g
global.get $g
i32.const 1
i32.add
set_global $g
global.set $g
)
(start $start)
(func (export "run") (result i32)
get_global $g
global.get $g
)
)`, 1);
@ -125,22 +125,22 @@ for (let [p, result] of [
wasmFullPass(`(module
(func (export "run") (result i32) (param $p i32) (local $n i32)
i32.const 0
set_local $n
local.set $n
block $c block $b block $a
get_local $p
local.get $p
br_table $a $b $c
end $a
get_local $n
local.get $n
i32.const 1
i32.add
set_local $n
local.set $n
end $b
get_local $n
local.get $n
i32.const 2
i32.add
set_local $n
local.set $n
end $c
get_local $n
local.get $n
i32.const 4
i32.add
)

Просмотреть файл

@ -137,9 +137,9 @@
(type $p (struct (field i64)))
(type $q (struct (field i32) (field i32)))
(func $f (param anyref) (result i32)
(ref.is_null (struct.narrow anyref (ref $q) (get_local 0))))
(ref.is_null (struct.narrow anyref (ref $q) (local.get 0))))
(func $g (param anyref) (result i32)
(ref.is_null (struct.narrow anyref (ref $p) (get_local 0))))
(ref.is_null (struct.narrow anyref (ref $p) (local.get 0))))
(func (export "t1") (result i32)
(call $f (struct.new $p (i64.const 0))))
(func (export "t2") (result i32)

Просмотреть файл

@ -46,7 +46,7 @@ for (let v of VALUES)
(gc_feature_opt_in 3)
(type $S (struct (field $S.x (mut anyref))))
(func (export "make") (param $v anyref) (result anyref)
(struct.new $S (get_local $v))))`);
(struct.new $S (local.get $v))))`);
let x = ins.exports.make(v);
assertEq(x._0, v);
}
@ -62,7 +62,7 @@ for (let v of VALUES)
(func (export "make") (result anyref)
(struct.new $S (ref.null)))
(func (export "get") (param $o anyref) (result anyref)
(struct.get $S 0 (struct.narrow anyref (ref $S) (get_local $o)))))`);
(struct.get $S 0 (struct.narrow anyref (ref $S) (local.get $o)))))`);
let x = ins.exports.make();
x._0 = v;
assertEq(ins.exports.get(x), v);
@ -79,7 +79,7 @@ for (let v of VALUES)
(func (export "make") (result anyref)
(struct.new $S (ref.null)))
(func (export "get") (param $o anyref) (result anyref)
(struct.get $S 0 (struct.narrow anyref (ref $S) (get_local $o)))))`);
(struct.get $S 0 (struct.narrow anyref (ref $S) (local.get $o)))))`);
let constructor = ins.exports.make().constructor;
let x = new constructor({_0: v});
assertEq(ins.exports.get(x), v);
@ -147,7 +147,7 @@ for (let v of VALUES) {
{
let fields = iota(10).map(() => `(field anyref)`).join(' ');
let params = iota(10).map((i) => `(param $${i} anyref)`).join(' ');
let args = iota(10).map((i) => `(get_local $${i})`).join(' ');
let args = iota(10).map((i) => `(local.get $${i})`).join(' ');
let txt = `(module
(gc_feature_opt_in 3)
(type $S (struct ${fields}))

Просмотреть файл

@ -26,12 +26,12 @@ let VALUES = [null,
// - on initialization when created from JS
// - on initialization when created in Wasm, from an imported global
// - through the "value" property if the value is mutable
// - through the set_global wasm instruction, ditto
// - through the global.set wasm instruction, ditto
//
// Their values can be obtained in several ways:
//
// - through the "value" property
// - through the get_global wasm instruction
// - through the global.get wasm instruction
// - read when other globals are initialized from them
// Set via initialization and read via 'value'
@ -51,7 +51,7 @@ for (let v of VALUES)
assertEq(g.value, v);
}
// Set via initialization, then read via get_global and returned
// Set via initialization, then read via global.get and returned
for (let v of VALUES)
{
@ -60,12 +60,12 @@ for (let v of VALUES)
`(module
(import $glob "m" "g" (global anyref))
(func (export "f") (result anyref)
(get_global $glob)))`,
(global.get $glob)))`,
{m:{g}});
assertEq(ins.exports.f(), v);
}
// Set via set_global, then read via 'value'
// Set via global.set, then read via 'value'
for (let v of VALUES)
{
@ -74,7 +74,7 @@ for (let v of VALUES)
`(module
(import $glob "m" "g" (global (mut anyref)))
(func (export "f") (param $v anyref)
(set_global $glob (get_local $v))))`,
(global.set $glob (local.get $v))))`,
{m:{g}});
ins.exports.f(v);
assertEq(g.value, v);
@ -112,7 +112,7 @@ for (let v of VALUES)
`(module
(import $t "m" "t" (table 10 anyref))
(func (export "f") (param $v anyref)
(table.set $t (i32.const 3) (get_local $v))))`,
(table.set $t (i32.const 3) (local.get $v))))`,
{m:{t}});
ins.exports.f(v);
assertEq(t.get(3), v);
@ -147,7 +147,7 @@ for (let v of VALUES)
(func (export "test_returner") (result anyref)
(call $returner))
(func (export "test_receiver") (param $v anyref)
(call $receiver (get_local $v))))`,
(call $receiver (local.get $v))))`,
{m:{returner, receiver}});
assertEq(ins.exports.test_returner(), v);
ins.exports.test_receiver(v);

Просмотреть файл

@ -12,10 +12,10 @@ function Baguette(calories) {
wasmEvalText(`(module
(global (mut anyref) (ref.null))
(func (export "f")
get_global 0
global.get 0
ref.null
set_global 0
set_global 0
global.set 0
global.set 0
)
)`).exports.f();
})();
@ -23,14 +23,14 @@ function Baguette(calories) {
let exportsPlain = wasmEvalText(`(module
(global i32 (i32.const 42))
(global $g (mut anyref) (ref.null))
(func (export "set") (param anyref) get_local 0 set_global $g)
(func (export "get") (result anyref) get_global $g)
(func (export "set") (param anyref) local.get 0 global.set $g)
(func (export "get") (result anyref) global.get $g)
)`).exports;
let exportsObj = wasmEvalText(`(module
(global $g (export "g") (mut anyref) (ref.null))
(func (export "set") (param anyref) get_local 0 set_global $g)
(func (export "get") (result anyref) get_global $g)
(func (export "set") (param anyref) local.get 0 global.set $g)
(func (export "get") (result anyref) global.get $g)
)`).exports;
// 7 => Generational GC zeal.

Просмотреть файл

@ -11,7 +11,7 @@ const { startProfiling, endProfiling, assertEqPreciseStacks, isSingleStepProfili
let e = wasmEvalText(`(module
(global $g (mut anyref) (ref.null))
(func (export "set") (param anyref) get_local 0 set_global $g)
(func (export "set") (param anyref) local.get 0 global.set $g)
)`).exports;
let obj = { field: null };

Просмотреть файл

@ -6,10 +6,10 @@ let { exports } = wasmEvalText(`(module
(gc_feature_opt_in 3)
(func (export "ref_eq") (param $a anyref) (param $b anyref) (result i32)
(ref.eq (get_local $a) (get_local $b)))
(ref.eq (local.get $a) (local.get $b)))
(func (export "ref_eq_for_control") (param $a anyref) (param $b anyref) (result f64)
(if f64 (ref.eq (get_local $a) (get_local $b))
(if f64 (ref.eq (local.get $a) (local.get $b))
(f64.const 5.0)
(f64.const 3.0))))`);

Просмотреть файл

@ -3,7 +3,7 @@
gczeal(14, 1);
let { exports } = wasmEvalText(`(module
(global $anyref (import "glob" "anyref") anyref)
(func (export "get") (result anyref) get_global $anyref)
(func (export "get") (result anyref) global.get $anyref)
)`, {
glob: {
anyref: { sentinel: "lol" },

Просмотреть файл

@ -42,7 +42,7 @@ let simpleTests = [
"(module (func $test (param anyref)))",
"(module (func $test (result anyref) (ref.null)))",
"(module (func $test (block anyref (unreachable)) unreachable))",
"(module (func $test (local anyref) (result i32) (ref.is_null (get_local 0))))",
"(module (func $test (local anyref) (result i32) (ref.is_null (local.get 0))))",
`(module (import "a" "b" (param anyref)))`,
`(module (import "a" "b" (result anyref)))`,
`(module (global anyref (ref.null)))`,
@ -63,7 +63,7 @@ let { exports } = wasmEvalText(`(module
)
(func $sum (result i32) (param i32)
get_local 0
local.get 0
i32.const 42
i32.add
)
@ -78,11 +78,11 @@ let { exports } = wasmEvalText(`(module
(func (export "is_null_local") (result i32) (local anyref)
ref.null
set_local 0
local.set 0
i32.const 58
call $sum
drop
get_local 0
local.get 0
ref.is_null
)
)`);
@ -95,30 +95,30 @@ assertEq(exports.is_null_local(), 1);
exports = wasmEvalText(`(module
(func (export "is_null") (result i32) (param $ref anyref)
get_local $ref
local.get $ref
ref.is_null
)
(func (export "ref_or_null") (result anyref) (param $ref anyref) (param $selector i32)
get_local $ref
local.get $ref
ref.null
get_local $selector
local.get $selector
select
)
(func $recursive (export "nested") (result anyref) (param $ref anyref) (param $i i32)
;; i == 10 => ret $ref
get_local $i
local.get $i
i32.const 10
i32.eq
if
get_local $ref
local.get $ref
return
end
get_local $ref
local.get $ref
get_local $i
local.get $i
i32.const 1
i32.add
@ -173,26 +173,26 @@ function assertJoin(body) {
assertEq(val.i, -1);
}
assertJoin("(block anyref get_local $ref)");
assertJoin("(block $out anyref get_local $ref br $out)");
assertJoin("(loop anyref get_local $ref)");
assertJoin("(block anyref local.get $ref)");
assertJoin("(block $out anyref local.get $ref br $out)");
assertJoin("(loop anyref local.get $ref)");
assertJoin(`(block $out anyref (loop $top anyref
get_local $i
local.get $i
i32.const 1
i32.add
tee_local $i
i32.const 10
i32.eq
if
get_local $ref
local.get $ref
return
end
br $top))
`);
assertJoin(`(block $out (loop $top
get_local $i
local.get $i
i32.const 1
i32.add
tee_local $i
@ -201,15 +201,15 @@ assertJoin(`(block $out (loop $top
if
br $top
else
get_local $ref
local.get $ref
return
end
)) unreachable
`);
assertJoin(`(block $out anyref (loop $top
get_local $ref
get_local $i
local.get $ref
local.get $i
i32.const 1
i32.add
tee_local $i
@ -221,8 +221,8 @@ assertJoin(`(block $out anyref (loop $top
`);
assertJoin(`(block $out anyref (block $unreachable anyref (loop $top
get_local $ref
get_local $i
local.get $ref
local.get $i
i32.const 1
i32.add
tee_local $i
@ -233,9 +233,9 @@ assertJoin(`(block $out anyref (block $unreachable anyref (loop $top
let x = { i: 42 }, y = { f: 53 };
exports = wasmEvalText(`(module
(func (export "test") (param $lhs anyref) (param $rhs anyref) (param $i i32) (result anyref)
get_local $lhs
get_local $rhs
get_local $i
local.get $lhs
local.get $rhs
local.get $i
select
)
)`).exports;
@ -290,8 +290,8 @@ exports = wasmEvalText(`(module
(import $param "funcs" "param" (param anyref))
(func (export "param") (param $x anyref) (param $y anyref)
get_local $y
get_local $x
local.get $y
local.get $x
call $param
call $param
)
@ -322,21 +322,21 @@ exports = wasmEvalText(`(module
(func $f (param $param anyref) (result anyref)
i32.const 1
get_global $count_f
global.get $count_f
i32.add
set_global $count_f
global.set $count_f
get_local $param
local.get $param
call $augment
)
(func $g (param $param anyref) (result anyref)
i32.const 1
get_global $count_g
global.get $count_g
i32.add
set_global $count_g
global.set $count_g
get_local $param
local.get $param
call $mirror
)
@ -345,13 +345,13 @@ exports = wasmEvalText(`(module
(type $table_type (func (param anyref) (result anyref)))
(func (export "call_indirect") (param $i i32) (param $ref anyref) (result anyref)
get_local $ref
get_local $i
local.get $ref
local.get $i
call_indirect $table_type
)
(func (export "count_f") (result i32) get_global $count_f)
(func (export "count_g") (result i32) get_global $count_g)
(func (export "count_f") (result i32) global.get $count_f)
(func (export "count_g") (result i32) global.get $count_g)
)`, {
funcs: {
mirror(x) {
@ -422,22 +422,22 @@ exports = wasmEvalText(`(module
(global $g_imp_mut_bread (import "constants" "mut_bread") (mut anyref))
(global $g_imm_null anyref (ref.null))
(global $g_imm_getglob anyref (get_global $g_imp_imm_bread))
(global $g_imm_getglob anyref (global.get $g_imp_imm_bread))
(global $g_mut (mut anyref) (ref.null))
(func (export "imm_null") (result anyref) get_global $g_imm_null)
(func (export "imm_getglob") (result anyref) get_global $g_imm_getglob)
(func (export "imm_null") (result anyref) global.get $g_imm_null)
(func (export "imm_getglob") (result anyref) global.get $g_imm_getglob)
(func (export "imp_imm_null") (result anyref) get_global $g_imp_imm_null)
(func (export "imp_imm_bread") (result anyref) get_global $g_imp_imm_bread)
(func (export "imp_mut_null") (result anyref) get_global $g_imp_mut_null)
(func (export "imp_mut_bread") (result anyref) get_global $g_imp_mut_bread)
(func (export "imp_imm_null") (result anyref) global.get $g_imp_imm_null)
(func (export "imp_imm_bread") (result anyref) global.get $g_imp_imm_bread)
(func (export "imp_mut_null") (result anyref) global.get $g_imp_mut_null)
(func (export "imp_mut_bread") (result anyref) global.get $g_imp_mut_bread)
(func (export "set_imp_null") (param anyref) get_local 0 set_global $g_imp_mut_null)
(func (export "set_imp_bread") (param anyref) get_local 0 set_global $g_imp_mut_bread)
(func (export "set_imp_null") (param anyref) local.get 0 global.set $g_imp_mut_null)
(func (export "set_imp_bread") (param anyref) local.get 0 global.set $g_imp_mut_bread)
(func (export "set_mut") (param anyref) get_local 0 set_global $g_mut)
(func (export "get_mut") (result anyref) get_global $g_mut)
(func (export "set_mut") (param anyref) local.get 0 global.set $g_mut)
(func (export "get_mut") (result anyref) global.get $g_mut)
)`, imports).exports;
assertEq(exports.imp_imm_null(), imports.constants.imm_null);

Просмотреть файл

@ -3,7 +3,7 @@
(function() {
let g = newGlobal({newCompartment: true});
let dbg = new Debugger(g);
g.eval(`o = new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary('(module (func (result anyref) (param anyref) get_local 0) (export "" 0))')));`);
g.eval(`o = new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary('(module (func (result anyref) (param anyref) local.get 0) (export "" 0))')));`);
})();
(function() {
@ -13,7 +13,7 @@
let src = `
(module
(func (export "func") (result anyref) (param $ref anyref)
get_local $ref
local.get $ref
)
)
`;

Просмотреть файл

@ -10,7 +10,7 @@ let simpleTests = [
"(module (func $test (param anyref)))",
"(module (func $test (result anyref) (ref.null)))",
"(module (func $test (block anyref (unreachable)) unreachable))",
"(module (func $test (local anyref) (result i32) (ref.is_null (get_local 0))))",
"(module (func $test (local anyref) (result i32) (ref.is_null (local.get 0))))",
`(module (import "a" "b" (param anyref)))`,
`(module (import "a" "b" (result anyref)))`,
`(module (type $s (struct)))`,

Просмотреть файл

@ -20,14 +20,14 @@
;; as a return value. See ref-restrict.js.
(func (export "get") (result anyref)
(get_global $g1))
(global.get $g1))
(func (export "copy")
(set_global $g2 (get_global $g1)))
(global.set $g2 (global.get $g1)))
(func (export "clear")
(set_global $g1 (get_global $g3))
(set_global $g2 (ref.null))))`);
(global.set $g1 (global.get $g3))
(global.set $g2 (ref.null))))`);
let mod = new WebAssembly.Module(bin);
let ins = new WebAssembly.Instance(mod).exports;
@ -51,19 +51,19 @@
(global $glob (mut (ref $point)) (ref.null))
(func (export "init")
(set_global $glob (struct.new $point (f64.const 0.5) (f64.const 2.75))))
(global.set $glob (struct.new $point (f64.const 0.5) (f64.const 2.75))))
(func (export "change")
(set_global $glob (struct.new $point (f64.const 3.5) (f64.const 37.25))))
(global.set $glob (struct.new $point (f64.const 3.5) (f64.const 37.25))))
(func (export "clear")
(set_global $glob (ref.null)))
(global.set $glob (ref.null)))
(func (export "x") (result f64)
(struct.get $point 0 (get_global $glob)))
(struct.get $point 0 (global.get $glob)))
(func (export "y") (result f64)
(struct.get $point 1 (get_global $glob))))`);
(struct.get $point 1 (global.get $glob))))`);
let mod = new WebAssembly.Module(bin);
let ins = new WebAssembly.Instance(mod).exports;
@ -89,9 +89,9 @@
`(module
(gc_feature_opt_in 3)
(import $g "" "g" (global anyref))
(global $glob anyref (get_global $g))
(global $glob anyref (global.get $g))
(func (export "get") (result anyref)
(get_global $glob)))`);
(global.get $glob)))`);
let mod = new WebAssembly.Module(bin);
let obj = {zappa:37};

Просмотреть файл

@ -244,7 +244,7 @@ assertErrorMessage(() => wasmCompile(
(type $fn (func (param (ref $box))))
(table (export "tbl") 1 funcref)
(func (param i32)
(call_indirect $fn (ref.null) (get_local 0))))`),
(call_indirect $fn (ref.null) (local.get 0))))`),
WebAssembly.CompileError,
/cannot expose reference type/);
@ -255,7 +255,7 @@ assertErrorMessage(() => wasmCompile(
(type $fn (func (result (ref $box))))
(table (export "tbl") 1 funcref)
(func (param i32) (result (ref $box))
(call_indirect $fn (get_local 0))))`),
(call_indirect $fn (local.get 0))))`),
WebAssembly.CompileError,
/cannot expose reference type/);
@ -264,7 +264,7 @@ assertEq(typeof wasmCompile(
(type $fn (func (param anyref)))
(table (export "tbl") 1 funcref)
(func (param i32)
(call_indirect $fn (ref.null) (get_local 0))))`),
(call_indirect $fn (ref.null) (local.get 0))))`),
"object");
assertEq(typeof wasmCompile(
@ -272,7 +272,7 @@ assertEq(typeof wasmCompile(
(type $fn (func (result anyref)))
(table (export "tbl") 1 funcref)
(func (param i32) (result anyref)
(call_indirect $fn (get_local 0))))`),
(call_indirect $fn (local.get 0))))`),
"object");
// Can't call via imported table with type that is exposed for Ref, though anyref is OK.
@ -284,7 +284,7 @@ assertErrorMessage(() => wasmCompile(
(type $fn (func (param (ref $box))))
(import "m" "tbl" (table 1 funcref))
(func (param i32)
(call_indirect $fn (ref.null) (get_local 0))))`),
(call_indirect $fn (ref.null) (local.get 0))))`),
WebAssembly.CompileError,
/cannot expose reference type/);
@ -295,7 +295,7 @@ assertErrorMessage(() => wasmCompile(
(type $fn (func (result (ref $box))))
(import "m" "tbl" (table 1 funcref))
(func (param i32) (result (ref $box))
(call_indirect $fn (get_local 0))))`),
(call_indirect $fn (local.get 0))))`),
WebAssembly.CompileError,
/cannot expose reference type/);
@ -304,7 +304,7 @@ assertEq(typeof wasmCompile(
(type $fn (func (param anyref)))
(import "m" "tbl" (table 1 funcref))
(func (param i32)
(call_indirect $fn (ref.null) (get_local 0))))`),
(call_indirect $fn (ref.null) (local.get 0))))`),
"object");
assertEq(typeof wasmCompile(
@ -312,7 +312,7 @@ assertEq(typeof wasmCompile(
(type $fn (func (result anyref)))
(import "m" "tbl" (table 1 funcref))
(func (param i32) (result anyref)
(call_indirect $fn (get_local 0))))`),
(call_indirect $fn (local.get 0))))`),
"object");
// We can call via a private table with a type that is exposed for Ref.
@ -327,7 +327,7 @@ assertEq(typeof wasmCompile(
(elem (i32.const 0) $f1)
(func $f1 (param (ref $box)) (result i32) (i32.const 37))
(func (export "f") (param i32) (result i32)
(call_indirect $fn (ref.null) (get_local 0))))`);
(call_indirect $fn (ref.null) (local.get 0))))`);
let i = new WebAssembly.Instance(m).exports;
assertEq(i.f(0), 37);
}

Просмотреть файл

@ -38,54 +38,54 @@ function checkInvalid(body, errorMessage) {
(global $k (mut i32) (i32.const 0))
(func (export "init") (param $n i32)
(set_global $g (call $make (get_local $n))))
(global.set $g (call $make (local.get $n))))
(func $make (param $n i32) (result (ref $wabbit))
(local $tmp i32)
(set_local $tmp (get_global $k))
(set_global $k (i32.add (get_local $tmp) (i32.const 1)))
(if (ref $wabbit) (i32.le_s (get_local $n) (i32.const 2))
(struct.new $wabbit (get_local $tmp) (ref.null) (ref.null))
(local.set $tmp (global.get $k))
(global.set $k (i32.add (local.get $tmp) (i32.const 1)))
(if (ref $wabbit) (i32.le_s (local.get $n) (i32.const 2))
(struct.new $wabbit (local.get $tmp) (ref.null) (ref.null))
(block (ref $wabbit)
(struct.new $wabbit
(get_local $tmp)
(call $make (i32.sub (get_local $n) (i32.const 1)))
(call $make (i32.sub (get_local $n) (i32.const 2)))))))
(local.get $tmp)
(call $make (i32.sub (local.get $n) (i32.const 1)))
(call $make (i32.sub (local.get $n) (i32.const 2)))))))
(func (export "accumulate") (result i32)
(call $accum (get_global $g)))
(call $accum (global.get $g)))
(func $accum (param $w (ref $wabbit)) (result i32)
(if i32 (ref.is_null (get_local $w))
(if i32 (ref.is_null (local.get $w))
(i32.const 0)
(i32.add (struct.get $wabbit 0 (get_local $w))
(i32.sub (call $accum (struct.get $wabbit 1 (get_local $w)))
(call $accum (struct.get $wabbit 2 (get_local $w)))))))
(i32.add (struct.get $wabbit 0 (local.get $w))
(i32.sub (call $accum (struct.get $wabbit 1 (local.get $w)))
(call $accum (struct.get $wabbit 2 (local.get $w)))))))
(func (export "reverse")
(call $reverse (get_global $g)))
(call $reverse (global.get $g)))
(func $reverse (param $w (ref $wabbit))
(local $tmp (ref $wabbit))
(if (i32.eqz (ref.is_null (get_local $w)))
(if (i32.eqz (ref.is_null (local.get $w)))
(block
(struct.set $wabbit 0 (get_local $w) (i32.mul (i32.const 2) (struct.get $wabbit 0 (get_local $w))))
(set_local $tmp (struct.get $wabbit 1 (get_local $w)))
(struct.set $wabbit 1 (get_local $w) (struct.get $wabbit 2 (get_local $w)))
(struct.set $wabbit 2 (get_local $w) (get_local $tmp))
(call $reverse (struct.get $wabbit 1 (get_local $w)))
(call $reverse (struct.get $wabbit 2 (get_local $w))))))
(struct.set $wabbit 0 (local.get $w) (i32.mul (i32.const 2) (struct.get $wabbit 0 (local.get $w))))
(local.set $tmp (struct.get $wabbit 1 (local.get $w)))
(struct.set $wabbit 1 (local.get $w) (struct.get $wabbit 2 (local.get $w)))
(struct.set $wabbit 2 (local.get $w) (local.get $tmp))
(call $reverse (struct.get $wabbit 1 (local.get $w)))
(call $reverse (struct.get $wabbit 2 (local.get $w))))))
(func (export "print")
(call $pr (get_global $g)))
(call $pr (global.get $g)))
(func $pr (param $w (ref $wabbit))
(if (i32.eqz (ref.is_null (get_local $w)))
(if (i32.eqz (ref.is_null (local.get $w)))
(block
(call $print_lp)
(call $print_int (struct.get $wabbit 0 (get_local $w)))
(call $pr (struct.get $wabbit 1 (get_local $w)))
(call $pr (struct.get $wabbit 2 (get_local $w)))
(call $print_int (struct.get $wabbit 0 (local.get $w)))
(call $pr (struct.get $wabbit 1 (local.get $w)))
(call $pr (struct.get $wabbit 2 (local.get $w)))
(call $print_rp))))
)`);
@ -123,7 +123,7 @@ wasmEvalText(
(type $node (struct (field (mut (ref $node)))))
(type $nix (struct (field (mut (ref $node))) (field i32)))
(func $f (param $p (ref $node)) (param $q (ref $nix))
(struct.set $node 0 (get_local $p) (get_local $q))))`);
(struct.set $node 0 (local.get $p) (local.get $q))))`);
// struct.narrow: if the pointer's null we get null
@ -133,7 +133,7 @@ assertEq(wasmEvalText(
(type $node (struct (field i32)))
(type $node2 (struct (field i32) (field f32)))
(func $f (param $p (ref $node)) (result (ref $node2))
(struct.narrow (ref $node) (ref $node2) (get_local $p)))
(struct.narrow (ref $node) (ref $node2) (local.get $p)))
(func (export "test") (result anyref)
(call $f (ref.null))))`).exports.test(),
null);
@ -146,11 +146,11 @@ assertEq(wasmEvalText(
(type $node (struct (field i32)))
(type $node2 (struct (field i32) (field f32)))
(func $f (param $p (ref $node)) (result (ref $node2))
(struct.narrow (ref $node) (ref $node2) (get_local $p)))
(struct.narrow (ref $node) (ref $node2) (local.get $p)))
(func (export "test") (result i32)
(local $n (ref $node))
(set_local $n (struct.new $node2 (i32.const 0) (f32.const 12)))
(ref.eq (call $f (get_local $n)) (get_local $n))))`).exports.test(),
(local.set $n (struct.new $node2 (i32.const 0) (f32.const 12)))
(ref.eq (call $f (local.get $n)) (local.get $n))))`).exports.test(),
1);
// And once more with mutable fields
@ -161,11 +161,11 @@ assertEq(wasmEvalText(
(type $node (struct (field (mut i32))))
(type $node2 (struct (field (mut i32)) (field f32)))
(func $f (param $p (ref $node)) (result (ref $node2))
(struct.narrow (ref $node) (ref $node2) (get_local $p)))
(struct.narrow (ref $node) (ref $node2) (local.get $p)))
(func (export "test") (result i32)
(local $n (ref $node))
(set_local $n (struct.new $node2 (i32.const 0) (f32.const 12)))
(ref.eq (call $f (get_local $n)) (get_local $n))))`).exports.test(),
(local.set $n (struct.new $node2 (i32.const 0) (f32.const 12)))
(ref.eq (call $f (local.get $n)) (local.get $n))))`).exports.test(),
1);
// A more subtle case: the downcast is to a struct that looks like the original
@ -186,12 +186,12 @@ assertEq(wasmEvalText(
(type $node2b (struct (field i32) (field (ref $node))))
(func $f (param $p (ref $node)) (result (ref $node2b))
(struct.narrow (ref $node) (ref $node2b) (get_local $p)))
(struct.narrow (ref $node) (ref $node2b) (local.get $p)))
(func (export "test") (result i32)
(local $n (ref $node))
(set_local $n (struct.new $node2a (i32.const 0) (ref.null)))
(ref.eq (call $f (get_local $n)) (get_local $n))))`).exports.test(),
(local.set $n (struct.new $node2a (i32.const 0) (ref.null)))
(ref.eq (call $f (local.get $n)) (local.get $n))))`).exports.test(),
1);
assertEq(wasmEvalText(
@ -204,12 +204,12 @@ assertEq(wasmEvalText(
(type $node2b (struct (field i32) (field (ref $nodeCopy))))
(func $f (param $p (ref $node)) (result (ref $node2b))
(struct.narrow (ref $node) (ref $node2b) (get_local $p)))
(struct.narrow (ref $node) (ref $node2b) (local.get $p)))
(func (export "test") (result i32)
(local $n (ref $node))
(set_local $n (struct.new $node2a (i32.const 0) (ref.null)))
(ref.eq (call $f (get_local $n)) (get_local $n))))`).exports.test(),
(local.set $n (struct.new $node2a (i32.const 0) (ref.null)))
(ref.eq (call $f (local.get $n)) (local.get $n))))`).exports.test(),
0);
// Another subtle case: struct.narrow can target a type that is not the concrete
@ -222,11 +222,11 @@ assertEq(wasmEvalText(
(type $node2 (struct (field i32) (field f32)))
(type $node3 (struct (field i32) (field f32) (field f64)))
(func $f (param $p (ref $node)) (result (ref $node2))
(struct.narrow (ref $node) (ref $node2) (get_local $p)))
(struct.narrow (ref $node) (ref $node2) (local.get $p)))
(func (export "test") (result i32)
(local $n (ref $node))
(set_local $n (struct.new $node3 (i32.const 0) (f32.const 12) (f64.const 17)))
(ref.eq (call $f (get_local $n)) (get_local $n))))`).exports.test(),
(local.set $n (struct.new $node3 (i32.const 0) (f32.const 12) (f64.const 17)))
(ref.eq (call $f (local.get $n)) (local.get $n))))`).exports.test(),
1);
// struct.narrow: if the downcast fails we get null
@ -238,7 +238,7 @@ assertEq(wasmEvalText(
(type $node2 (struct (field i32) (field f32)))
(type $snort (struct (field i32) (field f64)))
(func $f (param $p (ref $node)) (result (ref $node2))
(struct.narrow (ref $node) (ref $node2) (get_local $p)))
(struct.narrow (ref $node) (ref $node2) (local.get $p)))
(func (export "test") (result anyref)
(call $f (struct.new $snort (i32.const 0) (f64.const 12)))))`).exports.test(),
null);
@ -251,11 +251,11 @@ assertEq(wasmEvalText(
(gc_feature_opt_in 3)
(type $node (struct (field i32)))
(func $f (param $p anyref) (result (ref $node))
(struct.narrow anyref (ref $node) (get_local $p)))
(struct.narrow anyref (ref $node) (local.get $p)))
(func (export "test") (result i32)
(local $n (ref $node))
(set_local $n (struct.new $node (i32.const 0)))
(ref.eq (call $f (get_local $n)) (get_local $n))))`).exports.test(),
(local.set $n (struct.new $node (i32.const 0)))
(ref.eq (call $f (local.get $n)) (local.get $n))))`).exports.test(),
1);
// struct.narrow: anyref -> struct when the anyref is some random gunk.
@ -265,7 +265,7 @@ assertEq(wasmEvalText(
(gc_feature_opt_in 3)
(type $node (struct (field i32)))
(func (export "test") (param $p anyref) (result anyref)
(struct.narrow anyref (ref $node) (get_local $p))))`).exports.test({hi:37}),
(struct.narrow anyref (ref $node) (local.get $p))))`).exports.test({hi:37}),
null);
// Types are private to an instance and struct.narrow can't break this
@ -276,9 +276,9 @@ assertEq(wasmEvalText(
(gc_feature_opt_in 3)
(type $node (struct (field i32)))
(func (export "make") (param $n i32) (result anyref)
(struct.new $node (get_local $n)))
(struct.new $node (local.get $n)))
(func (export "coerce") (param $p anyref) (result i32)
(ref.is_null (struct.narrow anyref (ref $node) (get_local $p)))))`;
(ref.is_null (struct.narrow anyref (ref $node) (local.get $p)))))`;
let mod = new WebAssembly.Module(wasmTextToBinary(txt));
let ins1 = new WebAssembly.Instance(mod).exports;
let ins2 = new WebAssembly.Instance(mod).exports;
@ -296,7 +296,7 @@ assertErrorMessage(() => wasmEvalText(
(gc_feature_opt_in 3)
(type $node (struct (field i32)))
(func $f (param $p (ref $node))
(struct.set $node 0 (get_local $p) (i32.const 37))))`),
(struct.set $node 0 (local.get $p) (i32.const 37))))`),
WebAssembly.CompileError,
/field is not mutable/);
@ -307,7 +307,7 @@ assertErrorMessage(() => wasmEvalText(
(gc_feature_opt_in 3)
(type $node (struct (field (mut i32))))
(func $f (param $p (ref $node))
(struct.set $node 0 (get_local $p) (f32.const 37))))`),
(struct.set $node 0 (local.get $p) (f32.const 37))))`),
WebAssembly.CompileError,
/expression has type f32 but expected i32/);
@ -318,7 +318,7 @@ assertErrorMessage(() => wasmEvalText(
(gc_feature_opt_in 3)
(type $node (struct (field i32)))
(func $f (param $p (ref $node)) (result i32)
(struct.get $node 1 (get_local $p))))`),
(struct.get $node 1 (local.get $p))))`),
WebAssembly.CompileError,
/field index out of range/);
@ -329,7 +329,7 @@ assertErrorMessage(() => wasmEvalText(
(gc_feature_opt_in 3)
(type $node (struct (field (mut i32))))
(func $f (param $p (ref $node))
(struct.set $node 1 (get_local $p) (i32.const 37))))`),
(struct.set $node 1 (local.get $p) (i32.const 37))))`),
WebAssembly.CompileError,
/field index out of range/);
@ -341,7 +341,7 @@ assertErrorMessage(() => wasmEvalText(
(type $node (struct (field i32)))
(type $snort (struct (field f64)))
(func $f (param $p (ref $snort)) (result i32)
(struct.get $node 0 (get_local $p))))`),
(struct.get $node 0 (local.get $p))))`),
WebAssembly.CompileError,
/expression has type.*but expected.*/);
@ -353,7 +353,7 @@ assertErrorMessage(() => wasmEvalText(
(type $node (struct (field (mut i32))))
(type $snort (struct (field f64)))
(func $f (param $p (ref $snort)) (result i32)
(struct.set $node 0 (get_local $p) (i32.const 0))))`),
(struct.set $node 0 (local.get $p) (i32.const 0))))`),
WebAssembly.CompileError,
/expression has type.*but expected.*/);
@ -366,7 +366,7 @@ assertErrorMessage(() => wasmEvalText(
(type $node2 (struct (field i32) (field f32)))
(type $snort (struct (field f64)))
(func $f (param $p (ref $snort)) (result (ref $node2))
(struct.narrow (ref $node) (ref $node2) (get_local 0))))`),
(struct.narrow (ref $node) (ref $node2) (local.get 0))))`),
WebAssembly.CompileError,
/expression has type.*but expected.*/);
@ -378,7 +378,7 @@ assertErrorMessage(() => wasmEvalText(
(type $node (struct (field i32)))
(type $node2 (struct (field (mut i32)) (field f32)))
(func $f (param $p (ref $node)) (result (ref $node2))
(struct.narrow (ref $node) (ref $node2) (get_local 0))))`),
(struct.narrow (ref $node) (ref $node2) (local.get 0))))`),
WebAssembly.CompileError,
/invalid narrowing operation/);
@ -388,7 +388,7 @@ assertErrorMessage(() => wasmEvalText(
(type $node (struct (field (mut i32))))
(type $node2 (struct (field i32) (field f32)))
(func $f (param $p (ref $node)) (result (ref $node2))
(struct.narrow (ref $node) (ref $node2) (get_local 0))))`),
(struct.narrow (ref $node) (ref $node2) (local.get 0))))`),
WebAssembly.CompileError,
/invalid narrowing operation/);
@ -399,7 +399,7 @@ assertErrorMessage(() => wasmEvalText(
(gc_feature_opt_in 3)
(type $node (struct (field i32)))
(func $f (param $p (ref $node)) (result anyref)
(struct.narrow i32 anyref (get_local 0))))`),
(struct.narrow i32 anyref (local.get 0))))`),
SyntaxError,
/struct.narrow requires ref type/);
@ -408,7 +408,7 @@ assertErrorMessage(() => wasmEvalText(
(gc_feature_opt_in 3)
(type $node (struct (field i32)))
(func $f (param $p (ref $node)) (result anyref)
(struct.narrow anyref i32 (get_local 0))))`),
(struct.narrow anyref i32 (local.get 0))))`),
SyntaxError,
/struct.narrow requires ref type/);
@ -437,7 +437,7 @@ assertErrorMessage(() => wasmEvalText(
(gc_feature_opt_in 3)
(type $node (struct (field i32)))
(func $f (param $p (ref $node)) (result anyref)
(struct.narrow (ref $node) anyref (get_local 0))))`),
(struct.narrow (ref $node) anyref (local.get 0))))`),
WebAssembly.CompileError,
/invalid type combination in struct.narrow/);
@ -449,7 +449,7 @@ assertErrorMessage(() => wasmEvalText(
(type $node (struct (field i32)))
(type $node2 (struct (field i32) (field f32)))
(func $f (param $p (ref $node2)) (result anyref)
(struct.narrow (ref $node2) (ref $node) (get_local 0))))`),
(struct.narrow (ref $node2) (ref $node) (local.get 0))))`),
WebAssembly.CompileError,
/invalid narrowing operation/);
@ -463,7 +463,7 @@ assertErrorMessage(function() {
(func (export "test")
(drop (call $f (ref.null))))
(func $f (param $p (ref $node)) (result i32)
(struct.get $node 0 (get_local $p))))`);
(struct.get $node 0 (local.get $p))))`);
ins.exports.test();
},
WebAssembly.RuntimeError,
@ -479,7 +479,7 @@ assertErrorMessage(function() {
(func (export "test")
(call $f (ref.null)))
(func $f (param $p (ref $node))
(struct.set $node 0 (get_local $p) (i32.const 0))))`);
(struct.set $node 0 (local.get $p) (i32.const 0))))`);
ins.exports.test();
},
WebAssembly.RuntimeError,

Просмотреть файл

@ -30,12 +30,12 @@ var bin = wasmTextToBinary(
(func $cdr (param $p (ref $cons)) (result (ref $cons))
(local $l (ref $cons))
;; store null value of correct type
(set_local $l (ref.null))
(local.set $l (ref.null))
;; store local of correct type
(set_local $l (get_local $p))
(local.set $l (local.get $p))
;; store call result of correct type
(set_local $l (call $cdr (get_local $p)))
;; TODO: eventually also a test with get_global
(local.set $l (call $cdr (local.get $p)))
;; TODO: eventually also a test with global.get
;; blocks and if with result type
(block (ref $cons)
(if (ref $cons) (i32.eqz (i32.const 0))
@ -49,16 +49,16 @@ var bin = wasmTextToBinary(
(ref.null))
(func (param (ref $cons))
(call $cdr (get_local 0))
(call $cdr (local.get 0))
drop
(call $imp (get_local 0))
(call $imp (local.get 0))
drop)
(func (param (ref $cons))
(drop (ref.eq (get_local 0) (ref.null)))
(drop (ref.eq (ref.null) (get_local 0)))
(drop (ref.eq (get_local 0) (ref.null)))
(drop (ref.eq (ref.null) (get_local 0))))
(drop (ref.eq (local.get 0) (ref.null)))
(drop (ref.eq (ref.null) (local.get 0)))
(drop (ref.eq (local.get 0) (ref.null)))
(drop (ref.eq (ref.null) (local.get 0))))
)`);
// Validation
@ -72,7 +72,7 @@ new WebAssembly.Module(wasmTextToBinary(`
(gc_feature_opt_in 3)
(type $s (struct))
(func $null (param (ref $s)) (result i32)
(ref.is_null (get_local 0))))
(ref.is_null (local.get 0))))
`))
// Automatic upcast to anyref
@ -81,7 +81,7 @@ new WebAssembly.Module(wasmTextToBinary(`
(module
(gc_feature_opt_in 3)
(type $s (struct (field i32)))
(func $f (param (ref $s)) (call $g (get_local 0)))
(func $f (param (ref $s)) (call $g (local.get 0)))
(func $g (param anyref) (unreachable)))
`));
@ -103,7 +103,7 @@ wasmEvalText(`
(type $s (struct (field i32)))
(type $t (struct (field i32)))
(func $f (param (ref $s)) (unreachable))
(func $g (param (ref $t)) (call $f (get_local 0)))
(func $g (param (ref $t)) (call $f (local.get 0)))
)`);
assertErrorMessage(() => wasmEvalText(`
@ -112,7 +112,7 @@ assertErrorMessage(() => wasmEvalText(`
(type $s (struct (field i32)))
(type $t (struct (field f32))) ;; Incompatible type
(func $f (param (ref $s)) (unreachable))
(func $g (param (ref $t)) (call $f (get_local 0)))
(func $g (param (ref $t)) (call $f (local.get 0)))
)`),
WebAssembly.CompileError, /expression has type ref.*but expected ref/);
@ -122,7 +122,7 @@ assertErrorMessage(() => wasmEvalText(`
(type $s (struct (field i32)))
(type $t (struct (field (mut i32)))) ;; Incompatible mutability
(func $f (param (ref $s)) (unreachable))
(func $g (param (ref $t)) (call $f (get_local 0)))
(func $g (param (ref $t)) (call $f (local.get 0)))
)`),
WebAssembly.CompileError, /expression has type ref.*but expected ref/);
@ -134,7 +134,7 @@ wasmEvalText(`
(gc_feature_opt_in 3)
(type $s (struct (field i32)))
(type $t (struct (field i32)))
(func $f (param (ref $s)) (local (ref $t)) (set_local 1 (get_local 0))))
(func $f (param (ref $s)) (local (ref $t)) (local.set 1 (local.get 0))))
`)
assertErrorMessage(() => wasmEvalText(`
@ -142,7 +142,7 @@ assertErrorMessage(() => wasmEvalText(`
(gc_feature_opt_in 3)
(type $s (struct (field i32)))
(type $t (struct (field f32)))
(func $f (param (ref $s)) (local (ref $t)) (set_local 1 (get_local 0))))
(func $f (param (ref $s)) (local (ref $t)) (local.set 1 (local.get 0))))
`),
WebAssembly.CompileError, /expression has type ref.*but expected ref/);
@ -152,7 +152,7 @@ assertErrorMessage(() => wasmEvalText(`
(type $s (struct (field i32)))
(type $t (struct (field (mut i32))))
(func $f (param (ref $s)) (unreachable))
(func $g (param (ref $t)) (call $f (get_local 0)))
(func $g (param (ref $t)) (call $f (local.get 0)))
)`),
WebAssembly.CompileError, /expression has type ref.*but expected ref/);
@ -164,7 +164,7 @@ wasmEvalText(`
(gc_feature_opt_in 3)
(type $s (struct (field i32)))
(type $t (struct (field i32)))
(func $f (param (ref $s)) (result (ref $t)) (get_local 0)))
(func $f (param (ref $s)) (result (ref $t)) (local.get 0)))
`);
assertErrorMessage(() => wasmEvalText(`
@ -172,7 +172,7 @@ assertErrorMessage(() => wasmEvalText(`
(gc_feature_opt_in 3)
(type $s (struct (field i32)))
(type $t (struct (field f32)))
(func $f (param (ref $s)) (result (ref $t)) (get_local 0)))
(func $f (param (ref $s)) (result (ref $t)) (local.get 0)))
`),
WebAssembly.CompileError, /expression has type ref.*but expected ref/);
@ -181,7 +181,7 @@ assertErrorMessage(() => wasmEvalText(`
(gc_feature_opt_in 3)
(type $s (struct (field i32)))
(type $t (struct (field (mut i32))))
(func $f (param (ref $s)) (result (ref $t)) (get_local 0)))
(func $f (param (ref $s)) (result (ref $t)) (local.get 0)))
`),
WebAssembly.CompileError, /expression has type ref.*but expected ref/);
@ -209,7 +209,7 @@ assertErrorMessage(() => wasmEvalText(`
(module
(gc_feature_opt_in 3)
(type $s (struct (field i32)))
(func $f (param anyref) (call $g (get_local 0)))
(func $f (param anyref) (call $g (local.get 0)))
(func $g (param (ref $s)) (unreachable)))
`),
WebAssembly.CompileError, /expression has type anyref but expected ref/);

Просмотреть файл

@ -32,11 +32,11 @@ let t =
(param $arg4 anyref) (param $arg5 anyref) (param $arg6 i32)
(call $alloc)
drop
(i32.add (i32.add (get_local $arg1) (get_local $arg3)) (get_local $arg6))
(i32.add (i32.add (local.get $arg1) (local.get $arg3)) (local.get $arg6))
;; Poke the ref-typed arguments, to be sure that they got kept alive
;; properly across any GC that the |alloc| call might have done.
(call $check3 (get_local $arg2) (get_local $arg4) (get_local $arg5))
(call $check3 (local.get $arg2) (local.get $arg4) (local.get $arg5))
)
;; -- fn 1
@ -45,26 +45,26 @@ let t =
(loop i32
;; call direct 0
(call $fn0 (i32.const 10) (get_local $arg1) (i32.const 12)
(get_local $arg1) (get_local $arg1) (i32.const 15))
(call $fn0 (i32.const 10) (local.get $arg1) (i32.const 12)
(local.get $arg1) (local.get $arg1) (i32.const 15))
;; call indirect 0
(call_indirect $typeOfFn0
(i32.const 10) (get_local $arg1) (i32.const 12)
(get_local $arg1) (get_local $arg1) (i32.const 15)
(i32.const 10) (local.get $arg1) (i32.const 12)
(local.get $arg1) (local.get $arg1) (i32.const 15)
(i32.const 0)) ;; table index
i32.add
;; Do 60k iterations of this loop, to get a good amount of allocation
(set_local $i (i32.add (get_local $i) (i32.const 1)))
(br_if 0 (i32.lt_s (get_local $i) (i32.const 60000)))
(local.set $i (i32.add (local.get $i) (i32.const 1)))
(br_if 0 (i32.lt_s (local.get $i) (i32.const 60000)))
)
)
;; -- fn 2
(func $fn2 (export "fn2") (param $arg1 anyref) (result i32)
(call $fn1 (get_local $arg1))
(call $fn1 (local.get $arg1))
)
)`;

Просмотреть файл

@ -46,28 +46,28 @@ let t =
;; spinloop to waste time
(loop
(set_local $i (i32.add (get_local $i) (i32.const 1)))
(br_if 0 (i32.lt_s (get_local $i) (i32.const 100)))
(local.set $i (i32.add (local.get $i) (i32.const 1)))
(br_if 0 (i32.lt_s (local.get $i) (i32.const 100)))
)
(i32.add (i32.add (get_local $arg1) (get_local $arg3)) (get_local $arg6))
(i32.add (i32.add (local.get $arg1) (local.get $arg3)) (local.get $arg6))
;; Poke the ref-typed arguments, to be sure that they got kept alive
;; properly across any GC that might have happened.
(call $check3 (get_local $arg2) (get_local $arg4) (get_local $arg5))
(call $check3 (local.get $arg2) (local.get $arg4) (local.get $arg5))
)
;; -- fn 1
(func $fn1 (export "fn1") (param $arg1 anyref) (result i32)
(loop i32
;; call direct to $fn0
(call $fn0 (i32.const 10) (get_local $arg1) (i32.const 12)
(get_local $arg1) (get_local $arg1) (i32.const 15))
(call $fn0 (i32.const 10) (local.get $arg1) (i32.const 12)
(local.get $arg1) (local.get $arg1) (i32.const 15))
;; call indirect to table index 0, which is $fn0
(call_indirect $typeOfFn0
(i32.const 10) (get_local $arg1) (i32.const 12)
(get_local $arg1) (get_local $arg1) (i32.const 15)
(i32.const 10) (local.get $arg1) (i32.const 12)
(local.get $arg1) (local.get $arg1) (i32.const 15)
(i32.const 0)) ;; table index
i32.add
@ -79,7 +79,7 @@ let t =
;; -- fn 2
(func $fn2 (export "fn2") (param $arg1 anyref) (result i32)
(call $fn1 (get_local $arg1))
(call $fn1 (local.get $arg1))
)
)`;

Просмотреть файл

@ -34,8 +34,8 @@ let t =
(func $mkConsIgnoringScalar (result anyref)
(param $hd anyref) (param i32) (param $tl anyref)
(get_local $hd)
(get_local $tl)
(local.get $hd)
(local.get $tl)
call $mkCons
)
@ -48,14 +48,14 @@ let t =
;; scalars for added confusion
(local $scalar99 i32)
(local $scalar97 i32)
(set_local $scalar99 (i32.const 99))
(set_local $scalar97 (i32.const 97))
(local.set $scalar99 (i32.const 99))
(local.set $scalar97 (i32.const 97))
call $mkBoxedInt
get_local $scalar99
local.get $scalar99
call $mkBoxedInt
call $mkBoxedInt
get_local $scalar97
local.get $scalar97
call $mkBoxedInt
call $mkBoxedInt
call $mkBoxedInt

Просмотреть файл

@ -44,19 +44,19 @@ var bin = wasmTextToBinary(
(func $x2 (import "m" "x2") (type $f2))
(func (export "hello") (param f64) (param i32) (result f64)
(call_indirect $f2 (get_local 0) (get_local 1)))
(call_indirect $f2 (local.get 0) (local.get 1)))
(func $doit (param f64) (result f64)
(f64.sqrt (get_local 0)))
(f64.sqrt (local.get 0)))
(func $doitagain (param f64) (result f64)
(f64.mul (get_local 0) (get_local 0)))
(f64.mul (local.get 0) (local.get 0)))
(func (export "x1") (param i32) (result i32)
(call $x1 (get_local 0)))
(call $x1 (local.get 0)))
(func (export "x2") (param f64) (result f64)
(call $x2 (get_local 0)))
(call $x2 (local.get 0)))
;; Useful for testing to ensure that the type is not type #0 here.
@ -64,7 +64,7 @@ var bin = wasmTextToBinary(
(struct.new $point (i32.const 37) (i32.const 42)))
(func (export "mk_int_node") (param i32) (param anyref) (result anyref)
(struct.new $int_node (get_local 0) (get_local 1)))
(struct.new $int_node (local.get 0) (local.get 1)))
;; Too big to fit in an InlineTypedObject.
@ -187,7 +187,7 @@ var bin = wasmTextToBinary(
(func (export "mk_withfloats")
(param f32) (param f64) (param anyref) (param f32) (param i32)
(result anyref)
(struct.new $withfloats (get_local 0) (get_local 1) (get_local 2) (get_local 3) (get_local 4)))
(struct.new $withfloats (local.get 0) (local.get 1) (local.get 2) (local.get 3) (local.get 4)))
)`)
@ -232,11 +232,11 @@ var stress = wasmTextToBinary(
(local $list (ref $node))
(block $exit
(loop $loop
(br_if $exit (i32.eqz (get_local $n)))
(set_local $list (struct.new $node (get_local $n) (get_local $list)))
(set_local $n (i32.sub (get_local $n) (i32.const 1)))
(br_if $exit (i32.eqz (local.get $n)))
(local.set $list (struct.new $node (local.get $n) (local.get $list)))
(local.set $n (i32.sub (local.get $n) (i32.const 1)))
(br $loop)))
(get_local $list)))`);
(local.get $list)))`);
var stressIns = new WebAssembly.Instance(new WebAssembly.Module(stress)).exports;
var stressLevel = conf.x64 && !conf.tsan && !conf.asan && !conf.valgrind ? 100000 : 1000;
var the_list = stressIns.iota1(stressLevel);
@ -263,20 +263,20 @@ assertEq(the_list, null);
(func (export "set") (param anyref)
(local (ref $big))
(set_local 1 (struct.narrow anyref (ref $big) (get_local 0)))
(struct.set $big 1 (get_local 1) (i64.const 0x3333333376544567)))
(local.set 1 (struct.narrow anyref (ref $big) (local.get 0)))
(struct.set $big 1 (local.get 1) (i64.const 0x3333333376544567)))
(func (export "set2") (param $p anyref)
(struct.set $big 1
(struct.narrow anyref (ref $big) (get_local $p))
(struct.narrow anyref (ref $big) (local.get $p))
(i64.const 0x3141592653589793)))
(func (export "low") (param $p anyref) (result i32)
(i32.wrap/i64 (struct.get $big 1 (struct.narrow anyref (ref $big) (get_local $p)))))
(i32.wrap/i64 (struct.get $big 1 (struct.narrow anyref (ref $big) (local.get $p)))))
(func (export "high") (param $p anyref) (result i32)
(i32.wrap/i64 (i64.shr_u
(struct.get $big 1 (struct.narrow anyref (ref $big) (get_local $p)))
(struct.get $big 1 (struct.narrow anyref (ref $big) (local.get $p)))
(i64.const 32))))
(func (export "mk") (result anyref)
@ -324,34 +324,34 @@ assertEq(the_list, null);
(global $g (mut (ref $big)) (ref.null))
(func (export "make") (result anyref)
(set_global $g
(global.set $g
(struct.new $big (i32.const 0x7aaaaaaa) (i64.const 0x4201020337) (i32.const 0x6bbbbbbb)))
(get_global $g))
(global.get $g))
(func (export "update0") (param $x i32)
(struct.set $big 0 (get_global $g) (get_local $x)))
(struct.set $big 0 (global.get $g) (local.get $x)))
(func (export "get0") (result i32)
(struct.get $big 0 (get_global $g)))
(struct.get $big 0 (global.get $g)))
(func (export "update1") (param $hi i32) (param $lo i32)
(struct.set $big 1 (get_global $g)
(struct.set $big 1 (global.get $g)
(i64.or
(i64.shl (i64.extend_u/i32 (get_local $hi)) (i64.const 32))
(i64.extend_u/i32 (get_local $lo)))))
(i64.shl (i64.extend_u/i32 (local.get $hi)) (i64.const 32))
(i64.extend_u/i32 (local.get $lo)))))
(func (export "get1_low") (result i32)
(i32.wrap/i64 (struct.get $big 1 (get_global $g))))
(i32.wrap/i64 (struct.get $big 1 (global.get $g))))
(func (export "get1_high") (result i32)
(i32.wrap/i64
(i64.shr_u (struct.get $big 1 (get_global $g)) (i64.const 32))))
(i64.shr_u (struct.get $big 1 (global.get $g)) (i64.const 32))))
(func (export "update2") (param $x i32)
(struct.set $big 2 (get_global $g) (get_local $x)))
(struct.set $big 2 (global.get $g) (local.get $x)))
(func (export "get2") (result i32)
(struct.get $big 2 (get_global $g)))
(struct.get $big 2 (global.get $g)))
)`;
@ -396,16 +396,16 @@ var bin = wasmTextToBinary(
(global $g (mut (ref $cons)) (ref.null))
(func (export "push") (param i32)
(set_global $g (struct.new $cons (get_local 0) (get_global $g))))
(global.set $g (struct.new $cons (local.get 0) (global.get $g))))
(func (export "top") (result i32)
(struct.get $cons 0 (get_global $g)))
(struct.get $cons 0 (global.get $g)))
(func (export "pop")
(set_global $g (struct.get $cons 1 (get_global $g))))
(global.set $g (struct.get $cons 1 (global.get $g))))
(func (export "is_empty") (result i32)
(ref.is_null (get_global $g)))
(ref.is_null (global.get $g)))
)`);
@ -437,7 +437,7 @@ assertErrorMessage(() => ins.pop(),
(func (export "mk") (result anyref)
(struct.new $Node (i32.const 37)))
(func (export "f") (param $n anyref) (result anyref)
(struct.narrow anyref (ref $Node) (get_local $n))))`).exports;
(struct.narrow anyref (ref $Node) (local.get $n))))`).exports;
var n = ins.mk();
assertEq(ins.f(n), n);
assertEq(ins.f(wrapWithProto(n, {})), null);
@ -457,16 +457,16 @@ assertErrorMessage(() => ins.pop(),
(field $y i32)))
(func $f (param $p (ref $s)) (result i32)
(struct.get $s $x (get_local $p)))
(struct.get $s $x (local.get $p)))
(func $g (param $p (ref $s)) (result i32)
(struct.get $s $y (get_local $p)))
(struct.get $s $y (local.get $p)))
(func (export "testf") (param $n i32) (result i32)
(call $f (struct.new $s (get_local $n) (i32.mul (get_local $n) (i32.const 2)))))
(call $f (struct.new $s (local.get $n) (i32.mul (local.get $n) (i32.const 2)))))
(func (export "testg") (param $n i32) (result i32)
(call $g (struct.new $s (get_local $n) (i32.mul (get_local $n) (i32.const 2)))))
(call $g (struct.new $s (local.get $n) (i32.mul (local.get $n) (i32.const 2)))))
)`))).exports;
@ -495,7 +495,7 @@ assertErrorMessage(() => new WebAssembly.Module(wasmTextToBinary(`
(gc_feature_opt_in 3)
(type $r (struct (field i32)))
(func $f (param f64) (result anyref)
(struct.new $r (get_local 0)))
(struct.new $r (local.get 0)))
)`)),
WebAssembly.CompileError, /type mismatch/);

Просмотреть файл

@ -12,11 +12,11 @@
(table (export "t") 10 anyref)
(type $dummy (struct (field i32)))
(func (export "set_anyref") (param i32) (param anyref)
(table.set (get_local 0) (get_local 1)))
(table.set (local.get 0) (local.get 1)))
(func (export "set_null") (param i32)
(table.set (get_local 0) (ref.null)))
(table.set (local.get 0) (ref.null)))
(func (export "set_ref") (param i32) (param anyref)
(table.set (get_local 0) (struct.narrow anyref (ref $dummy) (get_local 1))))
(table.set (local.get 0) (struct.narrow anyref (ref $dummy) (local.get 1))))
(func (export "make_struct") (result anyref)
(struct.new $dummy (i32.const 37))))`);
let x = {};

Просмотреть файл

@ -162,7 +162,7 @@ function dummy() { return 37 }
`(module
(table (export "t") 10 anyref)
(func (export "f") (param i32) (result anyref)
(table.get (get_local 0))))`);
(table.get (local.get 0))))`);
let x = {};
ins.exports.t.set(0, x);
assertEq(ins.exports.f(0), x);
@ -177,7 +177,7 @@ assertErrorMessage(() => new WebAssembly.Module(wasmTextToBinary(
`(module
(table 10 anyref)
(func (export "f") (param f64) (result anyref)
(table.get (get_local 0))))`)),
(table.get (local.get 0))))`)),
WebAssembly.CompileError,
/type mismatch/);
@ -188,7 +188,7 @@ assertErrorMessage(() => new WebAssembly.Module(wasmTextToBinary(
`(module
(table 10 funcref)
(func (export "f") (param i32)
(drop (table.get (get_local 0)))))`)),
(drop (table.get (local.get 0)))))`)),
WebAssembly.CompileError,
/table.get only on tables of anyref/);
@ -196,7 +196,7 @@ assertErrorMessage(() => new WebAssembly.Module(wasmTextToBinary(
`(module
(table 10 funcref)
(func (export "f") (param i32)
(drop (table.get (get_local 0)))))`)),
(drop (table.get (local.get 0)))))`)),
WebAssembly.CompileError,
/table.get only on tables of anyref/);
@ -205,7 +205,7 @@ assertErrorMessage(() => new WebAssembly.Module(wasmTextToBinary(
assertErrorMessage(() => new WebAssembly.Module(wasmTextToBinary(
`(module
(func (export "f") (param i32)
(drop (table.get (get_local 0)))))`)),
(drop (table.get (local.get 0)))))`)),
WebAssembly.CompileError,
/table index out of range for table.get/);
@ -218,9 +218,9 @@ assertErrorMessage(() => new WebAssembly.Module(wasmTextToBinary(
`(module
(table (export "t") 10 anyref)
(func (export "set_anyref") (param i32) (param anyref)
(table.set (get_local 0) (get_local 1)))
(table.set (local.get 0) (local.get 1)))
(func (export "set_null") (param i32)
(table.set (get_local 0) (ref.null))))`);
(table.set (local.get 0) (ref.null))))`);
let x = {};
ins.exports.set_anyref(3, x);
assertEq(ins.exports.t.get(3), x);
@ -237,7 +237,7 @@ assertErrorMessage(() => new WebAssembly.Module(wasmTextToBinary(
`(module
(table 10 anyref)
(func (export "f") (param f64)
(table.set (get_local 0) (ref.null))))`)),
(table.set (local.get 0) (ref.null))))`)),
WebAssembly.CompileError,
/type mismatch/);
@ -247,7 +247,7 @@ assertErrorMessage(() => new WebAssembly.Module(wasmTextToBinary(
`(module
(table 10 anyref)
(func (export "f") (param f64)
(table.set (i32.const 0) (get_local 0))))`)),
(table.set (i32.const 0) (local.get 0))))`)),
WebAssembly.CompileError,
/type mismatch/);
@ -257,7 +257,7 @@ assertErrorMessage(() => new WebAssembly.Module(wasmTextToBinary(
`(module
(table 10 funcref)
(func (export "f") (param anyref)
(table.set (i32.const 0) (get_local 0))))`)),
(table.set (i32.const 0) (local.get 0))))`)),
WebAssembly.CompileError,
/table.set only on tables of anyref/);
@ -266,7 +266,7 @@ assertErrorMessage(() => new WebAssembly.Module(wasmTextToBinary(
assertErrorMessage(() => new WebAssembly.Module(wasmTextToBinary(
`(module
(func (export "f") (param anyref)
(table.set (i32.const 0) (get_local 0))))`)),
(table.set (i32.const 0) (local.get 0))))`)),
WebAssembly.CompileError,
/table index out of range for table.set/);
@ -280,7 +280,7 @@ let ins = wasmEvalText(
`(module
(table (export "t") 10 20 anyref)
(func (export "grow") (param i32) (result i32)
(table.grow (get_local 0) (ref.null))))`);
(table.grow (local.get 0) (ref.null))))`);
assertEq(ins.exports.grow(0), 10);
assertEq(ins.exports.t.length, 10);
assertEq(ins.exports.grow(1), 10);
@ -308,7 +308,7 @@ assertEq(ins.exports.t.length, 20)
`(module
(table 10 anyref)
(func (export "grow") (param i32) (result i32)
(table.grow (get_local 0) (ref.null))))`);
(table.grow (local.get 0) (ref.null))))`);
assertEq(ins.exports.grow(0), 10);
assertEq(ins.exports.grow(1), 10);
assertEq(ins.exports.grow(9), 11);
@ -331,7 +331,7 @@ assertErrorMessage(() => new WebAssembly.Module(wasmTextToBinary(
`(module
(table 10 anyref)
(func (export "f") (param f64)
(table.grow (get_local 0) (ref.null))))`)),
(table.grow (local.get 0) (ref.null))))`)),
WebAssembly.CompileError,
/type mismatch/);
@ -340,7 +340,7 @@ assertErrorMessage(() => new WebAssembly.Module(wasmTextToBinary(
assertErrorMessage(() => new WebAssembly.Module(wasmTextToBinary(
`(module
(func (export "f") (param i32)
(table.grow (get_local 0) (ref.null))))`)),
(table.grow (local.get 0) (ref.null))))`)),
WebAssembly.CompileError,
/table index out of range for table.grow/);
@ -354,7 +354,7 @@ for (let visibility of ['', '(export "t")', '(import "m" "t")']) {
`(module
(table ${visibility} 10 20 anyref)
(func (export "grow") (param i32) (result i32)
(table.grow (get_local 0) (ref.null)))
(table.grow (local.get 0) (ref.null)))
(func (export "size") (result i32)
(table.size)))`,
exp);
@ -414,7 +414,7 @@ let VALUES = [null,
let ins = wasmEvalText(
`(module
(func (export "f") (param i32) (result i32)
(get_local 0)))`);
(local.get 0)))`);
t.grow(1);
assertEq(t.get(t.length-1), null);
t.grow(2, ins.exports.f);

Просмотреть файл

@ -19,17 +19,17 @@ var ins = wasmEvalText(
(elem $t1 (i32.const 0) $f1 $f2)
(elem $t2 (i32.const 0) $f3 $f4)
(func $f1 (param $n i32) (result i32)
(i32.add (get_local $n) (i32.const 1)))
(i32.add (local.get $n) (i32.const 1)))
(func $f2 (param $n i32) (result i32)
(i32.add (get_local $n) (i32.const 2)))
(i32.add (local.get $n) (i32.const 2)))
(func $f3 (param $n i32) (result i32)
(i32.add (get_local $n) (i32.const 3)))
(i32.add (local.get $n) (i32.const 3)))
(func $f4 (param $n i32) (result i32)
(i32.add (get_local $n) (i32.const 4)))
(i32.add (local.get $n) (i32.const 4)))
(func (export "f") (param $fn i32) (param $n i32) (result i32)
(call_indirect $t1 $ftype (get_local $n) (get_local $fn)))
(call_indirect $t1 $ftype (local.get $n) (local.get $fn)))
(func (export "g") (param $fn i32) (param $n i32) (result i32)
(call_indirect $t2 $ftype (get_local $n) (get_local $fn))))`).exports;
(call_indirect $t2 $ftype (local.get $n) (local.get $fn))))`).exports;
assertEq(ins.f(0, 10), 11);
assertEq(ins.f(1, 10), 12);
@ -64,26 +64,26 @@ var ins = wasmEvalText(
`(module
(table $t0 (import "m" "t0") 2 funcref)
(type $id_i32_t (func (param i32) (result i32)))
(func $id_i32 (param i32) (result i32) (get_local 0))
(func $id_i32 (param i32) (result i32) (local.get 0))
(elem $t0 (i32.const 1) $id_i32)
(table $t1 (import "m" "t1") 3 anyref)
(table $t2 (import "m" "t2") 4 funcref)
(type $id_f64_t (func (param f64) (result f64)))
(func $id_f64 (param f64) (result f64) (get_local 0))
(func $id_f64 (param f64) (result f64) (local.get 0))
(elem $t2 (i32.const 3) $id_f64)
(table $t3 (import "m" "t3") 5 anyref)
(func (export "f0") (param i32) (result i32)
(call_indirect $t0 $id_i32_t (get_local 0) (i32.const 1)))
(call_indirect $t0 $id_i32_t (local.get 0) (i32.const 1)))
(func (export "f1") (param anyref)
(table.set $t1 (i32.const 2) (get_local 0)))
(table.set $t1 (i32.const 2) (local.get 0)))
(func (export "f2") (param f64) (result f64)
(call_indirect $t2 $id_f64_t (get_local 0) (i32.const 3)))
(call_indirect $t2 $id_f64_t (local.get 0) (i32.const 3)))
(func (export "f3")
(table.set $t3 (i32.const 4) (table.get $t1 (i32.const 2)))))`,
@ -133,7 +133,7 @@ var ins = wasmEvalText(
(table $t0 (import "m" "t0") 2 anyref)
(table $t1 (import "m" "t1") 3 anyref)
(func (export "f") (param $dest i32) (param $src i32) (param $len i32)
(table.copy $t1 (get_local $dest) $t0 (get_local $src) (get_local $len))))`,
(table.copy $t1 (local.get $dest) $t0 (local.get $src) (local.get $len))))`,
exp);
exp.m.t0.set(0, {x:0});
@ -149,14 +149,14 @@ var ins = wasmEvalText(
(table $t0 2 anyref)
(table $t1 2 anyref)
(func (export "copy") (param $dest i32) (param $src i32) (param $len i32)
get_local $dest
get_local $src
get_local $len
local.get $dest
local.get $src
local.get $len
table.copy $t1 $t0)
(func (export "set") (param $n i32) (param $v anyref)
(table.set $t0 (get_local $n) (get_local $v)))
(table.set $t0 (local.get $n) (local.get $v)))
(func (export "get") (param $n i32) (result anyref)
(table.get $t1 (get_local $n))))`,
(table.get $t1 (local.get $n))))`,
exp);
var values = [{x:0}, {x:1}];
@ -188,7 +188,7 @@ for (let [x,y,result,init] of [['(export "t")', '', arg*13, true],
(table $t (export "t") 2 funcref)
(type $fn1 (func (param i32) (result i32)))
(func $f1 (param $n i32) (result i32)
(i32.sub (get_local $n) (i32.const 11)))
(i32.sub (local.get $n) (i32.const 11)))
(elem $t (i32.const 1) $f1))`);
let text =
@ -198,12 +198,12 @@ for (let [x,y,result,init] of [['(export "t")', '', arg*13, true],
(table $t1 ${y} 2 funcref)
(type $fn1 (func (param i32) (result i32)))
(func $f1 (param $n i32) (result i32)
(i32.mul (get_local $n) (i32.const 13)))
(i32.mul (local.get $n) (i32.const 13)))
${init ? "(elem $t1 (i32.const 1) $f1)" : ""}
(func (export "f") (param $n i32) (result i32)
(table.copy $t0 (i32.const 0) $t1 (i32.const 0) (i32.const 2))
(call_indirect $t0 $fn1 (get_local $n) (i32.const 1))))`;
(call_indirect $t0 $fn1 (local.get $n) (i32.const 1))))`;
var ins = wasmEvalText(text, {m: otherins.exports});
assertEq(ins.exports.f(arg), result);
@ -247,11 +247,11 @@ var ins = wasmEvalText(
(elem passive $f0 $f1) ;; 0
(type $ftype (func (param i32) (result i32)))
(func $f0 (param i32) (result i32)
(i32.mul (get_local 0) (i32.const 13)))
(i32.mul (local.get 0) (i32.const 13)))
(func $f1 (param i32) (result i32)
(i32.sub (get_local 0) (i32.const 11)))
(i32.sub (local.get 0) (i32.const 11)))
(func (export "call") (param i32) (param i32) (result i32)
(call_indirect $t1 $ftype (get_local 1) (get_local 0)))
(call_indirect $t1 $ftype (local.get 1) (local.get 0)))
(func (export "init")
(table.init $t1 0 (i32.const 0) (i32.const 0) (i32.const 2))))`);
@ -277,11 +277,11 @@ var ins = wasmEvalText(
(import "m" "t1" (table $t1 2 funcref))
(type $ftype (func (param f64) (result f64)))
(func (export "f") (param $n f64) (result f64)
(f64.mul (get_local $n) (f64.const 3.25)))
(f64.mul (local.get $n) (f64.const 3.25)))
(func (export "do0") (param $i i32) (param $n f64) (result f64)
(call_indirect $t0 $ftype (get_local $n) (get_local $i)))
(call_indirect $t0 $ftype (local.get $n) (local.get $i)))
(func (export "do1") (param $i i32) (param $n f64) (result f64)
(call_indirect $t1 $ftype (get_local $n) (get_local $i))))`,
(call_indirect $t1 $ftype (local.get $n) (local.get $i))))`,
exp);
var ins2 = wasmEvalText(
`(module
@ -289,9 +289,9 @@ var ins2 = wasmEvalText(
(import "m" "t1" (table $t1 2 funcref))
(type $ftype (func (param f64) (result f64)))
(func (export "do0") (param $i i32) (param $n f64) (result f64)
(call_indirect $t0 $ftype (get_local $n) (get_local $i)))
(call_indirect $t0 $ftype (local.get $n) (local.get $i)))
(func (export "do1") (param $i i32) (param $n f64) (result f64)
(call_indirect $t1 $ftype (get_local $n) (get_local $i))))`,
(call_indirect $t1 $ftype (local.get $n) (local.get $i))))`,
exp);
assertEq(tbl.grow(10), 2);
@ -333,7 +333,7 @@ assertErrorMessage(() => wasmEvalText(
(table $t0 2 anyref)
(table $t1 2 anyref)
(func $f (param anyref)
(table.set 2 (i32.const 0) (get_local 0))))`),
(table.set 2 (i32.const 0) (local.get 0))))`),
WebAssembly.CompileError,
/table index out of range for table.set/);

Просмотреть файл

@ -12,24 +12,24 @@ for ( let prefix of ['', '(table $prefix 0 32 funcref)']) {
(local $last i32)
(local $iters i32)
(local $tmp anyref)
(set_local $last (table.grow $tbl (i32.const 1) (ref.null)))
(table.set $tbl (get_local $last) (call $item))
(local.set $last (table.grow $tbl (i32.const 1) (ref.null)))
(table.set $tbl (local.get $last) (call $item))
(loop $iter_continue
(set_local $i (i32.const 0))
(set_local $j (get_local $last))
(local.set $i (i32.const 0))
(local.set $j (local.get $last))
(block $l_break
(loop $l_continue
(br_if $l_break (i32.ge_s (get_local $j) (get_local $i)))
(set_local $tmp (table.get $tbl (get_local $i)))
(if (i32.eqz (i32.rem_s (get_local $i) (i32.const 3)))
(set_local $tmp (call $item)))
(table.set $tbl (get_local $i) (table.get $tbl (get_local $j)))
(table.set $tbl (get_local $j) (get_local $tmp))
(set_local $i (i32.add (get_local $i) (i32.const 1)))
(set_local $j (i32.sub (get_local $j) (i32.const 1)))
(br_if $l_break (i32.ge_s (local.get $j) (local.get $i)))
(local.set $tmp (table.get $tbl (local.get $i)))
(if (i32.eqz (i32.rem_s (local.get $i) (i32.const 3)))
(local.set $tmp (call $item)))
(table.set $tbl (local.get $i) (table.get $tbl (local.get $j)))
(table.set $tbl (local.get $j) (local.get $tmp))
(local.set $i (i32.add (local.get $i) (i32.const 1)))
(local.set $j (i32.sub (local.get $j) (i32.const 1)))
(br $l_continue))
(set_local $iters (i32.add (get_local $iters) (i32.const 1)))
(br_if $iter_continue (i32.lt_s (get_local $iters) (get_local $numiters)))))))`));
(local.set $iters (i32.add (local.get $iters) (i32.const 1)))
(br_if $iter_continue (i32.lt_s (local.get $iters) (local.get $numiters)))))))`));
for (let [mode,freq] of [[14,100], // Compact every 100 allocations
[2,12], // Collect every 12 allocations

Просмотреть файл

@ -16,25 +16,25 @@ let txt =
(local $tmp64 i64)
(local $tmp32 i32)
(loop
(set_global $ind64 (i64.add (get_global $ind64) (i64.const 11)))
(set_global $ind32 (i32.add (get_global $ind32) (i32.const 22)))
(set_global $dir64 (i64.add (get_global $dir64) (i64.const 33)))
(set_global $dir32 (i32.add (get_global $dir32) (i32.const 44)))
(global.set $ind64 (i64.add (global.get $ind64) (i64.const 11)))
(global.set $ind32 (i32.add (global.get $ind32) (i32.const 22)))
(global.set $dir64 (i64.add (global.get $dir64) (i64.const 33)))
(global.set $dir32 (i32.add (global.get $dir32) (i32.const 44)))
(set_local $tmp64 (i64.and (get_global $ind64) (get_global $dir64)))
(set_local $tmp32 (i32.or (get_global $ind32) (get_global $dir32)))
(local.set $tmp64 (i64.and (global.get $ind64) (global.get $dir64)))
(local.set $tmp32 (i32.or (global.get $ind32) (global.get $dir32)))
(set_local $sum
(i32.sub (get_local $sum) (i32.xor (i32.wrap/i64 (get_local $tmp64))
(get_local $tmp32))))
(local.set $sum
(i32.sub (local.get $sum) (i32.xor (i32.wrap/i64 (local.get $tmp64))
(local.get $tmp32))))
(set_local $loopctr
(i32.add (get_local $loopctr) (i32.const 1)))
(local.set $loopctr
(i32.add (local.get $loopctr) (i32.const 1)))
(br_if 0
(i32.lt_u (get_local $loopctr) (i32.const 10)))
(i32.lt_u (local.get $loopctr) (i32.const 10)))
)
(get_local $sum)
(local.get $sum)
)
)`;

Просмотреть файл

@ -11,7 +11,7 @@ wasmFailValidateText(`(module (global f64 (f32.const 13.37)))`, /type mismatch/)
wasmFailValidateText(`(module (global i32 (i32.add (i32.const 13) (i32.const 37))))`, /failed to read end/);
wasmFailValidateText(`(module (global i32 (global.get 0)))`, /out of range/);
wasmFailValidateText(`(module (global i32 (get_global 1)) (global i32 (i32.const 1)))`, /out of range/);
wasmFailValidateText(`(module (global i32 (global.get 1)) (global i32 (i32.const 1)))`, /out of range/);
// Test a well-defined global section.
function testInner(type, initialValue, nextValue, coercion)
@ -20,10 +20,10 @@ function testInner(type, initialValue, nextValue, coercion)
(global (mut ${type}) (${type}.const ${initialValue}))
(global ${type} (${type}.const ${initialValue}))
(func $get (result ${type}) (get_global 0))
(func $set (param ${type}) (global.set 0 (get_local 0)))
(func $get (result ${type}) (global.get 0))
(func $set (param ${type}) (global.set 0 (local.get 0)))
(func $get_cst (result ${type}) (get_global 1))
(func $get_cst (result ${type}) (global.get 1))
(export "get" $get)
(export "get_cst" $get_cst)
@ -43,15 +43,15 @@ testInner('f32', 13.37, 0.1989, Math.fround);
testInner('f64', 13.37, 0.1989, x => +x);
// Semantic errors.
wasmFailValidateText(`(module (global (mut i32) (i32.const 1337)) (func (set_global 1 (i32.const 0))))`, /out of range/);
wasmFailValidateText(`(module (global i32 (i32.const 1337)) (func (set_global 0 (i32.const 0))))`, /can't write an immutable global/);
wasmFailValidateText(`(module (global (mut i32) (i32.const 1337)) (func (global.set 1 (i32.const 0))))`, /out of range/);
wasmFailValidateText(`(module (global i32 (i32.const 1337)) (func (global.set 0 (i32.const 0))))`, /can't write an immutable global/);
// Big module with many variables: test that setting one doesn't overwrite the
// other ones.
function get_set(i, type) {
return `
(func $get_${i} (result ${type}) (get_global ${i}))
(func $set_${i} (param ${type}) (set_global ${i} (get_local 0)))
(func $get_${i} (result ${type}) (global.get ${i}))
(func $set_${i} (param ${type}) (global.set ${i} (local.get 0)))
`;
}
@ -91,12 +91,12 @@ for (let i = 0; i < 5; i++) {
}
// Initializer expressions can also be used in elem section initializers.
wasmFailValidateText(`(module (import "globals" "a" (global f32)) (table 4 funcref) (elem (get_global 0) $f) (func $f))`, /type mismatch/);
wasmFailValidateText(`(module (import "globals" "a" (global f32)) (table 4 funcref) (elem (global.get 0) $f) (func $f))`, /type mismatch/);
module = wasmEvalText(`(module
(import "globals" "a" (global i32))
(table (export "tbl") 4 funcref)
(elem (get_global 0) $f)
(elem (global.get 0) $f)
(func $f)
(export "f" $f)
)`, {
@ -109,7 +109,7 @@ assertEq(module.f, module.tbl.get(1));
// Import/export semantics.
module = wasmEvalText(`(module
(import $g "globals" "x" (global i32))
(func $get (result i32) (get_global $g))
(func $get (result i32) (global.get $g))
(export "getter" $get)
(export "value" global 0)
)`, { globals: {x: 42} }).exports;
@ -176,25 +176,25 @@ assertEq(Number(module.imported), 42);
assertEq(Number(module.defined), 1337);
// Initializer expressions can reference an imported immutable global.
wasmFailValidateText(`(module (global f32 (f32.const 13.37)) (global i32 (get_global 0)))`, /must reference a global immutable import/);
wasmFailValidateText(`(module (global (mut f32) (f32.const 13.37)) (global i32 (get_global 0)))`, /must reference a global immutable import/);
wasmFailValidateText(`(module (global (mut i32) (i32.const 0)) (global i32 (get_global 0)))`, /must reference a global immutable import/);
wasmFailValidateText(`(module (global f32 (f32.const 13.37)) (global i32 (global.get 0)))`, /must reference a global immutable import/);
wasmFailValidateText(`(module (global (mut f32) (f32.const 13.37)) (global i32 (global.get 0)))`, /must reference a global immutable import/);
wasmFailValidateText(`(module (global (mut i32) (i32.const 0)) (global i32 (global.get 0)))`, /must reference a global immutable import/);
wasmFailValidateText(`(module (import "globals" "a" (global f32)) (global i32 (get_global 0)))`, /type mismatch/);
wasmFailValidateText(`(module (import "globals" "a" (global f32)) (global i32 (global.get 0)))`, /type mismatch/);
function testInitExpr(type, initialValue, nextValue, coercion, assertFunc = assertEq) {
var module = wasmEvalText(`(module
(import "globals" "a" (global ${type}))
(global $glob_mut (mut ${type}) (get_global 0))
(global $glob_imm ${type} (get_global 0))
(global $glob_mut (mut ${type}) (global.get 0))
(global $glob_imm ${type} (global.get 0))
(func $get0 (result ${type}) (get_global 0))
(func $get0 (result ${type}) (global.get 0))
(func $get1 (result ${type}) (get_global 1))
(func $set1 (param ${type}) (set_global 1 (get_local 0)))
(func $get1 (result ${type}) (global.get 1))
(func $set1 (param ${type}) (global.set 1 (local.get 0)))
(func $get_cst (result ${type}) (get_global 2))
(func $get_cst (result ${type}) (global.get 2))
(export "get0" $get0)
(export "get1" $get1)
@ -255,7 +255,7 @@ assertErrorMessage(() => wasmEvalText(`(module
let j = wasmEvalText(`(module
(import "globals" "g" (global i64))
(func (export "f") (result i32)
(i64.eq (get_global 0) (i64.const 37))))`,
(i64.eq (global.get 0) (i64.const 37))))`,
{globals: {g: i.exports.g}});
assertEq(j.exports.f(), 1);
@ -277,9 +277,9 @@ var nextValue = '0x531642753864975F';
wasmAssert(`(module
(global (mut i64) (i64.const ${initialValue}))
(global i64 (i64.const ${initialValue}))
(func $get (result i64) (get_global 0))
(func $set (param i64) (set_global 0 (get_local 0)))
(func $get_cst (result i64) (get_global 1))
(func $get (result i64) (global.get 0))
(func $set (param i64) (global.set 0 (local.get 0)))
(func $get_cst (result i64) (global.get 1))
(export "get" $get)
(export "get_cst" $get_cst)
(export "set" $set)
@ -338,7 +338,7 @@ wasmAssert(`(module
let mod = wasmEvalText(`(module
(import "" "g" (global i64))
(func (export "f") (result i32)
(i64.eqz (get_global 0))))`,
(i64.eqz (global.get 0))))`,
{"":{g: new Global({value: "i64"})}});
assertEq(mod.exports.f(), 1);
@ -389,7 +389,7 @@ wasmAssert(`(module
let j = wasmEvalText(`(module
(global (import "" "g") i32)
(func (export "f") (result i32)
(get_global 0)))`,
(global.get 0)))`,
{ "": { "g": i.exports.g }});
// And when it is then accessed it has the right value:
@ -434,16 +434,16 @@ wasmAssert(`(module
let i = wasmEvalText(`(module
(global (export "g") (mut i32) (i32.const 37))
(func (export "getter") (result i32)
(get_global 0))
(global.get 0))
(func (export "setter") (param i32)
(set_global 0 (get_local 0))))`);
(global.set 0 (local.get 0))))`);
let j = wasmEvalText(`(module
(import "" "g" (global (mut i32)))
(func (export "getter") (result i32)
(get_global 0))
(global.get 0))
(func (export "setter") (param i32)
(set_global 0 (get_local 0))))`,
(global.set 0 (local.get 0))))`,
{"": {g: i.exports.g}});
// Initial values

Просмотреть файл

@ -408,7 +408,7 @@ assertEq(e4.baz, e4.tbl.get(2));
// i64 is fully allowed for imported wasm functions
var code1 = wasmTextToBinary('(module (func $exp (param i64) (result i64) (i64.add (get_local 0) (i64.const 10))) (export "exp" $exp))');
var code1 = wasmTextToBinary('(module (func $exp (param i64) (result i64) (i64.add (local.get 0) (i64.const 10))) (export "exp" $exp))');
var e1 = new Instance(new Module(code1)).exports;
var code2 = wasmTextToBinary('(module (import $i "a" "b" (param i64) (result i64)) (func $f (result i32) (i32.wrap/i64 (call $i (i64.const 42)))) (export "f" $f))');
var e2 = new Instance(new Module(code2), {a:{b:e1.exp}}).exports;
@ -462,7 +462,7 @@ var m = new Module(wasmTextToBinary(`
(data (i32.const 0) "\\0a\\0b")
(data (i32.const 100) "\\0c\\0d")
(func $get (param $p i32) (result i32)
(i32.load8_u (get_local $p)))
(i32.load8_u (local.get $p)))
(export "get" $get))
`));
var mem = new Memory({initial:1, maximum:1});
@ -487,7 +487,7 @@ var m = new Module(wasmTextToBinary(`
(module
(import "glob" "a" (global i32))
(memory 1)
(data (get_global 0) "\\0a\\0b"))
(data (global.get 0) "\\0a\\0b"))
`));
assertEq(new Instance(m, {glob:{a:0}}) instanceof Instance, true);
assertEq(new Instance(m, {glob:{a:(64*1024 - 2)}}) instanceof Instance, true);
@ -522,8 +522,8 @@ var m = new Module(wasmTextToBinary(`
(func $g)
(data (i32.const 0) "\\01")
(elem (i32.const 0) $f)
(data (get_global $memOff) "\\02")
(elem (get_global $tblOff) $g)
(data (global.get $memOff) "\\02")
(elem (global.get $tblOff) $g)
(export "f" $f)
(export "g" $g))
`));
@ -678,7 +678,7 @@ assertEq(tbl.get(3)(), undefined);
// Cross-instance calls
var i1 = new Instance(new Module(wasmTextToBinary(`(module (func) (func (param i32) (result i32) (i32.add (get_local 0) (i32.const 1))) (func) (export "f" 1))`)));
var i1 = new Instance(new Module(wasmTextToBinary(`(module (func) (func (param i32) (result i32) (i32.add (local.get 0) (i32.const 1))) (func) (export "f" 1))`)));
var i2 = new Instance(new Module(wasmTextToBinary(`(module (import $imp "a" "b" (param i32) (result i32)) (func $g (result i32) (call $imp (i32.const 13))) (export "g" $g))`)), {a:{b:i1.exports.f}});
assertEq(i2.exports.g(), 14);
@ -696,7 +696,7 @@ var i2 = new Instance(new Module(wasmTextToBinary(`(module
(elem (i32.const 0) $imp $def)
(func $def (result i32) (i32.load (i32.const 0)))
(type $v2i (func (result i32)))
(func $call (param i32) (result i32) (call_indirect $v2i (get_local 0)))
(func $call (param i32) (result i32) (call_indirect $v2i (local.get 0)))
(export "call" $call)
)`)), {a:{b:i1.exports.f}});
assertEq(i2.exports.call(0), 0x42);
@ -706,11 +706,11 @@ var m = new Module(wasmTextToBinary(`(module
(import $val "a" "val" (global i32))
(import $next "a" "next" (result i32))
(memory 1)
(func $start (i32.store (i32.const 0) (get_global $val)))
(func $start (i32.store (i32.const 0) (global.get $val)))
(start $start)
(func $call (result i32)
(i32.add
(get_global $val)
(global.get $val)
(i32.add
(i32.load (i32.const 0))
(call $next))))
@ -760,7 +760,7 @@ assertEq(e.call(), 1090);
(import $missingThreeArgs "a" "sum" (result i32))
(func (export "foo") (param i32) (result i32)
get_local 0
local.get 0
call $ffi
)
@ -769,13 +769,13 @@ assertEq(e.call(), 1090);
)
(func (export "missTwo") (param i32) (result i32)
get_local 0
local.get 0
call $missingTwoArgs
)
(func (export "missOne") (param i32) (param i32) (result i32)
get_local 0
get_local 1
local.get 0
local.get 1
call $missingOneArg
)
)`, imports).exports;

Просмотреть файл

@ -7,42 +7,42 @@ function testUnary(type, opcode, op, expect) {
// Test with constant
wasmFullPassI64(`(module (func $run (result ${type}) (${type}.${opcode} (${type}.const ${op}))))`, expect);
// Test with param
wasmFullPassI64(`(module (func $run (param ${type}) (result ${type}) (${type}.${opcode} (get_local 0))))`, expect, {}, `i64.const ${op}`);
wasmFullPassI64(`(module (func $run (param ${type}) (result ${type}) (${type}.${opcode} (local.get 0))))`, expect, {}, `i64.const ${op}`);
return;
}
// Test with constant
wasmFullPass(`(module (func (result ${type}) (${type}.${opcode} (${type}.const ${op}))) (export "run" 0))`, expect);
// Test with param
wasmFullPass(`(module (func (param ${type}) (result ${type}) (${type}.${opcode} (get_local 0))) (export "run" 0))`, expect, {}, op);
wasmFullPass(`(module (func (param ${type}) (result ${type}) (${type}.${opcode} (local.get 0))) (export "run" 0))`, expect, {}, op);
}
function testBinary64(opcode, lhs, rhs, expect) {
let lsrc = `i64.const ${lhs}`;
let rsrc = `i64.const ${rhs}`;
wasmFullPassI64(`(module (func $run (param i64) (param i64) (result i64) (i64.${opcode} (get_local 0) (get_local 1))))`, expect, {}, lsrc, rsrc);
wasmFullPassI64(`(module (func $run (param i64) (param i64) (result i64) (i64.${opcode} (local.get 0) (local.get 1))))`, expect, {}, lsrc, rsrc);
// The same, but now the RHS is a constant.
wasmFullPassI64(`(module (func $run (param i64) (result i64) (i64.${opcode} (get_local 0) (i64.const ${rhs}))))`, expect, {}, lsrc);
wasmFullPassI64(`(module (func $run (param i64) (result i64) (i64.${opcode} (local.get 0) (i64.const ${rhs}))))`, expect, {}, lsrc);
// LHS and RHS are constants.
wasmFullPassI64(`(module (func $run (result i64) (i64.${opcode} (i64.const ${lhs}) (i64.const ${rhs}))))`, expect);
}
function testBinary32(opcode, lhs, rhs, expect) {
wasmFullPass(`(module (func (param i32) (param i32) (result i32) (i32.${opcode} (get_local 0) (get_local 1))) (export "run" 0))`, expect, {}, lhs, rhs);
wasmFullPass(`(module (func (param i32) (param i32) (result i32) (i32.${opcode} (local.get 0) (local.get 1))) (export "run" 0))`, expect, {}, lhs, rhs);
// The same, but now the RHS is a constant.
wasmFullPass(`(module (func (param i32) (result i32) (i32.${opcode} (get_local 0) (i32.const ${rhs}))) (export "run" 0))`, expect, {}, lhs);
wasmFullPass(`(module (func (param i32) (result i32) (i32.${opcode} (local.get 0) (i32.const ${rhs}))) (export "run" 0))`, expect, {}, lhs);
// LHS and RHS are constants.
wasmFullPass(`(module (func (result i32) (i32.${opcode} (i32.const ${lhs}) (i32.const ${rhs}))) (export "run" 0))`, expect);
}
function testComparison32(opcode, lhs, rhs, expect) {
wasmFullPass(`(module (func (param i32) (param i32) (result i32) (i32.${opcode} (get_local 0) (get_local 1))) (export "run" 0))`, expect, {}, lhs, rhs);
wasmFullPass(`(module (func (param i32) (param i32) (result i32) (i32.${opcode} (local.get 0) (local.get 1))) (export "run" 0))`, expect, {}, lhs, rhs);
}
function testComparison64(opcode, lhs, rhs, expect) {
let lsrc = `i64.const ${lhs}`;
let rsrc = `i64.const ${rhs}`;
wasmFullPass(`(module
(func $cmp (param i64) (param i64) (result i32) (i64.${opcode} (get_local 0) (get_local 1)))
(func $cmp (param i64) (param i64) (result i32) (i64.${opcode} (local.get 0) (local.get 1)))
(func $assert (result i32)
i64.const ${lhs}
i64.const ${rhs}
@ -53,7 +53,7 @@ function testComparison64(opcode, lhs, rhs, expect) {
// Also test `if`, for the compare-and-branch path.
wasmFullPass(`(module
(func $cmp (param i64) (param i64) (result i32)
(if i32 (i64.${opcode} (get_local 0) (get_local 1))
(if i32 (i64.${opcode} (local.get 0) (local.get 1))
(i32.const 1)
(i32.const 0)))
(func $assert (result i32)
@ -67,15 +67,15 @@ function testComparison64(opcode, lhs, rhs, expect) {
function testI64Eqz(input, expect) {
wasmFullPass(`(module (func (result i32) (i64.eqz (i64.const ${input}))) (export "run" 0))`, expect, {});
wasmFullPass(`(module
(func (param i64) (result i32) (i64.eqz (get_local 0)))
(func (param i64) (result i32) (i64.eqz (local.get 0)))
(func $assert (result i32) (i64.const ${input}) (call 0))
(export "run" $assert))`, expect);
}
function testTrap32(opcode, lhs, rhs, expect) {
assertErrorMessage(() => wasmEvalText(`(module (func (param i32) (param i32) (result i32) (i32.${opcode} (get_local 0) (get_local 1))) (export "" 0))`).exports[""](lhs, rhs), Error, expect);
assertErrorMessage(() => wasmEvalText(`(module (func (param i32) (param i32) (result i32) (i32.${opcode} (local.get 0) (local.get 1))) (export "" 0))`).exports[""](lhs, rhs), Error, expect);
// The same, but now the RHS is a constant.
assertErrorMessage(() => wasmEvalText(`(module (func (param i32) (result i32) (i32.${opcode} (get_local 0) (i32.const ${rhs}))) (export "" 0))`).exports[""](lhs), Error, expect);
assertErrorMessage(() => wasmEvalText(`(module (func (param i32) (result i32) (i32.${opcode} (local.get 0) (i32.const ${rhs}))) (export "" 0))`).exports[""](lhs), Error, expect);
// LHS and RHS are constants.
assertErrorMessage(wasmEvalText(`(module (func (result i32) (i32.${opcode} (i32.const ${lhs}) (i32.const ${rhs}))) (export "" 0))`).exports[""], Error, expect);
}
@ -84,12 +84,12 @@ function testTrap64(opcode, lhs, rhs, expect) {
let $call = ``;
assertErrorMessage(wasmEvalText(`(module
(func (param i64) (param i64) (result i64) (i64.${opcode} (get_local 0) (get_local 1)))
(func (param i64) (param i64) (result i64) (i64.${opcode} (local.get 0) (local.get 1)))
(func $f (export "") (i64.const ${lhs}) (i64.const ${rhs}) (call 0) drop)
)`).exports[""], Error, expect);
// The same, but now the RHS is a constant.
assertErrorMessage(wasmEvalText(`(module
(func (param i64) (result i64) (i64.${opcode} (get_local 0) (i64.const ${rhs})))
(func (param i64) (result i64) (i64.${opcode} (local.get 0) (i64.const ${rhs})))
(func $f (export "") (i64.const ${lhs}) (call 0) drop)
)`).exports[""], Error, expect);
// LHS and RHS are constants.
@ -174,7 +174,7 @@ if (getJitCompilerOptions()["ion.warmup.trigger"] === 0)
gc();
// Test MTest's GVN branch inversion.
var testTrunc = wasmEvalText(`(module (func (param f32) (result i32) (if i32 (i32.eqz (i32.trunc_s/f32 (get_local 0))) (i32.const 0) (i32.const 1))) (export "" 0))`).exports[""];
var testTrunc = wasmEvalText(`(module (func (param f32) (result i32) (if i32 (i32.eqz (i32.trunc_s/f32 (local.get 0))) (i32.const 0) (i32.const 1))) (export "" 0))`).exports[""];
assertEq(testTrunc(0), 0);
assertEq(testTrunc(13.37), 1);
@ -368,26 +368,26 @@ testUnary('i64', 'popcnt', 0, 0);
testI64Eqz(40, 0);
testI64Eqz(0, 1);
wasmAssert(`(module (func $run (param i64) (result i64) (local i64) (set_local 1 (i64.shl (get_local 0) (get_local 0))) (i64.shl (get_local 1) (get_local 1))))`,
wasmAssert(`(module (func $run (param i64) (result i64) (local i64) (local.set 1 (i64.shl (local.get 0) (local.get 0))) (i64.shl (local.get 1) (local.get 1))))`,
[{ type: 'i64', func: '$run', args: ['i64.const 2'], expected: 2048}]);
// Test MTest's GVN branch inversion.
var testTrunc = wasmEvalText(`(module (func (param f32) (result i32) (if i32 (i64.eqz (i64.trunc_s/f32 (get_local 0))) (i32.const 0) (i32.const 1))) (export "" 0))`).exports[""];
var testTrunc = wasmEvalText(`(module (func (param f32) (result i32) (if i32 (i64.eqz (i64.trunc_s/f32 (local.get 0))) (i32.const 0) (i32.const 1))) (export "" 0))`).exports[""];
assertEq(testTrunc(0), 0);
assertEq(testTrunc(13.37), 1);
wasmAssert(`(module (func $run (result i64) (local i64) (set_local 0 (i64.rem_s (i64.const 1) (i64.const 0xf))) (i64.rem_s (get_local 0) (get_local 0))))`,
wasmAssert(`(module (func $run (result i64) (local i64) (local.set 0 (i64.rem_s (i64.const 1) (i64.const 0xf))) (i64.rem_s (local.get 0) (local.get 0))))`,
[{ type: 'i64', func: '$run', expected: 0 }]);
wasmFailValidateText('(module (func (param f32) (result i32) (i32.clz (get_local 0))))', mismatchError("f32", "i32"));
wasmFailValidateText('(module (func (param i32) (result f32) (i32.clz (get_local 0))))', mismatchError("i32", "f32"));
wasmFailValidateText('(module (func (param f32) (result f32) (i32.clz (get_local 0))))', mismatchError("f32", "i32"));
wasmFailValidateText('(module (func (param f32) (result i32) (i32.clz (local.get 0))))', mismatchError("f32", "i32"));
wasmFailValidateText('(module (func (param i32) (result f32) (i32.clz (local.get 0))))', mismatchError("i32", "f32"));
wasmFailValidateText('(module (func (param f32) (result f32) (i32.clz (local.get 0))))', mismatchError("f32", "i32"));
wasmFailValidateText('(module (func (param f32) (param i32) (result i32) (i32.add (get_local 0) (get_local 1))))', mismatchError("f32", "i32"));
wasmFailValidateText('(module (func (param i32) (param f32) (result i32) (i32.add (get_local 0) (get_local 1))))', mismatchError("f32", "i32"));
wasmFailValidateText('(module (func (param i32) (param i32) (result f32) (i32.add (get_local 0) (get_local 1))))', mismatchError("i32", "f32"));
wasmFailValidateText('(module (func (param f32) (param f32) (result f32) (i32.add (get_local 0) (get_local 1))))', mismatchError("f32", "i32"));
wasmFailValidateText('(module (func (param f32) (param i32) (result i32) (i32.add (local.get 0) (local.get 1))))', mismatchError("f32", "i32"));
wasmFailValidateText('(module (func (param i32) (param f32) (result i32) (i32.add (local.get 0) (local.get 1))))', mismatchError("f32", "i32"));
wasmFailValidateText('(module (func (param i32) (param i32) (result f32) (i32.add (local.get 0) (local.get 1))))', mismatchError("i32", "f32"));
wasmFailValidateText('(module (func (param f32) (param f32) (result f32) (i32.add (local.get 0) (local.get 1))))', mismatchError("f32", "i32"));
wasmFailValidateText('(module (func (param f32) (param i32) (result i32) (i32.eq (get_local 0) (get_local 1))))', mismatchError("f32", "i32"));
wasmFailValidateText('(module (func (param i32) (param f32) (result i32) (i32.eq (get_local 0) (get_local 1))))', mismatchError("f32", "i32"));
wasmFailValidateText('(module (func (param i32) (param i32) (result f32) (i32.eq (get_local 0) (get_local 1))))', mismatchError("i32", "f32"));
wasmFailValidateText('(module (func (param f32) (param i32) (result i32) (i32.eq (local.get 0) (local.get 1))))', mismatchError("f32", "i32"));
wasmFailValidateText('(module (func (param i32) (param f32) (result i32) (i32.eq (local.get 0) (local.get 1))))', mismatchError("f32", "i32"));
wasmFailValidateText('(module (func (param i32) (param i32) (result f32) (i32.eq (local.get 0) (local.get 1))))', mismatchError("i32", "f32"));

Просмотреть файл

@ -1,21 +1,21 @@
let { exports } = wasmEvalText(`(module
(func (export "i32") (result i32) (param i32)
get_local 0
local.get 0
)
(func (export "f32") (result f32) (param f32)
get_local 0
local.get 0
)
(func (export "f64") (result f64) (param f64)
get_local 0
local.get 0
)
(func (export "mixed_args") (result f64)
(param i32) (param i32) (param i32) (param i32) (param i32) ;; 5 i32
(param $f64 f64) ;; 1 f64
(param i32)
get_local $f64
local.get $f64
)
)`);
@ -82,7 +82,7 @@ let {func} = wasmEvalText(`(module
(func (export "func") (result i32)
${Array(32).join('(param i32)')}
(param $last i32)
get_local $last
local.get $last
)
)`).exports;
@ -99,7 +99,7 @@ func = wasmEvalText(`(module
(func (export "func") (result i32)
${Array(32).join('(param f64)')}
(param $last i32)
get_local $last
local.get $last
)
)`).exports.func;
@ -124,7 +124,7 @@ func = wasmEvalText(`(module
(func (export "func") (result i32)
${Array(32).join('(param f64)')}
(param $last i32)
get_local $last
local.get $last
)
)`).exports.func;

Просмотреть файл

@ -10,21 +10,21 @@ const EXCEPTION_ITER = ITER - 2;
var instance = wasmEvalText(`(module
(func $add (export "add") (result i32) (param i32) (param i32)
get_local 0
get_local 1
local.get 0
local.get 1
i32.add
)
(func $addi64 (export "add64") (result i64) (param i32) (param i32)
get_local 0
get_local 1
local.get 0
local.get 1
call $add
i64.extend_s/i32
)
(func $add_two_i64 (export "add_two_i64") (result i64) (param i64) (param i64)
get_local 0
get_local 1
local.get 0
local.get 1
i64.add
)
)`).exports;

Просмотреть файл

@ -19,8 +19,8 @@ enableGeckoProfiling();
for (let type of ['i32', 'f32', 'f64']) {
var instance = wasmEvalText(`(module
(func $add (export "add") (result ${type}) (param ${type}) (param ${type})
get_local 0
get_local 1
local.get 0
local.get 1
${type}.add
)
)`).exports;

Просмотреть файл

@ -7,15 +7,15 @@ enableGeckoProfiling();
let { add } = wasmEvalText(`(module
(func $add (export "add") (result i32) (param i32) (param i32)
get_local 0
local.get 0
i32.const 42
i32.eq
if
unreachable
end
get_local 0
get_local 1
local.get 0
local.get 1
i32.add
)
)`).exports;

Просмотреть файл

@ -20,20 +20,20 @@ var imports = {
var instance = new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary(`(module
(import $main "main" "f" (func))
(func $lol (export "add") (result i32) (param i32) (param i32)
get_local 0
get_local 1
local.get 0
local.get 1
call $add
)
(func $add (result i32) (param i32) (param i32)
get_local 0
local.get 0
i32.const 5000
i32.eq
if
call $main
end
get_local 0
get_local 1
local.get 0
local.get 1
i32.add
)
)`)), imports).exports;
@ -83,12 +83,12 @@ var imports = {
var instance = new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary(`(module
(import $main "main" "f" (func))
(func $lol (export "add") (result i32) (param i32) (param i32)
get_local 0
get_local 1
local.get 0
local.get 1
call $add
)
(func $add (result i32) (param i32) (param i32)
get_local 0
local.get 0
i32.const 5000
i32.eq
if
@ -96,8 +96,8 @@ var instance = new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary(
unreachable
end
get_local 0
get_local 1
local.get 0
local.get 1
i32.add
)
)`)), imports).exports;

Просмотреть файл

@ -9,8 +9,8 @@ const EXCEPTION_ITER = TRIGGER + 5;
for (let type of ['i32', 'f32', 'f64']) {
var instance = wasmEvalText(`(module
(func $add (export "add") (result ${type}) (param ${type}) (param ${type})
get_local 0
get_local 1
local.get 0
local.get 1
${type}.add
)
)`).exports;

Просмотреть файл

@ -16,8 +16,8 @@ const EXPECTED_STACKS = [SLOW_ENTRY_STACK, FAST_ENTRY_STACK, INLINED_CALL_STACK]
function main() {
var { table } = wasmEvalText(`(module
(func $add (result i32) (param i32) (param i32)
get_local 0
get_local 1
local.get 0
local.get 1
i32.add
)
(table (export "table") 10 funcref)
@ -36,8 +36,8 @@ function withTier2() {
var module = new WebAssembly.Module(wasmTextToBinary(`(module
(func $add (result i32) (param i32) (param i32)
get_local 0
get_local 1
local.get 0
local.get 1
i32.add
)
(table (export "table") 10 funcref)

Просмотреть файл

@ -3,8 +3,8 @@ var INNER_ITERATIONS = 100;
let instance = wasmEvalText(`(module
(func (export "add") (result i32) (param i32) (param i32)
get_local 0
get_local 1
local.get 0
local.get 1
i32.add
)
@ -17,19 +17,19 @@ let instance = wasmEvalText(`(module
(global $g (mut i32) (i32.const 0))
(func (export "set_global_one") (param i32)
get_local 0
set_global $g
local.get 0
global.set $g
)
(func (export "set_global_two") (param i32) (param i32)
get_local 0
get_local 1
local.get 0
local.get 1
i32.add
set_global $g
global.set $g
)
(func (export "glob") (result i32)
get_global $g
global.get $g
)
)`).exports;

Просмотреть файл

@ -3,14 +3,14 @@ var i = wasmEvalText(
(memory 1) (data (i32.const 0) "\\01\\02\\03\\04\\05\\06\\07\\08")
(func $off1 (param $base i32) (result i32)
(i32.add
(i32.load8_u (get_local $base))
(i32.load8_u offset=1 (get_local $base)))
(i32.load8_u (local.get $base))
(i32.load8_u offset=1 (local.get $base)))
)
(export "off1" $off1)
(func $off2 (param $base i32) (result i32)
(i32.add
(i32.load8_u offset=1 (get_local $base))
(i32.load8_u offset=2 (get_local $base)))
(i32.load8_u offset=1 (local.get $base))
(i32.load8_u offset=2 (local.get $base)))
)
(export "off2" $off2)
)`).exports;

Просмотреть файл

@ -65,7 +65,7 @@ const WASMPAGE = 65536;
{
let text = `(module
(memory (import "" "memory") 1 1 shared)
(func (export "id") (param i32) (result i32) (get_local 0)))`;
(func (export "id") (param i32) (result i32) (local.get 0)))`;
let mod = new WebAssembly.Module(wasmTextToBinary(text));
let mem = new WebAssembly.Memory({initial: 1, maximum: 1, shared: true});
let ins = new WebAssembly.Instance(mod, {"": {memory: mem}});
@ -77,7 +77,7 @@ const WASMPAGE = 65536;
{
let text = `(module
(memory (import "" "memory") 1 1 shared)
(func (export "id") (param i32) (result i32) (get_local 0)))`;
(func (export "id") (param i32) (result i32) (local.get 0)))`;
let mod = new WebAssembly.Module(wasmTextToBinary(text));
let mem = new WebAssembly.Memory({initial: 1, maximum: 1});
assertErrorMessage(() => new WebAssembly.Instance(mod, {"": {memory: mem}}),
@ -90,7 +90,7 @@ const WASMPAGE = 65536;
{
let text = `(module
(memory (import "" "memory") 1 1)
(func (export "id") (param i32) (result i32) (get_local 0)))`;
(func (export "id") (param i32) (result i32) (local.get 0)))`;
let mod = new WebAssembly.Module(wasmTextToBinary(text));
let mem = new WebAssembly.Memory({initial: 1, maximum: 1, shared: true});
assertErrorMessage(() => new WebAssembly.Instance(mod, {"": {memory: mem}}),
@ -104,7 +104,7 @@ const WASMPAGE = 65536;
{
let text = `(module
(memory (import "" "memory") 2 4 shared)
(func (export "id") (param i32) (result i32) (get_local 0)))`;
(func (export "id") (param i32) (result i32) (local.get 0)))`;
let mod = new WebAssembly.Module(wasmTextToBinary(text));
// some cases that are non-matching are allowed, eg, initial > declared min
@ -137,8 +137,8 @@ const WASMPAGE = 65536;
(memory (export "memory") 2 4 shared)
(func (export "c") (result i32) memory.size)
(func (export "g") (result i32) (memory.grow (i32.const 1)))
(func (export "l") (param i32) (result i32) (i32.load (get_local 0)))
(func (export "s") (param i32) (param i32) (i32.store (get_local 0) (get_local 1))))`;
(func (export "l") (param i32) (result i32) (i32.load (local.get 0)))
(func (export "s") (param i32) (param i32) (i32.store (local.get 0) (local.get 1))))`;
let mod = new WebAssembly.Module(wasmTextToBinary(text));
let ins = new WebAssembly.Instance(mod);
let exp = ins.exports;
@ -200,7 +200,7 @@ const WASMPAGE = 65536;
let text = `(module
(memory (import "" "memory") 2 4 shared)
(data (i32.const 0) "abcdefghijklmnopqrstuvwxyz")
(func (export "l") (param i32) (result i32) (i32.load8_u (get_local 0))))`;
(func (export "l") (param i32) (result i32) (i32.load8_u (local.get 0))))`;
let mod = new WebAssembly.Module(wasmTextToBinary(text));
let mem = new WebAssembly.Memory({initial: 2, maximum: 4, shared: true});
let ins = new WebAssembly.Instance(mod, {"": {memory: mem}});

Просмотреть файл

@ -11,7 +11,7 @@ function loadModuleSrc(type, ext, offset, align, drop = false) {
(${type}.load${ext}
offset=${offset}
${align != 0 ? 'align=' + align : ''}
(get_local 0)
(local.get 0)
)
${maybeDrop}
) (export "" 0))`;
@ -30,15 +30,15 @@ function storeModuleSrc(type, ext, offset, align) {
(${type}.store${ext}
offset=${offset}
${align != 0 ? 'align=' + align : ''}
(get_local 0)
(get_local 1)
(local.get 0)
(local.get 1)
)
) (export "store" 0)
(func $load (param i32) (result ${type})
(${type}.load${load_ext}
offset=${offset}
${align != 0 ? 'align=' + align : ''}
(get_local 0)
(local.get 0)
)
) (export "load" 1))`;
}
@ -56,7 +56,7 @@ function storeModuleCstSrc(type, ext, offset, align, value) {
(${type}.store${ext}
offset=${offset}
${align != 0 ? 'align=' + align : ''}
(get_local 0)
(local.get 0)
(${type}.const ${value})
)
) (export "store" 0)
@ -64,7 +64,7 @@ function storeModuleCstSrc(type, ext, offset, align, value) {
(${type}.load${load_ext}
offset=${offset}
${align != 0 ? 'align=' + align : ''}
(get_local 0)
(local.get 0)
)
) (export "load" 1))`;
}
@ -122,11 +122,11 @@ function testStoreOOB(type, ext, base, offset, align, value) {
}
function badLoadModule(type, ext) {
wasmFailValidateText( `(module (func (param i32) (${type}.load${ext} (get_local 0))) (export "" 0))`, /can't touch memory/);
wasmFailValidateText( `(module (func (param i32) (${type}.load${ext} (local.get 0))) (export "" 0))`, /can't touch memory/);
}
function badStoreModule(type, ext) {
wasmFailValidateText(`(module (func (param i32) (${type}.store${ext} (get_local 0) (${type}.const 0))) (export "" 0))`, /can't touch memory/);
wasmFailValidateText(`(module (func (param i32) (${type}.store${ext} (local.get 0) (${type}.const 0))) (export "" 0))`, /can't touch memory/);
}
// Can't touch memory.
@ -310,30 +310,30 @@ for (var foldOffsets = 0; foldOffsets <= 1; foldOffsets++) {
(data (i32.const 0) "\\00\\01\\02\\03\\04\\05\\06\\07\\08\\09\\0a\\0b\\0c\\0d\\0e\\0f")
(data (i32.const 16) "\\f0\\f1\\f2\\f3\\f4\\f5\\f6\\f7\\f8\\f9\\fa\\fb\\fc\\fd\\fe\\ff")
(func (param i32) (local i32 i32 i32 i32 f32 f64) (result i32)
(set_local 1 (i32.load8_s offset=4 (get_local 0)))
(set_local 2 (i32.load16_s (get_local 1)))
(i32.store8 offset=4 (get_local 0) (get_local 1))
(set_local 3 (i32.load16_u (get_local 2)))
(i32.store16 (get_local 1) (get_local 2))
(set_local 4 (i32.load (get_local 2)))
(i32.store (get_local 1) (get_local 2))
(set_local 5 (f32.load (get_local 4)))
(f32.store (get_local 4) (get_local 5))
(set_local 6 (f64.load (get_local 4)))
(f64.store (get_local 4) (get_local 6))
(local.set 1 (i32.load8_s offset=4 (local.get 0)))
(local.set 2 (i32.load16_s (local.get 1)))
(i32.store8 offset=4 (local.get 0) (local.get 1))
(local.set 3 (i32.load16_u (local.get 2)))
(i32.store16 (local.get 1) (local.get 2))
(local.set 4 (i32.load (local.get 2)))
(i32.store (local.get 1) (local.get 2))
(local.set 5 (f32.load (local.get 4)))
(f32.store (local.get 4) (local.get 5))
(local.set 6 (f64.load (local.get 4)))
(f64.store (local.get 4) (local.get 6))
(i32.add
(i32.add
(get_local 0)
(get_local 1)
(local.get 0)
(local.get 1)
)
(i32.add
(i32.add
(get_local 2)
(get_local 3)
(local.get 2)
(local.get 3)
)
(i32.add
(get_local 4)
(i32.reinterpret/f32 (get_local 5))
(local.get 4)
(i32.reinterpret/f32 (local.get 5))
)
)
)

Просмотреть файл

@ -84,22 +84,22 @@ wasmAssert(`(module
(func $add (result f32) (f32.add ${f32_snan_code} (f32.const 0)))
;; Shouldn't affect NaNess.
(func $set_get_global_f32 (result f32)
(func $global.set.get_f32 (result f32)
${f32_snan_code}
set_global 0
get_global 0
global.set 0
global.get 0
)
;; Shouldn't affect NaNess.
(func $set_get_global_f64 (result f64)
(func $global.set.get_f64 (result f64)
${f64_snan_code}
set_global 1
get_global 1
global.set 1
global.get 1
)
)`, [
{ type: 'f32', func: '$add', expected: f32_qnan },
{ type: 'f32', func: '$set_get_global_f32', expected: f32_snan },
{ type: 'f64', func: '$set_get_global_f64', expected: f64_snan },
{ type: 'f32', func: '$global.set.get_f32', expected: f32_snan },
{ type: 'f64', func: '$global.set.get_f64', expected: f64_snan },
]);
// NaN propagation behavior.
@ -116,9 +116,9 @@ function test(type, opcode, lhs_code, rhs_code) {
// - (variable, variable)
wasmAssert(`(module
(func $1 (result ${t}) (${t}.${op} ${lhs_code} ${rhs_code}))
(func $2 (param ${t}) (result ${t}) (${t}.${op} (get_local 0) ${rhs_code}))
(func $3 (param ${t}) (result ${t}) (${t}.${op} ${lhs_code} (get_local 0)))
(func $4 (param ${t}) (param ${t}) (result ${t}) (${t}.${op} (get_local 0) (get_local 1)))
(func $2 (param ${t}) (result ${t}) (${t}.${op} (local.get 0) ${rhs_code}))
(func $3 (param ${t}) (result ${t}) (${t}.${op} ${lhs_code} (local.get 0)))
(func $4 (param ${t}) (param ${t}) (result ${t}) (${t}.${op} (local.get 0) (local.get 1)))
)`, [
{ type, func: '$1', expected: qnan_code },
{ type, func: '$2', args: [lhs_code], expected: qnan_code },

Просмотреть файл

@ -60,7 +60,7 @@ function gen_tab_impmod_t(insn)
(func (export "check") (param i32) (result i32)
;; call the selected table entry, which will either return a value,
;; or will cause an exception.
get_local 0 ;; callIx
local.get 0 ;; callIx
call_indirect 0 ;; and its return value is our return value.
)
)`;
@ -354,7 +354,7 @@ checkPassiveElemSegment("end", /failed to read end of initializer expression/);
(func $g)
(func $h)
(func (export "doit") (param $idx i32)
(table.init 4 (get_local $idx) (i32.const 0) (i32.const 5))))`;
(table.init 4 (local.get $idx) (i32.const 0) (i32.const 5))))`;
let ins = wasmEvalText(txt);
ins.exports.doit(0);
ins.exports.doit(5);

Просмотреть файл

@ -23,7 +23,7 @@ function mem_fill(min, max, shared, backup, write=backup*2) {
`(module
(memory (export "mem") ${min} ${max} ${shared})
(func (export "run") (param $offs i32) (param $val i32) (param $len i32)
(memory.fill (get_local $offs) (get_local $val) (get_local $len))))`);
(memory.fill (local.get $offs) (local.get $val) (local.get $len))))`);
// A fill past the end should throw *and* have filled all the way up to the end
let offs = min*PAGESIZE - backup;
let val = 37;
@ -60,7 +60,7 @@ function mem_init(min, max, shared, backup, write) {
(memory (export "mem") ${min} ${max} ${shared})
(data passive "\\42\\42\\42\\42\\42\\42\\42\\42\\42\\42\\42\\42\\42\\42\\42\\42")
(func (export "run") (param $offs i32) (param $len i32)
(memory.init 0 (get_local $offs) (i32.const 0) (get_local $len))))`);
(memory.init 0 (local.get $offs) (i32.const 0) (local.get $len))))`);
// A fill writing past the end of the memory should throw *and* have filled
// all the way up to the end.
//
@ -118,7 +118,7 @@ function mem_copy(min, max, shared, srcOffs, targetOffs, len, copyDown=false) {
`(module
(memory (export "mem") ${min} ${max} ${shared})
(func (export "run") (param $targetOffs i32) (param $srcOffs i32) (param $len i32)
(memory.copy (get_local $targetOffs) (get_local $srcOffs) (get_local $len))))`);
(memory.copy (local.get $targetOffs) (local.get $srcOffs) (local.get $len))))`);
let v = new Uint8Array(ins.exports.mem.buffer);

Просмотреть файл

@ -33,7 +33,7 @@ function tbl_init(min, max, backup, write, segoffs=0) {
(func $f14 (export "f14"))
(func $f15 (export "f15"))
(func (export "run") (param $offs i32) (param $len i32)
(table.init 0 (get_local $offs) (i32.const ${segoffs}) (get_local $len))))`);
(table.init 0 (local.get $offs) (i32.const ${segoffs}) (local.get $len))))`);
// A fill writing past the end of the table should throw *and* have filled
// all the way up to the end.
//
@ -109,7 +109,7 @@ function tbl_copy(min, max, srcOffs, targetOffs, len, copyDown=false) {
(func $f14 (export "f14"))
(func $f15 (export "f15"))
(func (export "run") (param $targetOffs i32) (param $srcOffs i32) (param $len i32)
(table.copy (get_local $targetOffs) (get_local $srcOffs) (get_local $len))))`);
(table.copy (local.get $targetOffs) (local.get $srcOffs) (local.get $len))))`);
let tbl = ins.exports.tbl;

Просмотреть файл

@ -63,7 +63,7 @@ test(
test(`(module
(import $f32 "Math" "sin" (param f32) (result f32))
(func (export "") (param f32) (result f32)
get_local 0
local.get 0
call $f32
)
)`,
@ -75,7 +75,7 @@ if (getBuildConfiguration()["arm-simulator"]) {
for (let op of ['div_s', 'rem_s', 'div_u', 'rem_u']) {
test(`(module
(func (export "") (param i32) (result i32)
get_local 0
local.get 0
i64.extend_s/i32
i64.const 0x1a2b3c4d5e6f
i64.${op}
@ -116,7 +116,7 @@ for (let type of ['f32', 'f64']) {
for (let func of ['ceil', 'floor', 'nearest', 'trunc']) {
test(`(module
(func (export "") (param ${type}) (result ${type})
get_local 0
local.get 0
${type}.${func}
)
)`,
@ -206,7 +206,7 @@ for (let type of ['f32', 'f64']) {
(import "a" "b" (table 10 funcref))
(elem (i32.const 2) $bar)
(func $bar (result i32) (i32.const 99))
(func $baz (param $i i32) (result i32) (call_indirect $v2i (get_local $i)))
(func $baz (param $i i32) (result i32) (call_indirect $v2i (local.get $i)))
(export "baz" $baz)
)`, {a:{b:e.tbl}}).exports;
@ -281,11 +281,11 @@ for (let type of ['f32', 'f64']) {
(import $missingOneArg "a" "sumTwo" (param i32) (result i32))
(func (export "foo") (param i32) (result i32)
get_local 0
local.get 0
call $ffi)
(func (export "id") (param i32) (result i32)
get_local 0
local.get 0
call $missingOneArg
)
)`));
@ -388,13 +388,13 @@ for (let type of ['f32', 'f64']) {
// Ion->wasm calls.
let func = wasmEvalText(`(module
(func $inner (result i32) (param i32) (param i32)
get_local 0
get_local 1
local.get 0
local.get 1
i32.add
)
(func (export "add") (result i32) (param i32) (param i32)
get_local 0
get_local 1
local.get 0
local.get 1
call $inner
)
)`).exports.add;

Просмотреть файл

@ -4,19 +4,19 @@ var bin = wasmTextToBinary(
(local i32 i64 i64 i64 f32)
i32.const 1
tee_local 0
get_local 0
get_local 0
get_local 0
get_local 0
get_local 0
get_local 0
get_local 0
local.get 0
local.get 0
local.get 0
local.get 0
local.get 0
local.get 0
local.get 0
if i32
get_local 0
local.get 0
else
get_local 0
local.get 0
tee_local 0
get_local 0
local.get 0
br_if 1
end
drop

Просмотреть файл

@ -12,9 +12,9 @@ var prog = wasmEvalText(
(local $x f64)
(local $y f64)
(local $z f64)
(set_local $x (get_local $a))
(set_local $y (get_local $b))
(set_local $z (f64.floor (f64.div (get_local $x) (get_local $y))))
(get_local $z)))`);
(local.set $x (local.get $a))
(local.set $y (local.get $b))
(local.set $z (f64.floor (f64.div (local.get $x) (local.get $y))))
(local.get $z)))`);
assertEq(prog.exports.test(16096, 32), 503);

Просмотреть файл

@ -15,16 +15,16 @@
wasmEvalText(`(module
(memory 1)
(func $run (param i64) (param i32) (param i32)
get_local 1
get_local 2
local.get 1
local.get 2
i32.add
get_local 1
get_local 2
local.get 1
local.get 2
i32.add
i32.const 0
get_local 0
local.get 0
i64.store8
drop

Просмотреть файл

@ -10,9 +10,9 @@ for ( let i=0; i < 8; i++) {
`(module
(func (export "f") (param i32) (result i32)
${adds(i)}
(set_local 0 (i32.extend8_s (i32.add (get_local 0) (i32.const 1))))
(local.set 0 (i32.extend8_s (i32.add (local.get 0) (i32.const 1))))
${drops(i)}
(get_local 0)))`;
(local.get 0)))`;
let ins = new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary(txt)));
assertEq(ins.exports.f(254), -1);
}
@ -20,7 +20,7 @@ for ( let i=0; i < 8; i++) {
function adds(n) {
let s = ""
for ( let i=0; i < n; i++ )
s += "(i32.add (get_local 0) (i32.const 1))\n";
s += "(i32.add (local.get 0) (i32.const 1))\n";
return s;
}

Просмотреть файл

@ -2,33 +2,33 @@ new WebAssembly.Module(wasmTextToBinary(`
(module
(global $g (mut i32) (i32.const 42))
(func (param $i i32)
get_local $i
get_global $g
get_global $g
get_global $g
get_global $g
get_global $g
get_global $g
get_global $g
get_global $g
get_global $g
get_global $g
get_global $g
get_global $g
get_global $g
get_global $g
get_global $g
get_global $g
get_global $g
get_global $g
get_global $g
get_global $g
get_global $g
get_global $g
get_global $g
get_global $g
get_global $g
get_global $g
local.get $i
global.get $g
global.get $g
global.get $g
global.get $g
global.get $g
global.get $g
global.get $g
global.get $g
global.get $g
global.get $g
global.get $g
global.get $g
global.get $g
global.get $g
global.get $g
global.get $g
global.get $g
global.get $g
global.get $g
global.get $g
global.get $g
global.get $g
global.get $g
global.get $g
global.get $g
global.get $g
unreachable
)
)
@ -38,20 +38,20 @@ new WebAssembly.Module(wasmTextToBinary(`
(module
(global $g (mut i32) (i32.const 42))
(func (param $i i32)
get_global $g
get_global $g
get_global $g
get_global $g
get_global $g
get_global $g
get_global $g
get_global $g
get_global $g
get_global $g
get_global $g
get_global $g
get_local $i
set_global $g
global.get $g
global.get $g
global.get $g
global.get $g
global.get $g
global.get $g
global.get $g
global.get $g
global.get $g
global.get $g
global.get $g
global.get $g
local.get $i
global.set $g
unreachable
)
)

Просмотреть файл

@ -7,7 +7,7 @@ wasmEvalText(
(func $run (param i64) (param i64) (result i64)
block i64
i64.const 1
(i64.lt_s (get_local 0) (get_local 1))
(i64.lt_s (local.get 0) (local.get 1))
br_if 0
drop
i64.const 2

Просмотреть файл

@ -4,7 +4,7 @@ var f = wasmEvalText(`(module (func (result i32) (param i32)
(block $1
(block $2
(block $default
(br_table $0 $1 $2 $default (get_local 0))))))
(br_table $0 $1 $2 $default (local.get 0))))))
(return (i32.const 0)))
(export "" 0)
)`).exports[""];

Просмотреть файл

@ -1,7 +1,7 @@
// Bug 1316181
// There are locals with different values here to ensure that the
// get_local at the end picks up the right one even if the stack might
// local.get at the end picks up the right one even if the stack might
// have become unbalanced by a failure to adjust SP along the branch
// edge. The logic is that we use SP-relative addressing, and if the
// actual SP is not what the compiler thinks it is we will read
@ -19,16 +19,16 @@ var o = wasmEvalText(
(local $v6 i32)
(local $v7 i32)
(local $res i32)
(set_local $v0 (i32.const 0xDEADBEEF))
(set_local $v1 (i32.const 0xFDEADBEE))
(set_local $v2 (i32.const 0xEFDEADBE))
(set_local $v3 (i32.const 0xEEFDEADB))
(set_local $v4 (i32.const 0xBEEFDEAD))
(set_local $v5 (i32.const 0xDBEEFDEA))
(set_local $v6 (i32.const 0xADBEEFDE))
(set_local $v7 (i32.const 0xEADBEEFD))
(local.set $v0 (i32.const 0xDEADBEEF))
(local.set $v1 (i32.const 0xFDEADBEE))
(local.set $v2 (i32.const 0xEFDEADBE))
(local.set $v3 (i32.const 0xEEFDEADB))
(local.set $v4 (i32.const 0xBEEFDEAD))
(local.set $v5 (i32.const 0xDBEEFDEA))
(local.set $v6 (i32.const 0xADBEEFDE))
(local.set $v7 (i32.const 0xEADBEEFD))
(block $b
(set_local $res
(local.set $res
(i32.add
(i32.add (i32.const 1) (i32.const 2))
(i32.add
@ -60,7 +60,7 @@ var o = wasmEvalText(
(i32.add
(i32.add (i32.const 29) (i32.const 30))
(br_if $b (i32.const 31) (i32.const 1)))))))))))))))))))
(return (get_local $v3)))
(return (local.get $v3)))
(export "a" 0))`).exports;
assertEq(o["a"](), 0xEEFDEADB|0);

Просмотреть файл

@ -9,7 +9,7 @@ assertEq(wasmEvalText(`
br_table $out $out
end
end
get_local $p
local.get $p
br_if 0
)
(export "f" $f)

Просмотреть файл

@ -2,7 +2,7 @@
var code = "(module ";
for (var i = 0; i < 100; i++)
code += "(func (param i32) (result i32) (i32.add (i32.const 1) (get_local 0))) ";
code += "(func (param i32) (result i32) (i32.add (i32.const 1) (local.get 0))) ";
code += ")";
var buf = wasmTextToBinary(code);
WebAssembly.compile(buf);

Просмотреть файл

@ -9,14 +9,14 @@ function wasmEvalText(str, imports) {
assertEq(wasmEvalText(`(module
(global (import "a" "b") i32)
(export "g" (global 0))
(func (export "get") (result i32) get_global 0))`,
(func (export "get") (result i32) global.get 0))`,
{ a: { b: 42 }}).exports.get(),
42);
for (let v of []) {}
function testInitExpr(type, initialValue, nextValue, coercion, assertFunc = assertEq) {
var module = wasmEvalText(`(module
(import "globals" "a" (global ${type}))
(global $glob_imm ${type} (get_global 0))
(global $glob_imm ${type} (global.get 0))
(export "global_imm" (global $glob_imm))
)`, {
globals: {

Просмотреть файл

@ -13,12 +13,12 @@ let mt = `
(local i32)
(local i32)
(block i32
(set_local 0 (get_global 0))
(local.set 0 (global.get 0))
(block i32
(set_global 1 (i32.const 37))
(global.set 1 (i32.const 37))
(block i32
(set_local 1 (get_global 0))
(i32.add (get_local 0) (get_local 1)))))))
(local.set 1 (global.get 0))
(i32.add (local.get 0) (local.get 1)))))))
`;
let glob = new WebAssembly.Global({value:'i32', mutable:true}, 88);

Просмотреть файл

@ -22,7 +22,7 @@ let i = new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary(`
i64.mul
;; get the last byte index accessed by an int32 access.
get_local $i
local.get $i
i32.const 3
i32.add
tee_local $i
@ -32,7 +32,7 @@ let i = new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary(`
i64.le_u
if
;; get the floor of the accessed *page* index.
get_local $i
local.get $i
i64.extend_u/i32
i64.const 65536
i64.div_u
@ -56,15 +56,15 @@ let i = new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary(`
)
(func (export "set") (param $i i32) (param $v i32)
get_local $i
local.get $i
call $maybeGrow
get_local $i
get_local $v
local.get $i
local.get $v
i32.store
)
(func (export "get") (param $i i32) (result i32)
get_local $i
local.get $i
i32.load
)
)

Просмотреть файл

@ -24,8 +24,8 @@ var bin = wasmTextToBinary(
(param i32) (param i32) (param i32) (param i32) (param i32)))
(func (export "test") (param $a i32) (param $b i32) (param $c i32) (param $d i32) (param $e i32)
(param $f i32) (param $g i32) (param $h i32) (param $i i32) (param $j i32)
(call $f (get_local $a) (get_local $b) (get_local $c) (get_local $d) (get_local $e)
(get_local $f) (get_local $g) (get_local $h) (get_local $i) (get_local $j))))`);
(call $f (local.get $a) (local.get $b) (local.get $c) (local.get $d) (local.get $e)
(local.get $f) (local.get $g) (local.get $h) (local.get $i) (local.get $j))))`);
var mod = new WebAssembly.Module(bin);
var ins = new WebAssembly.Instance(mod, {m:{f}});

Просмотреть файл

@ -3,14 +3,14 @@ wasmEvalText(`(module
(func $f (param $p i32)
(local $x i32) (local $y i32)
loop $top
get_local $x
get_local $p
get_local $x
local.get $x
local.get $p
local.get $x
br_if $top
i32.const 1
tee_local $p
get_local $y
set_local $x
local.get $y
local.set $x
i32.add
call $f
br_if $top

Просмотреть файл

@ -22,12 +22,12 @@ var letext =`(module
(export "load" $func1)
(export "assert_0" $func2)
(func $func0 (param $var0 i32) (param $var1 i64)
get_local $var0
get_local $var1
local.get $var0
local.get $var1
i64.store16 offset=16
)
(func $func1 (param $var0 i32) (result i64)
get_local $var0
local.get $var0
i64.load16_s offset=16
)
(func $func2 (result i32)

Просмотреть файл

@ -26,7 +26,7 @@ let { exports } = new WebAssembly.Instance(
(module
(func $imp (import "env" "importedFunc") (param i32))
(func (export "exp") (param i32)
get_local 0
local.get 0
call $imp
)
)

Просмотреть файл

@ -1,7 +1,7 @@
(function coerceinplace() {
var { table } = wasmEvalText(`(module
(func $add (result i32) (param i32) (param i32)
get_local 0
local.get 0
)
(table (export "table") 10 funcref)
(elem (i32.const 0) $add)
@ -15,14 +15,14 @@
(function reporti64() {
var instance = wasmEvalText(`(module
(func $add (export "add") (result i32) (param i32) (param i32)
get_local 0
get_local 1
local.get 0
local.get 1
i32.add
)
(func $addi64 (result i64) (param i32) (param i32)
get_local 0
get_local 1
local.get 0
local.get 1
call $add
i64.extend_s/i32
)

Просмотреть файл

@ -14,7 +14,7 @@ const { exports } = wasmEvalText(`
(module
(import "global" "func" (param i32) (result i32))
(func (export "func_0") (param i32)(result i32)
get_local 0
local.get 0
call 0
)
)

Просмотреть файл

@ -1,24 +1,24 @@
wasmFailValidateText(`(module
(func (result i32) (param i32)
(loop (if (i32.const 0) (br 0)) (get_local 0)))
(loop (if (i32.const 0) (br 0)) (local.get 0)))
(export "" 0)
)`, /unused values not explicitly dropped by end of block/);
wasmFailValidateText(`(module
(func (param i32)
(loop (if (i32.const 0) (br 0)) (get_local 0)))
(loop (if (i32.const 0) (br 0)) (local.get 0)))
(export "" 0)
)`, /unused values not explicitly dropped by end of block/);
wasmFailValidateText(`(module
(func (result i32) (param i32)
(loop (if (i32.const 0) (br 0)) (drop (get_local 0))))
(loop (if (i32.const 0) (br 0)) (drop (local.get 0))))
(export "" 0)
)`, emptyStackError);
assertEq(wasmEvalText(`(module
(func (result i32) (param i32)
(loop (if (i32.const 0) (br 0))) (get_local 0))
(loop (if (i32.const 0) (br 0))) (local.get 0))
(export "" 0)
)`).exports[""](42), 42);
@ -85,8 +85,8 @@ wasmEvalText(`
(module
(import "check" "one" (param i32))
(import "check" "two" (param i32) (param i32))
(func (param i32) (call 0 (get_local 0)))
(func (param i32) (param i32) (call 1 (get_local 0) (get_local 1)))
(func (param i32) (call 0 (local.get 0)))
(func (param i32) (param i32) (call 1 (local.get 0) (local.get 1)))
(func
(call 1
(i32.const 43)

Просмотреть файл

@ -24,9 +24,9 @@ for (let body of bodies) {
(module
(func $f (param $x i32) (result i32)
loop $top i32
get_local $x
local.get $x
if
get_local $x
local.get $x
br 2
end
${body}

Просмотреть файл

@ -8,7 +8,7 @@ try {
var bin = wasmTextToBinary(
`(module (func (result i32) (param f64) (param f32)
i64.const 0
get_local 0
local.get 0
drop
i32.wrap/i64
f64.const 0

Просмотреть файл

@ -2,7 +2,7 @@ var params = '';
var locals = '';
for (let i = 0; i < 20; i++) {
params += '(param i64) ';
locals += `(get_local ${i}) `;
locals += `(local.get ${i}) `;
}
wasmEvalText(`

Просмотреть файл

@ -1,13 +1,13 @@
wasmFullPassI64(`
(module
(global (mut i64) (i64.const 9970292656026947164))
(func (export "get_global_0") (result i64) get_global 0)
(func (export "global.get_0") (result i64) global.get 0)
(func $run (result i64) (param i32)
i64.const 8692897571457488645
i64.const 1028567229461950342
i64.mul
get_global 0
global.get 0
f32.const 3.141592653
f32.floor
f32.const -13.37

Просмотреть файл

@ -3,14 +3,14 @@
wasmEvalText(
`(module
(func $func0 (param $arg0 i32) (result i32) (local $var0 i64)
(set_local $var0 (i64.extend_u/i32 (get_local $arg0)))
(local.set $var0 (i64.extend_u/i32 (local.get $arg0)))
(i32.wrap/i64
(i64.add
(block i64
(loop $label1 $label0
(drop (block $label2 i64
(br_table $label2 (i64.const 0) (get_local $arg0))))
(set_local $var0 (i64.mul (i64.const 2) (get_local $var0))))
(tee_local $var0 (i64.add (i64.const 4) (get_local $var0))))
(br_table $label2 (i64.const 0) (local.get $arg0))))
(local.set $var0 (i64.mul (i64.const 2) (local.get $var0))))
(tee_local $var0 (i64.add (i64.const 4) (local.get $var0))))
(i64.const 1))))
(export "" 0))`);

Просмотреть файл

@ -9,10 +9,10 @@ for (let i = 15; i --> 0;) {
tests = `
(if i64
(i64.eq
(get_local ${i + 8})
(get_local ${i})
(local.get ${i + 8})
(local.get ${i})
)
(get_local ${i + 8})
(local.get ${i + 8})
${tests}
)`;
}
@ -30,23 +30,23 @@ wasmEvalText(code);
assertEq(wasmEvalText(`(module
(memory 1)
(func (param $p i32) (local $l i32) (result i32)
(set_local $l (i32.const 0))
(local.set $l (i32.const 0))
(if
(get_local $p)
(set_local $l
(local.get $p)
(local.set $l
(i32.add
(get_local $l)
(i32.load8_s (get_local $p))
(local.get $l)
(i32.load8_s (local.get $p))
)
)
)
(set_local $l
(local.set $l
(i32.add
(get_local $l)
(i32.load8_s (get_local $p))
(local.get $l)
(i32.load8_s (local.get $p))
)
)
(get_local $l)
(local.get $l)
)
(data (i32.const 0) "\\00\\01\\02\\03\\04\\05\\06\\07\\08\\09\\0a\\0b\\0c\\0d\\0e\\0f")
(export "test" 0)

Просмотреть файл

@ -2,11 +2,11 @@ var ins = new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary(
`(module
(memory (export "mem") 1 1)
(func (export "store_32_1") (param $ptr i32)
(i64.store32 align=1 (get_local $ptr) (i64.const 0xabba1337)))
(i64.store32 align=1 (local.get $ptr) (i64.const 0xabba1337)))
(func (export "store_32_2") (param $ptr i32)
(i64.store32 align=2 (get_local $ptr) (i64.const 0xabba1337)))
(i64.store32 align=2 (local.get $ptr) (i64.const 0xabba1337)))
(func (export "store_16") (param $ptr i32)
(i64.store16 align=1 (get_local $ptr) (i64.const 0x1337))))`))).exports;
(i64.store16 align=1 (local.get $ptr) (i64.const 0x1337))))`))).exports;
var mem = new Uint8Array(ins.mem.buffer);

Просмотреть файл

@ -84,13 +84,13 @@ var mem = new Memory({initial:1});
new Int32Array(mem.buffer)[0] = 42;
var mod = new Module(wasmTextToBinary(`(module
(import "" "mem" (memory 1))
(func $gm (param i32) (result i32) (memory.grow (get_local 0)))
(func $gm (param i32) (result i32) (memory.grow (local.get 0)))
(export "grow_memory" $gm)
(func $cm (result i32) (memory.size))
(export "current_memory" $cm)
(func $ld (param i32) (result i32) (i32.load (get_local 0)))
(func $ld (param i32) (result i32) (i32.load (local.get 0)))
(export "load" $ld)
(func $st (param i32) (param i32) (i32.store (get_local 0) (get_local 1)))
(func $st (param i32) (param i32) (i32.store (local.get 0) (local.get 1)))
(export "store" $st)
)`));
var exp1 = new Instance(mod, {"":{mem}}).exports;
@ -198,7 +198,7 @@ tbl.set(0, src.one);
var mod = new Module(wasmTextToBinary(`(module
(type $v2i (func (result i32)))
(table (import "" "tbl") 1 funcref)
(func $ci (param i32) (result i32) (call_indirect $v2i (get_local 0)))
(func $ci (param i32) (result i32) (call_indirect $v2i (local.get 0)))
(export "call_indirect" $ci)
)`));
var exp1 = new Instance(mod, {"":{tbl}}).exports;

Просмотреть файл

@ -36,7 +36,7 @@ wasmFullPass(` (module
i32.const 0
i32.load
f64.const 5.0
set_local $local
local.set $local
f64.const 5.0
tee_local $local
drop

Просмотреть файл

@ -7,7 +7,7 @@ const Instance = WebAssembly.Instance;
const Table = WebAssembly.Table;
const RuntimeError = WebAssembly.RuntimeError;
var caller = `(type $v2i (func (result i32))) (func $call (param $i i32) (result i32) (call_indirect $v2i (get_local $i))) (export "call" $call)`
var caller = `(type $v2i (func (result i32))) (func $call (param $i i32) (result i32) (call_indirect $v2i (local.get $i))) (export "call" $call)`
var callee = i => `(func $f${i} (type $v2i) (i32.const ${i}))`;
// A table should not hold exported functions alive and exported functions
@ -204,10 +204,10 @@ var m = new Module(wasmTextToBinary(`(module
(import "a" "b" (table ${N} funcref))
(type $i2i (func (param i32) (result i32)))
(func $f (param $i i32) (result i32)
(set_local $i (i32.sub (get_local $i) (i32.const 1)))
(local.set $i (i32.sub (local.get $i) (i32.const 1)))
(i32.add
(i32.const 1)
(call_indirect $i2i (get_local $i) (get_local $i))))
(call_indirect $i2i (local.get $i) (local.get $i))))
(export "f" $f)
)`));
for (var i = 1; i < N; i++) {

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше