[vm] Propagate more UTF8 conversion errors

Change-Id: I8d4f3a892a51bed8b922961bd74bcad727f66508
Reviewed-on: https://dart-review.googlesource.com/73280
Commit-Queue: Zach Anderson <zra@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
This commit is contained in:
Zach Anderson 2018-09-06 02:23:21 +00:00 committed by commit-bot@chromium.org
parent cf6ac73349
commit 27c79f9459
29 changed files with 198 additions and 253 deletions

View file

@ -52,6 +52,8 @@ const char* const DartUtils::kUriLibURL = "dart:uri";
const char* const DartUtils::kHttpScheme = "http:";
const char* const DartUtils::kVMServiceLibURL = "dart:vmservice";
dart::SimpleHashMap* DartUtils::environment_ = NULL;
MagicNumberData appjit_magic_number = {8, {0xdc, 0xdc, 0xf6, 0xf6, 0, 0, 0, 0}};
MagicNumberData snapshot_magic_number = {4, {0xf5, 0xf5, 0xdc, 0xdc}};
MagicNumberData kernel_magic_number = {4, {0x90, 0xab, 0xcd, 0xef}};
@ -803,6 +805,43 @@ Dart_Handle DartUtils::GetCanonicalizableWorkingDirectory() {
return Dart_NewStringFromCString(new_str);
}
void DartUtils::SetEnvironment(dart::SimpleHashMap* environment) {
environment_ = environment;
}
Dart_Handle DartUtils::EnvironmentCallback(Dart_Handle name) {
uint8_t* utf8_array;
intptr_t utf8_len;
Dart_Handle result = Dart_Null();
Dart_Handle handle = Dart_StringToUTF8(name, &utf8_array, &utf8_len);
if (Dart_IsError(handle)) {
handle = Dart_ThrowException(
DartUtils::NewDartArgumentError(Dart_GetError(handle)));
} else {
char* name_chars = reinterpret_cast<char*>(malloc(utf8_len + 1));
memmove(name_chars, utf8_array, utf8_len);
name_chars[utf8_len] = '\0';
const char* value = NULL;
if (environment_ != NULL) {
SimpleHashMap::Entry* entry =
environment_->Lookup(GetHashmapKeyFromString(name_chars),
SimpleHashMap::StringHash(name_chars), false);
if (entry != NULL) {
value = reinterpret_cast<char*>(entry->value);
}
}
if (value != NULL) {
result = Dart_NewStringFromUTF8(reinterpret_cast<const uint8_t*>(value),
strlen(value));
if (Dart_IsError(result)) {
result = Dart_Null();
}
}
free(name_chars);
}
return result;
}
// Statically allocated Dart_CObject instances for immutable
// objects. As these will be used by different threads the use of
// these depends on the fact that the marking internally in the

View file

