| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 5659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5670 case Variable::LOOKUP: | 5670 case Variable::LOOKUP: |
| 5671 return Bailout("reference to a variable which requires dynamic lookup"); | 5671 return Bailout("reference to a variable which requires dynamic lookup"); |
| 5672 } | 5672 } |
| 5673 } | 5673 } |
| 5674 | 5674 |
| 5675 | 5675 |
| 5676 void HOptimizedGraphBuilder::VisitLiteral(Literal* expr) { | 5676 void HOptimizedGraphBuilder::VisitLiteral(Literal* expr) { |
| 5677 ASSERT(!HasStackOverflow()); | 5677 ASSERT(!HasStackOverflow()); |
| 5678 ASSERT(current_block() != NULL); | 5678 ASSERT(current_block() != NULL); |
| 5679 ASSERT(current_block()->HasPredecessor()); | 5679 ASSERT(current_block()->HasPredecessor()); |
| 5680 HConstant* instr = new(zone()) HConstant(expr->handle()); | 5680 HConstant* instr = new(zone()) HConstant(expr->value()); |
| 5681 return ast_context()->ReturnInstruction(instr, expr->id()); | 5681 return ast_context()->ReturnInstruction(instr, expr->id()); |
| 5682 } | 5682 } |
| 5683 | 5683 |
| 5684 | 5684 |
| 5685 void HOptimizedGraphBuilder::VisitRegExpLiteral(RegExpLiteral* expr) { | 5685 void HOptimizedGraphBuilder::VisitRegExpLiteral(RegExpLiteral* expr) { |
| 5686 ASSERT(!HasStackOverflow()); | 5686 ASSERT(!HasStackOverflow()); |
| 5687 ASSERT(current_block() != NULL); | 5687 ASSERT(current_block() != NULL); |
| 5688 ASSERT(current_block()->HasPredecessor()); | 5688 ASSERT(current_block()->HasPredecessor()); |
| 5689 Handle<JSFunction> closure = function_state()->compilation_info()->closure(); | 5689 Handle<JSFunction> closure = function_state()->compilation_info()->closure(); |
| 5690 Handle<FixedArray> literals(closure->literals()); | 5690 Handle<FixedArray> literals(closure->literals()); |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5931 if (property->IsCompileTimeValue()) continue; | 5931 if (property->IsCompileTimeValue()) continue; |
| 5932 | 5932 |
| 5933 Literal* key = property->key(); | 5933 Literal* key = property->key(); |
| 5934 Expression* value = property->value(); | 5934 Expression* value = property->value(); |
| 5935 | 5935 |
| 5936 switch (property->kind()) { | 5936 switch (property->kind()) { |
| 5937 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | 5937 case ObjectLiteral::Property::MATERIALIZED_LITERAL: |
| 5938 ASSERT(!CompileTimeValue::IsCompileTimeValue(value)); | 5938 ASSERT(!CompileTimeValue::IsCompileTimeValue(value)); |
| 5939 // Fall through. | 5939 // Fall through. |
| 5940 case ObjectLiteral::Property::COMPUTED: | 5940 case ObjectLiteral::Property::COMPUTED: |
| 5941 if (key->handle()->IsInternalizedString()) { | 5941 if (key->value()->IsInternalizedString()) { |
| 5942 if (property->emit_store()) { | 5942 if (property->emit_store()) { |
| 5943 CHECK_ALIVE(VisitForValue(value)); | 5943 CHECK_ALIVE(VisitForValue(value)); |
| 5944 HValue* value = Pop(); | 5944 HValue* value = Pop(); |
| 5945 Handle<Map> map = property->GetReceiverType(); | 5945 Handle<Map> map = property->GetReceiverType(); |
| 5946 Handle<String> name = property->key()->AsPropertyName(); | 5946 Handle<String> name = property->key()->AsPropertyName(); |
| 5947 HInstruction* store; | 5947 HInstruction* store; |
| 5948 if (map.is_null()) { | 5948 if (map.is_null()) { |
| 5949 // If we don't know the monomorphic type, do a generic store. | 5949 // If we don't know the monomorphic type, do a generic store. |
| 5950 CHECK_ALIVE(store = BuildStoreNamedGeneric(literal, name, value)); | 5950 CHECK_ALIVE(store = BuildStoreNamedGeneric(literal, name, value)); |
| 5951 } else { | 5951 } else { |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6584 | 6584 |
| 6585 | 6585 |
| 6586 void HOptimizedGraphBuilder::BuildStoreNamed(Expression* expr, | 6586 void HOptimizedGraphBuilder::BuildStoreNamed(Expression* expr, |
| 6587 BailoutId id, | 6587 BailoutId id, |
| 6588 int position, | 6588 int position, |
| 6589 BailoutId assignment_id, | 6589 BailoutId assignment_id, |
| 6590 Property* prop, | 6590 Property* prop, |
| 6591 HValue* object, | 6591 HValue* object, |
| 6592 HValue* value) { | 6592 HValue* value) { |
| 6593 Literal* key = prop->key()->AsLiteral(); | 6593 Literal* key = prop->key()->AsLiteral(); |
| 6594 Handle<String> name = Handle<String>::cast(key->handle()); | 6594 Handle<String> name = Handle<String>::cast(key->value()); |
| 6595 ASSERT(!name.is_null()); | 6595 ASSERT(!name.is_null()); |
| 6596 | 6596 |
| 6597 HInstruction* instr = NULL; | 6597 HInstruction* instr = NULL; |
| 6598 SmallMapList* types = expr->GetReceiverTypes(); | 6598 SmallMapList* types = expr->GetReceiverTypes(); |
| 6599 bool monomorphic = expr->IsMonomorphic(); | 6599 bool monomorphic = expr->IsMonomorphic(); |
| 6600 Handle<Map> map; | 6600 Handle<Map> map; |
| 6601 if (monomorphic) { | 6601 if (monomorphic) { |
| 6602 map = types->first(); | 6602 map = types->first(); |
| 6603 if (map->is_dictionary_map()) monomorphic = false; | 6603 if (map->is_dictionary_map()) monomorphic = false; |
| 6604 } | 6604 } |
| (...skipping 2894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9499 } | 9499 } |
| 9500 | 9500 |
| 9501 | 9501 |
| 9502 // Check for the form (%_ClassOf(foo) === 'BarClass'). | 9502 // Check for the form (%_ClassOf(foo) === 'BarClass'). |
| 9503 static bool IsClassOfTest(CompareOperation* expr) { | 9503 static bool IsClassOfTest(CompareOperation* expr) { |
| 9504 if (expr->op() != Token::EQ_STRICT) return false; | 9504 if (expr->op() != Token::EQ_STRICT) return false; |
| 9505 CallRuntime* call = expr->left()->AsCallRuntime(); | 9505 CallRuntime* call = expr->left()->AsCallRuntime(); |
| 9506 if (call == NULL) return false; | 9506 if (call == NULL) return false; |
| 9507 Literal* literal = expr->right()->AsLiteral(); | 9507 Literal* literal = expr->right()->AsLiteral(); |
| 9508 if (literal == NULL) return false; | 9508 if (literal == NULL) return false; |
| 9509 if (!literal->handle()->IsString()) return false; | 9509 if (!literal->value()->IsString()) return false; |
| 9510 if (!call->name()->IsOneByteEqualTo(STATIC_ASCII_VECTOR("_ClassOf"))) { | 9510 if (!call->name()->IsOneByteEqualTo(STATIC_ASCII_VECTOR("_ClassOf"))) { |
| 9511 return false; | 9511 return false; |
| 9512 } | 9512 } |
| 9513 ASSERT(call->arguments()->length() == 1); | 9513 ASSERT(call->arguments()->length() == 1); |
| 9514 return true; | 9514 return true; |
| 9515 } | 9515 } |
| 9516 | 9516 |
| 9517 | 9517 |
| 9518 void HOptimizedGraphBuilder::VisitBinaryOperation(BinaryOperation* expr) { | 9518 void HOptimizedGraphBuilder::VisitBinaryOperation(BinaryOperation* expr) { |
| 9519 ASSERT(!HasStackOverflow()); | 9519 ASSERT(!HasStackOverflow()); |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9745 void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) { | 9745 void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) { |
| 9746 ASSERT(!HasStackOverflow()); | 9746 ASSERT(!HasStackOverflow()); |
| 9747 ASSERT(current_block() != NULL); | 9747 ASSERT(current_block() != NULL); |
| 9748 ASSERT(current_block()->HasPredecessor()); | 9748 ASSERT(current_block()->HasPredecessor()); |
| 9749 if (IsClassOfTest(expr)) { | 9749 if (IsClassOfTest(expr)) { |
| 9750 CallRuntime* call = expr->left()->AsCallRuntime(); | 9750 CallRuntime* call = expr->left()->AsCallRuntime(); |
| 9751 ASSERT(call->arguments()->length() == 1); | 9751 ASSERT(call->arguments()->length() == 1); |
| 9752 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); | 9752 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); |
| 9753 HValue* value = Pop(); | 9753 HValue* value = Pop(); |
| 9754 Literal* literal = expr->right()->AsLiteral(); | 9754 Literal* literal = expr->right()->AsLiteral(); |
| 9755 Handle<String> rhs = Handle<String>::cast(literal->handle()); | 9755 Handle<String> rhs = Handle<String>::cast(literal->value()); |
| 9756 HClassOfTestAndBranch* instr = | 9756 HClassOfTestAndBranch* instr = |
| 9757 new(zone()) HClassOfTestAndBranch(value, rhs); | 9757 new(zone()) HClassOfTestAndBranch(value, rhs); |
| 9758 instr->set_position(expr->position()); | 9758 instr->set_position(expr->position()); |
| 9759 return ast_context()->ReturnControl(instr, expr->id()); | 9759 return ast_context()->ReturnControl(instr, expr->id()); |
| 9760 } | 9760 } |
| 9761 | 9761 |
| 9762 Handle<Type> left_type = expr->left()->lower_type(); | 9762 Handle<Type> left_type = expr->left()->lower_type(); |
| 9763 Handle<Type> right_type = expr->right()->lower_type(); | 9763 Handle<Type> right_type = expr->right()->lower_type(); |
| 9764 Handle<Type> combined_type = expr->combined_type(); | 9764 Handle<Type> combined_type = expr->combined_type(); |
| 9765 Representation combined_rep = ToRepresentation(combined_type); | 9765 Representation combined_rep = ToRepresentation(combined_type); |
| (...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10536 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); | 10536 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); |
| 10537 HValue* value = Pop(); | 10537 HValue* value = Pop(); |
| 10538 HValueOf* result = new(zone()) HValueOf(value); | 10538 HValueOf* result = new(zone()) HValueOf(value); |
| 10539 return ast_context()->ReturnInstruction(result, call->id()); | 10539 return ast_context()->ReturnInstruction(result, call->id()); |
| 10540 } | 10540 } |
| 10541 | 10541 |
| 10542 | 10542 |
| 10543 void HOptimizedGraphBuilder::GenerateDateField(CallRuntime* call) { | 10543 void HOptimizedGraphBuilder::GenerateDateField(CallRuntime* call) { |
| 10544 ASSERT(call->arguments()->length() == 2); | 10544 ASSERT(call->arguments()->length() == 2); |
| 10545 ASSERT_NE(NULL, call->arguments()->at(1)->AsLiteral()); | 10545 ASSERT_NE(NULL, call->arguments()->at(1)->AsLiteral()); |
| 10546 Smi* index = Smi::cast(*(call->arguments()->at(1)->AsLiteral()->handle())); | 10546 Smi* index = Smi::cast(*(call->arguments()->at(1)->AsLiteral()->value())); |
| 10547 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); | 10547 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); |
| 10548 HValue* date = Pop(); | 10548 HValue* date = Pop(); |
| 10549 HDateField* result = new(zone()) HDateField(date, index); | 10549 HDateField* result = new(zone()) HDateField(date, index); |
| 10550 return ast_context()->ReturnInstruction(result, call->id()); | 10550 return ast_context()->ReturnInstruction(result, call->id()); |
| 10551 } | 10551 } |
| 10552 | 10552 |
| 10553 | 10553 |
| 10554 void HOptimizedGraphBuilder::GenerateOneByteSeqStringSetChar( | 10554 void HOptimizedGraphBuilder::GenerateOneByteSeqStringSetChar( |
| 10555 CallRuntime* call) { | 10555 CallRuntime* call) { |
| 10556 ASSERT(call->arguments()->length() == 3); | 10556 ASSERT(call->arguments()->length() == 3); |
| (...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11584 } | 11584 } |
| 11585 } | 11585 } |
| 11586 | 11586 |
| 11587 #ifdef DEBUG | 11587 #ifdef DEBUG |
| 11588 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 11588 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
| 11589 if (allocator_ != NULL) allocator_->Verify(); | 11589 if (allocator_ != NULL) allocator_->Verify(); |
| 11590 #endif | 11590 #endif |
| 11591 } | 11591 } |
| 11592 | 11592 |
| 11593 } } // namespace v8::internal | 11593 } } // namespace v8::internal |
| OLD | NEW |