mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
![Liam Appelbe](/assets/img/avatar_default.png)
This reverts commit224f82c21c
. Reason for revert: Just need to split DBC section into 32 and 64 bit Original change's description: > Revert "[vm] Create offsets_extractor tool." > > This reverts commit3015d79371
. > > Reason for revert: Fails the Flutter build > /b/s/w/ir/cache/builder/mac_sdk -mmacosx-version-min=10.12 -m32 -fno-strict-aliasing -fstack-protector-all -fcolor-diagnostics -Wall -Wextra -Wendif-labels -Werror -Wno-missing-field-initializers -Wno-unused-parameter -Wunguarded-availability -fvisibility=hidden -stdlib=libc++ -Wheader-hygiene -Wstring-conversion -Wthread-safety -O2 -fno-ident -fdata-sections -ffunction-sections -g2 -Werror -Wall -Wextra -Wno-unused-parameter -Wno-unused-private-field -Wnon-virtual-dtor -Wvla -Wno-conversion-null -Woverloaded-virtual -Wno-comments -g3 -ggdb3 -fno-rtti -fno-exceptions -Wimplicit-fallthrough -O3 -fvisibility-inlines-hidden -std=c++14 -fno-rtti -fno-exceptions -c ../../third_party/dart/runtime/vm/dart.cc -o clang_x86/obj/third_party/dart/runtime/vm/libdart_vm_nosnapshot_with_precompiler.dart.o > In file included from ../../third_party/dart/runtime/vm/dart.cc:9: > ../../third_party/dart/runtime/vm/compiler/runtime_offsets_extracted.h:958:50: error: implicit conversion from 'long long' to 'const dart::word' (aka 'const long') changes value from 576460752303423487 to -1 [-Werror,-Wconstant-conversion] > static constexpr dart::word Array_kMaxElements = 576460752303423487; > ~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~ > ../../third_party/dart/runtime/vm/compiler/runtime_offsets_extracted.h:965:51: error: implicit conversion from 'long long' to 'const dart::word' (aka 'const long') changes value from 2305843009213693951 to -1 [-Werror,-Wconstant-conversion] > static constexpr dart::word String_kMaxElements = 2305843009213693951; > ~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~ > 2 errors generated. > > Change-Id: Iaf509c6ee7a2ce75664935519ac02a933a9eb2bf > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/104402 > Reviewed-by: Siva Annamalai <asiva@google.com> > Commit-Queue: Siva Annamalai <asiva@google.com> > Auto-Submit: Siva Annamalai <asiva@google.com> TBR=asiva@google.com Change-Id: Ibf749ceee274b03cdffa6d7ed46fcbe75d1a1e94 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/104620 Reviewed-by: Liam Appelbe <liama@google.com> Reviewed-by: Siva Annamalai <asiva@google.com> Commit-Queue: Liam Appelbe <liama@google.com>
242 lines
9 KiB
C++
242 lines
9 KiB
C++
// Copyright (c) 2011, 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.
|
|
|
|
#ifndef RUNTIME_VM_DART_ENTRY_H_
|
|
#define RUNTIME_VM_DART_ENTRY_H_
|
|
|
|
#include "vm/allocation.h"
|
|
#include "vm/growable_array.h"
|
|
#include "vm/object.h"
|
|
#include "vm/raw_object.h"
|
|
|
|
namespace dart {
|
|
|
|
// Forward declarations.
|
|
class Array;
|
|
class Closure;
|
|
class Function;
|
|
class Instance;
|
|
class Integer;
|
|
class Library;
|
|
class Object;
|
|
class RawArray;
|
|
class RawInstance;
|
|
class RawObject;
|
|
class RawString;
|
|
class String;
|
|
|
|
// An arguments descriptor array consists of the type argument vector length (0
|
|
// if none); total argument count (not counting type argument vector); the
|
|
// positional argument count; a sequence of (name, position) pairs, sorted
|
|
// by name, for each named optional argument; and a terminating null to
|
|
// simplify iterating in generated code.
|
|
class ArgumentsDescriptor : public ValueObject {
|
|
public:
|
|
explicit ArgumentsDescriptor(const Array& array);
|
|
|
|
// Accessors.
|
|
intptr_t TypeArgsLen() const; // 0 if no type argument vector is passed.
|
|
intptr_t FirstArgIndex() const { return TypeArgsLen() > 0 ? 1 : 0; }
|
|
intptr_t CountWithTypeArgs() const { return FirstArgIndex() + Count(); }
|
|
intptr_t Count() const; // Excluding type arguments vector.
|
|
intptr_t PositionalCount() const; // Excluding type arguments vector.
|
|
intptr_t NamedCount() const { return Count() - PositionalCount(); }
|
|
RawString* NameAt(intptr_t i) const;
|
|
intptr_t PositionAt(intptr_t i) const;
|
|
bool MatchesNameAt(intptr_t i, const String& other) const;
|
|
// Returns array of argument names in the arguments order.
|
|
RawArray* GetArgumentNames() const;
|
|
|
|
// Generated code support.
|
|
static intptr_t type_args_len_offset() {
|
|
return Array::element_offset(kTypeArgsLenIndex);
|
|
}
|
|
|
|
static intptr_t count_offset() { return Array::element_offset(kCountIndex); }
|
|
|
|
static intptr_t positional_count_offset() {
|
|
return Array::element_offset(kPositionalCountIndex);
|
|
}
|
|
|
|
static intptr_t first_named_entry_offset() {
|
|
return Array::element_offset(kFirstNamedEntryIndex);
|
|
}
|
|
|
|
static intptr_t name_offset() { return kNameOffset * kWordSize; }
|
|
static intptr_t position_offset() { return kPositionOffset * kWordSize; }
|
|
static intptr_t named_entry_size() { return kNamedEntrySize * kWordSize; }
|
|
|
|
// Allocate and return an arguments descriptor. The first
|
|
// (num_arguments - optional_arguments_names.Length()) arguments are
|
|
// positional and the remaining ones are named optional arguments.
|
|
// The presence of a type argument vector as first argument (not counted in
|
|
// num_arguments) is indicated by a non-zero type_args_len.
|
|
static RawArray* New(intptr_t type_args_len,
|
|
intptr_t num_arguments,
|
|
const Array& optional_arguments_names);
|
|
|
|
// Allocate and return an arguments descriptor that has no optional
|
|
// arguments. All arguments are positional. The presence of a type argument
|
|
// vector as first argument (not counted in num_arguments) is indicated
|
|
// by a non-zero type_args_len.
|
|
static RawArray* New(intptr_t type_args_len, intptr_t num_arguments);
|
|
|
|
// Initialize the preallocated fixed length arguments descriptors cache.
|
|
static void Init();
|
|
|
|
// Clear the preallocated fixed length arguments descriptors cache.
|
|
static void Cleanup();
|
|
|
|
enum { kCachedDescriptorCount = 32 };
|
|
|
|
private:
|
|
// Absolute indices into the array.
|
|
// Keep these in sync with the constants in invocation_mirror_patch.dart.
|
|
enum {
|
|
kTypeArgsLenIndex,
|
|
kCountIndex,
|
|
kPositionalCountIndex,
|
|
kFirstNamedEntryIndex,
|
|
};
|
|
|
|
private:
|
|
// Relative indexes into each named argument entry.
|
|
enum {
|
|
kNameOffset,
|
|
// The least significant bit of the entry in 'kPositionOffset' (second
|
|
// least-significant after Smi-encoding) holds the strong-mode checking bit
|
|
// for the named argument.
|
|
kPositionOffset,
|
|
kNamedEntrySize,
|
|
};
|
|
|
|
public:
|
|
static intptr_t LengthFor(intptr_t num_named_arguments) {
|
|
// Add 1 for the terminating null.
|
|
return kFirstNamedEntryIndex + (kNamedEntrySize * num_named_arguments) + 1;
|
|
}
|
|
|
|
static RawArray* NewNonCached(intptr_t type_args_len,
|
|
intptr_t num_arguments,
|
|
bool canonicalize);
|
|
|
|
// Used by Simulator to parse argument descriptors.
|
|
static intptr_t name_index(intptr_t index) {
|
|
return kFirstNamedEntryIndex + (index * kNamedEntrySize) + kNameOffset;
|
|
}
|
|
|
|
static intptr_t position_index(intptr_t index) {
|
|
return kFirstNamedEntryIndex + (index * kNamedEntrySize) + kPositionOffset;
|
|
}
|
|
|
|
const Array& array_;
|
|
|
|
// A cache of VM heap allocated arguments descriptors.
|
|
static RawArray* cached_args_descriptors_[kCachedDescriptorCount];
|
|
|
|
friend class SnapshotReader;
|
|
friend class SnapshotWriter;
|
|
friend class Serializer;
|
|
friend class Deserializer;
|
|
friend class Interpreter;
|
|
friend class InterpreterHelpers;
|
|
friend class Simulator;
|
|
friend class SimulatorHelpers;
|
|
DISALLOW_COPY_AND_ASSIGN(ArgumentsDescriptor);
|
|
};
|
|
|
|
// DartEntry abstracts functionality needed to resolve dart functions
|
|
// and invoke them from C++.
|
|
class DartEntry : public AllStatic {
|
|
public:
|
|
// On success, returns a RawInstance. On failure, a RawError.
|
|
typedef RawObject* (*invokestub)(const Code& target_code,
|
|
const Array& arguments_descriptor,
|
|
const Array& arguments,
|
|
Thread* thread);
|
|
|
|
// Invokes the specified instance function or static function.
|
|
// The first argument of an instance function is the receiver.
|
|
// On success, returns a RawInstance. On failure, a RawError.
|
|
// This is used when there is no type argument vector and
|
|
// no named arguments in the call.
|
|
static RawObject* InvokeFunction(const Function& function,
|
|
const Array& arguments);
|
|
|
|
// Invokes the specified instance, static, or closure function.
|
|
// On success, returns a RawInstance. On failure, a RawError.
|
|
static RawObject* InvokeFunction(
|
|
const Function& function,
|
|
const Array& arguments,
|
|
const Array& arguments_descriptor,
|
|
uword current_sp = OSThread::GetCurrentStackPointer());
|
|
|
|
// Invokes the closure object given as the first argument.
|
|
// On success, returns a RawInstance. On failure, a RawError.
|
|
// This is used when there is no type argument vector and
|
|
// no named arguments in the call.
|
|
static RawObject* InvokeClosure(const Array& arguments);
|
|
|
|
// Invokes the closure object given as the first argument.
|
|
// On success, returns a RawInstance. On failure, a RawError.
|
|
static RawObject* InvokeClosure(const Array& arguments,
|
|
const Array& arguments_descriptor);
|
|
|
|
// Invokes the noSuchMethod instance function on the receiver.
|
|
// On success, returns a RawInstance. On failure, a RawError.
|
|
static RawObject* InvokeNoSuchMethod(const Instance& receiver,
|
|
const String& target_name,
|
|
const Array& arguments,
|
|
const Array& arguments_descriptor);
|
|
};
|
|
|
|
// Utility functions to call from VM into Dart bootstrap libraries.
|
|
// Each may return an exception object.
|
|
class DartLibraryCalls : public AllStatic {
|
|
public:
|
|
// On success, returns a RawInstance. On failure, a RawError.
|
|
static RawObject* InstanceCreate(const Library& library,
|
|
const String& exception_name,
|
|
const String& constructor_name,
|
|
const Array& arguments);
|
|
|
|
// On success, returns a RawInstance. On failure, a RawError.
|
|
static RawObject* ToString(const Instance& receiver);
|
|
|
|
// On success, returns a RawInstance. On failure, a RawError.
|
|
static RawObject* HashCode(const Instance& receiver);
|
|
|
|
// On success, returns a RawInstance. On failure, a RawError.
|
|
static RawObject* Equals(const Instance& left, const Instance& right);
|
|
|
|
// On success, returns a RawInstance. On failure, a RawError.
|
|
static RawObject* IdentityHashCode(const Instance& object);
|
|
|
|
// Returns the handler if one has been registered for this port id.
|
|
static RawObject* LookupHandler(Dart_Port port_id);
|
|
|
|
// Returns null on success, a RawError on failure.
|
|
static RawObject* HandleMessage(const Object& handler,
|
|
const Instance& dart_message);
|
|
|
|
// Returns null on success, a RawError on failure.
|
|
static RawObject* DrainMicrotaskQueue();
|
|
|
|
// Ensures that the isolate's _pendingImmediateCallback is set to
|
|
// _startMicrotaskLoop from dart:async.
|
|
// Returns null on success, a RawError on failure.
|
|
static RawObject* EnsureScheduleImmediate();
|
|
|
|
// map[key] = value;
|
|
//
|
|
// Returns null on success, a RawError on failure.
|
|
static RawObject* MapSetAt(const Instance& map,
|
|
const Instance& key,
|
|
const Instance& value);
|
|
};
|
|
|
|
} // namespace dart
|
|
|
|
#endif // RUNTIME_VM_DART_ENTRY_H_
|