Files
sdk/runtime/vm/assembler_macros_ia32.cc
T
asiva@google.com d4d781d636 - Unify class ids and snapshot object ids list so that we don't have disparate
and sometimes confusing values.
- Remove instance_kind_ field from RawClass.
- Rename all class id names to have a Cid suffix.
- Remove code from object.h and object_store.h which dealt with object ids
  of predefined classes for snapshots.
Review URL: https://chromiumcodereview.appspot.com//10827209

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@10418 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-08 19:46:23 +00:00

90 lines
2.8 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.
#include "vm/globals.h"
#if defined(TARGET_ARCH_IA32)
#include "vm/assembler_macros.h"
#include "vm/assembler.h"
namespace dart {
DECLARE_FLAG(bool, inline_alloc);
#define __ assembler->
// Static.
void AssemblerMacros::TryAllocate(Assembler* assembler,
const Class& cls,
Label* failure,
Register instance_reg) {
ASSERT(failure != NULL);
if (FLAG_inline_alloc) {
Heap* heap = Isolate::Current()->heap();
const intptr_t instance_size = cls.instance_size();
__ movl(instance_reg, Address::Absolute(heap->TopAddress()));
__ addl(instance_reg, Immediate(instance_size));
// instance_reg: potential next object start.
__ cmpl(instance_reg, Address::Absolute(heap->EndAddress()));
__ j(ABOVE_EQUAL, failure, Assembler::kNearJump);
// Successfully allocated the object, now update top to point to
// next object start and store the class in the class field of object.
__ movl(Address::Absolute(heap->TopAddress()), instance_reg);
ASSERT(instance_size >= kHeapObjectTag);
__ subl(instance_reg, Immediate(instance_size - kHeapObjectTag));
uword tags = 0;
tags = RawObject::SizeTag::update(instance_size, tags);
ASSERT(cls.id() != kIllegalCid);
tags = RawObject::ClassIdTag::update(cls.id(), tags);
__ movl(FieldAddress(instance_reg, Object::tags_offset()), Immediate(tags));
} else {
__ jmp(failure);
}
}
void AssemblerMacros::EnterDartFrame(Assembler* assembler,
intptr_t frame_size) {
const intptr_t offset = assembler->CodeSize();
__ EnterFrame(0);
Label dart_entry;
__ call(&dart_entry);
__ Bind(&dart_entry);
// Adjust saved PC for any intrinsic code that could have been generated
// before a frame is created.
if (offset != 0) {
__ addl(Address(ESP, 0), Immediate(-offset));
}
if (frame_size != 0) {
__ subl(ESP, Immediate(frame_size));
}
}
void AssemblerMacros::EnterDartLeafFrame(Assembler* assembler,
intptr_t frame_size) {
__ EnterFrame(0);
Label dart_entry;
// Leave room for the saved PC, it will be filled in lazily, leave
// uninitialized.
__ subl(ESP, Immediate(frame_size + kWordSize));
#if defined(DEBUG)
// Store an invalid object in saved PC slot.
__ movl(Address(EBP, -kWordSize), Immediate(kHeapObjectTag));
#endif
}
void AssemblerMacros::EnterStubFrame(Assembler* assembler) {
__ EnterFrame(0);
__ pushl(Immediate(0)); // Push 0 in the saved PC area for stub frames.
}
#undef __
} // namespace dart
#endif // defined TARGET_ARCH_IA32