[wasm] Fix maximum value length in scope info

i64 values can be up to 20 characters long (19 + sign), plus we need
one character for the terminating null character. Thus the previous 18
needs to be increased to 21.
Also extend the test to check the longest possible i64 values.

R=ahaas@chromium.org
CC=kozyatinskiy@chromium.org

Bug: v8:8644
Change-Id: Ia9458db162a55dd57b5e8bc7cf7db73c3bab4734
Reviewed-on: https://chromium-review.googlesource.com/c/1404443
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58724}
This commit is contained in:
Clemens Hammacher 2019-01-10 14:35:42 +01:00 committed by Commit Bot
parent f59d6d96e1
commit 1740bc7bf6
3 changed files with 172 additions and 72 deletions

View File

@ -31,9 +31,9 @@ namespace {
template <bool internal, typename... Args>
Handle<String> PrintFToOneByteString(Isolate* isolate, const char* format,
Args... args) {
// Maximum length of a formatted value name ("param#%d", "local#%d",
// "global#%d").
constexpr int kMaxStrLen = 18;
// Maximum length of a formatted value name ("arg#%d", "local#%d",
// "global#%d", i32 constants, i64 constants), including null character.
static constexpr int kMaxStrLen = 21;
EmbeddedVector<char, kMaxStrLen> value;
int len = SNPrintF(value, format, args...);
CHECK(len > 0 && len < value.length());
@ -49,11 +49,13 @@ Handle<Object> WasmValueToValueObject(Isolate* isolate, WasmValue value) {
if (Smi::IsValid(value.to<int32_t>()))
return handle(Smi::FromInt(value.to<int32_t>()), isolate);
return PrintFToOneByteString<false>(isolate, "%d", value.to<int32_t>());
case kWasmI64:
if (Smi::IsValid(value.to<int64_t>()))
return handle(Smi::FromIntptr(value.to<int64_t>()), isolate);
return PrintFToOneByteString<false>(isolate, "%" PRId64,
value.to<int64_t>());
case kWasmI64: {
int64_t i64 = value.to<int64_t>();
int32_t i32 = static_cast<int32_t>(i64);
if (i32 == i64 && Smi::IsValid(i32))
return handle(Smi::FromIntptr(i32), isolate);
return PrintFToOneByteString<false>(isolate, "%" PRId64, i64);
}
case kWasmF32:
return isolate->factory()->NewNumber(value.to<float>());
case kWasmF64:

View File

@ -10,157 +10,243 @@ Setting breakpoint on line 2 (first instruction)
scriptId : <scriptId>
}
Paused:
(local i32 f64)
(local i32 i64 f64)
#i32.const 11
set_local 0
Scope:
at func (2:2):
- scope (global):
-- skipped
-- skipped globals
- scope (local):
locals: "i32Arg": 4 (number), "local#1": 0 (number), "unicode☼f64": 0 (number)
locals: "i32Arg": 4 (number), "local#1": 0 (number), "i64_local": 0 (number), "unicode☼f64": 0 (number)
stack:
at (anonymous) (0:17):
- scope (global):
-- skipped
-- skipped globals
Paused:
i32.const 11
#set_local 0
i32.const 47
Scope:
at func (3:2):
- scope (global):
-- skipped
-- skipped globals
- scope (local):
locals: "i32Arg": 4 (number), "local#1": 0 (number), "unicode☼f64": 0 (number)
locals: "i32Arg": 4 (number), "local#1": 0 (number), "i64_local": 0 (number), "unicode☼f64": 0 (number)
stack: "0": 11 (number)
at (anonymous) (0:17):
- scope (global):
-- skipped
-- skipped globals
Paused:
set_local 0
#i32.const 47
set_local 1
Scope:
at func (4:2):
- scope (global):
-- skipped
-- skipped globals
- scope (local):
locals: "i32Arg": 11 (number), "local#1": 0 (number), "unicode☼f64": 0 (number)
locals: "i32Arg": 11 (number), "local#1": 0 (number), "i64_local": 0 (number), "unicode☼f64": 0 (number)
stack:
at (anonymous) (0:17):
- scope (global):
-- skipped
-- skipped globals
Paused:
i32.const 47
#set_local 1
i32.const 1
i64.const 9223372036854775807
Scope:
at func (5:2):
- scope (global):
-- skipped
-- skipped globals
- scope (local):
locals: "i32Arg": 11 (number), "local#1": 0 (number), "unicode☼f64": 0 (number)
locals: "i32Arg": 11 (number), "local#1": 0 (number), "i64_local": 0 (number), "unicode☼f64": 0 (number)
stack: "0": 47 (number)
at (anonymous) (0:17):
- scope (global):
-- skipped
-- skipped globals
Paused:
set_local 1
#i32.const 1
f64.convert_u/i32
#i64.const 9223372036854775807
set_local 2
Scope:
at func (6:2):
- scope (global):
-- skipped
-- skipped globals
- scope (local):
locals: "i32Arg": 11 (number), "local#1": 47 (number), "unicode☼f64": 0 (number)
locals: "i32Arg": 11 (number), "local#1": 47 (number), "i64_local": 0 (number), "unicode☼f64": 0 (number)
stack:
at (anonymous) (0:17):
- scope (global):
-- skipped
-- skipped globals
Paused:
i64.const 9223372036854775807
#set_local 2
i64.const -9223372036854775808
Scope:
at func (7:2):
- scope (global):
-- skipped globals
- scope (local):
locals: "i32Arg": 11 (number), "local#1": 47 (number), "i64_local": 0 (number), "unicode☼f64": 0 (number)
stack: "0": 9223372036854775807 (string)
at (anonymous) (0:17):
- scope (global):
-- skipped globals
Paused:
set_local 2
#i64.const -9223372036854775808
set_local 2
Scope:
at func (8:2):
- scope (global):
-- skipped globals
- scope (local):
locals: "i32Arg": 11 (number), "local#1": 47 (number), "i64_local": 9223372036854775807 (string), "unicode☼f64": 0 (number)
stack:
at (anonymous) (0:17):
- scope (global):
-- skipped globals
Paused:
i64.const -9223372036854775808
#set_local 2
i32.const 1
Scope:
at func (9:2):
- scope (global):
-- skipped globals
- scope (local):
locals: "i32Arg": 11 (number), "local#1": 47 (number), "i64_local": 9223372036854775807 (string), "unicode☼f64": 0 (number)
stack: "0": -9223372036854775808 (string)
at (anonymous) (0:17):
- scope (global):
-- skipped globals
Paused:
set_local 2
#i32.const 1
f64.convert_u/i32
Scope:
at func (10:2):
- scope (global):
-- skipped globals
- scope (local):
locals: "i32Arg": 11 (number), "local#1": 47 (number), "i64_local": -9223372036854775808 (string), "unicode☼f64": 0 (number)
stack:
at (anonymous) (0:17):
- scope (global):
-- skipped globals
Paused:
i32.const 1
#f64.convert_u/i32
i32.const 7
at func (7:2):
Scope:
at func (11:2):
- scope (global):
-- skipped
-- skipped globals
- scope (local):
locals: "i32Arg": 11 (number), "local#1": 47 (number), "unicode☼f64": 0 (number)
locals: "i32Arg": 11 (number), "local#1": 47 (number), "i64_local": -9223372036854775808 (string), "unicode☼f64": 0 (number)
stack: "0": 1 (number)
at (anonymous) (0:17):
- scope (global):
-- skipped
-- skipped globals
Paused:
f64.convert_u/i32
#i32.const 7
f64.convert_u/i32
at func (8:2):
Scope:
at func (12:2):
- scope (global):
-- skipped
-- skipped globals
- scope (local):
locals: "i32Arg": 11 (number), "local#1": 47 (number), "unicode☼f64": 0 (number)
locals: "i32Arg": 11 (number), "local#1": 47 (number), "i64_local": -9223372036854775808 (string), "unicode☼f64": 0 (number)
stack: "0": 1 (number)
at (anonymous) (0:17):
- scope (global):
-- skipped
-- skipped globals
Paused:
i32.const 7
#f64.convert_u/i32
f64.div
at func (9:2):
Scope:
at func (13:2):
- scope (global):
-- skipped
-- skipped globals
- scope (local):
locals: "i32Arg": 11 (number), "local#1": 47 (number), "unicode☼f64": 0 (number)
locals: "i32Arg": 11 (number), "local#1": 47 (number), "i64_local": -9223372036854775808 (string), "unicode☼f64": 0 (number)
stack: "0": 1 (number), "1": 7 (number)
at (anonymous) (0:17):
- scope (global):
-- skipped
-- skipped globals
Paused:
f64.convert_u/i32
#f64.div
set_local 2
set_local 3
at func (10:2):
Scope:
at func (14:2):
- scope (global):
-- skipped
-- skipped globals
- scope (local):
locals: "i32Arg": 11 (number), "local#1": 47 (number), "unicode☼f64": 0 (number)
locals: "i32Arg": 11 (number), "local#1": 47 (number), "i64_local": -9223372036854775808 (string), "unicode☼f64": 0 (number)
stack: "0": 1 (number), "1": 7 (number)
at (anonymous) (0:17):
- scope (global):
-- skipped
-- skipped globals
Paused:
f64.div
#set_local 2
#set_local 3
end
at func (11:2):
Scope:
at func (15:2):
- scope (global):
-- skipped
-- skipped globals
- scope (local):
locals: "i32Arg": 11 (number), "local#1": 47 (number), "unicode☼f64": 0 (number)
locals: "i32Arg": 11 (number), "local#1": 47 (number), "i64_local": -9223372036854775808 (string), "unicode☼f64": 0 (number)
stack: "0": 0.14285714285714285 (number)
at (anonymous) (0:17):
- scope (global):
-- skipped
-- skipped globals
Paused:
set_local 2
set_local 3
#end
at func (12:0):
Scope:
at func (16:0):
- scope (global):
-- skipped
-- skipped globals
- scope (local):
locals: "i32Arg": 11 (number), "local#1": 47 (number), "unicode☼f64": 0.14285714285714285 (number)
locals: "i32Arg": 11 (number), "local#1": 47 (number), "i64_local": -9223372036854775808 (string), "unicode☼f64": 0.14285714285714285 (number)
stack:
at (anonymous) (0:17):
- scope (global):
-- skipped
-- skipped globals
exports.main returned. Test finished.

View File

@ -37,15 +37,22 @@ async function instantiateWasm() {
builder.addFunction('func', kSig_v_i)
.addLocals(
{i32_count: 1, f64_count: 1}, ['i32Arg', undefined, 'unicode☼f64'])
{i32_count: 1, i64_count: 1, f64_count: 1},
['i32Arg', undefined, 'i64_local', 'unicode☼f64'])
.addBody([
// Set param 0 to 11.
kExprI32Const, 11, kExprSetLocal, 0,
// Set local 1 to 47.
kExprI32Const, 47, kExprSetLocal, 1,
// Set local 2 to 1/7.
// Set local 2 to 0x7FFFFFFFFFFFFFFF (max i64).
kExprI64Const, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0,
kExprSetLocal, 2,
// Set local 2 to 0x8000000000000000 (min i64).
kExprI64Const, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x7f,
kExprSetLocal, 2,
// Set local 3 to 1/7.
kExprI32Const, 1, kExprF64UConvertI32, kExprI32Const, 7,
kExprF64UConvertI32, kExprF64Div, kExprSetLocal, 2
kExprF64UConvertI32, kExprF64Div, kExprSetLocal, 3
])
.exportAs('main');
@ -98,26 +105,30 @@ async function waitForWasmScript() {
}
}
async function getValueString(value) {
if (value.type == 'object') {
var msg = await Protocol.Runtime.getProperties({objectId: value.objectId});
printFailure(msg);
let printProperty = elem => '"' + elem.name + '"' +
': ' + elem.value.description + ' (' + elem.value.type + ')';
return msg.result.result.map(printProperty).join(', ');
async function getScopeValues(value) {
if (value.type != 'object') {
InspectorTest.log('Expected object. Found:');
InspectorTest.logObject(value);
return;
}
return JSON.stringify(value.value) + ' (' + value.type + ')';
let msg = await Protocol.Runtime.getProperties({objectId: value.objectId});
printFailure(msg);
let printProperty = elem => '"' + elem.name + '"' +
': ' + elem.value.value + ' (' + elem.value.type + ')';
return msg.result.result.map(printProperty).join(', ');
}
async function dumpProperties(message) {
async function dumpScopeProperties(message) {
printFailure(message);
for (var value of message.result.result) {
var value_str = await getValueString(value.value);
var value_str = await getScopeValues(value.value);
InspectorTest.log(' ' + value.name + ': ' + value_str);
}
}
async function dumpScopeChainsOnPause(message) {
InspectorTest.log(`Scope:`);
for (var frame of message.params.callFrames) {
var functionName = frame.functionName || '(anonymous)';
var lineNumber = frame.location ? frame.location.lineNumber : frame.lineNumber;
@ -126,12 +137,13 @@ async function dumpScopeChainsOnPause(message) {
for (var scope of frame.scopeChain) {
InspectorTest.logObject(' - scope (' + scope.type + '):');
if (scope.type == 'global') {
InspectorTest.logObject(' -- skipped');
} else {
var properties = await Protocol.Runtime.getProperties(
{'objectId': scope.object.objectId});
await dumpProperties(properties);
InspectorTest.logObject(' -- skipped globals');
continue;
}
var properties = await Protocol.Runtime.getProperties(
{'objectId': scope.object.objectId});
await dumpScopeProperties(properties);
}
}
InspectorTest.log();
}