0af6dde79d
This is a reland of commit d24b5d1f5e
On top of the original change, the following is fixed and improved:
1) Flow graph builder (FGB) body is now also applied to
dynamic invocation forwarders (similarly to graph
intrinsics).
2) Frame can be omitted for functions which have a
call on a shared slow path. This is needed to make
FGB implementation of GetIndexed frameless, as it has
GenericCheckBound which calls on shared slow path.
(Graph intrinsics are frameless).
3) Range analysis is enabled for force-optimized functions,
so more efficient code can be generated for boxing
instructions. Range analysis is fixed to avoid crashes
and correctly intersect ranges with constant boundaries
(needed for some force-optimized FFI functions).
4) EliminateStackOverflowChecks pass is enabled for
force-optimized functions so CheckStackOverflow can be
eliminated.
Original change's description:
> [vm] Replace array GetIndexed graph intrinsics with flow graph builder implementation
>
> _Array, _GrowableList, internal and external typed data 'operator []'
> are now implemented in the flow graph builder.
>
> Unlike graph intrinsics, flow graph created in the flow graph builder
> can be used by the inliner. Corresponding graph intrinsics and native
> methods are removed.
>
> Also, this change adds missing external typed data indexing operations.
>
> TEST=ci
>
> Change-Id: Ic19784481feadf54c096a587413e67b4e18353dc
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/359940
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Commit-Queue: Alexander Markov <alexmarkov@google.com>
TEST=ci
Change-Id: I04ef008a04238d432683d7543cd047e35bad17c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/360560
Reviewed-by: Tess Strickland <sstrickl@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
77 lines
2.8 KiB
C++
77 lines
2.8 KiB
C++
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
#include "platform/assert.h"
|
|
#include "vm/bootstrap_natives.h"
|
|
#include "vm/exceptions.h"
|
|
#include "vm/native_entry.h"
|
|
#include "vm/object.h"
|
|
|
|
namespace dart {
|
|
|
|
DEFINE_NATIVE_ENTRY(List_allocate, 0, 2) {
|
|
// Implemented in FlowGraphBuilder::VisitNativeBody.
|
|
UNREACHABLE();
|
|
return Object::null();
|
|
}
|
|
|
|
DEFINE_NATIVE_ENTRY(List_setIndexed, 0, 3) {
|
|
const Array& array = Array::CheckedHandle(zone, arguments->NativeArgAt(0));
|
|
GET_NON_NULL_NATIVE_ARGUMENT(Smi, index, arguments->NativeArgAt(1));
|
|
const Instance& value =
|
|
Instance::CheckedHandle(zone, arguments->NativeArgAt(2));
|
|
if ((index.Value() < 0) || (index.Value() >= array.Length())) {
|
|
Exceptions::ThrowRangeError("index", index, 0, array.Length() - 1);
|
|
}
|
|
array.SetAt(index.Value(), value);
|
|
return Object::null();
|
|
}
|
|
|
|
DEFINE_NATIVE_ENTRY(List_getLength, 0, 1) {
|
|
const Array& array = Array::CheckedHandle(zone, arguments->NativeArgAt(0));
|
|
return Smi::New(array.Length());
|
|
}
|
|
|
|
// ObjectArray src, int start, int count, bool needTypeArgument.
|
|
DEFINE_NATIVE_ENTRY(List_slice, 0, 4) {
|
|
const Array& src = Array::CheckedHandle(zone, arguments->NativeArgAt(0));
|
|
GET_NON_NULL_NATIVE_ARGUMENT(Smi, start, arguments->NativeArgAt(1));
|
|
GET_NON_NULL_NATIVE_ARGUMENT(Smi, count, arguments->NativeArgAt(2));
|
|
GET_NON_NULL_NATIVE_ARGUMENT(Bool, needs_type_arg, arguments->NativeArgAt(3));
|
|
intptr_t istart = start.Value();
|
|
if ((istart < 0) || (istart > src.Length())) {
|
|
Exceptions::ThrowRangeError("start", start, 0, src.Length());
|
|
}
|
|
intptr_t icount = count.Value();
|
|
// Zero count should be handled outside already.
|
|
if ((icount <= 0) || (icount > src.Length())) {
|
|
Exceptions::ThrowRangeError("count", count,
|
|
0, // This is the limit the user sees.
|
|
src.Length() - istart);
|
|
}
|
|
|
|
return src.Slice(istart, icount, needs_type_arg.value());
|
|
}
|
|
|
|
// Private factory, expects correct arguments.
|
|
DEFINE_NATIVE_ENTRY(ImmutableList_from, 0, 4) {
|
|
// Ignore first argument of this factory (type argument).
|
|
const Array& from_array =
|
|
Array::CheckedHandle(zone, arguments->NativeArgAt(1));
|
|
const Smi& smi_offset = Smi::CheckedHandle(zone, arguments->NativeArgAt(2));
|
|
const Smi& smi_length = Smi::CheckedHandle(zone, arguments->NativeArgAt(3));
|
|
const intptr_t length = smi_length.Value();
|
|
const intptr_t offset = smi_offset.Value();
|
|
const Array& result = Array::Handle(Array::New(length));
|
|
Object& temp = Object::Handle();
|
|
for (intptr_t i = 0; i < length; i++) {
|
|
temp = from_array.At(i + offset);
|
|
result.SetAt(i, temp);
|
|
}
|
|
result.MakeImmutable();
|
|
return result.ptr();
|
|
}
|
|
|
|
} // namespace dart
|