Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Issue 2927763004: Optimize runtime code on hot methods (Closed)

Created:
3 years, 6 months ago by vsm
Modified:
3 years, 6 months ago
CC:
dev-compiler+reviews_dartlang.org
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Optimize runtime code on hot methods ochafik: this should include your internal fixes. Here are generated diffs: JSArray: [dartx._get](index) { - if (!(typeof index == 'number')) dart.throw(_js_helper.diagnoseIndexError(this, index)); - if (dart.notNull(index) >= dart.notNull(this[dartx.length]) || dart.notNull(index) < 0) dart.throw(_js_helper.diagnoseIndexError(this, index)); + if (index == null || index >= this.length || index < 0) { + dart.throw(_js_helper.diagnoseIndexError(this, index)); + } return this[index]; } [dartx._set](index, value) { E._check(value); this[dartx.checkMutable]('indexed set'); - if (!(typeof index == 'number')) dart.throw(_js_helper.diagnoseIndexError(this, index)); - if (dart.notNull(index) >= dart.notNull(this[dartx.length]) || dart.notNull(index) < 0) dart.throw(_js_helper.diagnoseIndexError(this, index)); + if (index == null || index >= this.length || index < 0) { + dart.throw(_js_helper.diagnoseIndexError(this, index)); + } R=jmesserly@google.com, ochafik@google.com JSString: [dartx.codeUnitAt](index) { - if (!(typeof index == 'number')) dart.throw(_js_helper.diagnoseIndexError(this, index)); - if (dart.notNull(index) < 0) dart.throw(_js_helper.diagnoseIndexError(this, index)); - if (dart.notNull(index) >= dart.notNull(this[dartx.length])) dart.throw(_js_helper.diagnoseIndexError(this, index)); + if (index == null || index < 0 || index >= this.length) { + dart.throw(_js_helper.diagnoseIndexError(this, index)); + } return this.charCodeAt(index); } [dartx.startsWith](pattern, index) { if (index === void 0) index = 0; - _js_helper.checkInt(index); - if (dart.notNull(index) < 0 || dart.notNull(index) > dart.notNull(this[dartx.length])) { + let length = this.length; + if (dart.notNull(index) < 0 || index > length) { dart.throw(new core.RangeError.range(index, 0, this[dartx.length])); } if (typeof pattern == 'string') { let other = pattern; - let otherLength = other[dartx.length]; - let endIndex = dart.notNull(index) + dart.notNull(otherLength); - if (endIndex > dart.notNull(this[dartx.length])) return false; + let otherLength = other.length; + let endIndex = index + otherLength; + if (endIndex > length) return false; return other == this.substring(index, endIndex); } return pattern[dartx.matchAsPrefix](this, index) != null; } get [dartx.isEmpty]() { - return this[dartx.length] == 0; + return this.length == 0; } [dartx.compareTo](other) { - if (!(typeof other == 'string')) dart.throw(_js_helper.argumentErrorValue(other)); + if (other == null) dart.throw(_js_helper.argumentErrorValue(other)); return dart.equals(this, other) ? 0 : this < other ? -1 : 1; } get [dartx.hashCode]() { let hash = 0; - for (let i = 0; i < dart.notNull(this[dartx.length]); i++) { + let length = this.length; + for (let i = 0; i < length; i++) { hash = 536870911 & hash + this.charCodeAt(i); hash = 536870911 & hash + ((524287 & hash) << 10); hash = hash ^ hash >> 6; ... } [dartx._get](index) { - if (!(typeof index == 'number')) dart.throw(_js_helper.diagnoseIndexError(this, index)); - if (dart.notNull(index) >= dart.notNull(this[dartx.length]) || dart.notNull(index) < 0) dart.throw(_js_helper.diagnoseIndexError(this, index)); + if (index == null || index >= this.length || index < 0) { + dart.throw(_js_helper.diagnoseIndexError(this, index)); + } return this[index]; } Committed: https://github.com/dart-lang/sdk/commit/a7645f817f775f34e13d1cc73bef078a487f5817

Patch Set 1 #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+32 lines, -15 lines) Patch
M pkg/dev_compiler/lib/sdk/ddc_sdk.sum View Binary file 0 comments Download
M pkg/dev_compiler/tool/input_sdk/private/js_array.dart View 1 chunk +11 lines, -4 lines 1 comment Download
M pkg/dev_compiler/tool/input_sdk/private/js_string.dart View 5 chunks +21 lines, -11 lines 0 comments Download

Messages

Total messages: 7 (3 generated)
vsm
3 years, 6 months ago (2017-06-08 15:50:21 UTC) #3
ochafik
lgtm https://codereview.chromium.org/2927763004/diff/1/pkg/dev_compiler/tool/input_sdk/private/js_array.dart File pkg/dev_compiler/tool/input_sdk/private/js_array.dart (right): https://codereview.chromium.org/2927763004/diff/1/pkg/dev_compiler/tool/input_sdk/private/js_array.dart#newcode562 pkg/dev_compiler/tool/input_sdk/private/js_array.dart:562: if (index == null || I wonder how ...
3 years, 6 months ago (2017-06-08 17:23:08 UTC) #4
Jennifer Messerly
lgtm!!!
3 years, 6 months ago (2017-06-08 18:33:31 UTC) #5
vsm
3 years, 6 months ago (2017-06-09 00:31:59 UTC) #7
Message was sent while issue was closed.
Committed patchset #1 (id:1) manually as
a7645f817f775f34e13d1cc73bef078a487f5817 (presubmit successful).

Powered by Google App Engine
This is Rietveld 408576698