1
// Copyright 2010 the V8 project authors. All rights reserved.
1
// Copyright 2011 the V8 project authors. All rights reserved.
2
2
// Redistribution and use in source and binary forms, with or without
3
3
// modification, are permitted provided that the following conditions are
260
261
VariableProxy* proxy = expr->AsVariableProxy();
261
262
if (proxy != NULL) {
262
Slot* slot = proxy->var()->slot();
263
Slot* slot = proxy->var()->AsSlot();
263
264
if (slot->type() == Slot::LOCAL) {
264
265
PushLocalAt(slot->index());
277
void VirtualFrame::Push(Handle<Object> value) {
278
if (ConstantPoolOverflowed()) {
279
Result temp = cgen()->allocator()->Allocate();
280
ASSERT(temp.is_valid());
281
if (value->IsSmi()) {
282
__ Move(temp.reg(), Smi::cast(*value));
284
__ movq(temp.reg(), value, RelocInfo::EMBEDDED_OBJECT);
288
FrameElement element =
289
FrameElement::ConstantElement(value, FrameElement::NOT_SYNCED);
290
elements_.Add(element);
276
295
void VirtualFrame::Drop(int count) {
277
296
ASSERT(count >= 0);
278
297
ASSERT(height() >= count);
1121
Result VirtualFrame::CallStoreIC(Handle<String> name, bool is_contextual) {
1140
Result VirtualFrame::CallStoreIC(Handle<String> name,
1142
StrictModeFlag strict_mode) {
1122
1143
// Value and (if not contextual) receiver are on top of the frame.
1123
1144
// The IC expects name in rcx, value in rax, and receiver in rdx.
1124
Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize));
1145
Handle<Code> ic(Builtins::builtin(
1146
(strict_mode == kStrictMode) ? Builtins::StoreIC_Initialize_Strict
1147
: Builtins::StoreIC_Initialize));
1125
1148
Result value = Pop();
1149
RelocInfo::Mode mode;
1126
1150
if (is_contextual) {
1127
1151
PrepareForCall(0, 0);
1128
1152
value.ToRegister(rax);
1129
1153
__ movq(rdx, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX)));
1155
mode = RelocInfo::CODE_TARGET_CONTEXT;
1132
1157
Result receiver = Pop();
1133
1158
PrepareForCall(0, 0);
1134
1159
MoveResultsToRegisters(&value, &receiver, rax, rdx);
1160
mode = RelocInfo::CODE_TARGET;
1136
1162
__ Move(rcx, name);
1137
return RawCallCodeObject(ic, RelocInfo::CODE_TARGET);
1163
return RawCallCodeObject(ic, mode);
1141
Result VirtualFrame::CallKeyedStoreIC() {
1167
Result VirtualFrame::CallKeyedStoreIC(StrictModeFlag strict_mode) {
1142
1168
// Value, key, and receiver are on the top of the frame. The IC
1143
1169
// expects value in rax, key in rcx, and receiver in rdx.
1144
1170
Result value = Pop();
1182
1208
receiver.Unuse();
1185
Handle<Code> ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize));
1211
Handle<Code> ic(Builtins::builtin(
1212
(strict_mode == kStrictMode) ? Builtins::KeyedStoreIC_Initialize_Strict
1213
: Builtins::KeyedStoreIC_Initialize));
1186
1214
return RawCallCodeObject(ic, RelocInfo::CODE_TARGET);
1194
1222
// and dropped by the call. The IC expects the name in rcx and the rest
1195
1223
// on the stack, and drops them all.
1196
1224
InLoopFlag in_loop = loop_nesting > 0 ? IN_LOOP : NOT_IN_LOOP;
1197
Handle<Code> ic = cgen()->ComputeCallInitialize(arg_count, in_loop);
1225
Handle<Code> ic = StubCache::ComputeCallInitialize(arg_count, in_loop);
1198
1226
Result name = Pop();
1199
1227
// Spill args, receiver, and function. The call will drop args and
1213
1241
// on the stack, and drops them all.
1214
1242
InLoopFlag in_loop = loop_nesting > 0 ? IN_LOOP : NOT_IN_LOOP;
1215
1243
Handle<Code> ic =
1216
cgen()->ComputeKeyedCallInitialize(arg_count, in_loop);
1244
StubCache::ComputeKeyedCallInitialize(arg_count, in_loop);
1217
1245
Result name = Pop();
1218
1246
// Spill args, receiver, and function. The call will drop args and
1230
1258
// and receiver on the stack.
1231
1259
Handle<Code> ic(Builtins::builtin(Builtins::JSConstructCall));
1232
1260
// Duplicate the function before preparing the frame.
1233
PushElementAt(arg_count + 1);
1261
PushElementAt(arg_count);
1234
1262
Result function = Pop();
1235
PrepareForCall(arg_count + 1, arg_count + 1); // Spill args and receiver.
1263
PrepareForCall(arg_count + 1, arg_count + 1); // Spill function and args.
1236
1264
function.ToRegister(rdi);
1238
1266
// Constructors are called with the number of arguments in register