@ -10,6 +10,7 @@
#include "include/dart_native_api.h"
#include "platform/assert.h"
#include "platform/globals.h"
#include "platform/hashmap.h"
namespace dart {
namespace bin {
@ -33,6 +34,10 @@ static inline Dart_Handle ThrowIfError(Dart_Handle handle) {
return handle;
}
static inline void* GetHashmapKeyFromString(char* key) {
return reinterpret_cast<void*>(key);
}
class CommandLineOptions {
public:
explicit CommandLineOptions(int max_count)
@ -256,6 +261,9 @@ class DartUtils {
static Dart_Handle LibraryFilePath(Dart_Handle library_uri);
static void SetEnvironment(dart::SimpleHashMap* environment);
static Dart_Handle EnvironmentCallback(Dart_Handle name);
private:
static Dart_Handle SetWorkingDirectory();
static Dart_Handle PrepareBuiltinLibrary(Dart_Handle builtin_lib,
@ -271,6 +279,8 @@ class DartUtils {
static Dart_Handle PrepareIsolateLibrary(Dart_Handle isolate_lib);
static Dart_Handle PrepareCLILibrary(Dart_Handle cli_lib);
static dart::SimpleHashMap* environment_;
DISALLOW_ALLOCATION();
DISALLOW_IMPLICIT_CONSTRUCTORS(DartUtils);
};

View file

@ -25,7 +25,8 @@ void FUNCTION_NAME(Directory_Current)(Dart_NativeArguments args) {
Namespace* namespc = Namespace::GetNamespace(args, 0);
const char* current = Directory::Current(namespc);
if (current != NULL) {
Dart_SetReturnValue(args, DartUtils::NewString(current));
Dart_Handle str = ThrowIfError(DartUtils::NewString(current));
Dart_SetReturnValue(args, str);
} else {
Dart_SetReturnValue(args, DartUtils::NewDartOSError());
}
@ -106,7 +107,8 @@ void FUNCTION_NAME(Directory_Create)(Dart_NativeArguments args) {
void FUNCTION_NAME(Directory_SystemTemp)(Dart_NativeArguments args) {
Namespace* namespc = Namespace::GetNamespace(args, 0);
const char* result = Directory::SystemTemp(namespc);
Dart_SetReturnValue(args, DartUtils::NewString(result));
Dart_Handle str = ThrowIfError(DartUtils::NewString(result));
Dart_SetReturnValue(args, str);
}
void FUNCTION_NAME(Directory_CreateTemp)(Dart_NativeArguments args) {
@ -125,7 +127,8 @@ void FUNCTION_NAME(Directory_CreateTemp)(Dart_NativeArguments args) {
}
}
if (result != NULL) {
Dart_SetReturnValue(args, DartUtils::NewString(result));
Dart_Handle str = ThrowIfError(DartUtils::NewString(result));
Dart_SetReturnValue(args, str);
} else {
Dart_SetReturnValue(args, DartUtils::NewDartOSError(&os_error));
}
@ -248,10 +251,7 @@ void FUNCTION_NAME(Directory_SetAsyncDirectoryListerPointer)(
sizeof(*listing), ReleaseListing);
Dart_Handle result = Dart_SetNativeInstanceField(
dart_this, kAsyncDirectoryListerFieldIndex, listing_pointer);
if (Dart_IsError(result)) {
Log::PrintErr("SetAsyncDirectoryListerPointer failed\n");
Dart_PropagateError(result);
}
ThrowIfError(result);
}
void Directory::SetSystemTemp(const char* path) {

View file

@ -413,7 +413,7 @@ class DescriptorInfoMultipleMixin : public DI {
virtual bool IsListeningSocket() const { return true; }
virtual void SetPortAndMask(Dart_Port port, intptr_t mask) {
HashMap::Entry* entry = tokens_map_.Lookup(
SimpleHashMap::Entry* entry = tokens_map_.Lookup(
GetHashmapKeyFromPort(port), GetHashmapHashFromPort(port), true);
PortEntry* pentry;
if (entry->value == NULL) {
@ -454,7 +454,7 @@ class DescriptorInfoMultipleMixin : public DI {
} while (current != root);
}
for (HashMap::Entry* entry = tokens_map_.Start(); entry != NULL;
for (SimpleHashMap::Entry* entry = tokens_map_.Start(); entry != NULL;
entry = tokens_map_.Next(entry)) {
PortEntry* pentry = reinterpret_cast<PortEntry*>(entry->value);
if (pentry->IsReady()) {
@ -467,7 +467,7 @@ class DescriptorInfoMultipleMixin : public DI {
}
virtual void RemovePort(Dart_Port port) {
HashMap::Entry* entry = tokens_map_.Lookup(
SimpleHashMap::Entry* entry = tokens_map_.Lookup(
GetHashmapKeyFromPort(port), GetHashmapHashFromPort(port), false);
if (entry != NULL) {
PortEntry* pentry = reinterpret_cast<PortEntry*>(entry->value);
@ -491,7 +491,7 @@ class DescriptorInfoMultipleMixin : public DI {
}
virtual void RemoveAllPorts() {
for (HashMap::Entry* entry = tokens_map_.Start(); entry != NULL;
for (SimpleHashMap::Entry* entry = tokens_map_.Start(); entry != NULL;
entry = tokens_map_.Next(entry)) {
PortEntry* pentry = reinterpret_cast<PortEntry*>(entry->value);
entry->value = NULL;
@ -532,7 +532,7 @@ class DescriptorInfoMultipleMixin : public DI {
ASSERT(IS_EVENT(events, kCloseEvent) || IS_EVENT(events, kErrorEvent) ||
IS_EVENT(events, kDestroyedEvent));
for (HashMap::Entry* entry = tokens_map_.Start(); entry != NULL;
for (SimpleHashMap::Entry* entry = tokens_map_.Start(); entry != NULL;
entry = tokens_map_.Next(entry)) {
PortEntry* pentry = reinterpret_cast<PortEntry*>(entry->value);
DartUtils::PostInt32(pentry->dart_port, events);
@ -550,7 +550,7 @@ class DescriptorInfoMultipleMixin : public DI {
}
virtual void ReturnTokens(Dart_Port port, int count) {
HashMap::Entry* entry = tokens_map_.Lookup(
SimpleHashMap::Entry* entry = tokens_map_.Lookup(
GetHashmapKeyFromPort(port), GetHashmapHashFromPort(port), false);
ASSERT(entry != NULL);
@ -588,7 +588,7 @@ class DescriptorInfoMultipleMixin : public DI {
// A convenience mapping:
// Dart_Port -> struct PortEntry { dart_port, mask, token_count }
HashMap tokens_map_;
SimpleHashMap tokens_map_;
bool disable_tokens_;

View file

@ -75,7 +75,7 @@ static void AddToEpollInstance(intptr_t epoll_fd_, DescriptorInfo* di) {
}
EventHandlerImplementation::EventHandlerImplementation()
: socket_map_(&HashMap::SamePointerValue, 16) {
: socket_map_(&SimpleHashMap::SamePointerValue, 16) {
intptr_t result;
result = NO_RETRY_EXPECTED(pipe(interrupt_fds_));
if (result != 0) {
@ -143,8 +143,8 @@ DescriptorInfo* EventHandlerImplementation::GetDescriptorInfo(
intptr_t fd,
bool is_listening) {
ASSERT(fd >= 0);
HashMap::Entry* entry = socket_map_.Lookup(GetHashmapKeyFromFd(fd),
GetHashmapHashFromFd(fd), true);
SimpleHashMap::Entry* entry = socket_map_.Lookup(
GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd), true);
ASSERT(entry != NULL);
DescriptorInfo* di = reinterpret_cast<DescriptorInfo*>(entry->value);
if (di == NULL) {

View file

@ -85,7 +85,7 @@ class EventHandlerImplementation {
static void* GetHashmapKeyFromFd(intptr_t fd);
static uint32_t GetHashmapHashFromFd(intptr_t fd);
HashMap socket_map_;
SimpleHashMap socket_map_;
TimeoutQueue timeout_queue_;
bool shutdown_;
int interrupt_fds_[2];

View file

@ -266,7 +266,7 @@ void EventHandlerImplementation::RemoveFromPort(zx_handle_t port_handle,
}
EventHandlerImplementation::EventHandlerImplementation()
: socket_map_(&HashMap::SamePointerValue, 16) {
: socket_map_(&SimpleHashMap::SamePointerValue, 16) {
shutdown_ = false;
// Create the port.
port_handle_ = ZX_HANDLE_INVALID;
@ -311,7 +311,7 @@ DescriptorInfo* EventHandlerImplementation::GetDescriptorInfo(
bool is_listening) {
IOHandle* handle = reinterpret_cast<IOHandle*>(fd);
ASSERT(handle->fd() >= 0);
HashMap::Entry* entry =
SimpleHashMap::Entry* entry =
socket_map_.Lookup(GetHashmapKeyFromFd(handle->fd()),
GetHashmapHashFromFd(handle->fd()), true);
ASSERT(entry != NULL);

View file

@ -158,7 +158,7 @@ class EventHandlerImplementation {
intptr_t GetPollEvents(intptr_t events);
void HandleInterrupt(InterruptMessage* msg);
HashMap socket_map_;
SimpleHashMap socket_map_;
TimeoutQueue timeout_queue_;
bool shutdown_;
zx_handle_t port_handle_;

View file

@ -69,7 +69,7 @@ static void AddToEpollInstance(intptr_t epoll_fd_, DescriptorInfo* di) {
}
EventHandlerImplementation::EventHandlerImplementation()
: socket_map_(&HashMap::SamePointerValue, 16) {
: socket_map_(&SimpleHashMap::SamePointerValue, 16) {
intptr_t result;
result = NO_RETRY_EXPECTED(pipe(interrupt_fds_));
if (result != 0) {
@ -151,8 +151,8 @@ DescriptorInfo* EventHandlerImplementation::GetDescriptorInfo(
intptr_t fd,
bool is_listening) {
ASSERT(fd >= 0);
HashMap::Entry* entry = socket_map_.Lookup(GetHashmapKeyFromFd(fd),
GetHashmapHashFromFd(fd), true);
SimpleHashMap::Entry* entry = socket_map_.Lookup(
GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd), true);
ASSERT(entry != NULL);
DescriptorInfo* di = reinterpret_cast<DescriptorInfo*>(entry->value);
if (di == NULL) {

View file

@ -83,7 +83,7 @@ class EventHandlerImplementation {
static void* GetHashmapKeyFromFd(intptr_t fd);
static uint32_t GetHashmapHashFromFd(intptr_t fd);
HashMap socket_map_;
SimpleHashMap socket_map_;
TimeoutQueue timeout_queue_;
bool shutdown_;
int interrupt_fds_[2];

View file

@ -93,7 +93,7 @@ static void AddToKqueue(intptr_t kqueue_fd_, DescriptorInfo* di) {
}
EventHandlerImplementation::EventHandlerImplementation()
: socket_map_(&HashMap::SamePointerValue, 16) {
: socket_map_(&SimpleHashMap::SamePointerValue, 16) {
intptr_t result;
result = NO_RETRY_EXPECTED(pipe(interrupt_fds_));
if (result != 0) {
@ -160,8 +160,8 @@ DescriptorInfo* EventHandlerImplementation::GetDescriptorInfo(
intptr_t fd,
bool is_listening) {
ASSERT(fd >= 0);
HashMap::Entry* entry = socket_map_.Lookup(GetHashmapKeyFromFd(fd),
GetHashmapHashFromFd(fd), true);
SimpleHashMap::Entry* entry = socket_map_.Lookup(
GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd), true);
ASSERT(entry != NULL);
DescriptorInfo* di = reinterpret_cast<DescriptorInfo*>(entry->value);
if (di == NULL) {

View file

@ -96,7 +96,7 @@ class EventHandlerImplementation {
static void* GetHashmapKeyFromFd(intptr_t fd);
static uint32_t GetHashmapHashFromFd(intptr_t fd);
HashMap socket_map_;
SimpleHashMap socket_map_;
TimeoutQueue timeout_queue_;
bool shutdown_;
int interrupt_fds_[2];

View file

@ -49,10 +49,7 @@ static void SetFile(Dart_Handle dart_this, intptr_t file_pointer) {
DEBUG_ASSERT(IsFile(dart_this));
Dart_Handle result = Dart_SetNativeInstanceField(
dart_this, kFileNativeFieldIndex, file_pointer);
if (Dart_IsError(result)) {
Log::PrintErr("SetNativeInstanceField in SetFile() failed\n");
Dart_PropagateError(result);
}
ThrowIfError(result);
}
void FUNCTION_NAME(File_GetPointer)(Dart_NativeArguments args) {
@ -213,9 +210,7 @@ void FUNCTION_NAME(File_Read)(Dart_NativeArguments args) {
dart_args[2] = Dart_NewInteger(bytes_read);
// TODO(sgjesse): Cache the _makeUint8ListView function somewhere.
Dart_Handle io_lib = Dart_LookupLibrary(DartUtils::NewString("dart:io"));
if (Dart_IsError(io_lib)) {
Dart_PropagateError(io_lib);
}
ThrowIfError(io_lib);
Dart_Handle array_view =
Dart_Invoke(io_lib, DartUtils::NewString("_makeUint8ListView"),
kNumArgs, dart_args);
@ -239,9 +234,7 @@ void FUNCTION_NAME(File_ReadInto)(Dart_NativeArguments args) {
intptr_t length = end - start;
intptr_t array_len = 0;
Dart_Handle result = Dart_ListLength(buffer_obj, &array_len);
if (Dart_IsError(result)) {
Dart_PropagateError(result);
}
ThrowIfError(result);
ASSERT(end <= array_len);
uint8_t* buffer = Dart_ScopeAllocate(length);
int64_t bytes_read = file->Read(reinterpret_cast<void*>(buffer), length);
@ -278,9 +271,7 @@ void FUNCTION_NAME(File_WriteFrom)(Dart_NativeArguments args) {
void* buffer = NULL;
Dart_Handle result =
Dart_TypedDataAcquireData(buffer_obj, &type, &buffer, &buffer_len);
if (Dart_IsError(result)) {
Dart_PropagateError(result);
}
ThrowIfError(result);
ASSERT(type == Dart_TypedData_kUint8 || type == Dart_TypedData_kInt8);
ASSERT(end <= buffer_len);
@ -291,11 +282,7 @@ void FUNCTION_NAME(File_WriteFrom)(Dart_NativeArguments args) {
bool success = file->WriteFully(byte_buffer + start, length);
// Release the direct pointer acquired above.
result = Dart_TypedDataReleaseData(buffer_obj);
if (Dart_IsError(result)) {
Dart_PropagateError(result);
}
ThrowIfError(Dart_TypedDataReleaseData(buffer_obj));
if (!success) {
Dart_SetReturnValue(args, DartUtils::NewDartOSError());
} else {
@ -567,7 +554,8 @@ void FUNCTION_NAME(File_LinkTarget)(Dart_NativeArguments args) {
if (target == NULL) {
Dart_SetReturnValue(args, DartUtils::NewDartOSError(&os_error));
} else {
Dart_SetReturnValue(args, DartUtils::NewString(target));
Dart_Handle str = ThrowIfError(DartUtils::NewString(target));
Dart_SetReturnValue(args, str);
}
}
@ -700,7 +688,8 @@ void FUNCTION_NAME(File_ResolveSymbolicLinks)(Dart_NativeArguments args) {
}
}
if (path != NULL) {
Dart_SetReturnValue(args, DartUtils::NewString(path));
Dart_Handle str = ThrowIfError(DartUtils::NewString(path));
Dart_SetReturnValue(args, str);
} else {
Dart_SetReturnValue(args, DartUtils::NewDartOSError(&os_error));
}
@ -743,22 +732,16 @@ void FUNCTION_NAME(File_Stat)(Dart_NativeArguments args) {
}
Dart_Handle returned_data =
Dart_NewTypedData(Dart_TypedData_kInt64, File::kStatSize);
if (Dart_IsError(returned_data)) {
Dart_PropagateError(returned_data);
}
ThrowIfError(returned_data);
Dart_TypedData_Type data_type_unused;
void* data_location;
intptr_t data_length_unused;
Dart_Handle status = Dart_TypedDataAcquireData(
returned_data, &data_type_unused, &data_location, &data_length_unused);
if (Dart_IsError(status)) {
Dart_PropagateError(status);
}
ThrowIfError(status);
memmove(data_location, stat_data, File::kStatSize * sizeof(int64_t));
status = Dart_TypedDataReleaseData(returned_data);
if (Dart_IsError(status)) {
Dart_PropagateError(status);
}
ThrowIfError(status);
Dart_SetReturnValue(args, returned_data);
}

View file

@ -123,10 +123,12 @@ Dart_Handle FileSystemWatcher::ReadEvents(intptr_t id, intptr_t path_id) {
Dart_ListSetAt(event, 0, Dart_NewInteger(mask));
Dart_ListSetAt(event, 1, Dart_NewInteger(e->cookie));
if (e->len > 0) {
Dart_ListSetAt(
event, 2,
Dart_NewStringFromUTF8(reinterpret_cast<uint8_t*>(e->name),
strlen(e->name)));
Dart_Handle name = Dart_NewStringFromUTF8(
reinterpret_cast<uint8_t*>(e->name), strlen(e->name));
if (Dart_IsError(name)) {
return name;
}
Dart_ListSetAt(event, 2, name);
} else {
Dart_ListSetAt(event, 2, Dart_Null());
}

View file

@ -123,10 +123,12 @@ Dart_Handle FileSystemWatcher::ReadEvents(intptr_t id, intptr_t path_id) {
Dart_ListSetAt(event, 0, Dart_NewInteger(mask));
Dart_ListSetAt(event, 1, Dart_NewInteger(e->cookie));
if (e->len > 0) {
Dart_ListSetAt(
event, 2,
Dart_NewStringFromUTF8(reinterpret_cast<uint8_t*>(e->name),
strlen(e->name)));
Dart_Handle name = Dart_NewStringFromUTF8(
reinterpret_cast<uint8_t*>(e->name), strlen(e->name));
if (Dart_IsError(name)) {
return name;
}
Dart_ListSetAt(event, 2, name);
} else {
Dart_ListSetAt(event, 2, Dart_Null());
}

View file

@ -376,9 +376,12 @@ Dart_Handle FileSystemWatcher::ReadEvents(intptr_t id, intptr_t path_id) {
}
Dart_ListSetAt(event, 0, Dart_NewInteger(mask));
Dart_ListSetAt(event, 1, Dart_NewInteger(1));
Dart_ListSetAt(event, 2,
Dart_NewStringFromUTF8(
reinterpret_cast<uint8_t*>(e.data.path), path_len));
Dart_Handle name = Dart_NewStringFromUTF8(
reinterpret_cast<uint8_t*>(e.data.path), path_len);
if (Dart_IsError(name)) {
return name;
}
Dart_ListSetAt(event, 2, name);
Dart_ListSetAt(event, 3, Dart_NewBoolean(true));
Dart_ListSetAt(event, 4, Dart_NewInteger(path_id));
Dart_ListSetAt(events, i, event);

View file

@ -86,11 +86,7 @@ static char* app_script_name = NULL;
static CommandLineOptions* entry_points_files = NULL;
// The environment provided through the command line using -D options.
static dart::HashMap* environment = NULL;
static void* GetHashmapKeyFromString(char* key) {
return reinterpret_cast<void*>(key);
}
static dart::SimpleHashMap* environment = NULL;
static bool ProcessEnvironmentOption(const char* arg,
CommandLineOptions* vm_options) {
@ -98,36 +94,6 @@ static bool ProcessEnvironmentOption(const char* arg,
&environment);
}
static Dart_Handle EnvironmentCallback(Dart_Handle name) {
uint8_t* utf8_array;
intptr_t utf8_len;
Dart_Handle result = Dart_Null();
Dart_Handle handle = Dart_StringToUTF8(name, &utf8_array, &utf8_len);
if (Dart_IsError(handle)) {
handle = Dart_ThrowException(
DartUtils::NewDartArgumentError(Dart_GetError(handle)));
} else {
char* name_chars = reinterpret_cast<char*>(malloc(utf8_len + 1));
memmove(name_chars, utf8_array, utf8_len);
name_chars[utf8_len] = '\0';
const char* value = NULL;
if (environment != NULL) {
HashMap::Entry* entry =
environment->Lookup(GetHashmapKeyFromString(name_chars),
HashMap::StringHash(name_chars), false);
if (entry != NULL) {
value = reinterpret_cast<char*>(entry->value);
}
}
if (value != NULL) {
result = Dart_NewStringFromUTF8(reinterpret_cast<const uint8_t*>(value),
strlen(value));
}
free(name_chars);
}
return result;
}
static const char* kSnapshotKindNames[] = {
"core",
"core-jit",
@ -1423,7 +1389,8 @@ static int GenerateSnapshotFromKernel(const uint8_t* kernel_buffer,
}
Dart_EnterScope();
Dart_Handle result = Dart_SetEnvironmentCallback(EnvironmentCallback);
Dart_Handle result =
Dart_SetEnvironmentCallback(DartUtils::EnvironmentCallback);
CHECK_RESULT(result);
// The root library has to be set to generate AOT snapshots, and sometimes we
@ -1510,6 +1477,7 @@ int main(int argc, char** argv) {
PrintUsage();
return kErrorExitCode;
}
DartUtils::SetEnvironment(environment);
// Sniff the script to check if it is actually a dill file.
uint8_t* kernel_buffer = NULL;
@ -1656,7 +1624,7 @@ int main(int argc, char** argv) {
return 0;
}
result = Dart_SetEnvironmentCallback(EnvironmentCallback);
result = Dart_SetEnvironmentCallback(DartUtils::EnvironmentCallback);
CHECK_RESULT(result);
// Load up the script before a snapshot is created.
@ -1709,7 +1677,7 @@ int main(int argc, char** argv) {
exit(kErrorExitCode);
}
Dart_EnterScope();
result = Dart_SetEnvironmentCallback(EnvironmentCallback);
result = Dart_SetEnvironmentCallback(DartUtils::EnvironmentCallback);
CHECK_RESULT(result);
// Set up the library tag handler in such a manner that it will use the

View file

@ -17,11 +17,12 @@ typedef uint32_t (*IntKeyHash)(uint32_t key);
class IntSet {
public:
explicit IntSet(IntKeyHash hash)
: hash_(hash), map_(HashMap::SamePointerValue, kInitialSize) {}
: hash_(hash), map_(SimpleHashMap::SamePointerValue, kInitialSize) {}
void Insert(int x) {
EXPECT_NE(0, x); // 0 corresponds to (void*)NULL - illegal key value
HashMap::Entry* p = map_.Lookup(reinterpret_cast<void*>(x), hash_(x), true);
SimpleHashMap::Entry* p =
map_.Lookup(reinterpret_cast<void*>(x), hash_(x), true);
EXPECT(p != NULL); // insert is set!
EXPECT_EQ(reinterpret_cast<void*>(x), p->key);
// We don't care about p->value.
@ -33,7 +34,7 @@ class IntSet {
}
bool Present(int x) {
HashMap::Entry* p =
SimpleHashMap::Entry* p =
map_.Lookup(reinterpret_cast<void*>(x), hash_(x), false);
if (p != NULL) {
EXPECT_EQ(reinterpret_cast<void*>(x), p->key);
@ -45,7 +46,7 @@ class IntSet {
uint32_t occupancy() const {
uint32_t count = 0;
for (HashMap::Entry* p = map_.Start(); p != NULL; p = map_.Next(p)) {
for (SimpleHashMap::Entry* p = map_.Start(); p != NULL; p = map_.Next(p)) {
count++;
}
EXPECT_EQ(map_.occupancy_, count);
@ -54,7 +55,7 @@ class IntSet {
private:
IntKeyHash hash_;
HashMap map_;
SimpleHashMap map_;
};
static uint32_t WordHash(uint32_t key) {
@ -166,7 +167,7 @@ void TestSet(IntKeyHash hash, int size) {
EXPECT_EQ(0u, set.occupancy());
}
VM_UNIT_TEST_CASE(HashMap_Basic) {
VM_UNIT_TEST_CASE(SimpleHashMap_Basic) {
TestSet(WordHash, 100);
TestSet(Hash, 100);
TestSet(CollisionHash1, 50);

View file

@ -114,40 +114,6 @@ static Dart_Handle CreateRuntimeOptions(CommandLineOptions* options) {
return dart_arguments;
}
static void* GetHashmapKeyFromString(char* key) {
return reinterpret_cast<void*>(key);
}
static Dart_Handle EnvironmentCallback(Dart_Handle name) {
uint8_t* utf8_array;
intptr_t utf8_len;
Dart_Handle result = Dart_Null();
Dart_Handle handle = Dart_StringToUTF8(name, &utf8_array, &utf8_len);
if (Dart_IsError(handle)) {
handle = Dart_ThrowException(
DartUtils::NewDartArgumentError(Dart_GetError(handle)));
} else {
char* name_chars = reinterpret_cast<char*>(malloc(utf8_len + 1));
memmove(name_chars, utf8_array, utf8_len);
name_chars[utf8_len] = '\0';
const char* value = NULL;
if (Options::environment() != NULL) {
HashMap::Entry* entry = Options::environment()->Lookup(
GetHashmapKeyFromString(name_chars), HashMap::StringHash(name_chars),
false);
if (entry != NULL) {
value = reinterpret_cast<char*>(entry->value);
}
}
if (value != NULL) {
result = Dart_NewStringFromUTF8(reinterpret_cast<const uint8_t*>(value),
strlen(value));
}
free(name_chars);
}
return result;
}
#define SAVE_ERROR_AND_EXIT(result) \
*error = strdup(Dart_GetError(result)); \
if (Dart_IsCompilationError(result)) { \
@ -330,7 +296,7 @@ static Dart_Isolate IsolateSetupHelper(Dart_Isolate isolate,
#endif
}
result = Dart_SetEnvironmentCallback(EnvironmentCallback);
result = Dart_SetEnvironmentCallback(DartUtils::EnvironmentCallback);
CHECK_RESULT(result);
#if !defined(DART_PRECOMPILED_RUNTIME)
@ -626,7 +592,7 @@ static Dart_Isolate CreateAndSetupServiceIsolate(const char* script_uri,
result = Dart_CompileAll();
CHECK_RESULT(result);
}
result = Dart_SetEnvironmentCallback(EnvironmentCallback);
result = Dart_SetEnvironmentCallback(DartUtils::EnvironmentCallback);
CHECK_RESULT(result);
Dart_ExitScope();
Dart_ExitIsolate();
@ -1182,6 +1148,7 @@ void main(int argc, char** argv) {
Platform::Exit(kErrorExitCode);
}
}
DartUtils::SetEnvironment(Options::environment());
Loader::InitOnce();

View file

@ -227,7 +227,7 @@ void Options::PrintUsage() {
}
// clang-format on
dart::HashMap* Options::environment_ = NULL;
dart::SimpleHashMap* Options::environment_ = NULL;
bool Options::ProcessEnvironmentOption(const char* arg,
CommandLineOptions* vm_options) {
return OptionProcessor::ProcessEnvironmentOption(arg, vm_options,
@ -236,7 +236,7 @@ bool Options::ProcessEnvironmentOption(const char* arg,
void Options::DestroyEnvironment() {
if (environment_ != NULL) {
for (HashMap::Entry* p = environment_->Start(); p != NULL;
for (SimpleHashMap::Entry* p = environment_->Start(); p != NULL;
p = environment_->Next(p)) {
free(p->key);
free(p->value);

View file

@ -115,7 +115,7 @@ class Options {
static void SetDart2Options(CommandLineOptions* vm_options);
static void SetDart1Options(CommandLineOptions* vm_options);
static dart::HashMap* environment() { return environment_; }
static dart::SimpleHashMap* environment() { return environment_; }
static const char* vm_service_server_ip() { return vm_service_server_ip_; }
static int vm_service_server_port() { return vm_service_server_port_; }
@ -148,7 +148,7 @@ class Options {
ENUM_OPTIONS_LIST(ENUM_OPTION_DECL)
#undef ENUM_OPTION_DECL
static dart::HashMap* environment_;
static dart::SimpleHashMap* environment_;
// Frontend argument processing.
#if !defined(DART_PRECOMPILED_RUNTIME)

View file

@ -41,13 +41,10 @@ bool OptionProcessor::TryProcess(const char* option,
return false;
}
static void* GetHashmapKeyFromString(char* key) {
return reinterpret_cast<void*>(key);
}
bool OptionProcessor::ProcessEnvironmentOption(const char* arg,
CommandLineOptions* vm_options,
dart::HashMap** environment) {
bool OptionProcessor::ProcessEnvironmentOption(
const char* arg,
CommandLineOptions* vm_options,
dart::SimpleHashMap** environment) {
ASSERT(arg != NULL);
ASSERT(environment != NULL);
if (*arg == '\0') {
@ -64,7 +61,7 @@ bool OptionProcessor::ProcessEnvironmentOption(const char* arg,
return true;
}
if (*environment == NULL) {
*environment = new HashMap(&HashMap::SameStringValue, 4);
*environment = new SimpleHashMap(&SimpleHashMap::SameStringValue, 4);
}
// Split the name=value part of the -Dname=value argument.
char* name;
@ -85,9 +82,10 @@ bool OptionProcessor::ProcessEnvironmentOption(const char* arg,
strncpy(name, arg, name_len);
name[name_len] = '\0';
value = strdup(equals_pos + 1);
HashMap::Entry* entry = (*environment)
->Lookup(GetHashmapKeyFromString(name),
HashMap::StringHash(name), true);
SimpleHashMap::Entry* entry =
(*environment)
->Lookup(GetHashmapKeyFromString(name),
SimpleHashMap::StringHash(name), true);
ASSERT(entry != NULL); // Lookup adds an entry if key not found.
if (entry->value != NULL) {
free(name);

View file

@ -34,7 +34,7 @@ class OptionProcessor {
static bool ProcessEnvironmentOption(const char* arg,
CommandLineOptions* vm_options,
dart::HashMap** environment);
dart::SimpleHashMap** environment);
private:
static OptionProcessor* first_;

View file

@ -4,6 +4,7 @@
#include "bin/platform.h"
#include "bin/dartutils.h"
#include "bin/file.h"
#include "bin/utils.h"
#include "include/dart_api.h"
@ -16,7 +17,9 @@ void FUNCTION_NAME(Platform_NumberOfProcessors)(Dart_NativeArguments args) {
}
void FUNCTION_NAME(Platform_OperatingSystem)(Dart_NativeArguments args) {
Dart_SetReturnValue(args, DartUtils::NewString(Platform::OperatingSystem()));
Dart_Handle str = DartUtils::NewString(Platform::OperatingSystem());
ThrowIfError(str);
Dart_SetReturnValue(args, str);
}
void FUNCTION_NAME(Platform_OperatingSystemVersion)(Dart_NativeArguments args) {
@ -24,19 +27,25 @@ void FUNCTION_NAME(Platform_OperatingSystemVersion)(Dart_NativeArguments args) {
if (version == NULL) {
Dart_SetReturnValue(args, DartUtils::NewDartOSError());
} else {
Dart_SetReturnValue(args, DartUtils::NewString(version));
Dart_Handle str = DartUtils::NewString(version);
ThrowIfError(str);
Dart_SetReturnValue(args, str);
}
}
void FUNCTION_NAME(Platform_PathSeparator)(Dart_NativeArguments args) {
Dart_SetReturnValue(args, DartUtils::NewString(File::PathSeparator()));
Dart_Handle str = DartUtils::NewString(File::PathSeparator());
ThrowIfError(str);
Dart_SetReturnValue(args, str);
}
void FUNCTION_NAME(Platform_LocalHostname)(Dart_NativeArguments args) {
const intptr_t HOSTNAME_LENGTH = 256;
char hostname[HOSTNAME_LENGTH];
if (Platform::LocalHostname(hostname, HOSTNAME_LENGTH)) {
Dart_SetReturnValue(args, DartUtils::NewString(hostname));
Dart_Handle str = DartUtils::NewString(hostname);
ThrowIfError(str);
Dart_SetReturnValue(args, str);
} else {
Dart_SetReturnValue(args, DartUtils::NewDartOSError());
}
@ -66,10 +75,8 @@ void FUNCTION_NAME(Platform_ExecutableArguments)(Dart_NativeArguments args) {
Dart_Handle result = Dart_NewListOf(Dart_CoreType_String, end - 1);
for (intptr_t i = 1; i < end; i++) {
Dart_Handle str = DartUtils::NewString(argv[i]);
Dart_Handle error = Dart_ListSetAt(result, i - 1, str);
if (Dart_IsError(error)) {
Dart_PropagateError(error);
}
ThrowIfError(str);
ThrowIfError(Dart_ListSetAt(result, i - 1, str));
}
Dart_SetReturnValue(args, result);
}
@ -83,9 +90,7 @@ void FUNCTION_NAME(Platform_Environment)(Dart_NativeArguments args) {
Dart_SetReturnValue(args, DartUtils::NewDartOSError(&error));
} else {
Dart_Handle result = Dart_NewList(count);
if (Dart_IsError(result)) {
Dart_PropagateError(result);
}
ThrowIfError(result);
intptr_t result_idx = 0;
for (intptr_t env_idx = 0; env_idx < count; env_idx++) {
Dart_Handle str = DartUtils::NewString(env[env_idx]);
@ -95,9 +100,7 @@ void FUNCTION_NAME(Platform_Environment)(Dart_NativeArguments args) {
continue;
}
Dart_Handle error = Dart_ListSetAt(result, result_idx, str);
if (Dart_IsError(error)) {
Dart_PropagateError(error);
}
ThrowIfError(error);
result_idx++;
}
Dart_SetReturnValue(args, result);

View file

@ -28,21 +28,15 @@ static char** ExtractCStringList(Dart_Handle strings,
ASSERT(Dart_IsList(strings));
intptr_t len = 0;
Dart_Handle result = Dart_ListLength(strings, &len);
if (Dart_IsError(result)) {
Dart_PropagateError(result);
}
ThrowIfError(result);
// Protect against user-defined list implementations that can have
// arbitrary length.
if ((len < 0) || (len > kMaxArgumentListLength)) {
result = DartUtils::SetIntegerField(status_handle, "_errorCode", 0);
if (Dart_IsError(result)) {
Dart_PropagateError(result);
}
ThrowIfError(result);
result = DartUtils::SetStringField(status_handle, "_errorMessage",
"Max argument list length exceeded");
if (Dart_IsError(result)) {
Dart_PropagateError(result);
}
ThrowIfError(result);
return NULL;
}
*length = len;
@ -51,19 +45,13 @@ static char** ExtractCStringList(Dart_Handle strings,
reinterpret_cast<char**>(Dart_ScopeAllocate(len * sizeof(*string_args)));
for (int i = 0; i < len; i++) {
Dart_Handle arg = Dart_ListGetAt(strings, i);
if (Dart_IsError(arg)) {
Dart_PropagateError(arg);
}
ThrowIfError(arg);
if (!Dart_IsString(arg)) {
result = DartUtils::SetIntegerField(status_handle, "_errorCode", 0);
if (Dart_IsError(result)) {
Dart_PropagateError(result);
}
ThrowIfError(result);
result =
DartUtils::SetStringField(status_handle, "_errorMessage", error_msg);
if (Dart_IsError(result)) {
Dart_PropagateError(result);
}
ThrowIfError(result);
return NULL;
}
string_args[i] = const_cast<char*>(DartUtils::GetStringValue(arg));
@ -100,14 +88,10 @@ void FUNCTION_NAME(Process_Start)(Dart_NativeArguments args) {
Dart_Handle result;
if (!Dart_IsString(path_handle)) {
result = DartUtils::SetIntegerField(status_handle, "_errorCode", 0);
if (Dart_IsError(result)) {
Dart_PropagateError(result);
}
ThrowIfError(result);
result = DartUtils::SetStringField(status_handle, "_errorMessage",
"Path must be a builtin string");
if (Dart_IsError(result)) {
Dart_PropagateError(result);
}
ThrowIfError(result);
Dart_SetBooleanReturnValue(args, false);
return;
}
@ -128,15 +112,11 @@ void FUNCTION_NAME(Process_Start)(Dart_NativeArguments args) {
working_directory = DartUtils::GetStringValue(working_directory_handle);
} else if (!Dart_IsNull(working_directory_handle)) {
result = DartUtils::SetIntegerField(status_handle, "_errorCode", 0);
if (Dart_IsError(result)) {
Dart_PropagateError(result);
}
ThrowIfError(result);
result =
DartUtils::SetStringField(status_handle, "_errorMessage",
"WorkingDirectory must be a builtin string");
if (Dart_IsError(result)) {
Dart_PropagateError(result);
}
ThrowIfError(result);
Dart_SetBooleanReturnValue(args, false);
return;
}
@ -183,16 +163,12 @@ void FUNCTION_NAME(Process_Start)(Dart_NativeArguments args) {
} else {
result =
DartUtils::SetIntegerField(status_handle, "_errorCode", error_code);
if (Dart_IsError(result)) {
Dart_PropagateError(result);
}
ThrowIfError(result);
result = DartUtils::SetStringField(status_handle, "_errorMessage",
os_error_message != NULL
? os_error_message
: "Cannot get error message");
if (Dart_IsError(result)) {
Dart_PropagateError(result);
}
ThrowIfError(result);
}
Dart_SetBooleanReturnValue(args, error_code == 0);
}
@ -220,13 +196,9 @@ void FUNCTION_NAME(Process_Wait)(Dart_NativeArguments args) {
exit_event->SetClosedFd();
if (success) {
Dart_Handle out = result.stdout_data();
if (Dart_IsError(out)) {
Dart_PropagateError(out);
}
ThrowIfError(out);
Dart_Handle err = result.stderr_data();
if (Dart_IsError(err)) {
Dart_PropagateError(err);
}
ThrowIfError(err);
Dart_Handle list = Dart_NewList(4);
Dart_ListSetAt(list, 0, Dart_NewInteger(pid));
Dart_ListSetAt(list, 1, Dart_NewInteger(result.exit_code()));
@ -316,15 +288,11 @@ void FUNCTION_NAME(SystemEncodingToString)(Dart_NativeArguments args) {
Dart_Handle bytes = Dart_GetNativeArgument(args, 0);
intptr_t bytes_length = 0;
Dart_Handle result = Dart_ListLength(bytes, &bytes_length);
if (Dart_IsError(result)) {
Dart_PropagateError(result);
}
ThrowIfError(result);
uint8_t* buffer = Dart_ScopeAllocate(bytes_length + 1);
result = Dart_ListGetAsBytes(bytes, 0, buffer, bytes_length);
buffer[bytes_length] = '\0';
if (Dart_IsError(result)) {
Dart_PropagateError(result);
}
ThrowIfError(result);
intptr_t len;
char* str = StringUtils::ConsoleStringToUtf8(reinterpret_cast<char*>(buffer),
bytes_length, &len);
@ -333,6 +301,7 @@ void FUNCTION_NAME(SystemEncodingToString)(Dart_NativeArguments args) {
DartUtils::NewInternalError("SystemEncodingToString failed"));
}
result = Dart_NewStringFromUTF8(reinterpret_cast<const uint8_t*>(str), len);
ThrowIfError(result);
Dart_SetReturnValue(args, result);
}
@ -342,9 +311,7 @@ void FUNCTION_NAME(StringToSystemEncoding)(Dart_NativeArguments args) {
intptr_t utf8_len;
Dart_Handle result =
Dart_StringToUTF8(str, reinterpret_cast<uint8_t**>(&utf8), &utf8_len);
if (Dart_IsError(result)) {
Dart_PropagateError(result);
}
ThrowIfError(result);
intptr_t system_len;
const char* system_string =
StringUtils::Utf8ToConsoleString(utf8, utf8_len, &system_len);

View file

@ -44,7 +44,7 @@ void ListeningSocketRegistry::Cleanup() {
ListeningSocketRegistry::OSSocket* ListeningSocketRegistry::LookupByPort(
intptr_t port) {
HashMap::Entry* entry = sockets_by_port_.Lookup(
SimpleHashMap::Entry* entry = sockets_by_port_.Lookup(
GetHashmapKeyFromIntptr(port), GetHashmapHashFromIntptr(port), false);
if (entry == NULL) {
return NULL;
@ -53,7 +53,7 @@ ListeningSocketRegistry::OSSocket* ListeningSocketRegistry::LookupByPort(
}
void ListeningSocketRegistry::InsertByPort(intptr_t port, OSSocket* socket) {
HashMap::Entry* entry = sockets_by_port_.Lookup(
SimpleHashMap::Entry* entry = sockets_by_port_.Lookup(
GetHashmapKeyFromIntptr(port), GetHashmapHashFromIntptr(port), true);
ASSERT(entry != NULL);
entry->value = reinterpret_cast<void*>(socket);
@ -66,7 +66,7 @@ void ListeningSocketRegistry::RemoveByPort(intptr_t port) {
ListeningSocketRegistry::OSSocket* ListeningSocketRegistry::LookupByFd(
Socket* fd) {
HashMap::Entry* entry = sockets_by_fd_.Lookup(
SimpleHashMap::Entry* entry = sockets_by_fd_.Lookup(
GetHashmapKeyFromIntptr(reinterpret_cast<intptr_t>(fd)),
GetHashmapHashFromIntptr(reinterpret_cast<intptr_t>(fd)), false);
if (entry == NULL) {
@ -76,7 +76,7 @@ ListeningSocketRegistry::OSSocket* ListeningSocketRegistry::LookupByFd(
}
void ListeningSocketRegistry::InsertByFd(Socket* fd, OSSocket* socket) {
HashMap::Entry* entry = sockets_by_fd_.Lookup(
SimpleHashMap::Entry* entry = sockets_by_fd_.Lookup(
GetHashmapKeyFromIntptr(reinterpret_cast<intptr_t>(fd)),
GetHashmapHashFromIntptr(reinterpret_cast<intptr_t>(fd)), true);
ASSERT(entry != NULL);
@ -234,7 +234,7 @@ bool ListeningSocketRegistry::CloseOneSafe(OSSocket* os_socket,
void ListeningSocketRegistry::CloseAllSafe() {
MutexLocker ml(mutex_);
for (HashMap::Entry* cursor = sockets_by_fd_.Start(); cursor != NULL;
for (SimpleHashMap::Entry* cursor = sockets_by_fd_.Start(); cursor != NULL;
cursor = sockets_by_fd_.Next(cursor)) {
CloseOneSafe(reinterpret_cast<OSSocket*>(cursor->value), false);
}

View file

@ -248,8 +248,8 @@ class ListeningSocketRegistry {
bool CloseOneSafe(OSSocket* os_socket, bool update_hash_maps);
void CloseAllSafe();
HashMap sockets_by_port_;
HashMap sockets_by_fd_;
SimpleHashMap sockets_by_port_;
SimpleHashMap sockets_by_fd_;
Mutex* mutex_;

View file

@ -8,16 +8,18 @@
namespace dart {
HashMap::HashMap(MatchFun match, uint32_t initial_capacity) {
SimpleHashMap::SimpleHashMap(MatchFun match, uint32_t initial_capacity) {
match_ = match;
Initialize(initial_capacity);
}
HashMap::~HashMap() {
SimpleHashMap::~SimpleHashMap() {
delete[] map_;
}
HashMap::Entry* HashMap::Lookup(void* key, uint32_t hash, bool insert) {
SimpleHashMap::Entry* SimpleHashMap::Lookup(void* key,
uint32_t hash,
bool insert) {
// Find a matching entry.
Entry* p = Probe(key, hash);
if (p->key != NULL) {
@ -44,7 +46,7 @@ HashMap::Entry* HashMap::Lookup(void* key, uint32_t hash, bool insert) {
return NULL;
}
void HashMap::Remove(void* key, uint32_t hash) {
void SimpleHashMap::Remove(void* key, uint32_t hash) {
// Lookup the entry for the key to remove.
Entry* candidate = Probe(key, hash);
if (candidate->key == NULL) {
@ -106,7 +108,7 @@ void HashMap::Remove(void* key, uint32_t hash) {
occupancy_--;
}
void HashMap::Clear(ClearFun clear) {
void SimpleHashMap::Clear(ClearFun clear) {
// Mark all entries as empty.
const Entry* end = map_end();
for (Entry* p = map_; p < end; p++) {
@ -118,11 +120,11 @@ void HashMap::Clear(ClearFun clear) {
occupancy_ = 0;
}
HashMap::Entry* HashMap::Start() const {
SimpleHashMap::Entry* SimpleHashMap::Start() const {
return Next(map_ - 1);
}
HashMap::Entry* HashMap::Next(Entry* p) const {
SimpleHashMap::Entry* SimpleHashMap::Next(Entry* p) const {
const Entry* end = map_end();
ASSERT(map_ - 1 <= p && p < end);
for (p++; p < end; p++) {
@ -133,7 +135,7 @@ HashMap::Entry* HashMap::Next(Entry* p) const {
return NULL;
}
HashMap::Entry* HashMap::Probe(void* key, uint32_t hash) {
SimpleHashMap::Entry* SimpleHashMap::Probe(void* key, uint32_t hash) {
ASSERT(key != NULL);
ASSERT(dart::Utils::IsPowerOfTwo(capacity_));
@ -152,7 +154,7 @@ HashMap::Entry* HashMap::Probe(void* key, uint32_t hash) {
return p;
}
void HashMap::Initialize(uint32_t capacity) {
void SimpleHashMap::Initialize(uint32_t capacity) {
ASSERT(dart::Utils::IsPowerOfTwo(capacity));
map_ = new Entry[capacity];
if (map_ == NULL) {
@ -162,7 +164,7 @@ void HashMap::Initialize(uint32_t capacity) {
occupancy_ = 0;
}
void HashMap::Resize() {
void SimpleHashMap::Resize() {
Entry* map = map_;
uint32_t n = occupancy_;

View file

@ -9,7 +9,7 @@
namespace dart {
class HashMap {
class SimpleHashMap {
public:
typedef bool (*MatchFun)(void* key1, void* key2);
@ -17,9 +17,9 @@ class HashMap {
// initial_capacity is the size of the initial hash map;
// it must be a power of 2 (and thus must not be 0).
HashMap(MatchFun match, uint32_t initial_capacity);
SimpleHashMap(MatchFun match, uint32_t initial_capacity);
~HashMap();
~SimpleHashMap();
static bool SamePointerValue(void* key1, void* key2) { return key1 == key2; }
@ -43,7 +43,7 @@ class HashMap {
reinterpret_cast<char*>(key2)) == 0;
}
// HashMap entries are (key, value, hash) triplets.
// SimpleHashMap entries are (key, value, hash) triplets.
// Some clients may not need to use the value slot
// (e.g. implementers of sets, where the key is the value).
struct Entry {
@ -62,7 +62,7 @@ class HashMap {
// Removes the entry with matching key.
//
// WARNING: This method cannot be called while iterating a `HashMap`
// WARNING: This method cannot be called while iterating a `SimpleHashMap`
// otherwise the iteration might step over elements!
void Remove(void* key, uint32_t hash);
@ -101,7 +101,7 @@ class HashMap {
void Resize();
friend class IntSet; // From hashmap_test.cc
DISALLOW_COPY_AND_ASSIGN(HashMap);
DISALLOW_COPY_AND_ASSIGN(SimpleHashMap);
};
} // namespace dart