Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/full-codegen/mips/full-codegen-mips.cc

Issue 1553703002: [runtime] TailCallRuntime and CallRuntime should use default argument counts (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@2015-12-29_TailCallRuntime_default_result_size_1_1550923002
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #if V8_TARGET_ARCH_MIPS 5 #if V8_TARGET_ARCH_MIPS
6 6
7 // Note on Mips implementation: 7 // Note on Mips implementation:
8 // 8 //
9 // The result_register() for mips is the 'v0' register, which is defined 9 // The result_register() for mips is the 'v0' register, which is defined
10 // by the ABI to contain function return values. However, the first 10 // by the ABI to contain function return values. However, the first
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 { Comment cmnt(masm_, "[ Allocate locals"); 145 { Comment cmnt(masm_, "[ Allocate locals");
146 int locals_count = info->scope()->num_stack_slots(); 146 int locals_count = info->scope()->num_stack_slots();
147 // Generators allocate locals, if any, in context slots. 147 // Generators allocate locals, if any, in context slots.
148 DCHECK(!IsGeneratorFunction(info->literal()->kind()) || locals_count == 0); 148 DCHECK(!IsGeneratorFunction(info->literal()->kind()) || locals_count == 0);
149 if (locals_count > 0) { 149 if (locals_count > 0) {
150 if (locals_count >= 128) { 150 if (locals_count >= 128) {
151 Label ok; 151 Label ok;
152 __ Subu(t5, sp, Operand(locals_count * kPointerSize)); 152 __ Subu(t5, sp, Operand(locals_count * kPointerSize));
153 __ LoadRoot(a2, Heap::kRealStackLimitRootIndex); 153 __ LoadRoot(a2, Heap::kRealStackLimitRootIndex);
154 __ Branch(&ok, hs, t5, Operand(a2)); 154 __ Branch(&ok, hs, t5, Operand(a2));
155 __ CallRuntime(Runtime::kThrowStackOverflow, 0); 155 __ CallRuntime(Runtime::kThrowStackOverflow);
156 __ bind(&ok); 156 __ bind(&ok);
157 } 157 }
158 __ LoadRoot(t5, Heap::kUndefinedValueRootIndex); 158 __ LoadRoot(t5, Heap::kUndefinedValueRootIndex);
159 int kMaxPushes = FLAG_optimize_for_size ? 4 : 32; 159 int kMaxPushes = FLAG_optimize_for_size ? 4 : 32;
160 if (locals_count >= kMaxPushes) { 160 if (locals_count >= kMaxPushes) {
161 int loop_iterations = locals_count / kMaxPushes; 161 int loop_iterations = locals_count / kMaxPushes;
162 __ li(a2, Operand(loop_iterations)); 162 __ li(a2, Operand(loop_iterations));
163 Label loop_header; 163 Label loop_header;
164 __ bind(&loop_header); 164 __ bind(&loop_header);
165 // Do pushes. 165 // Do pushes.
(...skipping 18 matching lines...) Expand all
184 184
185 // Possibly allocate a local context. 185 // Possibly allocate a local context.
186 if (info->scope()->num_heap_slots() > 0) { 186 if (info->scope()->num_heap_slots() > 0) {
187 Comment cmnt(masm_, "[ Allocate context"); 187 Comment cmnt(masm_, "[ Allocate context");
188 // Argument to NewContext is the function, which is still in a1. 188 // Argument to NewContext is the function, which is still in a1.
189 bool need_write_barrier = true; 189 bool need_write_barrier = true;
190 int slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; 190 int slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS;
191 if (info->scope()->is_script_scope()) { 191 if (info->scope()->is_script_scope()) {
192 __ push(a1); 192 __ push(a1);
193 __ Push(info->scope()->GetScopeInfo(info->isolate())); 193 __ Push(info->scope()->GetScopeInfo(info->isolate()));
194 __ CallRuntime(Runtime::kNewScriptContext, 2); 194 __ CallRuntime(Runtime::kNewScriptContext);
195 PrepareForBailoutForId(BailoutId::ScriptContext(), TOS_REG); 195 PrepareForBailoutForId(BailoutId::ScriptContext(), TOS_REG);
196 // The new target value is not used, clobbering is safe. 196 // The new target value is not used, clobbering is safe.
197 DCHECK_NULL(info->scope()->new_target_var()); 197 DCHECK_NULL(info->scope()->new_target_var());
198 } else { 198 } else {
199 if (info->scope()->new_target_var() != nullptr) { 199 if (info->scope()->new_target_var() != nullptr) {
200 __ push(a3); // Preserve new target. 200 __ push(a3); // Preserve new target.
201 } 201 }
202 if (slots <= FastNewContextStub::kMaximumSlots) { 202 if (slots <= FastNewContextStub::kMaximumSlots) {
203 FastNewContextStub stub(isolate(), slots); 203 FastNewContextStub stub(isolate(), slots);
204 __ CallStub(&stub); 204 __ CallStub(&stub);
205 // Result of FastNewContextStub is always in new space. 205 // Result of FastNewContextStub is always in new space.
206 need_write_barrier = false; 206 need_write_barrier = false;
207 } else { 207 } else {
208 __ push(a1); 208 __ push(a1);
209 __ CallRuntime(Runtime::kNewFunctionContext, 1); 209 __ CallRuntime(Runtime::kNewFunctionContext);
210 } 210 }
211 if (info->scope()->new_target_var() != nullptr) { 211 if (info->scope()->new_target_var() != nullptr) {
212 __ pop(a3); // Restore new target. 212 __ pop(a3); // Restore new target.
213 } 213 }
214 } 214 }
215 function_in_register_a1 = false; 215 function_in_register_a1 = false;
216 // Context is returned in v0. It replaces the context passed to us. 216 // Context is returned in v0. It replaces the context passed to us.
217 // It's saved in the stack and kept live in cp. 217 // It's saved in the stack and kept live in cp.
218 __ mov(cp, v0); 218 __ mov(cp, v0);
219 __ sw(v0, MemOperand(fp, StandardFrameConstants::kContextOffset)); 219 __ sw(v0, MemOperand(fp, StandardFrameConstants::kContextOffset));
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 bool is_unmapped = is_strict(language_mode()) || !has_simple_parameters(); 315 bool is_unmapped = is_strict(language_mode()) || !has_simple_parameters();
316 ArgumentsAccessStub::Type type = ArgumentsAccessStub::ComputeType( 316 ArgumentsAccessStub::Type type = ArgumentsAccessStub::ComputeType(
317 is_unmapped, literal()->has_duplicate_parameters()); 317 is_unmapped, literal()->has_duplicate_parameters());
318 ArgumentsAccessStub stub(isolate(), type); 318 ArgumentsAccessStub stub(isolate(), type);
319 __ CallStub(&stub); 319 __ CallStub(&stub);
320 320
321 SetVar(arguments, v0, a1, a2); 321 SetVar(arguments, v0, a1, a2);
322 } 322 }
323 323
324 if (FLAG_trace) { 324 if (FLAG_trace) {
325 __ CallRuntime(Runtime::kTraceEnter, 0); 325 __ CallRuntime(Runtime::kTraceEnter);
326 } 326 }
327 327
328 // Visit the declarations and body unless there is an illegal 328 // Visit the declarations and body unless there is an illegal
329 // redeclaration. 329 // redeclaration.
330 if (scope()->HasIllegalRedeclaration()) { 330 if (scope()->HasIllegalRedeclaration()) {
331 Comment cmnt(masm_, "[ Declarations"); 331 Comment cmnt(masm_, "[ Declarations");
332 VisitForEffect(scope()->GetIllegalRedeclaration()); 332 VisitForEffect(scope()->GetIllegalRedeclaration());
333 333
334 } else { 334 } else {
335 PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS); 335 PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 void FullCodeGenerator::EmitReturnSequence() { 433 void FullCodeGenerator::EmitReturnSequence() {
434 Comment cmnt(masm_, "[ Return sequence"); 434 Comment cmnt(masm_, "[ Return sequence");
435 if (return_label_.is_bound()) { 435 if (return_label_.is_bound()) {
436 __ Branch(&return_label_); 436 __ Branch(&return_label_);
437 } else { 437 } else {
438 __ bind(&return_label_); 438 __ bind(&return_label_);
439 if (FLAG_trace) { 439 if (FLAG_trace) {
440 // Push the return value on the stack as the parameter. 440 // Push the return value on the stack as the parameter.
441 // Runtime::TraceExit returns its parameter in v0. 441 // Runtime::TraceExit returns its parameter in v0.
442 __ push(v0); 442 __ push(v0);
443 __ CallRuntime(Runtime::kTraceExit, 1); 443 __ CallRuntime(Runtime::kTraceExit);
444 } 444 }
445 // Pretend that the exit is a backwards jump to the entry. 445 // Pretend that the exit is a backwards jump to the entry.
446 int weight = 1; 446 int weight = 1;
447 if (info_->ShouldSelfOptimize()) { 447 if (info_->ShouldSelfOptimize()) {
448 weight = FLAG_interrupt_budget / FLAG_self_opt_count; 448 weight = FLAG_interrupt_budget / FLAG_self_opt_count;
449 } else { 449 } else {
450 int distance = masm_->pc_offset(); 450 int distance = masm_->pc_offset();
451 weight = Min(kMaxBackEdgeWeight, 451 weight = Min(kMaxBackEdgeWeight,
452 Max(1, distance / kCodeSizeMultiplier)); 452 Max(1, distance / kCodeSizeMultiplier));
453 } 453 }
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 // 'undefined') because we may have a (legal) redeclaration and we 843 // 'undefined') because we may have a (legal) redeclaration and we
844 // must not destroy the current value. 844 // must not destroy the current value.
845 if (hole_init) { 845 if (hole_init) {
846 __ LoadRoot(a0, Heap::kTheHoleValueRootIndex); 846 __ LoadRoot(a0, Heap::kTheHoleValueRootIndex);
847 } else { 847 } else {
848 DCHECK(Smi::FromInt(0) == 0); 848 DCHECK(Smi::FromInt(0) == 0);
849 __ mov(a0, zero_reg); // Smi::FromInt(0) indicates no initial value. 849 __ mov(a0, zero_reg); // Smi::FromInt(0) indicates no initial value.
850 } 850 }
851 __ Push(a2, a0); 851 __ Push(a2, a0);
852 __ Push(Smi::FromInt(variable->DeclarationPropertyAttributes())); 852 __ Push(Smi::FromInt(variable->DeclarationPropertyAttributes()));
853 __ CallRuntime(Runtime::kDeclareLookupSlot, 3); 853 __ CallRuntime(Runtime::kDeclareLookupSlot);
854 break; 854 break;
855 } 855 }
856 } 856 }
857 } 857 }
858 858
859 859
860 void FullCodeGenerator::VisitFunctionDeclaration( 860 void FullCodeGenerator::VisitFunctionDeclaration(
861 FunctionDeclaration* declaration) { 861 FunctionDeclaration* declaration) {
862 VariableProxy* proxy = declaration->proxy(); 862 VariableProxy* proxy = declaration->proxy();
863 Variable* variable = proxy->var(); 863 Variable* variable = proxy->var();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 break; 900 break;
901 } 901 }
902 902
903 case VariableLocation::LOOKUP: { 903 case VariableLocation::LOOKUP: {
904 Comment cmnt(masm_, "[ FunctionDeclaration"); 904 Comment cmnt(masm_, "[ FunctionDeclaration");
905 __ li(a2, Operand(variable->name())); 905 __ li(a2, Operand(variable->name()));
906 __ Push(a2); 906 __ Push(a2);
907 // Push initial value for function declaration. 907 // Push initial value for function declaration.
908 VisitForStackValue(declaration->fun()); 908 VisitForStackValue(declaration->fun());
909 __ Push(Smi::FromInt(variable->DeclarationPropertyAttributes())); 909 __ Push(Smi::FromInt(variable->DeclarationPropertyAttributes()));
910 __ CallRuntime(Runtime::kDeclareLookupSlot, 3); 910 __ CallRuntime(Runtime::kDeclareLookupSlot);
911 break; 911 break;
912 } 912 }
913 } 913 }
914 } 914 }
915 915
916 916
917 void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) { 917 void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) {
918 // Call the runtime to declare the globals. 918 // Call the runtime to declare the globals.
919 __ li(a1, Operand(pairs)); 919 __ li(a1, Operand(pairs));
920 __ li(a0, Operand(Smi::FromInt(DeclareGlobalsFlags()))); 920 __ li(a0, Operand(Smi::FromInt(DeclareGlobalsFlags())));
921 __ Push(a1, a0); 921 __ Push(a1, a0);
922 __ CallRuntime(Runtime::kDeclareGlobals, 2); 922 __ CallRuntime(Runtime::kDeclareGlobals);
923 // Return value is ignored. 923 // Return value is ignored.
924 } 924 }
925 925
926 926
927 void FullCodeGenerator::DeclareModules(Handle<FixedArray> descriptions) { 927 void FullCodeGenerator::DeclareModules(Handle<FixedArray> descriptions) {
928 // Call the runtime to declare the modules. 928 // Call the runtime to declare the modules.
929 __ Push(descriptions); 929 __ Push(descriptions);
930 __ CallRuntime(Runtime::kDeclareModules, 1); 930 __ CallRuntime(Runtime::kDeclareModules);
931 // Return value is ignored. 931 // Return value is ignored.
932 } 932 }
933 933
934 934
935 void FullCodeGenerator::VisitSwitchStatement(SwitchStatement* stmt) { 935 void FullCodeGenerator::VisitSwitchStatement(SwitchStatement* stmt) {
936 Comment cmnt(masm_, "[ SwitchStatement"); 936 Comment cmnt(masm_, "[ SwitchStatement");
937 Breakable nested_statement(this, stmt); 937 Breakable nested_statement(this, stmt);
938 SetStatementPosition(stmt); 938 SetStatementPosition(stmt);
939 939
940 // Keep the switch value on the stack until a case matches. 940 // Keep the switch value on the stack until a case matches.
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 1073
1074 // The enum cache is valid. Load the map of the object being 1074 // The enum cache is valid. Load the map of the object being
1075 // iterated over and use the cache for the iteration. 1075 // iterated over and use the cache for the iteration.
1076 Label use_cache; 1076 Label use_cache;
1077 __ lw(v0, FieldMemOperand(a0, HeapObject::kMapOffset)); 1077 __ lw(v0, FieldMemOperand(a0, HeapObject::kMapOffset));
1078 __ Branch(&use_cache); 1078 __ Branch(&use_cache);
1079 1079
1080 // Get the set of properties to enumerate. 1080 // Get the set of properties to enumerate.
1081 __ bind(&call_runtime); 1081 __ bind(&call_runtime);
1082 __ push(a0); // Duplicate the enumerable object on the stack. 1082 __ push(a0); // Duplicate the enumerable object on the stack.
1083 __ CallRuntime(Runtime::kGetPropertyNamesFast, 1); 1083 __ CallRuntime(Runtime::kGetPropertyNamesFast);
1084 PrepareForBailoutForId(stmt->EnumId(), TOS_REG); 1084 PrepareForBailoutForId(stmt->EnumId(), TOS_REG);
1085 1085
1086 // If we got a map from the runtime call, we can do a fast 1086 // If we got a map from the runtime call, we can do a fast
1087 // modification check. Otherwise, we got a fixed array, and we have 1087 // modification check. Otherwise, we got a fixed array, and we have
1088 // to do a slow check. 1088 // to do a slow check.
1089 Label fixed_array; 1089 Label fixed_array;
1090 __ lw(a2, FieldMemOperand(v0, HeapObject::kMapOffset)); 1090 __ lw(a2, FieldMemOperand(v0, HeapObject::kMapOffset));
1091 __ LoadRoot(at, Heap::kMetaMapRootIndex); 1091 __ LoadRoot(at, Heap::kMetaMapRootIndex);
1092 __ Branch(&fixed_array, ne, a2, Operand(at)); 1092 __ Branch(&fixed_array, ne, a2, Operand(at));
1093 1093
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 // If not, we may have to filter the key. 1150 // If not, we may have to filter the key.
1151 Label update_each; 1151 Label update_each;
1152 __ lw(a1, MemOperand(sp, 4 * kPointerSize)); 1152 __ lw(a1, MemOperand(sp, 4 * kPointerSize));
1153 __ lw(t0, FieldMemOperand(a1, HeapObject::kMapOffset)); 1153 __ lw(t0, FieldMemOperand(a1, HeapObject::kMapOffset));
1154 __ Branch(&update_each, eq, t0, Operand(a2)); 1154 __ Branch(&update_each, eq, t0, Operand(a2));
1155 1155
1156 // Convert the entry to a string or (smi) 0 if it isn't a property 1156 // Convert the entry to a string or (smi) 0 if it isn't a property
1157 // any more. If the property has been removed while iterating, we 1157 // any more. If the property has been removed while iterating, we
1158 // just skip it. 1158 // just skip it.
1159 __ Push(a1, a3); // Enumerable and current entry. 1159 __ Push(a1, a3); // Enumerable and current entry.
1160 __ CallRuntime(Runtime::kForInFilter, 2); 1160 __ CallRuntime(Runtime::kForInFilter);
1161 PrepareForBailoutForId(stmt->FilterId(), TOS_REG); 1161 PrepareForBailoutForId(stmt->FilterId(), TOS_REG);
1162 __ mov(a3, result_register()); 1162 __ mov(a3, result_register());
1163 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); 1163 __ LoadRoot(at, Heap::kUndefinedValueRootIndex);
1164 __ Branch(loop_statement.continue_label(), eq, a3, Operand(at)); 1164 __ Branch(loop_statement.continue_label(), eq, a3, Operand(at));
1165 1165
1166 // Update the 'each' property or variable from the possibly filtered 1166 // Update the 'each' property or variable from the possibly filtered
1167 // entry in register a3. 1167 // entry in register a3.
1168 __ bind(&update_each); 1168 __ bind(&update_each);
1169 __ mov(result_register(), a3); 1169 __ mov(result_register(), a3);
1170 // Perform the assignment as if via '='. 1170 // Perform the assignment as if via '='.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 if (!FLAG_always_opt && 1210 if (!FLAG_always_opt &&
1211 !FLAG_prepare_always_opt && 1211 !FLAG_prepare_always_opt &&
1212 !pretenure && 1212 !pretenure &&
1213 scope()->is_function_scope() && 1213 scope()->is_function_scope() &&
1214 info->num_literals() == 0) { 1214 info->num_literals() == 0) {
1215 FastNewClosureStub stub(isolate(), info->language_mode(), info->kind()); 1215 FastNewClosureStub stub(isolate(), info->language_mode(), info->kind());
1216 __ li(a2, Operand(info)); 1216 __ li(a2, Operand(info));
1217 __ CallStub(&stub); 1217 __ CallStub(&stub);
1218 } else { 1218 } else {
1219 __ Push(info); 1219 __ Push(info);
1220 __ CallRuntime( 1220 __ CallRuntime(pretenure ? Runtime::kNewClosure_Tenured
1221 pretenure ? Runtime::kNewClosure_Tenured : Runtime::kNewClosure, 1); 1221 : Runtime::kNewClosure);
1222 } 1222 }
1223 context()->Plug(v0); 1223 context()->Plug(v0);
1224 } 1224 }
1225 1225
1226 1226
1227 void FullCodeGenerator::EmitSetHomeObject(Expression* initializer, int offset, 1227 void FullCodeGenerator::EmitSetHomeObject(Expression* initializer, int offset,
1228 FeedbackVectorSlot slot) { 1228 FeedbackVectorSlot slot) {
1229 DCHECK(NeedsHomeObject(initializer)); 1229 DCHECK(NeedsHomeObject(initializer));
1230 __ lw(StoreDescriptor::ReceiverRegister(), MemOperand(sp)); 1230 __ lw(StoreDescriptor::ReceiverRegister(), MemOperand(sp));
1231 __ li(StoreDescriptor::NameRegister(), 1231 __ li(StoreDescriptor::NameRegister(),
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1351 local->mode() == CONST_LEGACY) { 1351 local->mode() == CONST_LEGACY) {
1352 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); 1352 __ LoadRoot(at, Heap::kTheHoleValueRootIndex);
1353 __ subu(at, v0, at); // Sub as compare: at == 0 on eq. 1353 __ subu(at, v0, at); // Sub as compare: at == 0 on eq.
1354 if (local->mode() == CONST_LEGACY) { 1354 if (local->mode() == CONST_LEGACY) {
1355 __ LoadRoot(a0, Heap::kUndefinedValueRootIndex); 1355 __ LoadRoot(a0, Heap::kUndefinedValueRootIndex);
1356 __ Movz(v0, a0, at); // Conditional move: return Undefined if TheHole. 1356 __ Movz(v0, a0, at); // Conditional move: return Undefined if TheHole.
1357 } else { // LET || CONST 1357 } else { // LET || CONST
1358 __ Branch(done, ne, at, Operand(zero_reg)); 1358 __ Branch(done, ne, at, Operand(zero_reg));
1359 __ li(a0, Operand(var->name())); 1359 __ li(a0, Operand(var->name()));
1360 __ push(a0); 1360 __ push(a0);
1361 __ CallRuntime(Runtime::kThrowReferenceError, 1); 1361 __ CallRuntime(Runtime::kThrowReferenceError);
1362 } 1362 }
1363 } 1363 }
1364 __ Branch(done); 1364 __ Branch(done);
1365 } 1365 }
1366 } 1366 }
1367 1367
1368 1368
1369 void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy, 1369 void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy,
1370 TypeofMode typeof_mode) { 1370 TypeofMode typeof_mode) {
1371 Variable* var = proxy->var(); 1371 Variable* var = proxy->var();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1408 GetVar(v0, var); 1408 GetVar(v0, var);
1409 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); 1409 __ LoadRoot(at, Heap::kTheHoleValueRootIndex);
1410 __ subu(at, v0, at); // Sub as compare: at == 0 on eq. 1410 __ subu(at, v0, at); // Sub as compare: at == 0 on eq.
1411 if (var->mode() == LET || var->mode() == CONST) { 1411 if (var->mode() == LET || var->mode() == CONST) {
1412 // Throw a reference error when using an uninitialized let/const 1412 // Throw a reference error when using an uninitialized let/const
1413 // binding in harmony mode. 1413 // binding in harmony mode.
1414 Label done; 1414 Label done;
1415 __ Branch(&done, ne, at, Operand(zero_reg)); 1415 __ Branch(&done, ne, at, Operand(zero_reg));
1416 __ li(a0, Operand(var->name())); 1416 __ li(a0, Operand(var->name()));
1417 __ push(a0); 1417 __ push(a0);
1418 __ CallRuntime(Runtime::kThrowReferenceError, 1); 1418 __ CallRuntime(Runtime::kThrowReferenceError);
1419 __ bind(&done); 1419 __ bind(&done);
1420 } else { 1420 } else {
1421 // Uninitialized legacy const bindings are unholed. 1421 // Uninitialized legacy const bindings are unholed.
1422 DCHECK(var->mode() == CONST_LEGACY); 1422 DCHECK(var->mode() == CONST_LEGACY);
1423 __ LoadRoot(a0, Heap::kUndefinedValueRootIndex); 1423 __ LoadRoot(a0, Heap::kUndefinedValueRootIndex);
1424 __ Movz(v0, a0, at); // Conditional move: Undefined if TheHole. 1424 __ Movz(v0, a0, at); // Conditional move: Undefined if TheHole.
1425 } 1425 }
1426 context()->Plug(v0); 1426 context()->Plug(v0);
1427 break; 1427 break;
1428 } 1428 }
1429 context()->Plug(var); 1429 context()->Plug(var);
1430 break; 1430 break;
1431 } 1431 }
1432 1432
1433 case VariableLocation::LOOKUP: { 1433 case VariableLocation::LOOKUP: {
1434 Comment cmnt(masm_, "[ Lookup variable"); 1434 Comment cmnt(masm_, "[ Lookup variable");
1435 Label done, slow; 1435 Label done, slow;
1436 // Generate code for loading from variables potentially shadowed 1436 // Generate code for loading from variables potentially shadowed
1437 // by eval-introduced variables. 1437 // by eval-introduced variables.
1438 EmitDynamicLookupFastCase(proxy, typeof_mode, &slow, &done); 1438 EmitDynamicLookupFastCase(proxy, typeof_mode, &slow, &done);
1439 __ bind(&slow); 1439 __ bind(&slow);
1440 __ li(a1, Operand(var->name())); 1440 __ li(a1, Operand(var->name()));
1441 __ Push(cp, a1); // Context and name. 1441 __ Push(cp, a1); // Context and name.
1442 Runtime::FunctionId function_id = 1442 Runtime::FunctionId function_id =
1443 typeof_mode == NOT_INSIDE_TYPEOF 1443 typeof_mode == NOT_INSIDE_TYPEOF
1444 ? Runtime::kLoadLookupSlot 1444 ? Runtime::kLoadLookupSlot
1445 : Runtime::kLoadLookupSlotNoReferenceError; 1445 : Runtime::kLoadLookupSlotNoReferenceError;
1446 __ CallRuntime(function_id, 2); 1446 __ CallRuntime(function_id);
1447 __ bind(&done); 1447 __ bind(&done);
1448 context()->Plug(v0); 1448 context()->Plug(v0);
1449 } 1449 }
1450 } 1450 }
1451 } 1451 }
1452 1452
1453 1453
1454 void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { 1454 void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) {
1455 Comment cmnt(masm_, "[ RegExpLiteral"); 1455 Comment cmnt(masm_, "[ RegExpLiteral");
1456 __ lw(a3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); 1456 __ lw(a3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
(...skipping 26 matching lines...) Expand all
1483 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { 1483 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
1484 Comment cmnt(masm_, "[ ObjectLiteral"); 1484 Comment cmnt(masm_, "[ ObjectLiteral");
1485 1485
1486 Handle<FixedArray> constant_properties = expr->constant_properties(); 1486 Handle<FixedArray> constant_properties = expr->constant_properties();
1487 __ lw(a3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); 1487 __ lw(a3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
1488 __ li(a2, Operand(Smi::FromInt(expr->literal_index()))); 1488 __ li(a2, Operand(Smi::FromInt(expr->literal_index())));
1489 __ li(a1, Operand(constant_properties)); 1489 __ li(a1, Operand(constant_properties));
1490 __ li(a0, Operand(Smi::FromInt(expr->ComputeFlags()))); 1490 __ li(a0, Operand(Smi::FromInt(expr->ComputeFlags())));
1491 if (MustCreateObjectLiteralWithRuntime(expr)) { 1491 if (MustCreateObjectLiteralWithRuntime(expr)) {
1492 __ Push(a3, a2, a1, a0); 1492 __ Push(a3, a2, a1, a0);
1493 __ CallRuntime(Runtime::kCreateObjectLiteral, 4); 1493 __ CallRuntime(Runtime::kCreateObjectLiteral);
1494 } else { 1494 } else {
1495 FastCloneShallowObjectStub stub(isolate(), expr->properties_count()); 1495 FastCloneShallowObjectStub stub(isolate(), expr->properties_count());
1496 __ CallStub(&stub); 1496 __ CallStub(&stub);
1497 } 1497 }
1498 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); 1498 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG);
1499 1499
1500 // If result_saved is true the result is on top of the stack. If 1500 // If result_saved is true the result is on top of the stack. If
1501 // result_saved is false the result is in v0. 1501 // result_saved is false the result is in v0.
1502 bool result_saved = false; 1502 bool result_saved = false;
1503 1503
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1546 __ lw(a0, MemOperand(sp)); 1546 __ lw(a0, MemOperand(sp));
1547 __ push(a0); 1547 __ push(a0);
1548 VisitForStackValue(key); 1548 VisitForStackValue(key);
1549 VisitForStackValue(value); 1549 VisitForStackValue(value);
1550 if (property->emit_store()) { 1550 if (property->emit_store()) {
1551 if (NeedsHomeObject(value)) { 1551 if (NeedsHomeObject(value)) {
1552 EmitSetHomeObject(value, 2, property->GetSlot()); 1552 EmitSetHomeObject(value, 2, property->GetSlot());
1553 } 1553 }
1554 __ li(a0, Operand(Smi::FromInt(SLOPPY))); // PropertyAttributes. 1554 __ li(a0, Operand(Smi::FromInt(SLOPPY))); // PropertyAttributes.
1555 __ push(a0); 1555 __ push(a0);
1556 __ CallRuntime(Runtime::kSetProperty, 4); 1556 __ CallRuntime(Runtime::kSetProperty);
1557 } else { 1557 } else {
1558 __ Drop(3); 1558 __ Drop(3);
1559 } 1559 }
1560 break; 1560 break;
1561 case ObjectLiteral::Property::PROTOTYPE: 1561 case ObjectLiteral::Property::PROTOTYPE:
1562 // Duplicate receiver on stack. 1562 // Duplicate receiver on stack.
1563 __ lw(a0, MemOperand(sp)); 1563 __ lw(a0, MemOperand(sp));
1564 __ push(a0); 1564 __ push(a0);
1565 VisitForStackValue(value); 1565 VisitForStackValue(value);
1566 DCHECK(property->emit_store()); 1566 DCHECK(property->emit_store());
1567 __ CallRuntime(Runtime::kInternalSetPrototype, 2); 1567 __ CallRuntime(Runtime::kInternalSetPrototype);
1568 break; 1568 break;
1569 case ObjectLiteral::Property::GETTER: 1569 case ObjectLiteral::Property::GETTER:
1570 if (property->emit_store()) { 1570 if (property->emit_store()) {
1571 accessor_table.lookup(key)->second->getter = property; 1571 accessor_table.lookup(key)->second->getter = property;
1572 } 1572 }
1573 break; 1573 break;
1574 case ObjectLiteral::Property::SETTER: 1574 case ObjectLiteral::Property::SETTER:
1575 if (property->emit_store()) { 1575 if (property->emit_store()) {
1576 accessor_table.lookup(key)->second->setter = property; 1576 accessor_table.lookup(key)->second->setter = property;
1577 } 1577 }
1578 break; 1578 break;
1579 } 1579 }
1580 } 1580 }
1581 1581
1582 // Emit code to define accessors, using only a single call to the runtime for 1582 // Emit code to define accessors, using only a single call to the runtime for
1583 // each pair of corresponding getters and setters. 1583 // each pair of corresponding getters and setters.
1584 for (AccessorTable::Iterator it = accessor_table.begin(); 1584 for (AccessorTable::Iterator it = accessor_table.begin();
1585 it != accessor_table.end(); 1585 it != accessor_table.end();
1586 ++it) { 1586 ++it) {
1587 __ lw(a0, MemOperand(sp)); // Duplicate receiver. 1587 __ lw(a0, MemOperand(sp)); // Duplicate receiver.
1588 __ push(a0); 1588 __ push(a0);
1589 VisitForStackValue(it->first); 1589 VisitForStackValue(it->first);
1590 EmitAccessor(it->second->getter); 1590 EmitAccessor(it->second->getter);
1591 EmitAccessor(it->second->setter); 1591 EmitAccessor(it->second->setter);
1592 __ li(a0, Operand(Smi::FromInt(NONE))); 1592 __ li(a0, Operand(Smi::FromInt(NONE)));
1593 __ push(a0); 1593 __ push(a0);
1594 __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5); 1594 __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked);
1595 } 1595 }
1596 1596
1597 // Object literals have two parts. The "static" part on the left contains no 1597 // Object literals have two parts. The "static" part on the left contains no
1598 // computed property names, and so we can compute its map ahead of time; see 1598 // computed property names, and so we can compute its map ahead of time; see
1599 // runtime.cc::CreateObjectLiteralBoilerplate. The second "dynamic" part 1599 // runtime.cc::CreateObjectLiteralBoilerplate. The second "dynamic" part
1600 // starts with the first computed property name, and continues with all 1600 // starts with the first computed property name, and continues with all
1601 // properties to its right. All the code from above initializes the static 1601 // properties to its right. All the code from above initializes the static
1602 // component of the object literal, and arranges for the map of the result to 1602 // component of the object literal, and arranges for the map of the result to
1603 // reflect the static order in which the keys appear. For the dynamic 1603 // reflect the static order in which the keys appear. For the dynamic
1604 // properties, we compile them into a series of "SetOwnProperty" runtime 1604 // properties, we compile them into a series of "SetOwnProperty" runtime
1605 // calls. This will preserve insertion order. 1605 // calls. This will preserve insertion order.
1606 for (; property_index < expr->properties()->length(); property_index++) { 1606 for (; property_index < expr->properties()->length(); property_index++) {
1607 ObjectLiteral::Property* property = expr->properties()->at(property_index); 1607 ObjectLiteral::Property* property = expr->properties()->at(property_index);
1608 1608
1609 Expression* value = property->value(); 1609 Expression* value = property->value();
1610 if (!result_saved) { 1610 if (!result_saved) {
1611 __ push(v0); // Save result on the stack 1611 __ push(v0); // Save result on the stack
1612 result_saved = true; 1612 result_saved = true;
1613 } 1613 }
1614 1614
1615 __ lw(a0, MemOperand(sp)); // Duplicate receiver. 1615 __ lw(a0, MemOperand(sp)); // Duplicate receiver.
1616 __ push(a0); 1616 __ push(a0);
1617 1617
1618 if (property->kind() == ObjectLiteral::Property::PROTOTYPE) { 1618 if (property->kind() == ObjectLiteral::Property::PROTOTYPE) {
1619 DCHECK(!property->is_computed_name()); 1619 DCHECK(!property->is_computed_name());
1620 VisitForStackValue(value); 1620 VisitForStackValue(value);
1621 DCHECK(property->emit_store()); 1621 DCHECK(property->emit_store());
1622 __ CallRuntime(Runtime::kInternalSetPrototype, 2); 1622 __ CallRuntime(Runtime::kInternalSetPrototype);
1623 } else { 1623 } else {
1624 EmitPropertyKey(property, expr->GetIdForProperty(property_index)); 1624 EmitPropertyKey(property, expr->GetIdForProperty(property_index));
1625 VisitForStackValue(value); 1625 VisitForStackValue(value);
1626 if (NeedsHomeObject(value)) { 1626 if (NeedsHomeObject(value)) {
1627 EmitSetHomeObject(value, 2, property->GetSlot()); 1627 EmitSetHomeObject(value, 2, property->GetSlot());
1628 } 1628 }
1629 1629
1630 switch (property->kind()) { 1630 switch (property->kind()) {
1631 case ObjectLiteral::Property::CONSTANT: 1631 case ObjectLiteral::Property::CONSTANT:
1632 case ObjectLiteral::Property::MATERIALIZED_LITERAL: 1632 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
1633 case ObjectLiteral::Property::COMPUTED: 1633 case ObjectLiteral::Property::COMPUTED:
1634 if (property->emit_store()) { 1634 if (property->emit_store()) {
1635 __ li(a0, Operand(Smi::FromInt(NONE))); 1635 __ li(a0, Operand(Smi::FromInt(NONE)));
1636 __ push(a0); 1636 __ push(a0);
1637 __ CallRuntime(Runtime::kDefineDataPropertyUnchecked, 4); 1637 __ CallRuntime(Runtime::kDefineDataPropertyUnchecked);
1638 } else { 1638 } else {
1639 __ Drop(3); 1639 __ Drop(3);
1640 } 1640 }
1641 break; 1641 break;
1642 1642
1643 case ObjectLiteral::Property::PROTOTYPE: 1643 case ObjectLiteral::Property::PROTOTYPE:
1644 UNREACHABLE(); 1644 UNREACHABLE();
1645 break; 1645 break;
1646 1646
1647 case ObjectLiteral::Property::GETTER: 1647 case ObjectLiteral::Property::GETTER:
1648 __ li(a0, Operand(Smi::FromInt(NONE))); 1648 __ li(a0, Operand(Smi::FromInt(NONE)));
1649 __ push(a0); 1649 __ push(a0);
1650 __ CallRuntime(Runtime::kDefineGetterPropertyUnchecked, 4); 1650 __ CallRuntime(Runtime::kDefineGetterPropertyUnchecked);
1651 break; 1651 break;
1652 1652
1653 case ObjectLiteral::Property::SETTER: 1653 case ObjectLiteral::Property::SETTER:
1654 __ li(a0, Operand(Smi::FromInt(NONE))); 1654 __ li(a0, Operand(Smi::FromInt(NONE)));
1655 __ push(a0); 1655 __ push(a0);
1656 __ CallRuntime(Runtime::kDefineSetterPropertyUnchecked, 4); 1656 __ CallRuntime(Runtime::kDefineSetterPropertyUnchecked);
1657 break; 1657 break;
1658 } 1658 }
1659 } 1659 }
1660 } 1660 }
1661 1661
1662 if (expr->has_function()) { 1662 if (expr->has_function()) {
1663 DCHECK(result_saved); 1663 DCHECK(result_saved);
1664 __ lw(a0, MemOperand(sp)); 1664 __ lw(a0, MemOperand(sp));
1665 __ push(a0); 1665 __ push(a0);
1666 __ CallRuntime(Runtime::kToFastProperties, 1); 1666 __ CallRuntime(Runtime::kToFastProperties);
1667 } 1667 }
1668 1668
1669 if (result_saved) { 1669 if (result_saved) {
1670 context()->PlugTOS(); 1670 context()->PlugTOS();
1671 } else { 1671 } else {
1672 context()->Plug(v0); 1672 context()->Plug(v0);
1673 } 1673 }
1674 } 1674 }
1675 1675
1676 1676
(...skipping 11 matching lines...) Expand all
1688 allocation_site_mode = DONT_TRACK_ALLOCATION_SITE; 1688 allocation_site_mode = DONT_TRACK_ALLOCATION_SITE;
1689 } 1689 }
1690 1690
1691 __ mov(a0, result_register()); 1691 __ mov(a0, result_register());
1692 __ lw(a3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); 1692 __ lw(a3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
1693 __ li(a2, Operand(Smi::FromInt(expr->literal_index()))); 1693 __ li(a2, Operand(Smi::FromInt(expr->literal_index())));
1694 __ li(a1, Operand(constant_elements)); 1694 __ li(a1, Operand(constant_elements));
1695 if (MustCreateArrayLiteralWithRuntime(expr)) { 1695 if (MustCreateArrayLiteralWithRuntime(expr)) {
1696 __ li(a0, Operand(Smi::FromInt(expr->ComputeFlags()))); 1696 __ li(a0, Operand(Smi::FromInt(expr->ComputeFlags())));
1697 __ Push(a3, a2, a1, a0); 1697 __ Push(a3, a2, a1, a0);
1698 __ CallRuntime(Runtime::kCreateArrayLiteral, 4); 1698 __ CallRuntime(Runtime::kCreateArrayLiteral);
1699 } else { 1699 } else {
1700 FastCloneShallowArrayStub stub(isolate(), allocation_site_mode); 1700 FastCloneShallowArrayStub stub(isolate(), allocation_site_mode);
1701 __ CallStub(&stub); 1701 __ CallStub(&stub);
1702 } 1702 }
1703 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); 1703 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG);
1704 1704
1705 bool result_saved = false; // Is the result saved to the stack? 1705 bool result_saved = false; // Is the result saved to the stack?
1706 ZoneList<Expression*>* subexprs = expr->values(); 1706 ZoneList<Expression*>* subexprs = expr->values();
1707 int length = subexprs->length(); 1707 int length = subexprs->length();
1708 1708
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1747 for (; array_index < length; array_index++) { 1747 for (; array_index < length; array_index++) {
1748 Expression* subexpr = subexprs->at(array_index); 1748 Expression* subexpr = subexprs->at(array_index);
1749 1749
1750 __ Push(v0); 1750 __ Push(v0);
1751 if (subexpr->IsSpread()) { 1751 if (subexpr->IsSpread()) {
1752 VisitForStackValue(subexpr->AsSpread()->expression()); 1752 VisitForStackValue(subexpr->AsSpread()->expression());
1753 __ InvokeBuiltin(Context::CONCAT_ITERABLE_TO_ARRAY_BUILTIN_INDEX, 1753 __ InvokeBuiltin(Context::CONCAT_ITERABLE_TO_ARRAY_BUILTIN_INDEX,
1754 CALL_FUNCTION); 1754 CALL_FUNCTION);
1755 } else { 1755 } else {
1756 VisitForStackValue(subexpr); 1756 VisitForStackValue(subexpr);
1757 __ CallRuntime(Runtime::kAppendElement, 2); 1757 __ CallRuntime(Runtime::kAppendElement);
1758 } 1758 }
1759 1759
1760 PrepareForBailoutForId(expr->GetIdForElement(array_index), NO_REGISTERS); 1760 PrepareForBailoutForId(expr->GetIdForElement(array_index), NO_REGISTERS);
1761 } 1761 }
1762 1762
1763 if (result_saved) { 1763 if (result_saved) {
1764 context()->PlugTOS(); 1764 context()->PlugTOS();
1765 } else { 1765 } else {
1766 context()->Plug(v0); 1766 context()->Plug(v0);
1767 } 1767 }
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
2152 Label push_operand_holes, call_resume; 2152 Label push_operand_holes, call_resume;
2153 __ bind(&push_operand_holes); 2153 __ bind(&push_operand_holes);
2154 __ Subu(a3, a3, Operand(1)); 2154 __ Subu(a3, a3, Operand(1));
2155 __ Branch(&call_resume, lt, a3, Operand(zero_reg)); 2155 __ Branch(&call_resume, lt, a3, Operand(zero_reg));
2156 __ push(a2); 2156 __ push(a2);
2157 __ Branch(&push_operand_holes); 2157 __ Branch(&push_operand_holes);
2158 __ bind(&call_resume); 2158 __ bind(&call_resume);
2159 DCHECK(!result_register().is(a1)); 2159 DCHECK(!result_register().is(a1));
2160 __ Push(a1, result_register()); 2160 __ Push(a1, result_register());
2161 __ Push(Smi::FromInt(resume_mode)); 2161 __ Push(Smi::FromInt(resume_mode));
2162 __ CallRuntime(Runtime::kResumeJSGeneratorObject, 3); 2162 __ CallRuntime(Runtime::kResumeJSGeneratorObject);
2163 // Not reached: the runtime call returns elsewhere. 2163 // Not reached: the runtime call returns elsewhere.
2164 __ stop("not-reached"); 2164 __ stop("not-reached");
2165 2165
2166 __ bind(&done); 2166 __ bind(&done);
2167 context()->Plug(result_register()); 2167 context()->Plug(result_register());
2168 } 2168 }
2169 2169
2170 2170
2171 void FullCodeGenerator::EmitCreateIteratorResult(bool done) { 2171 void FullCodeGenerator::EmitCreateIteratorResult(bool done) {
2172 Label allocate, done_allocate; 2172 Label allocate, done_allocate;
2173 2173
2174 __ Allocate(JSIteratorResult::kSize, v0, a2, a3, &allocate, TAG_OBJECT); 2174 __ Allocate(JSIteratorResult::kSize, v0, a2, a3, &allocate, TAG_OBJECT);
2175 __ jmp(&done_allocate); 2175 __ jmp(&done_allocate);
2176 2176
2177 __ bind(&allocate); 2177 __ bind(&allocate);
2178 __ Push(Smi::FromInt(JSIteratorResult::kSize)); 2178 __ Push(Smi::FromInt(JSIteratorResult::kSize));
2179 __ CallRuntime(Runtime::kAllocateInNewSpace, 1); 2179 __ CallRuntime(Runtime::kAllocateInNewSpace);
2180 2180
2181 __ bind(&done_allocate); 2181 __ bind(&done_allocate);
2182 __ LoadNativeContextSlot(Context::ITERATOR_RESULT_MAP_INDEX, a1); 2182 __ LoadNativeContextSlot(Context::ITERATOR_RESULT_MAP_INDEX, a1);
2183 __ pop(a2); 2183 __ pop(a2);
2184 __ LoadRoot(a3, 2184 __ LoadRoot(a3,
2185 done ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex); 2185 done ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex);
2186 __ LoadRoot(t0, Heap::kEmptyFixedArrayRootIndex); 2186 __ LoadRoot(t0, Heap::kEmptyFixedArrayRootIndex);
2187 __ sw(a1, FieldMemOperand(v0, HeapObject::kMapOffset)); 2187 __ sw(a1, FieldMemOperand(v0, HeapObject::kMapOffset));
2188 __ sw(t0, FieldMemOperand(v0, JSObject::kPropertiesOffset)); 2188 __ sw(t0, FieldMemOperand(v0, JSObject::kPropertiesOffset));
2189 __ sw(t0, FieldMemOperand(v0, JSObject::kElementsOffset)); 2189 __ sw(t0, FieldMemOperand(v0, JSObject::kElementsOffset));
(...skipping 18 matching lines...) Expand all
2208 void FullCodeGenerator::EmitNamedSuperPropertyLoad(Property* prop) { 2208 void FullCodeGenerator::EmitNamedSuperPropertyLoad(Property* prop) {
2209 // Stack: receiver, home_object. 2209 // Stack: receiver, home_object.
2210 SetExpressionPosition(prop); 2210 SetExpressionPosition(prop);
2211 2211
2212 Literal* key = prop->key()->AsLiteral(); 2212 Literal* key = prop->key()->AsLiteral();
2213 DCHECK(!key->value()->IsSmi()); 2213 DCHECK(!key->value()->IsSmi());
2214 DCHECK(prop->IsSuperAccess()); 2214 DCHECK(prop->IsSuperAccess());
2215 2215
2216 __ Push(key->value()); 2216 __ Push(key->value());
2217 __ Push(Smi::FromInt(language_mode())); 2217 __ Push(Smi::FromInt(language_mode()));
2218 __ CallRuntime(Runtime::kLoadFromSuper, 4); 2218 __ CallRuntime(Runtime::kLoadFromSuper);
2219 } 2219 }
2220 2220
2221 2221
2222 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { 2222 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) {
2223 SetExpressionPosition(prop); 2223 SetExpressionPosition(prop);
2224 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate(), language_mode()).code(); 2224 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate(), language_mode()).code();
2225 __ li(LoadDescriptor::SlotRegister(), 2225 __ li(LoadDescriptor::SlotRegister(),
2226 Operand(SmiFromSlot(prop->PropertyFeedbackSlot()))); 2226 Operand(SmiFromSlot(prop->PropertyFeedbackSlot())));
2227 CallIC(ic); 2227 CallIC(ic);
2228 } 2228 }
2229 2229
2230 2230
2231 void FullCodeGenerator::EmitKeyedSuperPropertyLoad(Property* prop) { 2231 void FullCodeGenerator::EmitKeyedSuperPropertyLoad(Property* prop) {
2232 // Stack: receiver, home_object, key. 2232 // Stack: receiver, home_object, key.
2233 SetExpressionPosition(prop); 2233 SetExpressionPosition(prop);
2234 __ Push(Smi::FromInt(language_mode())); 2234 __ Push(Smi::FromInt(language_mode()));
2235 __ CallRuntime(Runtime::kLoadKeyedFromSuper, 4); 2235 __ CallRuntime(Runtime::kLoadKeyedFromSuper);
2236 } 2236 }
2237 2237
2238 2238
2239 void FullCodeGenerator::EmitInlineSmiBinaryOp(BinaryOperation* expr, 2239 void FullCodeGenerator::EmitInlineSmiBinaryOp(BinaryOperation* expr,
2240 Token::Value op, 2240 Token::Value op,
2241 Expression* left_expr, 2241 Expression* left_expr,
2242 Expression* right_expr) { 2242 Expression* right_expr) {
2243 Label done, smi_case, stub_call; 2243 Label done, smi_case, stub_call;
2244 2244
2245 Register scratch1 = a2; 2245 Register scratch1 = a2;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
2349 __ lw(scratch, MemOperand(sp, 0)); // prototype 2349 __ lw(scratch, MemOperand(sp, 0)); // prototype
2350 } 2350 }
2351 __ push(scratch); 2351 __ push(scratch);
2352 EmitPropertyKey(property, lit->GetIdForProperty(i)); 2352 EmitPropertyKey(property, lit->GetIdForProperty(i));
2353 2353
2354 // The static prototype property is read only. We handle the non computed 2354 // The static prototype property is read only. We handle the non computed
2355 // property name case in the parser. Since this is the only case where we 2355 // property name case in the parser. Since this is the only case where we
2356 // need to check for an own read only property we special case this so we do 2356 // need to check for an own read only property we special case this so we do
2357 // not need to do this for every property. 2357 // not need to do this for every property.
2358 if (property->is_static() && property->is_computed_name()) { 2358 if (property->is_static() && property->is_computed_name()) {
2359 __ CallRuntime(Runtime::kThrowIfStaticPrototype, 1); 2359 __ CallRuntime(Runtime::kThrowIfStaticPrototype);
2360 __ push(v0); 2360 __ push(v0);
2361 } 2361 }
2362 2362
2363 VisitForStackValue(value); 2363 VisitForStackValue(value);
2364 if (NeedsHomeObject(value)) { 2364 if (NeedsHomeObject(value)) {
2365 EmitSetHomeObject(value, 2, property->GetSlot()); 2365 EmitSetHomeObject(value, 2, property->GetSlot());
2366 } 2366 }
2367 2367
2368 switch (property->kind()) { 2368 switch (property->kind()) {
2369 case ObjectLiteral::Property::CONSTANT: 2369 case ObjectLiteral::Property::CONSTANT:
2370 case ObjectLiteral::Property::MATERIALIZED_LITERAL: 2370 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
2371 case ObjectLiteral::Property::PROTOTYPE: 2371 case ObjectLiteral::Property::PROTOTYPE:
2372 UNREACHABLE(); 2372 UNREACHABLE();
2373 case ObjectLiteral::Property::COMPUTED: 2373 case ObjectLiteral::Property::COMPUTED:
2374 __ CallRuntime(Runtime::kDefineClassMethod, 3); 2374 __ CallRuntime(Runtime::kDefineClassMethod);
2375 break; 2375 break;
2376 2376
2377 case ObjectLiteral::Property::GETTER: 2377 case ObjectLiteral::Property::GETTER:
2378 __ li(a0, Operand(Smi::FromInt(DONT_ENUM))); 2378 __ li(a0, Operand(Smi::FromInt(DONT_ENUM)));
2379 __ push(a0); 2379 __ push(a0);
2380 __ CallRuntime(Runtime::kDefineGetterPropertyUnchecked, 4); 2380 __ CallRuntime(Runtime::kDefineGetterPropertyUnchecked);
2381 break; 2381 break;
2382 2382
2383 case ObjectLiteral::Property::SETTER: 2383 case ObjectLiteral::Property::SETTER:
2384 __ li(a0, Operand(Smi::FromInt(DONT_ENUM))); 2384 __ li(a0, Operand(Smi::FromInt(DONT_ENUM)));
2385 __ push(a0); 2385 __ push(a0);
2386 __ CallRuntime(Runtime::kDefineSetterPropertyUnchecked, 4); 2386 __ CallRuntime(Runtime::kDefineSetterPropertyUnchecked);
2387 break; 2387 break;
2388 2388
2389 default: 2389 default:
2390 UNREACHABLE(); 2390 UNREACHABLE();
2391 } 2391 }
2392 } 2392 }
2393 2393
2394 // Set both the prototype and constructor to have fast properties, and also 2394 // Set both the prototype and constructor to have fast properties, and also
2395 // freeze them in strong mode. 2395 // freeze them in strong mode.
2396 __ CallRuntime(Runtime::kFinalizeClassDefinition, 2); 2396 __ CallRuntime(Runtime::kFinalizeClassDefinition);
2397 } 2397 }
2398 2398
2399 2399
2400 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, Token::Value op) { 2400 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, Token::Value op) {
2401 __ mov(a0, result_register()); 2401 __ mov(a0, result_register());
2402 __ pop(a1); 2402 __ pop(a1);
2403 Handle<Code> code = 2403 Handle<Code> code =
2404 CodeFactory::BinaryOpIC(isolate(), op, strength(language_mode())).code(); 2404 CodeFactory::BinaryOpIC(isolate(), op, strength(language_mode())).code();
2405 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. 2405 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code.
2406 CallIC(code, expr->BinaryOperationFeedbackId()); 2406 CallIC(code, expr->BinaryOperationFeedbackId());
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
2516 // Non-initializing assignment to let variable needs a write barrier. 2516 // Non-initializing assignment to let variable needs a write barrier.
2517 DCHECK(!var->IsLookupSlot()); 2517 DCHECK(!var->IsLookupSlot());
2518 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); 2518 DCHECK(var->IsStackAllocated() || var->IsContextSlot());
2519 Label assign; 2519 Label assign;
2520 MemOperand location = VarOperand(var, a1); 2520 MemOperand location = VarOperand(var, a1);
2521 __ lw(a3, location); 2521 __ lw(a3, location);
2522 __ LoadRoot(t0, Heap::kTheHoleValueRootIndex); 2522 __ LoadRoot(t0, Heap::kTheHoleValueRootIndex);
2523 __ Branch(&assign, ne, a3, Operand(t0)); 2523 __ Branch(&assign, ne, a3, Operand(t0));
2524 __ li(a3, Operand(var->name())); 2524 __ li(a3, Operand(var->name()));
2525 __ push(a3); 2525 __ push(a3);
2526 __ CallRuntime(Runtime::kThrowReferenceError, 1); 2526 __ CallRuntime(Runtime::kThrowReferenceError);
2527 // Perform the assignment. 2527 // Perform the assignment.
2528 __ bind(&assign); 2528 __ bind(&assign);
2529 EmitStoreToStackLocalOrContextSlot(var, location); 2529 EmitStoreToStackLocalOrContextSlot(var, location);
2530 2530
2531 } else if (var->mode() == CONST && op != Token::INIT) { 2531 } else if (var->mode() == CONST && op != Token::INIT) {
2532 // Assignment to const variable needs a write barrier. 2532 // Assignment to const variable needs a write barrier.
2533 DCHECK(!var->IsLookupSlot()); 2533 DCHECK(!var->IsLookupSlot());
2534 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); 2534 DCHECK(var->IsStackAllocated() || var->IsContextSlot());
2535 Label const_error; 2535 Label const_error;
2536 MemOperand location = VarOperand(var, a1); 2536 MemOperand location = VarOperand(var, a1);
2537 __ lw(a3, location); 2537 __ lw(a3, location);
2538 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); 2538 __ LoadRoot(at, Heap::kTheHoleValueRootIndex);
2539 __ Branch(&const_error, ne, a3, Operand(at)); 2539 __ Branch(&const_error, ne, a3, Operand(at));
2540 __ li(a3, Operand(var->name())); 2540 __ li(a3, Operand(var->name()));
2541 __ push(a3); 2541 __ push(a3);
2542 __ CallRuntime(Runtime::kThrowReferenceError, 1); 2542 __ CallRuntime(Runtime::kThrowReferenceError);
2543 __ bind(&const_error); 2543 __ bind(&const_error);
2544 __ CallRuntime(Runtime::kThrowConstAssignError, 0); 2544 __ CallRuntime(Runtime::kThrowConstAssignError);
2545 2545
2546 } else if (var->is_this() && var->mode() == CONST && op == Token::INIT) { 2546 } else if (var->is_this() && var->mode() == CONST && op == Token::INIT) {
2547 // Initializing assignment to const {this} needs a write barrier. 2547 // Initializing assignment to const {this} needs a write barrier.
2548 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); 2548 DCHECK(var->IsStackAllocated() || var->IsContextSlot());
2549 Label uninitialized_this; 2549 Label uninitialized_this;
2550 MemOperand location = VarOperand(var, a1); 2550 MemOperand location = VarOperand(var, a1);
2551 __ lw(a3, location); 2551 __ lw(a3, location);
2552 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); 2552 __ LoadRoot(at, Heap::kTheHoleValueRootIndex);
2553 __ Branch(&uninitialized_this, eq, a3, Operand(at)); 2553 __ Branch(&uninitialized_this, eq, a3, Operand(at));
2554 __ li(a0, Operand(var->name())); 2554 __ li(a0, Operand(var->name()));
2555 __ Push(a0); 2555 __ Push(a0);
2556 __ CallRuntime(Runtime::kThrowReferenceError, 1); 2556 __ CallRuntime(Runtime::kThrowReferenceError);
2557 __ bind(&uninitialized_this); 2557 __ bind(&uninitialized_this);
2558 EmitStoreToStackLocalOrContextSlot(var, location); 2558 EmitStoreToStackLocalOrContextSlot(var, location);
2559 2559
2560 } else if (!var->is_const_mode() || 2560 } else if (!var->is_const_mode() ||
2561 (var->mode() == CONST && op == Token::INIT)) { 2561 (var->mode() == CONST && op == Token::INIT)) {
2562 if (var->IsLookupSlot()) { 2562 if (var->IsLookupSlot()) {
2563 // Assignment to var. 2563 // Assignment to var.
2564 __ li(a1, Operand(var->name())); 2564 __ li(a1, Operand(var->name()));
2565 __ li(a0, Operand(Smi::FromInt(language_mode()))); 2565 __ li(a0, Operand(Smi::FromInt(language_mode())));
2566 __ Push(v0, cp, a1, a0); // Value, context, name, language mode. 2566 __ Push(v0, cp, a1, a0); // Value, context, name, language mode.
2567 __ CallRuntime(Runtime::kStoreLookupSlot, 4); 2567 __ CallRuntime(Runtime::kStoreLookupSlot);
2568 } else { 2568 } else {
2569 // Assignment to var or initializing assignment to let/const in harmony 2569 // Assignment to var or initializing assignment to let/const in harmony
2570 // mode. 2570 // mode.
2571 DCHECK((var->IsStackAllocated() || var->IsContextSlot())); 2571 DCHECK((var->IsStackAllocated() || var->IsContextSlot()));
2572 MemOperand location = VarOperand(var, a1); 2572 MemOperand location = VarOperand(var, a1);
2573 if (generate_debug_code_ && var->mode() == LET && op == Token::INIT) { 2573 if (generate_debug_code_ && var->mode() == LET && op == Token::INIT) {
2574 // Check for an uninitialized let binding. 2574 // Check for an uninitialized let binding.
2575 __ lw(a2, location); 2575 __ lw(a2, location);
2576 __ LoadRoot(t0, Heap::kTheHoleValueRootIndex); 2576 __ LoadRoot(t0, Heap::kTheHoleValueRootIndex);
2577 __ Check(eq, kLetBindingReInitialization, a2, Operand(t0)); 2577 __ Check(eq, kLetBindingReInitialization, a2, Operand(t0));
2578 } 2578 }
2579 EmitStoreToStackLocalOrContextSlot(var, location); 2579 EmitStoreToStackLocalOrContextSlot(var, location);
2580 } 2580 }
2581 2581
2582 } else if (var->mode() == CONST_LEGACY && op == Token::INIT) { 2582 } else if (var->mode() == CONST_LEGACY && op == Token::INIT) {
2583 // Const initializers need a write barrier. 2583 // Const initializers need a write barrier.
2584 DCHECK(!var->IsParameter()); // No const parameters. 2584 DCHECK(!var->IsParameter()); // No const parameters.
2585 if (var->IsLookupSlot()) { 2585 if (var->IsLookupSlot()) {
2586 __ li(a0, Operand(var->name())); 2586 __ li(a0, Operand(var->name()));
2587 __ Push(v0, cp, a0); // Context and name. 2587 __ Push(v0, cp, a0); // Context and name.
2588 __ CallRuntime(Runtime::kInitializeLegacyConstLookupSlot, 3); 2588 __ CallRuntime(Runtime::kInitializeLegacyConstLookupSlot);
2589 } else { 2589 } else {
2590 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); 2590 DCHECK(var->IsStackAllocated() || var->IsContextSlot());
2591 Label skip; 2591 Label skip;
2592 MemOperand location = VarOperand(var, a1); 2592 MemOperand location = VarOperand(var, a1);
2593 __ lw(a2, location); 2593 __ lw(a2, location);
2594 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); 2594 __ LoadRoot(at, Heap::kTheHoleValueRootIndex);
2595 __ Branch(&skip, ne, a2, Operand(at)); 2595 __ Branch(&skip, ne, a2, Operand(at));
2596 EmitStoreToStackLocalOrContextSlot(var, location); 2596 EmitStoreToStackLocalOrContextSlot(var, location);
2597 __ bind(&skip); 2597 __ bind(&skip);
2598 } 2598 }
2599 2599
2600 } else { 2600 } else {
2601 DCHECK(var->mode() == CONST_LEGACY && op != Token::INIT); 2601 DCHECK(var->mode() == CONST_LEGACY && op != Token::INIT);
2602 if (is_strict(language_mode())) { 2602 if (is_strict(language_mode())) {
2603 __ CallRuntime(Runtime::kThrowConstAssignError, 0); 2603 __ CallRuntime(Runtime::kThrowConstAssignError);
2604 } 2604 }
2605 // Silently ignore store in sloppy mode. 2605 // Silently ignore store in sloppy mode.
2606 } 2606 }
2607 } 2607 }
2608 2608
2609 2609
2610 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { 2610 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) {
2611 // Assignment to a property, using a named store IC. 2611 // Assignment to a property, using a named store IC.
2612 Property* prop = expr->target()->AsProperty(); 2612 Property* prop = expr->target()->AsProperty();
2613 DCHECK(prop != NULL); 2613 DCHECK(prop != NULL);
(...skipping 15 matching lines...) Expand all
2629 // Assignment to named property of super. 2629 // Assignment to named property of super.
2630 // v0 : value 2630 // v0 : value
2631 // stack : receiver ('this'), home_object 2631 // stack : receiver ('this'), home_object
2632 DCHECK(prop != NULL); 2632 DCHECK(prop != NULL);
2633 Literal* key = prop->key()->AsLiteral(); 2633 Literal* key = prop->key()->AsLiteral();
2634 DCHECK(key != NULL); 2634 DCHECK(key != NULL);
2635 2635
2636 __ Push(key->value()); 2636 __ Push(key->value());
2637 __ Push(v0); 2637 __ Push(v0);
2638 __ CallRuntime((is_strict(language_mode()) ? Runtime::kStoreToSuper_Strict 2638 __ CallRuntime((is_strict(language_mode()) ? Runtime::kStoreToSuper_Strict
2639 : Runtime::kStoreToSuper_Sloppy), 2639 : Runtime::kStoreToSuper_Sloppy));
2640 4);
2641 } 2640 }
2642 2641
2643 2642
2644 void FullCodeGenerator::EmitKeyedSuperPropertyStore(Property* prop) { 2643 void FullCodeGenerator::EmitKeyedSuperPropertyStore(Property* prop) {
2645 // Assignment to named property of super. 2644 // Assignment to named property of super.
2646 // v0 : value 2645 // v0 : value
2647 // stack : receiver ('this'), home_object, key 2646 // stack : receiver ('this'), home_object, key
2648 DCHECK(prop != NULL); 2647 DCHECK(prop != NULL);
2649 2648
2650 __ Push(v0); 2649 __ Push(v0);
2651 __ CallRuntime( 2650 __ CallRuntime((is_strict(language_mode())
2652 (is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict 2651 ? Runtime::kStoreKeyedToSuper_Strict
2653 : Runtime::kStoreKeyedToSuper_Sloppy), 2652 : Runtime::kStoreKeyedToSuper_Sloppy));
2654 4);
2655 } 2653 }
2656 2654
2657 2655
2658 void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { 2656 void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) {
2659 // Assignment to a property, using a keyed store IC. 2657 // Assignment to a property, using a keyed store IC.
2660 // Call keyed store IC. 2658 // Call keyed store IC.
2661 // The arguments are: 2659 // The arguments are:
2662 // - a0 is the value, 2660 // - a0 is the value,
2663 // - a1 is the key, 2661 // - a1 is the key,
2664 // - a2 is the receiver. 2662 // - a2 is the receiver.
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
2773 __ Push(key->value()); 2771 __ Push(key->value());
2774 __ Push(Smi::FromInt(language_mode())); 2772 __ Push(Smi::FromInt(language_mode()));
2775 2773
2776 // Stack here: 2774 // Stack here:
2777 // - home_object 2775 // - home_object
2778 // - this (receiver) 2776 // - this (receiver)
2779 // - this (receiver) <-- LoadFromSuper will pop here and below. 2777 // - this (receiver) <-- LoadFromSuper will pop here and below.
2780 // - home_object 2778 // - home_object
2781 // - key 2779 // - key
2782 // - language_mode 2780 // - language_mode
2783 __ CallRuntime(Runtime::kLoadFromSuper, 4); 2781 __ CallRuntime(Runtime::kLoadFromSuper);
2784 2782
2785 // Replace home_object with target function. 2783 // Replace home_object with target function.
2786 __ sw(v0, MemOperand(sp, kPointerSize)); 2784 __ sw(v0, MemOperand(sp, kPointerSize));
2787 2785
2788 // Stack here: 2786 // Stack here:
2789 // - target function 2787 // - target function
2790 // - this (receiver) 2788 // - this (receiver)
2791 EmitCall(expr); 2789 EmitCall(expr);
2792 } 2790 }
2793 2791
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2833 VisitForStackValue(prop->key()); 2831 VisitForStackValue(prop->key());
2834 __ Push(Smi::FromInt(language_mode())); 2832 __ Push(Smi::FromInt(language_mode()));
2835 2833
2836 // Stack here: 2834 // Stack here:
2837 // - home_object 2835 // - home_object
2838 // - this (receiver) 2836 // - this (receiver)
2839 // - this (receiver) <-- LoadKeyedFromSuper will pop here and below. 2837 // - this (receiver) <-- LoadKeyedFromSuper will pop here and below.
2840 // - home_object 2838 // - home_object
2841 // - key 2839 // - key
2842 // - language_mode 2840 // - language_mode
2843 __ CallRuntime(Runtime::kLoadKeyedFromSuper, 4); 2841 __ CallRuntime(Runtime::kLoadKeyedFromSuper);
2844 2842
2845 // Replace home_object with target function. 2843 // Replace home_object with target function.
2846 __ sw(v0, MemOperand(sp, kPointerSize)); 2844 __ sw(v0, MemOperand(sp, kPointerSize));
2847 2845
2848 // Stack here: 2846 // Stack here:
2849 // - target function 2847 // - target function
2850 // - this (receiver) 2848 // - this (receiver)
2851 EmitCall(expr); 2849 EmitCall(expr);
2852 } 2850 }
2853 2851
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2889 __ lw(t2, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); 2887 __ lw(t2, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
2890 2888
2891 // t1: the language mode. 2889 // t1: the language mode.
2892 __ li(t1, Operand(Smi::FromInt(language_mode()))); 2890 __ li(t1, Operand(Smi::FromInt(language_mode())));
2893 2891
2894 // t0: the start position of the scope the calls resides in. 2892 // t0: the start position of the scope the calls resides in.
2895 __ li(t0, Operand(Smi::FromInt(scope()->start_position()))); 2893 __ li(t0, Operand(Smi::FromInt(scope()->start_position())));
2896 2894
2897 // Do the runtime call. 2895 // Do the runtime call.
2898 __ Push(t3, t2, t1, t0); 2896 __ Push(t3, t2, t1, t0);
2899 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 5); 2897 __ CallRuntime(Runtime::kResolvePossiblyDirectEval);
2900 } 2898 }
2901 2899
2902 2900
2903 // See http://www.ecma-international.org/ecma-262/6.0/#sec-function-calls. 2901 // See http://www.ecma-international.org/ecma-262/6.0/#sec-function-calls.
2904 void FullCodeGenerator::PushCalleeAndWithBaseObject(Call* expr) { 2902 void FullCodeGenerator::PushCalleeAndWithBaseObject(Call* expr) {
2905 VariableProxy* callee = expr->expression()->AsVariableProxy(); 2903 VariableProxy* callee = expr->expression()->AsVariableProxy();
2906 if (callee->var()->IsLookupSlot()) { 2904 if (callee->var()->IsLookupSlot()) {
2907 Label slow, done; 2905 Label slow, done;
2908 2906
2909 SetExpressionPosition(callee); 2907 SetExpressionPosition(callee);
2910 // Generate code for loading from variables potentially shadowed by 2908 // Generate code for loading from variables potentially shadowed by
2911 // eval-introduced variables. 2909 // eval-introduced variables.
2912 EmitDynamicLookupFastCase(callee, NOT_INSIDE_TYPEOF, &slow, &done); 2910 EmitDynamicLookupFastCase(callee, NOT_INSIDE_TYPEOF, &slow, &done);
2913 2911
2914 __ bind(&slow); 2912 __ bind(&slow);
2915 // Call the runtime to find the function to call (returned in v0) 2913 // Call the runtime to find the function to call (returned in v0)
2916 // and the object holding it (returned in v1). 2914 // and the object holding it (returned in v1).
2917 DCHECK(!context_register().is(a2)); 2915 DCHECK(!context_register().is(a2));
2918 __ li(a2, Operand(callee->name())); 2916 __ li(a2, Operand(callee->name()));
2919 __ Push(context_register(), a2); 2917 __ Push(context_register(), a2);
2920 __ CallRuntime(Runtime::kLoadLookupSlot, 2); 2918 __ CallRuntime(Runtime::kLoadLookupSlot);
2921 __ Push(v0, v1); // Function, receiver. 2919 __ Push(v0, v1); // Function, receiver.
2922 PrepareForBailoutForId(expr->LookupId(), NO_REGISTERS); 2920 PrepareForBailoutForId(expr->LookupId(), NO_REGISTERS);
2923 2921
2924 // If fast case code has been generated, emit code to push the 2922 // If fast case code has been generated, emit code to push the
2925 // function and receiver and have the slow path jump around this 2923 // function and receiver and have the slow path jump around this
2926 // code. 2924 // code.
2927 if (done.is_linked()) { 2925 if (done.is_linked()) {
2928 Label call; 2926 Label call;
2929 __ Branch(&call); 2927 __ Branch(&call);
2930 __ bind(&done); 2928 __ bind(&done);
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
3568 ZoneList<Expression*>* args = expr->arguments(); 3566 ZoneList<Expression*>* args = expr->arguments();
3569 DCHECK_EQ(1, args->length()); 3567 DCHECK_EQ(1, args->length());
3570 3568
3571 // Load the argument into v0 and convert it. 3569 // Load the argument into v0 and convert it.
3572 VisitForAccumulatorValue(args->at(0)); 3570 VisitForAccumulatorValue(args->at(0));
3573 3571
3574 // Convert the object to an integer. 3572 // Convert the object to an integer.
3575 Label done_convert; 3573 Label done_convert;
3576 __ JumpIfSmi(v0, &done_convert); 3574 __ JumpIfSmi(v0, &done_convert);
3577 __ Push(v0); 3575 __ Push(v0);
3578 __ CallRuntime(Runtime::kToInteger, 1); 3576 __ CallRuntime(Runtime::kToInteger);
3579 __ bind(&done_convert); 3577 __ bind(&done_convert);
3580 context()->Plug(v0); 3578 context()->Plug(v0);
3581 } 3579 }
3582 3580
3583 3581
3584 void FullCodeGenerator::EmitToName(CallRuntime* expr) { 3582 void FullCodeGenerator::EmitToName(CallRuntime* expr) {
3585 ZoneList<Expression*>* args = expr->arguments(); 3583 ZoneList<Expression*>* args = expr->arguments();
3586 DCHECK_EQ(1, args->length()); 3584 DCHECK_EQ(1, args->length());
3587 3585
3588 // Load the argument into v0 and convert it. 3586 // Load the argument into v0 and convert it.
3589 VisitForAccumulatorValue(args->at(0)); 3587 VisitForAccumulatorValue(args->at(0));
3590 3588
3591 Label convert, done_convert; 3589 Label convert, done_convert;
3592 __ JumpIfSmi(v0, &convert); 3590 __ JumpIfSmi(v0, &convert);
3593 STATIC_ASSERT(FIRST_NAME_TYPE == FIRST_TYPE); 3591 STATIC_ASSERT(FIRST_NAME_TYPE == FIRST_TYPE);
3594 __ GetObjectType(v0, a1, a1); 3592 __ GetObjectType(v0, a1, a1);
3595 __ Branch(&done_convert, le, a1, Operand(LAST_NAME_TYPE)); 3593 __ Branch(&done_convert, le, a1, Operand(LAST_NAME_TYPE));
3596 __ bind(&convert); 3594 __ bind(&convert);
3597 __ Push(v0); 3595 __ Push(v0);
3598 __ CallRuntime(Runtime::kToName, 1); 3596 __ CallRuntime(Runtime::kToName);
3599 __ bind(&done_convert); 3597 __ bind(&done_convert);
3600 context()->Plug(v0); 3598 context()->Plug(v0);
3601 } 3599 }
3602 3600
3603 3601
3604 void FullCodeGenerator::EmitStringCharFromCode(CallRuntime* expr) { 3602 void FullCodeGenerator::EmitStringCharFromCode(CallRuntime* expr) {
3605 ZoneList<Expression*>* args = expr->arguments(); 3603 ZoneList<Expression*>* args = expr->arguments();
3606 DCHECK(args->length() == 1); 3604 DCHECK(args->length() == 1);
3607 3605
3608 VisitForAccumulatorValue(args->at(0)); 3606 VisitForAccumulatorValue(args->at(0));
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
4042 __ LoadRoot(t0, Heap::kEmptyFixedArrayRootIndex); 4040 __ LoadRoot(t0, Heap::kEmptyFixedArrayRootIndex);
4043 __ sw(a1, FieldMemOperand(v0, HeapObject::kMapOffset)); 4041 __ sw(a1, FieldMemOperand(v0, HeapObject::kMapOffset));
4044 __ sw(t0, FieldMemOperand(v0, JSObject::kPropertiesOffset)); 4042 __ sw(t0, FieldMemOperand(v0, JSObject::kPropertiesOffset));
4045 __ sw(t0, FieldMemOperand(v0, JSObject::kElementsOffset)); 4043 __ sw(t0, FieldMemOperand(v0, JSObject::kElementsOffset));
4046 __ sw(a2, FieldMemOperand(v0, JSIteratorResult::kValueOffset)); 4044 __ sw(a2, FieldMemOperand(v0, JSIteratorResult::kValueOffset));
4047 __ sw(a3, FieldMemOperand(v0, JSIteratorResult::kDoneOffset)); 4045 __ sw(a3, FieldMemOperand(v0, JSIteratorResult::kDoneOffset));
4048 STATIC_ASSERT(JSIteratorResult::kSize == 5 * kPointerSize); 4046 STATIC_ASSERT(JSIteratorResult::kSize == 5 * kPointerSize);
4049 __ jmp(&done); 4047 __ jmp(&done);
4050 4048
4051 __ bind(&runtime); 4049 __ bind(&runtime);
4052 __ CallRuntime(Runtime::kCreateIterResultObject, 2); 4050 __ CallRuntime(Runtime::kCreateIterResultObject);
4053 4051
4054 __ bind(&done); 4052 __ bind(&done);
4055 context()->Plug(v0); 4053 context()->Plug(v0);
4056 } 4054 }
4057 4055
4058 4056
4059 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) { 4057 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) {
4060 // Push undefined as the receiver. 4058 // Push undefined as the receiver.
4061 __ LoadRoot(v0, Heap::kUndefinedValueRootIndex); 4059 __ LoadRoot(v0, Heap::kUndefinedValueRootIndex);
4062 __ push(v0); 4060 __ push(v0);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
4135 case Token::DELETE: { 4133 case Token::DELETE: {
4136 Comment cmnt(masm_, "[ UnaryOperation (DELETE)"); 4134 Comment cmnt(masm_, "[ UnaryOperation (DELETE)");
4137 Property* property = expr->expression()->AsProperty(); 4135 Property* property = expr->expression()->AsProperty();
4138 VariableProxy* proxy = expr->expression()->AsVariableProxy(); 4136 VariableProxy* proxy = expr->expression()->AsVariableProxy();
4139 4137
4140 if (property != NULL) { 4138 if (property != NULL) {
4141 VisitForStackValue(property->obj()); 4139 VisitForStackValue(property->obj());
4142 VisitForStackValue(property->key()); 4140 VisitForStackValue(property->key());
4143 __ CallRuntime(is_strict(language_mode()) 4141 __ CallRuntime(is_strict(language_mode())
4144 ? Runtime::kDeleteProperty_Strict 4142 ? Runtime::kDeleteProperty_Strict
4145 : Runtime::kDeleteProperty_Sloppy, 4143 : Runtime::kDeleteProperty_Sloppy);
4146 2);
4147 context()->Plug(v0); 4144 context()->Plug(v0);
4148 } else if (proxy != NULL) { 4145 } else if (proxy != NULL) {
4149 Variable* var = proxy->var(); 4146 Variable* var = proxy->var();
4150 // Delete of an unqualified identifier is disallowed in strict mode but 4147 // Delete of an unqualified identifier is disallowed in strict mode but
4151 // "delete this" is allowed. 4148 // "delete this" is allowed.
4152 bool is_this = var->HasThisName(isolate()); 4149 bool is_this = var->HasThisName(isolate());
4153 DCHECK(is_sloppy(language_mode()) || is_this); 4150 DCHECK(is_sloppy(language_mode()) || is_this);
4154 if (var->IsUnallocatedOrGlobalSlot()) { 4151 if (var->IsUnallocatedOrGlobalSlot()) {
4155 __ LoadGlobalObject(a2); 4152 __ LoadGlobalObject(a2);
4156 __ li(a1, Operand(var->name())); 4153 __ li(a1, Operand(var->name()));
4157 __ Push(a2, a1); 4154 __ Push(a2, a1);
4158 __ CallRuntime(Runtime::kDeleteProperty_Sloppy, 2); 4155 __ CallRuntime(Runtime::kDeleteProperty_Sloppy);
4159 context()->Plug(v0); 4156 context()->Plug(v0);
4160 } else if (var->IsStackAllocated() || var->IsContextSlot()) { 4157 } else if (var->IsStackAllocated() || var->IsContextSlot()) {
4161 // Result of deleting non-global, non-dynamic variables is false. 4158 // Result of deleting non-global, non-dynamic variables is false.
4162 // The subexpression does not have side effects. 4159 // The subexpression does not have side effects.
4163 context()->Plug(is_this); 4160 context()->Plug(is_this);
4164 } else { 4161 } else {
4165 // Non-global variable. Call the runtime to try to delete from the 4162 // Non-global variable. Call the runtime to try to delete from the
4166 // context where the variable was introduced. 4163 // context where the variable was introduced.
4167 DCHECK(!context_register().is(a2)); 4164 DCHECK(!context_register().is(a2));
4168 __ li(a2, Operand(var->name())); 4165 __ li(a2, Operand(var->name()));
4169 __ Push(context_register(), a2); 4166 __ Push(context_register(), a2);
4170 __ CallRuntime(Runtime::kDeleteLookupSlot, 2); 4167 __ CallRuntime(Runtime::kDeleteLookupSlot);
4171 context()->Plug(v0); 4168 context()->Plug(v0);
4172 } 4169 }
4173 } else { 4170 } else {
4174 // Result of deleting non-property, non-variable reference is true. 4171 // Result of deleting non-property, non-variable reference is true.
4175 // The subexpression may have side effects. 4172 // The subexpression may have side effects.
4176 VisitForEffect(expr->expression()); 4173 VisitForEffect(expr->expression());
4177 context()->Plug(true); 4174 context()->Plug(true);
4178 } 4175 }
4179 break; 4176 break;
4180 } 4177 }
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
4593 Label* if_false = NULL; 4590 Label* if_false = NULL;
4594 Label* fall_through = NULL; 4591 Label* fall_through = NULL;
4595 context()->PrepareTest(&materialize_true, &materialize_false, 4592 context()->PrepareTest(&materialize_true, &materialize_false,
4596 &if_true, &if_false, &fall_through); 4593 &if_true, &if_false, &fall_through);
4597 4594
4598 Token::Value op = expr->op(); 4595 Token::Value op = expr->op();
4599 VisitForStackValue(expr->left()); 4596 VisitForStackValue(expr->left());
4600 switch (op) { 4597 switch (op) {
4601 case Token::IN: 4598 case Token::IN:
4602 VisitForStackValue(expr->right()); 4599 VisitForStackValue(expr->right());
4603 __ CallRuntime(Runtime::kHasProperty, 2); 4600 __ CallRuntime(Runtime::kHasProperty);
4604 PrepareForBailoutBeforeSplit(expr, false, NULL, NULL); 4601 PrepareForBailoutBeforeSplit(expr, false, NULL, NULL);
4605 __ LoadRoot(t0, Heap::kTrueValueRootIndex); 4602 __ LoadRoot(t0, Heap::kTrueValueRootIndex);
4606 Split(eq, v0, Operand(t0), if_true, if_false, fall_through); 4603 Split(eq, v0, Operand(t0), if_true, if_false, fall_through);
4607 break; 4604 break;
4608 4605
4609 case Token::INSTANCEOF: { 4606 case Token::INSTANCEOF: {
4610 VisitForAccumulatorValue(expr->right()); 4607 VisitForAccumulatorValue(expr->right());
4611 __ mov(a0, result_register()); 4608 __ mov(a0, result_register());
4612 __ pop(a1); 4609 __ pop(a1);
4613 InstanceOfStub stub(isolate()); 4610 InstanceOfStub stub(isolate());
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
4868 reinterpret_cast<uint32_t>( 4865 reinterpret_cast<uint32_t>(
4869 isolate->builtins()->OsrAfterStackCheck()->entry())); 4866 isolate->builtins()->OsrAfterStackCheck()->entry()));
4870 return OSR_AFTER_STACK_CHECK; 4867 return OSR_AFTER_STACK_CHECK;
4871 } 4868 }
4872 4869
4873 4870
4874 } // namespace internal 4871 } // namespace internal
4875 } // namespace v8 4872 } // namespace v8
4876 4873
4877 #endif // V8_TARGET_ARCH_MIPS 4874 #endif // V8_TARGET_ARCH_MIPS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698