Files
sdk/runtime/vm/assembler_test.cc
T
Daniel Andersson fd890f4097 Cache current thread in a reserved register and use it in LoadIsolate
Add THR register that caches the current thread in generated code.
Shuffle some registers around as needed to free one up.

Note: Assembler::LoadIsolate now always loads the *current* isolate whenever the code is executed, rather than the isolate in which the code was compiled (no existing code was affected by this slight change in semantics).

Rewrite some ia32 stubs to use one less register, and for some ia32 bigint intrinsics, explicitly save THR (like CTX in the past, see r44699).

Next steps:
- pass current thread rather than isolate in NativeArguments
- ditto for exception handler jump
- migrate fields vm_tag, top_exit_frame_info, etc. to thread

R=srdjan@google.com

Review URL: https://codereview.chromium.org//1156593002
2015-05-26 13:46:12 -07:00

78 lines
3.4 KiB
C++

// Copyright (c) 2013, 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 "vm/assembler.h"
#include "vm/globals.h"
#include "vm/os.h"
#include "vm/simulator.h"
#include "vm/unit_test.h"
#include "vm/virtual_memory.h"
namespace dart {
ASSEMBLER_TEST_EXTERN(StoreIntoObject);
ASSEMBLER_TEST_RUN(StoreIntoObject, test) {
#if defined(USING_SIMULATOR)
#define test_code(ctx, value, growable_array, thread) \
Simulator::Current()->Call( \
bit_cast<intptr_t, uword>(test->entry()), \
reinterpret_cast<intptr_t>(ctx), \
reinterpret_cast<intptr_t>(value), \
reinterpret_cast<intptr_t>(growable_array), \
reinterpret_cast<intptr_t>(thread))
#else
typedef void (*StoreData)(RawContext* ctx,
RawObject* value,
RawObject* growable_array,
Thread* thread);
StoreData test_code = reinterpret_cast<StoreData>(test->entry());
#endif
const Array& old_array = Array::Handle(Array::New(3, Heap::kOld));
const Array& new_array = Array::Handle(Array::New(3, Heap::kNew));
const GrowableObjectArray& grow_old_array = GrowableObjectArray::Handle(
GrowableObjectArray::New(old_array, Heap::kOld));
const GrowableObjectArray& grow_new_array = GrowableObjectArray::Handle(
GrowableObjectArray::New(old_array, Heap::kNew));
Smi& smi = Smi::Handle();
const Context& ctx = Context::Handle(Context::New(0));
Thread* thread = Thread::Current();
EXPECT(old_array.raw() == grow_old_array.data());
EXPECT(!Isolate::Current()->store_buffer()->Contains(grow_old_array.raw()));
EXPECT(old_array.raw() == grow_new_array.data());
EXPECT(!Isolate::Current()->store_buffer()->Contains(grow_new_array.raw()));
// Store Smis into the old object.
for (int i = -128; i < 128; i++) {
smi = Smi::New(i);
test_code(ctx.raw(), smi.raw(), grow_old_array.raw(), thread);
EXPECT(reinterpret_cast<RawArray*>(smi.raw()) == grow_old_array.data());
EXPECT(!Isolate::Current()->store_buffer()->Contains(grow_old_array.raw()));
}
// Store an old object into the old object.
test_code(ctx.raw(), old_array.raw(), grow_old_array.raw(), thread);
EXPECT(old_array.raw() == grow_old_array.data());
EXPECT(!Isolate::Current()->store_buffer()->Contains(grow_old_array.raw()));
// Store a new object into the old object.
test_code(ctx.raw(), new_array.raw(), grow_old_array.raw(), thread);
EXPECT(new_array.raw() == grow_old_array.data());
EXPECT(Isolate::Current()->store_buffer()->Contains(grow_old_array.raw()));
// Store a new object into the new object.
test_code(ctx.raw(), new_array.raw(), grow_new_array.raw(), thread);
EXPECT(new_array.raw() == grow_new_array.data());
EXPECT(!Isolate::Current()->store_buffer()->Contains(grow_new_array.raw()));
// Store an old object into the new object.
test_code(ctx.raw(), old_array.raw(), grow_new_array.raw(), thread);
EXPECT(old_array.raw() == grow_new_array.data());
EXPECT(!Isolate::Current()->store_buffer()->Contains(grow_new_array.raw()));
}
} // namespace dart