35614b7215
When TurboFan sees a call to Reflect.get with exactly two parameters, we can lower that to a direct call to the GetPropertyStub, which is certainly faster than the general C++ builtin. This gives a nice 7-8% improvement on the chai test in the web-tooling-benchmark. The micro-benchmark on the issue goes from reflectGetPresent: 461 ms. reflectGetAbsent: 470 ms. to reflectGetPresent: 141 ms. reflectGetAbsent: 245 ms. which is an up to 3.2x improvement. Bug: v8:5996, v8:6936, v8:6937 Change-Id: Ic439fccb13f1a2f84386bf9fc31b4283d101afc4 Reviewed-on: https://chromium-review.googlesource.com/732988 Commit-Queue: Benedikt Meurer <bmeurer@chromium.org> Reviewed-by: Michael Stanton <mvstanton@chromium.org> Reviewed-by: Benedikt Meurer <bmeurer@chromium.org> Cr-Commit-Position: refs/heads/master@{#48841}
69 lines
1.6 KiB
JavaScript
69 lines
1.6 KiB
JavaScript
// Copyright 2017 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
// Flags: --allow-natives-syntax
|
|
|
|
// Test Reflect.get with wrong (number of) arguments.
|
|
(function() {
|
|
"use strict";
|
|
function foo() { return Reflect.get(); }
|
|
|
|
assertThrows(foo);
|
|
assertThrows(foo);
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
assertThrows(foo);
|
|
})();
|
|
(function() {
|
|
"use strict";
|
|
function foo(o) { return Reflect.get(o); }
|
|
|
|
assertEquals(undefined, foo({}));
|
|
assertEquals(undefined, foo({}));
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
assertEquals(undefined, foo({}));
|
|
})();
|
|
(function() {
|
|
"use strict";
|
|
function foo(o) { return Reflect.get(o); }
|
|
|
|
assertThrows(foo.bind(undefined, 1));
|
|
assertThrows(foo.bind(undefined, undefined));
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
assertThrows(foo.bind(undefined, 'o'));
|
|
})();
|
|
|
|
// Test Reflect.get within try/catch.
|
|
(function() {
|
|
const o = {x: 10};
|
|
"use strict";
|
|
function foo() {
|
|
try {
|
|
return Reflect.get(o, "x");
|
|
} catch (e) {
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
assertEquals(10, foo());
|
|
assertEquals(10, foo());
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
assertEquals(10, foo());
|
|
})();
|
|
(function() {
|
|
"use strict";
|
|
const o = {};
|
|
function foo(n) {
|
|
try {
|
|
return Reflect.get(o, n);
|
|
} catch (e) {
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
assertEquals(1, foo({[Symbol.toPrimitive]() { throw new Error(); }}));
|
|
assertEquals(1, foo({[Symbol.toPrimitive]() { throw new Error(); }}));
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
assertEquals(1, foo({[Symbol.toPrimitive]() { throw new Error(); }}));
|
|
})();
|