~yolanda.robla/ubuntu/trusty/nodejs/add_distribution

« back to all changes in this revision

Viewing changes to deps/v8/src/x64/virtual-frame-x64.cc

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2011-03-12 10:45:08 UTC
  • mto: (7.2.4 experimental) (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 14.
  • Revision ID: james.westby@ubuntu.com-20110312104508-q0kxzl076edcxriv
Tags: upstream-0.4.2
ImportĀ upstreamĀ versionĀ 0.4.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
4
4
// met:
32
32
#include "codegen-inl.h"
33
33
#include "register-allocator-inl.h"
34
34
#include "scopes.h"
 
35
#include "stub-cache.h"
35
36
#include "virtual-frame-inl.h"
36
37
 
37
38
namespace v8 {
259
260
 
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());
265
266
      return;
273
274
}
274
275
 
275
276
 
 
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));
 
283
    } else {
 
284
      __ movq(temp.reg(), value, RelocInfo::EMBEDDED_OBJECT);
 
285
    }
 
286
    Push(&temp);
 
287
  } else {
 
288
    FrameElement element =
 
289
        FrameElement::ConstantElement(value, FrameElement::NOT_SYNCED);
 
290
    elements_.Add(element);
 
291
  }
 
292
}
 
293
 
 
294
 
276
295
void VirtualFrame::Drop(int count) {
277
296
  ASSERT(count >= 0);
278
297
  ASSERT(height() >= count);
1118
1137
}
1119
1138
 
1120
1139
 
1121
 
Result VirtualFrame::CallStoreIC(Handle<String> name, bool is_contextual) {
 
1140
Result VirtualFrame::CallStoreIC(Handle<String> name,
 
1141
                                 bool is_contextual,
 
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)));
1130
1154
    value.Unuse();
 
1155
    mode = RelocInfo::CODE_TARGET_CONTEXT;
1131
1156
  } else {
1132
1157
    Result receiver = Pop();
1133
1158
    PrepareForCall(0, 0);
1134
1159
    MoveResultsToRegisters(&value, &receiver, rax, rdx);
 
1160
    mode = RelocInfo::CODE_TARGET;
1135
1161
  }
1136
1162
  __ Move(rcx, name);
1137
 
  return RawCallCodeObject(ic, RelocInfo::CODE_TARGET);
 
1163
  return RawCallCodeObject(ic, mode);
1138
1164
}
1139
1165
 
1140
1166
 
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();
1183
1209
  }
1184
1210
 
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);
1187
1215
}
1188
1216
 
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
1200
1228
  // receiver.
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
1219
1247
  // receiver.
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);
1237
1265
 
1238
1266
  // Constructors are called with the number of arguments in register