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

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

Issue 1227893005: TypeofMode replaces TypeofState and ContextualMode. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: minor fix Created 5 years, 5 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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_MIPS64 7 #if V8_TARGET_ARCH_MIPS64
8 8
9 // Note on Mips implementation: 9 // Note on Mips implementation:
10 // 10 //
(...skipping 1343 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 Operand(isolate()->factory()->home_object_symbol())); 1354 Operand(isolate()->factory()->home_object_symbol()));
1355 __ ld(StoreDescriptor::ValueRegister(), 1355 __ ld(StoreDescriptor::ValueRegister(),
1356 MemOperand(sp, offset * kPointerSize)); 1356 MemOperand(sp, offset * kPointerSize));
1357 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); 1357 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot);
1358 CallStoreIC(); 1358 CallStoreIC();
1359 } 1359 }
1360 } 1360 }
1361 1361
1362 1362
1363 void FullCodeGenerator::EmitLoadGlobalCheckExtensions(VariableProxy* proxy, 1363 void FullCodeGenerator::EmitLoadGlobalCheckExtensions(VariableProxy* proxy,
1364 TypeofState typeof_state, 1364 TypeofMode typeof_mode,
1365 Label* slow) { 1365 Label* slow) {
1366 Register current = cp; 1366 Register current = cp;
1367 Register next = a1; 1367 Register next = a1;
1368 Register temp = a2; 1368 Register temp = a2;
1369 1369
1370 Scope* s = scope(); 1370 Scope* s = scope();
1371 while (s != NULL) { 1371 while (s != NULL) {
1372 if (s->num_heap_slots() > 0) { 1372 if (s->num_heap_slots() > 0) {
1373 if (s->calls_sloppy_eval()) { 1373 if (s->calls_sloppy_eval()) {
1374 // Check that extension is NULL. 1374 // Check that extension is NULL.
(...skipping 25 matching lines...) Expand all
1400 __ ld(temp, ContextOperand(next, Context::EXTENSION_INDEX)); 1400 __ ld(temp, ContextOperand(next, Context::EXTENSION_INDEX));
1401 __ Branch(slow, ne, temp, Operand(zero_reg)); 1401 __ Branch(slow, ne, temp, Operand(zero_reg));
1402 // Load next context in chain. 1402 // Load next context in chain.
1403 __ ld(next, ContextOperand(next, Context::PREVIOUS_INDEX)); 1403 __ ld(next, ContextOperand(next, Context::PREVIOUS_INDEX));
1404 __ Branch(&loop); 1404 __ Branch(&loop);
1405 __ bind(&fast); 1405 __ bind(&fast);
1406 } 1406 }
1407 1407
1408 // All extension objects were empty and it is safe to use a normal global 1408 // All extension objects were empty and it is safe to use a normal global
1409 // load machinery. 1409 // load machinery.
1410 EmitGlobalVariableLoad(proxy, typeof_state); 1410 EmitGlobalVariableLoad(proxy, typeof_mode);
1411 } 1411 }
1412 1412
1413 1413
1414 MemOperand FullCodeGenerator::ContextSlotOperandCheckExtensions(Variable* var, 1414 MemOperand FullCodeGenerator::ContextSlotOperandCheckExtensions(Variable* var,
1415 Label* slow) { 1415 Label* slow) {
1416 DCHECK(var->IsContextSlot()); 1416 DCHECK(var->IsContextSlot());
1417 Register context = cp; 1417 Register context = cp;
1418 Register next = a3; 1418 Register next = a3;
1419 Register temp = a4; 1419 Register temp = a4;
1420 1420
(...skipping 14 matching lines...) Expand all
1435 __ Branch(slow, ne, temp, Operand(zero_reg)); 1435 __ Branch(slow, ne, temp, Operand(zero_reg));
1436 1436
1437 // This function is used only for loads, not stores, so it's safe to 1437 // This function is used only for loads, not stores, so it's safe to
1438 // return an cp-based operand (the write barrier cannot be allowed to 1438 // return an cp-based operand (the write barrier cannot be allowed to
1439 // destroy the cp register). 1439 // destroy the cp register).
1440 return ContextOperand(context, var->index()); 1440 return ContextOperand(context, var->index());
1441 } 1441 }
1442 1442
1443 1443
1444 void FullCodeGenerator::EmitDynamicLookupFastCase(VariableProxy* proxy, 1444 void FullCodeGenerator::EmitDynamicLookupFastCase(VariableProxy* proxy,
1445 TypeofState typeof_state, 1445 TypeofMode typeof_mode,
1446 Label* slow, 1446 Label* slow, Label* done) {
1447 Label* done) {
1448 // Generate fast-case code for variables that might be shadowed by 1447 // Generate fast-case code for variables that might be shadowed by
1449 // eval-introduced variables. Eval is used a lot without 1448 // eval-introduced variables. Eval is used a lot without
1450 // introducing variables. In those cases, we do not want to 1449 // introducing variables. In those cases, we do not want to
1451 // perform a runtime call for all variables in the scope 1450 // perform a runtime call for all variables in the scope
1452 // containing the eval. 1451 // containing the eval.
1453 Variable* var = proxy->var(); 1452 Variable* var = proxy->var();
1454 if (var->mode() == DYNAMIC_GLOBAL) { 1453 if (var->mode() == DYNAMIC_GLOBAL) {
1455 EmitLoadGlobalCheckExtensions(proxy, typeof_state, slow); 1454 EmitLoadGlobalCheckExtensions(proxy, typeof_mode, slow);
1456 __ Branch(done); 1455 __ Branch(done);
1457 } else if (var->mode() == DYNAMIC_LOCAL) { 1456 } else if (var->mode() == DYNAMIC_LOCAL) {
1458 Variable* local = var->local_if_not_shadowed(); 1457 Variable* local = var->local_if_not_shadowed();
1459 __ ld(v0, ContextSlotOperandCheckExtensions(local, slow)); 1458 __ ld(v0, ContextSlotOperandCheckExtensions(local, slow));
1460 if (local->mode() == LET || local->mode() == CONST || 1459 if (local->mode() == LET || local->mode() == CONST ||
1461 local->mode() == CONST_LEGACY) { 1460 local->mode() == CONST_LEGACY) {
1462 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); 1461 __ LoadRoot(at, Heap::kTheHoleValueRootIndex);
1463 __ dsubu(at, v0, at); // Sub as compare: at == 0 on eq. 1462 __ dsubu(at, v0, at); // Sub as compare: at == 0 on eq.
1464 if (local->mode() == CONST_LEGACY) { 1463 if (local->mode() == CONST_LEGACY) {
1465 __ LoadRoot(a0, Heap::kUndefinedValueRootIndex); 1464 __ LoadRoot(a0, Heap::kUndefinedValueRootIndex);
1466 __ Movz(v0, a0, at); // Conditional move: return Undefined if TheHole. 1465 __ Movz(v0, a0, at); // Conditional move: return Undefined if TheHole.
1467 } else { // LET || CONST 1466 } else { // LET || CONST
1468 __ Branch(done, ne, at, Operand(zero_reg)); 1467 __ Branch(done, ne, at, Operand(zero_reg));
1469 __ li(a0, Operand(var->name())); 1468 __ li(a0, Operand(var->name()));
1470 __ push(a0); 1469 __ push(a0);
1471 __ CallRuntime(Runtime::kThrowReferenceError, 1); 1470 __ CallRuntime(Runtime::kThrowReferenceError, 1);
1472 } 1471 }
1473 } 1472 }
1474 __ Branch(done); 1473 __ Branch(done);
1475 } 1474 }
1476 } 1475 }
1477 1476
1478 1477
1479 void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy, 1478 void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy,
1480 TypeofState typeof_state) { 1479 TypeofMode typeof_mode) {
1481 Variable* var = proxy->var(); 1480 Variable* var = proxy->var();
1482 DCHECK(var->IsUnallocatedOrGlobalSlot() || 1481 DCHECK(var->IsUnallocatedOrGlobalSlot() ||
1483 (var->IsLookupSlot() && var->mode() == DYNAMIC_GLOBAL)); 1482 (var->IsLookupSlot() && var->mode() == DYNAMIC_GLOBAL));
1484 __ ld(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); 1483 __ ld(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand());
1485 __ li(LoadDescriptor::NameRegister(), Operand(var->name())); 1484 __ li(LoadDescriptor::NameRegister(), Operand(var->name()));
1486 __ li(LoadDescriptor::SlotRegister(), 1485 __ li(LoadDescriptor::SlotRegister(),
1487 Operand(SmiFromSlot(proxy->VariableFeedbackSlot()))); 1486 Operand(SmiFromSlot(proxy->VariableFeedbackSlot())));
1488 // Inside typeof use a regular load, not a contextual load, to avoid 1487 CallLoadIC(typeof_mode);
1489 // a reference error.
1490 CallLoadIC(typeof_state == NOT_INSIDE_TYPEOF ? CONTEXTUAL : NOT_CONTEXTUAL);
1491 } 1488 }
1492 1489
1493 1490
1494 void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy, 1491 void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy,
1495 TypeofState typeof_state) { 1492 TypeofMode typeof_mode) {
1496 // Record position before possible IC call. 1493 // Record position before possible IC call.
1497 SetExpressionPosition(proxy); 1494 SetExpressionPosition(proxy);
1498 PrepareForBailoutForId(proxy->BeforeId(), NO_REGISTERS); 1495 PrepareForBailoutForId(proxy->BeforeId(), NO_REGISTERS);
1499 Variable* var = proxy->var(); 1496 Variable* var = proxy->var();
1500 1497
1501 // Three cases: global variables, lookup variables, and all other types of 1498 // Three cases: global variables, lookup variables, and all other types of
1502 // variables. 1499 // variables.
1503 switch (var->location()) { 1500 switch (var->location()) {
1504 case VariableLocation::GLOBAL: 1501 case VariableLocation::GLOBAL:
1505 case VariableLocation::UNALLOCATED: { 1502 case VariableLocation::UNALLOCATED: {
1506 Comment cmnt(masm_, "[ Global variable"); 1503 Comment cmnt(masm_, "[ Global variable");
1507 EmitGlobalVariableLoad(proxy, typeof_state); 1504 EmitGlobalVariableLoad(proxy, typeof_mode);
1508 context()->Plug(v0); 1505 context()->Plug(v0);
1509 break; 1506 break;
1510 } 1507 }
1511 1508
1512 case VariableLocation::PARAMETER: 1509 case VariableLocation::PARAMETER:
1513 case VariableLocation::LOCAL: 1510 case VariableLocation::LOCAL:
1514 case VariableLocation::CONTEXT: { 1511 case VariableLocation::CONTEXT: {
1515 DCHECK_EQ(NOT_INSIDE_TYPEOF, typeof_state); 1512 DCHECK_EQ(NOT_INSIDE_TYPEOF, typeof_mode);
1516 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable" 1513 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable"
1517 : "[ Stack variable"); 1514 : "[ Stack variable");
1518 if (var->binding_needs_init()) { 1515 if (var->binding_needs_init()) {
1519 // var->scope() may be NULL when the proxy is located in eval code and 1516 // var->scope() may be NULL when the proxy is located in eval code and
1520 // refers to a potential outside binding. Currently those bindings are 1517 // refers to a potential outside binding. Currently those bindings are
1521 // always looked up dynamically, i.e. in that case 1518 // always looked up dynamically, i.e. in that case
1522 // var->location() == LOOKUP. 1519 // var->location() == LOOKUP.
1523 // always holds. 1520 // always holds.
1524 DCHECK(var->scope() != NULL); 1521 DCHECK(var->scope() != NULL);
1525 1522
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1581 } 1578 }
1582 context()->Plug(var); 1579 context()->Plug(var);
1583 break; 1580 break;
1584 } 1581 }
1585 1582
1586 case VariableLocation::LOOKUP: { 1583 case VariableLocation::LOOKUP: {
1587 Comment cmnt(masm_, "[ Lookup variable"); 1584 Comment cmnt(masm_, "[ Lookup variable");
1588 Label done, slow; 1585 Label done, slow;
1589 // Generate code for loading from variables potentially shadowed 1586 // Generate code for loading from variables potentially shadowed
1590 // by eval-introduced variables. 1587 // by eval-introduced variables.
1591 EmitDynamicLookupFastCase(proxy, typeof_state, &slow, &done); 1588 EmitDynamicLookupFastCase(proxy, typeof_mode, &slow, &done);
1592 __ bind(&slow); 1589 __ bind(&slow);
1593 __ li(a1, Operand(var->name())); 1590 __ li(a1, Operand(var->name()));
1594 __ Push(cp, a1); // Context and name. 1591 __ Push(cp, a1); // Context and name.
1595 Runtime::FunctionId function_id = 1592 Runtime::FunctionId function_id =
1596 typeof_state == NOT_INSIDE_TYPEOF 1593 typeof_mode == NOT_INSIDE_TYPEOF
1597 ? Runtime::kLoadLookupSlot 1594 ? Runtime::kLoadLookupSlot
1598 : Runtime::kLoadLookupSlotNoReferenceError; 1595 : Runtime::kLoadLookupSlotNoReferenceError;
1599 __ CallRuntime(function_id, 2); 1596 __ CallRuntime(function_id, 2);
1600 __ bind(&done); 1597 __ bind(&done);
1601 context()->Plug(v0); 1598 context()->Plug(v0);
1602 } 1599 }
1603 } 1600 }
1604 } 1601 }
1605 1602
1606 1603
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
2267 __ ld(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); 2264 __ ld(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
2268 __ Drop(1); // The function is still on the stack; drop it. 2265 __ Drop(1); // The function is still on the stack; drop it.
2269 2266
2270 // if (!result.done) goto l_try; 2267 // if (!result.done) goto l_try;
2271 __ Move(load_receiver, v0); 2268 __ Move(load_receiver, v0);
2272 2269
2273 __ push(load_receiver); // save result 2270 __ push(load_receiver); // save result
2274 __ LoadRoot(load_name, Heap::kdone_stringRootIndex); // "done" 2271 __ LoadRoot(load_name, Heap::kdone_stringRootIndex); // "done"
2275 __ li(LoadDescriptor::SlotRegister(), 2272 __ li(LoadDescriptor::SlotRegister(),
2276 Operand(SmiFromSlot(expr->DoneFeedbackSlot()))); 2273 Operand(SmiFromSlot(expr->DoneFeedbackSlot())));
2277 CallLoadIC(NOT_CONTEXTUAL); // v0=result.done 2274 CallLoadIC(INSIDE_TYPEOF); // v0=result.done
2278 __ mov(a0, v0); 2275 __ mov(a0, v0);
2279 Handle<Code> bool_ic = ToBooleanStub::GetUninitialized(isolate()); 2276 Handle<Code> bool_ic = ToBooleanStub::GetUninitialized(isolate());
2280 CallIC(bool_ic); 2277 CallIC(bool_ic);
2281 __ Branch(&l_try, eq, v0, Operand(zero_reg)); 2278 __ Branch(&l_try, eq, v0, Operand(zero_reg));
2282 2279
2283 // result.value 2280 // result.value
2284 __ pop(load_receiver); // result 2281 __ pop(load_receiver); // result
2285 __ LoadRoot(load_name, Heap::kvalue_stringRootIndex); // "value" 2282 __ LoadRoot(load_name, Heap::kvalue_stringRootIndex); // "value"
2286 __ li(LoadDescriptor::SlotRegister(), 2283 __ li(LoadDescriptor::SlotRegister(),
2287 Operand(SmiFromSlot(expr->ValueFeedbackSlot()))); 2284 Operand(SmiFromSlot(expr->ValueFeedbackSlot())));
2288 CallLoadIC(NOT_CONTEXTUAL); // v0=result.value 2285 CallLoadIC(INSIDE_TYPEOF); // v0=result.value
2289 context()->DropAndPlug(2, v0); // drop iter and g 2286 context()->DropAndPlug(2, v0); // drop iter and g
2290 break; 2287 break;
2291 } 2288 }
2292 } 2289 }
2293 } 2290 }
2294 2291
2295 2292
2296 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, 2293 void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
2297 Expression *value, 2294 Expression *value,
2298 JSGeneratorObject::ResumeMode resume_mode) { 2295 JSGeneratorObject::ResumeMode resume_mode) {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
2422 2419
2423 2420
2424 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { 2421 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) {
2425 SetExpressionPosition(prop); 2422 SetExpressionPosition(prop);
2426 Literal* key = prop->key()->AsLiteral(); 2423 Literal* key = prop->key()->AsLiteral();
2427 DCHECK(!prop->IsSuperAccess()); 2424 DCHECK(!prop->IsSuperAccess());
2428 2425
2429 __ li(LoadDescriptor::NameRegister(), Operand(key->value())); 2426 __ li(LoadDescriptor::NameRegister(), Operand(key->value()));
2430 __ li(LoadDescriptor::SlotRegister(), 2427 __ li(LoadDescriptor::SlotRegister(),
2431 Operand(SmiFromSlot(prop->PropertyFeedbackSlot()))); 2428 Operand(SmiFromSlot(prop->PropertyFeedbackSlot())));
2432 CallLoadIC(NOT_CONTEXTUAL, language_mode()); 2429 CallLoadIC(INSIDE_TYPEOF, language_mode());
2433 } 2430 }
2434 2431
2435 2432
2436 void FullCodeGenerator::EmitNamedSuperPropertyLoad(Property* prop) { 2433 void FullCodeGenerator::EmitNamedSuperPropertyLoad(Property* prop) {
2437 // Stack: receiver, home_object. 2434 // Stack: receiver, home_object.
2438 SetExpressionPosition(prop); 2435 SetExpressionPosition(prop);
2439 2436
2440 Literal* key = prop->key()->AsLiteral(); 2437 Literal* key = prop->key()->AsLiteral();
2441 DCHECK(!key->value()->IsSmi()); 2438 DCHECK(!key->value()->IsSmi());
2442 DCHECK(prop->IsSuperAccess()); 2439 DCHECK(prop->IsSuperAccess());
(...skipping 2296 matching lines...) Expand 10 before | Expand all | Expand 10 after
4739 // Push the builtins object as the receiver. 4736 // Push the builtins object as the receiver.
4740 Register receiver = LoadDescriptor::ReceiverRegister(); 4737 Register receiver = LoadDescriptor::ReceiverRegister();
4741 __ ld(receiver, GlobalObjectOperand()); 4738 __ ld(receiver, GlobalObjectOperand());
4742 __ ld(receiver, FieldMemOperand(receiver, GlobalObject::kBuiltinsOffset)); 4739 __ ld(receiver, FieldMemOperand(receiver, GlobalObject::kBuiltinsOffset));
4743 __ push(receiver); 4740 __ push(receiver);
4744 4741
4745 // Load the function from the receiver. 4742 // Load the function from the receiver.
4746 __ li(LoadDescriptor::NameRegister(), Operand(expr->name())); 4743 __ li(LoadDescriptor::NameRegister(), Operand(expr->name()));
4747 __ li(LoadDescriptor::SlotRegister(), 4744 __ li(LoadDescriptor::SlotRegister(),
4748 Operand(SmiFromSlot(expr->CallRuntimeFeedbackSlot()))); 4745 Operand(SmiFromSlot(expr->CallRuntimeFeedbackSlot())));
4749 CallLoadIC(NOT_CONTEXTUAL); 4746 CallLoadIC(INSIDE_TYPEOF);
4750 } 4747 }
4751 4748
4752 4749
4753 void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) { 4750 void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) {
4754 ZoneList<Expression*>* args = expr->arguments(); 4751 ZoneList<Expression*>* args = expr->arguments();
4755 int arg_count = args->length(); 4752 int arg_count = args->length();
4756 4753
4757 SetExpressionPosition(expr); 4754 SetExpressionPosition(expr);
4758 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); 4755 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS);
4759 __ ld(a1, MemOperand(sp, (arg_count + 1) * kPointerSize)); 4756 __ ld(a1, MemOperand(sp, (arg_count + 1) * kPointerSize));
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after
5556 reinterpret_cast<uint64_t>( 5553 reinterpret_cast<uint64_t>(
5557 isolate->builtins()->OsrAfterStackCheck()->entry())); 5554 isolate->builtins()->OsrAfterStackCheck()->entry()));
5558 return OSR_AFTER_STACK_CHECK; 5555 return OSR_AFTER_STACK_CHECK;
5559 } 5556 }
5560 5557
5561 5558
5562 } // namespace internal 5559 } // namespace internal
5563 } // namespace v8 5560 } // namespace v8
5564 5561
5565 #endif // V8_TARGET_ARCH_MIPS64 5562 #endif // V8_TARGET_ARCH_MIPS64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698