1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
|
// Copyright 2009 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "v8.h"
#if defined(V8_TARGET_ARCH_IA32)
#include "codegen-inl.h"
#include "register-allocator-inl.h"
#include "scopes.h"
#include "virtual-frame-inl.h"
#include "stub-cache.h"
namespace v8 {
namespace internal {
#define __ ACCESS_MASM(masm())
void VirtualFrame::SyncElementBelowStackPointer(int index) {
// Emit code to write elements below the stack pointer to their
// (already allocated) stack address.
ASSERT(index <= stack_pointer_);
FrameElement element = elements_[index];
ASSERT(!element.is_synced());
switch (element.type()) {
case FrameElement::INVALID:
break;
case FrameElement::MEMORY:
// This function should not be called with synced elements.
// (memory elements are always synced).
UNREACHABLE();
break;
case FrameElement::REGISTER:
__ mov(Operand(ebp, fp_relative(index)), element.reg());
break;
case FrameElement::CONSTANT:
if (cgen()->IsUnsafeSmi(element.handle())) {
cgen()->StoreUnsafeSmiToLocal(fp_relative(index), element.handle());
} else {
__ Set(Operand(ebp, fp_relative(index)),
Immediate(element.handle()));
}
break;
case FrameElement::COPY: {
int backing_index = element.index();
FrameElement backing_element = elements_[backing_index];
if (backing_element.is_memory()) {
Result temp = cgen()->allocator()->Allocate();
ASSERT(temp.is_valid());
__ mov(temp.reg(), Operand(ebp, fp_relative(backing_index)));
__ mov(Operand(ebp, fp_relative(index)), temp.reg());
} else {
ASSERT(backing_element.is_register());
__ mov(Operand(ebp, fp_relative(index)), backing_element.reg());
}
break;
}
}
elements_[index].set_sync();
}
void VirtualFrame::SyncElementByPushing(int index) {
// Sync an element of the frame that is just above the stack pointer
// by pushing it.
ASSERT(index == stack_pointer_ + 1);
stack_pointer_++;
FrameElement element = elements_[index];
switch (element.type()) {
case FrameElement::INVALID:
__ push(Immediate(Smi::FromInt(0)));
break;
case FrameElement::MEMORY:
// No memory elements exist above the stack pointer.
UNREACHABLE();
break;
case FrameElement::REGISTER:
__ push(element.reg());
break;
case FrameElement::CONSTANT:
if (cgen()->IsUnsafeSmi(element.handle())) {
cgen()->PushUnsafeSmi(element.handle());
} else {
__ push(Immediate(element.handle()));
}
break;
case FrameElement::COPY: {
int backing_index = element.index();
FrameElement backing = elements_[backing_index];
ASSERT(backing.is_memory() || backing.is_register());
if (backing.is_memory()) {
__ push(Operand(ebp, fp_relative(backing_index)));
} else {
__ push(backing.reg());
}
break;
}
}
elements_[index].set_sync();
}
// Clear the dirty bits for the range of elements in
// [min(stack_pointer_ + 1,begin), end].
void VirtualFrame::SyncRange(int begin, int end) {
ASSERT(begin >= 0);
ASSERT(end < element_count());
// Sync elements below the range if they have not been materialized
// on the stack.
int start = Min(begin, stack_pointer_ + 1);
// Emit normal push instructions for elements above stack pointer
// and use mov instructions if we are below stack pointer.
for (int i = start; i <= end; i++) {
if (!elements_[i].is_synced()) {
if (i <= stack_pointer_) {
SyncElementBelowStackPointer(i);
} else {
SyncElementByPushing(i);
}
}
}
}
void VirtualFrame::MakeMergable() {
for (int i = 0; i < element_count(); i++) {
FrameElement element = elements_[i];
// All number type information is reset to unknown for a mergable frame
// because of incoming back edges.
if (element.is_constant() || element.is_copy()) {
if (element.is_synced()) {
// Just spill.
elements_[i] = FrameElement::MemoryElement(TypeInfo::Unknown());
} else {
// Allocate to a register.
FrameElement backing_element; // Invalid if not a copy.
if (element.is_copy()) {
backing_element = elements_[element.index()];
}
Result fresh = cgen()->allocator()->Allocate();
ASSERT(fresh.is_valid()); // A register was spilled if all were in use.
elements_[i] =
FrameElement::RegisterElement(fresh.reg(),
FrameElement::NOT_SYNCED,
TypeInfo::Unknown());
Use(fresh.reg(), i);
// Emit a move.
if (element.is_constant()) {
if (cgen()->IsUnsafeSmi(element.handle())) {
cgen()->MoveUnsafeSmi(fresh.reg(), element.handle());
} else {
__ Set(fresh.reg(), Immediate(element.handle()));
}
} else {
ASSERT(element.is_copy());
// Copies are only backed by register or memory locations.
if (backing_element.is_register()) {
// The backing store may have been spilled by allocating,
// but that's OK. If it was, the value is right where we
// want it.
if (!fresh.reg().is(backing_element.reg())) {
__ mov(fresh.reg(), backing_element.reg());
}
} else {
ASSERT(backing_element.is_memory());
__ mov(fresh.reg(), Operand(ebp, fp_relative(element.index())));
}
}
}
// No need to set the copied flag --- there are no copies.
} else {
// Clear the copy flag of non-constant, non-copy elements.
// They cannot be copied because copies are not allowed.
// The copy flag is not relied on before the end of this loop,
// including when registers are spilled.
elements_[i].clear_copied();
elements_[i].set_type_info(TypeInfo::Unknown());
}
}
}
void VirtualFrame::MergeTo(VirtualFrame* expected) {
Comment cmnt(masm(), "[ Merge frame");
// We should always be merging the code generator's current frame to an
// expected frame.
ASSERT(cgen()->frame() == this);
// Adjust the stack pointer upward (toward the top of the virtual
// frame) if necessary.
if (stack_pointer_ < expected->stack_pointer_) {
int difference = expected->stack_pointer_ - stack_pointer_;
stack_pointer_ = expected->stack_pointer_;
__ sub(Operand(esp), Immediate(difference * kPointerSize));
}
MergeMoveRegistersToMemory(expected);
MergeMoveRegistersToRegisters(expected);
MergeMoveMemoryToRegisters(expected);
// Adjust the stack pointer downward if necessary.
if (stack_pointer_ > expected->stack_pointer_) {
int difference = stack_pointer_ - expected->stack_pointer_;
stack_pointer_ = expected->stack_pointer_;
__ add(Operand(esp), Immediate(difference * kPointerSize));
}
// At this point, the frames should be identical.
ASSERT(Equals(expected));
}
void VirtualFrame::MergeMoveRegistersToMemory(VirtualFrame* expected) {
ASSERT(stack_pointer_ >= expected->stack_pointer_);
// Move registers, constants, and copies to memory. Perform moves
// from the top downward in the frame in order to leave the backing
// stores of copies in registers.
//
// Moving memory-backed copies to memory requires a spare register
// for the memory-to-memory moves. Since we are performing a merge,
// we use esi (which is already saved in the frame). We keep track
// of the index of the frame element esi is caching or kIllegalIndex
// if esi has not been disturbed.
int esi_caches = kIllegalIndex;
for (int i = element_count() - 1; i >= 0; i--) {
FrameElement target = expected->elements_[i];
if (target.is_register()) continue; // Handle registers later.
if (target.is_memory()) {
FrameElement source = elements_[i];
switch (source.type()) {
case FrameElement::INVALID:
// Not a legal merge move.
UNREACHABLE();
break;
case FrameElement::MEMORY:
// Already in place.
break;
case FrameElement::REGISTER:
Unuse(source.reg());
if (!source.is_synced()) {
__ mov(Operand(ebp, fp_relative(i)), source.reg());
}
break;
case FrameElement::CONSTANT:
if (!source.is_synced()) {
if (cgen()->IsUnsafeSmi(source.handle())) {
esi_caches = i;
cgen()->MoveUnsafeSmi(esi, source.handle());
__ mov(Operand(ebp, fp_relative(i)), esi);
} else {
__ Set(Operand(ebp, fp_relative(i)), Immediate(source.handle()));
}
}
break;
case FrameElement::COPY:
if (!source.is_synced()) {
int backing_index = source.index();
FrameElement backing_element = elements_[backing_index];
if (backing_element.is_memory()) {
// If we have to spill a register, we spill esi.
if (esi_caches != backing_index) {
esi_caches = backing_index;
__ mov(esi, Operand(ebp, fp_relative(backing_index)));
}
__ mov(Operand(ebp, fp_relative(i)), esi);
} else {
ASSERT(backing_element.is_register());
__ mov(Operand(ebp, fp_relative(i)), backing_element.reg());
}
}
break;
}
}
elements_[i] = target;
}
if (esi_caches != kIllegalIndex) {
__ mov(esi, Operand(ebp, fp_relative(context_index())));
}
}
void VirtualFrame::MergeMoveRegistersToRegisters(VirtualFrame* expected) {
// We have already done X-to-memory moves.
ASSERT(stack_pointer_ >= expected->stack_pointer_);
for (int i = 0; i < RegisterAllocator::kNumRegisters; i++) {
// Move the right value into register i if it is currently in a register.
int index = expected->register_location(i);
int use_index = register_location(i);
// Skip if register i is unused in the target or else if source is
// not a register (this is not a register-to-register move).
if (index == kIllegalIndex || !elements_[index].is_register()) continue;
Register target = RegisterAllocator::ToRegister(i);
Register source = elements_[index].reg();
if (index != use_index) {
if (use_index == kIllegalIndex) { // Target is currently unused.
// Copy contents of source from source to target.
// Set frame element register to target.
Use(target, index);
Unuse(source);
__ mov(target, source);
} else {
// Exchange contents of registers source and target.
// Nothing except the register backing use_index has changed.
elements_[use_index].set_reg(source);
set_register_location(target, index);
set_register_location(source, use_index);
__ xchg(source, target);
}
}
if (!elements_[index].is_synced() &&
expected->elements_[index].is_synced()) {
__ mov(Operand(ebp, fp_relative(index)), target);
}
elements_[index] = expected->elements_[index];
}
}
void VirtualFrame::MergeMoveMemoryToRegisters(VirtualFrame* expected) {
// Move memory, constants, and copies to registers. This is the
// final step and since it is not done from the bottom up, but in
// register code order, we have special code to ensure that the backing
// elements of copies are in their correct locations when we
// encounter the copies.
for (int i = 0; i < RegisterAllocator::kNumRegisters; i++) {
int index = expected->register_location(i);
if (index != kIllegalIndex) {
FrameElement source = elements_[index];
FrameElement target = expected->elements_[index];
Register target_reg = RegisterAllocator::ToRegister(i);
ASSERT(target.reg().is(target_reg));
switch (source.type()) {
case FrameElement::INVALID: // Fall through.
UNREACHABLE();
break;
case FrameElement::REGISTER:
ASSERT(source.Equals(target));
// Go to next iteration. Skips Use(target_reg) and syncing
// below. It is safe to skip syncing because a target
// register frame element would only be synced if all source
// elements were.
continue;
break;
case FrameElement::MEMORY:
ASSERT(index <= stack_pointer_);
__ mov(target_reg, Operand(ebp, fp_relative(index)));
break;
case FrameElement::CONSTANT:
if (cgen()->IsUnsafeSmi(source.handle())) {
cgen()->MoveUnsafeSmi(target_reg, source.handle());
} else {
__ Set(target_reg, Immediate(source.handle()));
}
break;
case FrameElement::COPY: {
int backing_index = source.index();
FrameElement backing = elements_[backing_index];
ASSERT(backing.is_memory() || backing.is_register());
if (backing.is_memory()) {
ASSERT(backing_index <= stack_pointer_);
// Code optimization if backing store should also move
// to a register: move backing store to its register first.
if (expected->elements_[backing_index].is_register()) {
FrameElement new_backing = expected->elements_[backing_index];
Register new_backing_reg = new_backing.reg();
ASSERT(!is_used(new_backing_reg));
elements_[backing_index] = new_backing;
Use(new_backing_reg, backing_index);
__ mov(new_backing_reg,
Operand(ebp, fp_relative(backing_index)));
__ mov(target_reg, new_backing_reg);
} else {
__ mov(target_reg, Operand(ebp, fp_relative(backing_index)));
}
} else {
__ mov(target_reg, backing.reg());
}
}
}
// Ensure the proper sync state.
if (target.is_synced() && !source.is_synced()) {
__ mov(Operand(ebp, fp_relative(index)), target_reg);
}
Use(target_reg, index);
elements_[index] = target;
}
}
}
void VirtualFrame::Enter() {
// Registers live on entry: esp, ebp, esi, edi.
Comment cmnt(masm(), "[ Enter JS frame");
#ifdef DEBUG
if (FLAG_debug_code) {
// Verify that edi contains a JS function. The following code
// relies on eax being available for use.
__ test(edi, Immediate(kSmiTagMask));
__ Check(not_zero,
"VirtualFrame::Enter - edi is not a function (smi check).");
__ CmpObjectType(edi, JS_FUNCTION_TYPE, eax);
__ Check(equal,
"VirtualFrame::Enter - edi is not a function (map check).");
}
#endif
EmitPush(ebp);
__ mov(ebp, Operand(esp));
// Store the context in the frame. The context is kept in esi and a
// copy is stored in the frame. The external reference to esi
// remains.
EmitPush(esi);
// Store the function in the frame. The frame owns the register
// reference now (ie, it can keep it in edi or spill it later).
Push(edi);
SyncElementAt(element_count() - 1);
cgen()->allocator()->Unuse(edi);
}
void VirtualFrame::Exit() {
Comment cmnt(masm(), "[ Exit JS frame");
// Record the location of the JS exit code for patching when setting
// break point.
__ RecordJSReturn();
// Avoid using the leave instruction here, because it is too
// short. We need the return sequence to be a least the size of a
// call instruction to support patching the exit code in the
// debugger. See VisitReturnStatement for the full return sequence.
__ mov(esp, Operand(ebp));
stack_pointer_ = frame_pointer();
for (int i = element_count() - 1; i > stack_pointer_; i--) {
FrameElement last = elements_.RemoveLast();
if (last.is_register()) {
Unuse(last.reg());
}
}
EmitPop(ebp);
}
void VirtualFrame::AllocateStackSlots() {
int count = local_count();
if (count > 0) {
Comment cmnt(masm(), "[ Allocate space for locals");
// The locals are initialized to a constant (the undefined value), but
// we sync them with the actual frame to allocate space for spilling
// them later. First sync everything above the stack pointer so we can
// use pushes to allocate and initialize the locals.
SyncRange(stack_pointer_ + 1, element_count() - 1);
Handle<Object> undefined = Factory::undefined_value();
FrameElement initial_value =
FrameElement::ConstantElement(undefined, FrameElement::SYNCED);
if (count == 1) {
__ push(Immediate(undefined));
} else if (count < kLocalVarBound) {
// For less locals the unrolled loop is more compact.
Result temp = cgen()->allocator()->Allocate();
ASSERT(temp.is_valid());
__ Set(temp.reg(), Immediate(undefined));
for (int i = 0; i < count; i++) {
__ push(temp.reg());
}
} else {
// For more locals a loop in generated code is more compact.
Label alloc_locals_loop;
Result cnt = cgen()->allocator()->Allocate();
Result tmp = cgen()->allocator()->Allocate();
ASSERT(cnt.is_valid());
ASSERT(tmp.is_valid());
__ mov(cnt.reg(), Immediate(count));
__ mov(tmp.reg(), Immediate(undefined));
__ bind(&alloc_locals_loop);
__ push(tmp.reg());
__ dec(cnt.reg());
__ j(not_zero, &alloc_locals_loop);
}
for (int i = 0; i < count; i++) {
elements_.Add(initial_value);
stack_pointer_++;
}
}
}
void VirtualFrame::SaveContextRegister() {
ASSERT(elements_[context_index()].is_memory());
__ mov(Operand(ebp, fp_relative(context_index())), esi);
}
void VirtualFrame::RestoreContextRegister() {
ASSERT(elements_[context_index()].is_memory());
__ mov(esi, Operand(ebp, fp_relative(context_index())));
}
void VirtualFrame::PushReceiverSlotAddress() {
Result temp = cgen()->allocator()->Allocate();
ASSERT(temp.is_valid());
__ lea(temp.reg(), ParameterAt(-1));
Push(&temp);
}
int VirtualFrame::InvalidateFrameSlotAt(int index) {
FrameElement original = elements_[index];
// Is this element the backing store of any copies?
int new_backing_index = kIllegalIndex;
if (original.is_copied()) {
// Verify it is copied, and find first copy.
for (int i = index + 1; i < element_count(); i++) {
if (elements_[i].is_copy() && elements_[i].index() == index) {
new_backing_index = i;
break;
}
}
}
if (new_backing_index == kIllegalIndex) {
// No copies found, return kIllegalIndex.
if (original.is_register()) {
Unuse(original.reg());
}
elements_[index] = FrameElement::InvalidElement();
return kIllegalIndex;
}
// This is the backing store of copies.
Register backing_reg;
if (original.is_memory()) {
Result fresh = cgen()->allocator()->Allocate();
ASSERT(fresh.is_valid());
Use(fresh.reg(), new_backing_index);
backing_reg = fresh.reg();
__ mov(backing_reg, Operand(ebp, fp_relative(index)));
} else {
// The original was in a register.
backing_reg = original.reg();
set_register_location(backing_reg, new_backing_index);
}
// Invalidate the element at index.
elements_[index] = FrameElement::InvalidElement();
// Set the new backing element.
if (elements_[new_backing_index].is_synced()) {
elements_[new_backing_index] =
FrameElement::RegisterElement(backing_reg,
FrameElement::SYNCED,
original.type_info());
} else {
elements_[new_backing_index] =
FrameElement::RegisterElement(backing_reg,
FrameElement::NOT_SYNCED,
original.type_info());
}
// Update the other copies.
for (int i = new_backing_index + 1; i < element_count(); i++) {
if (elements_[i].is_copy() && elements_[i].index() == index) {
elements_[i].set_index(new_backing_index);
elements_[new_backing_index].set_copied();
}
}
return new_backing_index;
}
void VirtualFrame::TakeFrameSlotAt(int index) {
ASSERT(index >= 0);
ASSERT(index <= element_count());
FrameElement original = elements_[index];
int new_backing_store_index = InvalidateFrameSlotAt(index);
if (new_backing_store_index != kIllegalIndex) {
elements_.Add(CopyElementAt(new_backing_store_index));
return;
}
switch (original.type()) {
case FrameElement::MEMORY: {
// Emit code to load the original element's data into a register.
// Push that register as a FrameElement on top of the frame.
Result fresh = cgen()->allocator()->Allocate();
ASSERT(fresh.is_valid());
FrameElement new_element =
FrameElement::RegisterElement(fresh.reg(),
FrameElement::NOT_SYNCED,
original.type_info());
Use(fresh.reg(), element_count());
elements_.Add(new_element);
__ mov(fresh.reg(), Operand(ebp, fp_relative(index)));
break;
}
case FrameElement::REGISTER:
Use(original.reg(), element_count());
// Fall through.
case FrameElement::CONSTANT:
case FrameElement::COPY:
original.clear_sync();
elements_.Add(original);
break;
case FrameElement::INVALID:
UNREACHABLE();
break;
}
}
void VirtualFrame::StoreToFrameSlotAt(int index) {
// Store the value on top of the frame to the virtual frame slot at
// a given index. The value on top of the frame is left in place.
// This is a duplicating operation, so it can create copies.
ASSERT(index >= 0);
ASSERT(index < element_count());
int top_index = element_count() - 1;
FrameElement top = elements_[top_index];
FrameElement original = elements_[index];
if (top.is_copy() && top.index() == index) return;
ASSERT(top.is_valid());
InvalidateFrameSlotAt(index);
// InvalidateFrameSlotAt can potentially change any frame element, due
// to spilling registers to allocate temporaries in order to preserve
// the copy-on-write semantics of aliased elements. Reload top from
// the frame.
top = elements_[top_index];
if (top.is_copy()) {
// There are two cases based on the relative positions of the
// stored-to slot and the backing slot of the top element.
int backing_index = top.index();
ASSERT(backing_index != index);
if (backing_index < index) {
// 1. The top element is a copy of a slot below the stored-to
// slot. The stored-to slot becomes an unsynced copy of that
// same backing slot.
elements_[index] = CopyElementAt(backing_index);
} else {
// 2. The top element is a copy of a slot above the stored-to
// slot. The stored-to slot becomes the new (unsynced) backing
// slot and both the top element and the element at the former
// backing slot become copies of it. The sync state of the top
// and former backing elements is preserved.
FrameElement backing_element = elements_[backing_index];
ASSERT(backing_element.is_memory() || backing_element.is_register());
if (backing_element.is_memory()) {
// Because sets of copies are canonicalized to be backed by
// their lowest frame element, and because memory frame
// elements are backed by the corresponding stack address, we
// have to move the actual value down in the stack.
//
// TODO(209): considering allocating the stored-to slot to the
// temp register. Alternatively, allow copies to appear in
// any order in the frame and lazily move the value down to
// the slot.
Result temp = cgen()->allocator()->Allocate();
ASSERT(temp.is_valid());
__ mov(temp.reg(), Operand(ebp, fp_relative(backing_index)));
__ mov(Operand(ebp, fp_relative(index)), temp.reg());
} else {
set_register_location(backing_element.reg(), index);
if (backing_element.is_synced()) {
// If the element is a register, we will not actually move
// anything on the stack but only update the virtual frame
// element.
backing_element.clear_sync();
}
}
elements_[index] = backing_element;
// The old backing element becomes a copy of the new backing
// element.
FrameElement new_element = CopyElementAt(index);
elements_[backing_index] = new_element;
if (backing_element.is_synced()) {
elements_[backing_index].set_sync();
}
// All the copies of the old backing element (including the top
// element) become copies of the new backing element.
for (int i = backing_index + 1; i < element_count(); i++) {
if (elements_[i].is_copy() && elements_[i].index() == backing_index) {
elements_[i].set_index(index);
}
}
}
return;
}
// Move the top element to the stored-to slot and replace it (the
// top element) with a copy.
elements_[index] = top;
if (top.is_memory()) {
// TODO(209): consider allocating the stored-to slot to the temp
// register. Alternatively, allow copies to appear in any order
// in the frame and lazily move the value down to the slot.
FrameElement new_top = CopyElementAt(index);
new_top.set_sync();
elements_[top_index] = new_top;
// The sync state of the former top element is correct (synced).
// Emit code to move the value down in the frame.
Result temp = cgen()->allocator()->Allocate();
ASSERT(temp.is_valid());
__ mov(temp.reg(), Operand(esp, 0));
__ mov(Operand(ebp, fp_relative(index)), temp.reg());
} else if (top.is_register()) {
set_register_location(top.reg(), index);
// The stored-to slot has the (unsynced) register reference and
// the top element becomes a copy. The sync state of the top is
// preserved.
FrameElement new_top = CopyElementAt(index);
if (top.is_synced()) {
new_top.set_sync();
elements_[index].clear_sync();
}
elements_[top_index] = new_top;
} else {
// The stored-to slot holds the same value as the top but
// unsynced. (We do not have copies of constants yet.)
ASSERT(top.is_constant());
elements_[index].clear_sync();
}
}
void VirtualFrame::UntaggedPushFrameSlotAt(int index) {
ASSERT(index >= 0);
ASSERT(index <= element_count());
FrameElement original = elements_[index];
if (original.is_copy()) {
original = elements_[original.index()];
index = original.index();
}
switch (original.type()) {
case FrameElement::MEMORY:
case FrameElement::REGISTER: {
Label done;
// Emit code to load the original element's data into a register.
// Push that register as a FrameElement on top of the frame.
Result fresh = cgen()->allocator()->Allocate();
ASSERT(fresh.is_valid());
Register fresh_reg = fresh.reg();
FrameElement new_element =
FrameElement::RegisterElement(fresh_reg,
FrameElement::NOT_SYNCED,
original.type_info());
new_element.set_untagged_int32(true);
Use(fresh_reg, element_count());
fresh.Unuse(); // BreakTarget does not handle a live Result well.
elements_.Add(new_element);
if (original.is_register()) {
__ mov(fresh_reg, original.reg());
} else {
ASSERT(original.is_memory());
__ mov(fresh_reg, Operand(ebp, fp_relative(index)));
}
// Now convert the value to int32, or bail out.
if (original.type_info().IsSmi()) {
__ SmiUntag(fresh_reg);
// Pushing the element is completely done.
} else {
__ test(fresh_reg, Immediate(kSmiTagMask));
Label not_smi;
__ j(not_zero, ¬_smi);
__ SmiUntag(fresh_reg);
__ jmp(&done);
__ bind(¬_smi);
if (!original.type_info().IsNumber()) {
__ cmp(FieldOperand(fresh_reg, HeapObject::kMapOffset),
Factory::heap_number_map());
cgen()->unsafe_bailout_->Branch(not_equal);
}
if (!CpuFeatures::IsSupported(SSE2)) {
UNREACHABLE();
} else {
CpuFeatures::Scope use_sse2(SSE2);
__ movdbl(xmm0, FieldOperand(fresh_reg, HeapNumber::kValueOffset));
__ cvttsd2si(fresh_reg, Operand(xmm0));
__ cvtsi2sd(xmm1, Operand(fresh_reg));
__ ucomisd(xmm0, xmm1);
cgen()->unsafe_bailout_->Branch(not_equal);
cgen()->unsafe_bailout_->Branch(parity_even); // NaN.
// Test for negative zero.
__ test(fresh_reg, Operand(fresh_reg));
__ j(not_zero, &done);
__ movmskpd(fresh_reg, xmm0);
__ and_(fresh_reg, 0x1);
cgen()->unsafe_bailout_->Branch(not_equal);
}
__ bind(&done);
}
break;
}
case FrameElement::CONSTANT:
elements_.Add(CopyElementAt(index));
elements_[element_count() - 1].set_untagged_int32(true);
break;
case FrameElement::COPY:
case FrameElement::INVALID:
UNREACHABLE();
break;
}
}
void VirtualFrame::PushTryHandler(HandlerType type) {
ASSERT(cgen()->HasValidEntryRegisters());
// Grow the expression stack by handler size less one (the return
// address is already pushed by a call instruction).
Adjust(kHandlerSize - 1);
__ PushTryHandler(IN_JAVASCRIPT, type);
}
Result VirtualFrame::RawCallStub(CodeStub* stub) {
ASSERT(cgen()->HasValidEntryRegisters());
__ CallStub(stub);
Result result = cgen()->allocator()->Allocate(eax);
ASSERT(result.is_valid());
return result;
}
Result VirtualFrame::CallStub(CodeStub* stub, Result* arg) {
PrepareForCall(0, 0);
arg->ToRegister(eax);
arg->Unuse();
return RawCallStub(stub);
}
Result VirtualFrame::CallStub(CodeStub* stub, Result* arg0, Result* arg1) {
PrepareForCall(0, 0);
if (arg0->is_register() && arg0->reg().is(eax)) {
if (arg1->is_register() && arg1->reg().is(edx)) {
// Wrong registers.
__ xchg(eax, edx);
} else {
// Register edx is free for arg0, which frees eax for arg1.
arg0->ToRegister(edx);
arg1->ToRegister(eax);
}
} else {
// Register eax is free for arg1, which guarantees edx is free for
// arg0.
arg1->ToRegister(eax);
arg0->ToRegister(edx);
}
arg0->Unuse();
arg1->Unuse();
return RawCallStub(stub);
}
Result VirtualFrame::CallJSFunction(int arg_count) {
Result function = Pop();
// InvokeFunction requires function in edi. Move it in there.
function.ToRegister(edi);
function.Unuse();
// +1 for receiver.
PrepareForCall(arg_count + 1, arg_count + 1);
ASSERT(cgen()->HasValidEntryRegisters());
ParameterCount count(arg_count);
__ InvokeFunction(edi, count, CALL_FUNCTION);
RestoreContextRegister();
Result result = cgen()->allocator()->Allocate(eax);
ASSERT(result.is_valid());
return result;
}
Result VirtualFrame::CallRuntime(Runtime::Function* f, int arg_count) {
PrepareForCall(arg_count, arg_count);
ASSERT(cgen()->HasValidEntryRegisters());
__ CallRuntime(f, arg_count);
Result result = cgen()->allocator()->Allocate(eax);
ASSERT(result.is_valid());
return result;
}
Result VirtualFrame::CallRuntime(Runtime::FunctionId id, int arg_count) {
PrepareForCall(arg_count, arg_count);
ASSERT(cgen()->HasValidEntryRegisters());
__ CallRuntime(id, arg_count);
Result result = cgen()->allocator()->Allocate(eax);
ASSERT(result.is_valid());
return result;
}
#ifdef ENABLE_DEBUGGER_SUPPORT
void VirtualFrame::DebugBreak() {
PrepareForCall(0, 0);
ASSERT(cgen()->HasValidEntryRegisters());
__ DebugBreak();
Result result = cgen()->allocator()->Allocate(eax);
ASSERT(result.is_valid());
}
#endif
Result VirtualFrame::InvokeBuiltin(Builtins::JavaScript id,
InvokeFlag flag,
int arg_count) {
PrepareForCall(arg_count, arg_count);
ASSERT(cgen()->HasValidEntryRegisters());
__ InvokeBuiltin(id, flag);
Result result = cgen()->allocator()->Allocate(eax);
ASSERT(result.is_valid());
return result;
}
Result VirtualFrame::RawCallCodeObject(Handle<Code> code,
RelocInfo::Mode rmode) {
ASSERT(cgen()->HasValidEntryRegisters());
__ call(code, rmode);
Result result = cgen()->allocator()->Allocate(eax);
ASSERT(result.is_valid());
return result;
}
// This function assumes that the only results that could be in a_reg or b_reg
// are a and b. Other results can be live, but must not be in a_reg or b_reg.
void VirtualFrame::MoveResultsToRegisters(Result* a,
Result* b,
Register a_reg,
Register b_reg) {
if (a->is_register() && a->reg().is(a_reg)) {
b->ToRegister(b_reg);
} else if (!cgen()->allocator()->is_used(a_reg)) {
a->ToRegister(a_reg);
b->ToRegister(b_reg);
} else if (cgen()->allocator()->is_used(b_reg)) {
// a must be in b_reg, b in a_reg.
__ xchg(a_reg, b_reg);
// Results a and b will be invalidated, so it is ok if they are switched.
} else {
b->ToRegister(b_reg);
a->ToRegister(a_reg);
}
a->Unuse();
b->Unuse();
}
Result VirtualFrame::CallLoadIC(RelocInfo::Mode mode) {
// Name and receiver are on the top of the frame. The IC expects
// name in ecx and receiver in eax.
Result name = Pop();
Result receiver = Pop();
PrepareForCall(0, 0); // No stack arguments.
MoveResultsToRegisters(&name, &receiver, ecx, eax);
Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize));
return RawCallCodeObject(ic, mode);
}
Result VirtualFrame::CallKeyedLoadIC(RelocInfo::Mode mode) {
// Key and receiver are on top of the frame. Put them in eax and edx.
Result key = Pop();
Result receiver = Pop();
PrepareForCall(0, 0);
MoveResultsToRegisters(&key, &receiver, eax, edx);
Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize));
return RawCallCodeObject(ic, mode);
}
Result VirtualFrame::CallStoreIC(Handle<String> name, bool is_contextual) {
// Value and (if not contextual) receiver are on top of the frame.
// The IC expects name in ecx, value in eax, and receiver in edx.
Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize));
Result value = Pop();
if (is_contextual) {
PrepareForCall(0, 0);
value.ToRegister(eax);
__ mov(edx, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX)));
value.Unuse();
} else {
Result receiver = Pop();
PrepareForCall(0, 0);
MoveResultsToRegisters(&value, &receiver, eax, edx);
}
__ mov(ecx, name);
return RawCallCodeObject(ic, RelocInfo::CODE_TARGET);
}
Result VirtualFrame::CallKeyedStoreIC() {
// Value, key, and receiver are on the top of the frame. The IC
// expects value in eax, key in ecx, and receiver in edx.
Result value = Pop();
Result key = Pop();
Result receiver = Pop();
PrepareForCall(0, 0);
if (!cgen()->allocator()->is_used(eax) ||
(value.is_register() && value.reg().is(eax))) {
if (!cgen()->allocator()->is_used(eax)) {
value.ToRegister(eax);
}
MoveResultsToRegisters(&key, &receiver, ecx, edx);
value.Unuse();
} else if (!cgen()->allocator()->is_used(ecx) ||
(key.is_register() && key.reg().is(ecx))) {
if (!cgen()->allocator()->is_used(ecx)) {
key.ToRegister(ecx);
}
MoveResultsToRegisters(&value, &receiver, eax, edx);
key.Unuse();
} else if (!cgen()->allocator()->is_used(edx) ||
(receiver.is_register() && receiver.reg().is(edx))) {
if (!cgen()->allocator()->is_used(edx)) {
receiver.ToRegister(edx);
}
MoveResultsToRegisters(&key, &value, ecx, eax);
receiver.Unuse();
} else {
// All three registers are used, and no value is in the correct place.
// We have one of the two circular permutations of eax, ecx, edx.
ASSERT(value.is_register());
if (value.reg().is(ecx)) {
__ xchg(eax, edx);
__ xchg(eax, ecx);
} else {
__ xchg(eax, ecx);
__ xchg(eax, edx);
}
value.Unuse();
key.Unuse();
receiver.Unuse();
}
Handle<Code> ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize));
return RawCallCodeObject(ic, RelocInfo::CODE_TARGET);
}
Result VirtualFrame::CallCallIC(RelocInfo::Mode mode,
int arg_count,
int loop_nesting) {
// Function name, arguments, and receiver are on top of the frame.
// The IC expects the name in ecx and the rest on the stack and
// drops them all.
InLoopFlag in_loop = loop_nesting > 0 ? IN_LOOP : NOT_IN_LOOP;
Handle<Code> ic = StubCache::ComputeCallInitialize(arg_count, in_loop);
// Spill args, receiver, and function. The call will drop args and
// receiver.
Result name = Pop();
PrepareForCall(arg_count + 1, arg_count + 1); // Arguments + receiver.
name.ToRegister(ecx);
name.Unuse();
return RawCallCodeObject(ic, mode);
}
Result VirtualFrame::CallKeyedCallIC(RelocInfo::Mode mode,
int arg_count,
int loop_nesting) {
// Function name, arguments, and receiver are on top of the frame.
// The IC expects the name in ecx and the rest on the stack and
// drops them all.
InLoopFlag in_loop = loop_nesting > 0 ? IN_LOOP : NOT_IN_LOOP;
Handle<Code> ic = StubCache::ComputeKeyedCallInitialize(arg_count, in_loop);
// Spill args, receiver, and function. The call will drop args and
// receiver.
Result name = Pop();
PrepareForCall(arg_count + 1, arg_count + 1); // Arguments + receiver.
name.ToRegister(ecx);
name.Unuse();
return RawCallCodeObject(ic, mode);
}
Result VirtualFrame::CallConstructor(int arg_count) {
// Arguments, receiver, and function are on top of the frame. The
// IC expects arg count in eax, function in edi, and the arguments
// and receiver on the stack.
Handle<Code> ic(Builtins::builtin(Builtins::JSConstructCall));
// Duplicate the function before preparing the frame.
PushElementAt(arg_count);
Result function = Pop();
PrepareForCall(arg_count + 1, arg_count + 1); // Spill function and args.
function.ToRegister(edi);
// Constructors are called with the number of arguments in register
// eax for now. Another option would be to have separate construct
// call trampolines per different arguments counts encountered.
Result num_args = cgen()->allocator()->Allocate(eax);
ASSERT(num_args.is_valid());
__ Set(num_args.reg(), Immediate(arg_count));
function.Unuse();
num_args.Unuse();
return RawCallCodeObject(ic, RelocInfo::CONSTRUCT_CALL);
}
void VirtualFrame::Drop(int count) {
ASSERT(count >= 0);
ASSERT(height() >= count);
int num_virtual_elements = (element_count() - 1) - stack_pointer_;
// Emit code to lower the stack pointer if necessary.
if (num_virtual_elements < count) {
int num_dropped = count - num_virtual_elements;
stack_pointer_ -= num_dropped;
__ add(Operand(esp), Immediate(num_dropped * kPointerSize));
}
// Discard elements from the virtual frame and free any registers.
for (int i = 0; i < count; i++) {
FrameElement dropped = elements_.RemoveLast();
if (dropped.is_register()) {
Unuse(dropped.reg());
}
}
}
Result VirtualFrame::Pop() {
FrameElement element = elements_.RemoveLast();
int index = element_count();
ASSERT(element.is_valid());
ASSERT(element.is_untagged_int32() == cgen()->in_safe_int32_mode());
// Get number type information of the result.
TypeInfo info;
if (!element.is_copy()) {
info = element.type_info();
} else {
info = elements_[element.index()].type_info();
}
bool pop_needed = (stack_pointer_ == index);
if (pop_needed) {
stack_pointer_--;
if (element.is_memory()) {
Result temp = cgen()->allocator()->Allocate();
ASSERT(temp.is_valid());
__ pop(temp.reg());
temp.set_type_info(info);
temp.set_untagged_int32(element.is_untagged_int32());
return temp;
}
__ add(Operand(esp), Immediate(kPointerSize));
}
ASSERT(!element.is_memory());
// The top element is a register, constant, or a copy. Unuse
// registers and follow copies to their backing store.
if (element.is_register()) {
Unuse(element.reg());
} else if (element.is_copy()) {
ASSERT(!element.is_untagged_int32());
ASSERT(element.index() < index);
index = element.index();
element = elements_[index];
}
ASSERT(!element.is_copy());
// The element is memory, a register, or a constant.
if (element.is_memory()) {
// Memory elements could only be the backing store of a copy.
// Allocate the original to a register.
ASSERT(index <= stack_pointer_);
ASSERT(!element.is_untagged_int32());
Result temp = cgen()->allocator()->Allocate();
ASSERT(temp.is_valid());
Use(temp.reg(), index);
FrameElement new_element =
FrameElement::RegisterElement(temp.reg(),
FrameElement::SYNCED,
element.type_info());
// Preserve the copy flag on the element.
if (element.is_copied()) new_element.set_copied();
elements_[index] = new_element;
__ mov(temp.reg(), Operand(ebp, fp_relative(index)));
return Result(temp.reg(), info);
} else if (element.is_register()) {
Result return_value(element.reg(), info);
return_value.set_untagged_int32(element.is_untagged_int32());
return return_value;
} else {
ASSERT(element.is_constant());
Result return_value(element.handle());
return_value.set_untagged_int32(element.is_untagged_int32());
return return_value;
}
}
void VirtualFrame::EmitPop(Register reg) {
ASSERT(stack_pointer_ == element_count() - 1);
stack_pointer_--;
elements_.RemoveLast();
__ pop(reg);
}
void VirtualFrame::EmitPop(Operand operand) {
ASSERT(stack_pointer_ == element_count() - 1);
stack_pointer_--;
elements_.RemoveLast();
__ pop(operand);
}
void VirtualFrame::EmitPush(Register reg, TypeInfo info) {
ASSERT(stack_pointer_ == element_count() - 1);
elements_.Add(FrameElement::MemoryElement(info));
stack_pointer_++;
__ push(reg);
}
void VirtualFrame::EmitPush(Operand operand, TypeInfo info) {
ASSERT(stack_pointer_ == element_count() - 1);
elements_.Add(FrameElement::MemoryElement(info));
stack_pointer_++;
__ push(operand);
}
void VirtualFrame::EmitPush(Immediate immediate, TypeInfo info) {
ASSERT(stack_pointer_ == element_count() - 1);
elements_.Add(FrameElement::MemoryElement(info));
stack_pointer_++;
__ push(immediate);
}
void VirtualFrame::PushUntaggedElement(Handle<Object> value) {
elements_.Add(FrameElement::ConstantElement(value, FrameElement::NOT_SYNCED));
elements_[element_count() - 1].set_untagged_int32(true);
}
void VirtualFrame::Push(Expression* expr) {
ASSERT(expr->IsTrivial());
Literal* lit = expr->AsLiteral();
if (lit != NULL) {
Push(lit->handle());
return;
}
VariableProxy* proxy = expr->AsVariableProxy();
if (proxy != NULL) {
Slot* slot = proxy->var()->AsSlot();
if (slot->type() == Slot::LOCAL) {
PushLocalAt(slot->index());
return;
}
if (slot->type() == Slot::PARAMETER) {
PushParameterAt(slot->index());
return;
}
}
UNREACHABLE();
}
#undef __
} } // namespace v8::internal
#endif // V8_TARGET_ARCH_IA32
|