| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1157 } | 1157 } |
| 1158 } else { | 1158 } else { |
| 1159 present_flags_ |= array_[i].value->flags(); // Keep it. | 1159 present_flags_ |= array_[i].value->flags(); // Keep it. |
| 1160 } | 1160 } |
| 1161 } | 1161 } |
| 1162 } | 1162 } |
| 1163 } | 1163 } |
| 1164 | 1164 |
| 1165 | 1165 |
| 1166 HValue* HValueMap::Lookup(HValue* value) const { | 1166 HValue* HValueMap::Lookup(HValue* value) const { |
| 1167 uint32_t hash = value->Hashcode(); | 1167 uint32_t hash = static_cast<uint32_t>(value->Hashcode()); |
| 1168 uint32_t pos = Bound(hash); | 1168 uint32_t pos = Bound(hash); |
| 1169 if (array_[pos].value != NULL) { | 1169 if (array_[pos].value != NULL) { |
| 1170 if (array_[pos].value->Equals(value)) return array_[pos].value; | 1170 if (array_[pos].value->Equals(value)) return array_[pos].value; |
| 1171 int next = array_[pos].next; | 1171 int next = array_[pos].next; |
| 1172 while (next != kNil) { | 1172 while (next != kNil) { |
| 1173 if (lists_[next].value->Equals(value)) return lists_[next].value; | 1173 if (lists_[next].value->Equals(value)) return lists_[next].value; |
| 1174 next = lists_[next].next; | 1174 next = lists_[next].next; |
| 1175 } | 1175 } |
| 1176 } | 1176 } |
| 1177 return NULL; | 1177 return NULL; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1245 } | 1245 } |
| 1246 } | 1246 } |
| 1247 | 1247 |
| 1248 | 1248 |
| 1249 void HValueMap::Insert(HValue* value) { | 1249 void HValueMap::Insert(HValue* value) { |
| 1250 ASSERT(value != NULL); | 1250 ASSERT(value != NULL); |
| 1251 // Resizing when half of the hashtable is filled up. | 1251 // Resizing when half of the hashtable is filled up. |
| 1252 if (count_ >= array_size_ >> 1) Resize(array_size_ << 1); | 1252 if (count_ >= array_size_ >> 1) Resize(array_size_ << 1); |
| 1253 ASSERT(count_ < array_size_); | 1253 ASSERT(count_ < array_size_); |
| 1254 count_++; | 1254 count_++; |
| 1255 uint32_t pos = Bound(value->Hashcode()); | 1255 uint32_t pos = Bound(static_cast<uint32_t>(value->Hashcode())); |
| 1256 if (array_[pos].value == NULL) { | 1256 if (array_[pos].value == NULL) { |
| 1257 array_[pos].value = value; | 1257 array_[pos].value = value; |
| 1258 array_[pos].next = kNil; | 1258 array_[pos].next = kNil; |
| 1259 } else { | 1259 } else { |
| 1260 if (free_list_head_ == kNil) { | 1260 if (free_list_head_ == kNil) { |
| 1261 ResizeLists(lists_size_ << 1); | 1261 ResizeLists(lists_size_ << 1); |
| 1262 } | 1262 } |
| 1263 int new_element_pos = free_list_head_; | 1263 int new_element_pos = free_list_head_; |
| 1264 ASSERT(new_element_pos != kNil); | 1264 ASSERT(new_element_pos != kNil); |
| 1265 free_list_head_ = lists_[free_list_head_].next; | 1265 free_list_head_ = lists_[free_list_head_].next; |
| (...skipping 2704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3970 } | 3970 } |
| 3971 | 3971 |
| 3972 // Update inlined nodes count. | 3972 // Update inlined nodes count. |
| 3973 inlined_count_ += nodes_added; | 3973 inlined_count_ += nodes_added; |
| 3974 | 3974 |
| 3975 if (FLAG_trace_inlining) TraceInline(target, true); | 3975 if (FLAG_trace_inlining) TraceInline(target, true); |
| 3976 | 3976 |
| 3977 if (body->HasExit()) { | 3977 if (body->HasExit()) { |
| 3978 // Add a return of undefined if control can fall off the body. In a | 3978 // Add a return of undefined if control can fall off the body. In a |
| 3979 // test context, undefined is false. | 3979 // test context, undefined is false. |
| 3980 HValue* return_value = NULL; | 3980 HValue* return_value = graph()->GetConstantUndefined(); |
| 3981 HBasicBlock* target = NULL; | |
| 3982 if (test_context == NULL) { | 3981 if (test_context == NULL) { |
| 3983 ASSERT(function_return_ != NULL); | 3982 ASSERT(function_return_ != NULL); |
| 3984 return_value = graph()->GetConstantUndefined(); | 3983 body->exit_block()->AddLeaveInlined(return_value, function_return_); |
| 3985 target = function_return_; | |
| 3986 } else { | 3984 } else { |
| 3987 return_value = graph()->GetConstantFalse(); | 3985 // The graph builder assumes control can reach both branches of a |
| 3988 target = test_context->if_false(); | 3986 // test, so we materialize the undefined value and test it rather than |
| 3987 // simply jumping to the false target. |
| 3988 // |
| 3989 // TODO(3168478): refactor to avoid this. |
| 3990 HBasicBlock* materialize_true = graph()->CreateBasicBlock(); |
| 3991 HBasicBlock* materialize_false = graph()->CreateBasicBlock(); |
| 3992 HBranch* branch = |
| 3993 new HBranch(materialize_true, materialize_false, return_value); |
| 3994 body->exit_block()->Finish(branch); |
| 3995 |
| 3996 materialize_true->AddLeaveInlined(graph()->GetConstantTrue(), |
| 3997 test_context->if_true()); |
| 3998 materialize_false->AddLeaveInlined(graph()->GetConstantFalse(), |
| 3999 test_context->if_false()); |
| 3989 } | 4000 } |
| 3990 body->exit_block()->AddLeaveInlined(return_value, target); | |
| 3991 body->set_exit_block(NULL); | 4001 body->set_exit_block(NULL); |
| 3992 } | 4002 } |
| 3993 | 4003 |
| 3994 // Record the environment at the inlined function call. | 4004 // Record the environment at the inlined function call. |
| 3995 AddSimulate(expr->ReturnId()); | 4005 AddSimulate(expr->ReturnId()); |
| 3996 | 4006 |
| 3997 // Jump to the function entry (without re-recording the environment). | 4007 // Jump to the function entry (without re-recording the environment). |
| 3998 subgraph()->exit_block()->Finish(new HGoto(body->entry_block())); | 4008 subgraph()->exit_block()->Finish(new HGoto(body->entry_block())); |
| 3999 | 4009 |
| 4000 // Fix up the function exits. | 4010 // Fix up the function exits. |
| (...skipping 1530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5531 } | 5541 } |
| 5532 | 5542 |
| 5533 #ifdef DEBUG | 5543 #ifdef DEBUG |
| 5534 if (graph_ != NULL) graph_->Verify(); | 5544 if (graph_ != NULL) graph_->Verify(); |
| 5535 if (chunk_ != NULL) chunk_->Verify(); | 5545 if (chunk_ != NULL) chunk_->Verify(); |
| 5536 if (allocator_ != NULL) allocator_->Verify(); | 5546 if (allocator_ != NULL) allocator_->Verify(); |
| 5537 #endif | 5547 #endif |
| 5538 } | 5548 } |
| 5539 | 5549 |
| 5540 } } // namespace v8::internal | 5550 } } // namespace v8::internal |
| OLD | NEW |