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

Side by Side Diff: src/data-flow.cc

Issue 1132005: Add iterative primitive type analysis.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « src/data-flow.h ('k') | src/prettyprinter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1976 matching lines...) Expand 10 before | Expand all | Expand 10 after
1987 } 1987 }
1988 1988
1989 // Step 4: Based on RD_in for block nodes, propagate reaching definitions 1989 // Step 4: Based on RD_in for block nodes, propagate reaching definitions
1990 // to all variable uses in the block. 1990 // to all variable uses in the block.
1991 for (int i = 0; i < node_count; i++) { 1991 for (int i = 0; i < node_count; i++) {
1992 postorder_->at(i)->PropagateReachingDefinitions(&variables); 1992 postorder_->at(i)->PropagateReachingDefinitions(&variables);
1993 } 1993 }
1994 } 1994 }
1995 1995
1996 1996
1997 bool TypeAnalyzer::IsPrimitiveDef(int def_num) {
1998 if (def_num < param_count_) return false;
1999 if (def_num < variable_count_) return true;
2000 return body_definitions_->at(def_num - variable_count_)->IsPrimitive();
2001 }
2002
2003
2004 void TypeAnalyzer::Compute() {
2005 bool changed;
2006 int count = 0;
2007
2008 do {
2009 changed = false;
2010
2011 if (FLAG_print_graph_text) {
2012 PrintF("TypeAnalyzer::Compute - iteration %d\n", count++);
2013 }
2014
2015 for (int i = postorder_->length() - 1; i >= 0; --i) {
2016 Node* node = postorder_->at(i);
2017 if (node->IsBlockNode()) {
2018 BlockNode* block = BlockNode::cast(node);
2019 for (int j = 0; j < block->instructions()->length(); j++) {
2020 Expression* expr = block->instructions()->at(j)->AsExpression();
2021 if (expr != NULL) {
2022 // For variable uses: Compute new type from reaching definitions.
2023 VariableProxy* proxy = expr->AsVariableProxy();
2024 if (proxy != NULL && proxy->reaching_definitions() != NULL) {
2025 BitVector* rd = proxy->reaching_definitions();
2026 bool prim_type = true;
2027 // TODO(fsc): A sparse set representation of reaching
2028 // definitions would speed up iterating here.
2029 for (int k = 0; k < rd->length(); k++) {
2030 if (rd->Contains(k) && !IsPrimitiveDef(k)) {
2031 prim_type = false;
2032 break;
2033 }
2034 }
2035 // Reset changed flag if new type information was computed.
2036 if (prim_type != proxy->IsPrimitive()) {
2037 changed = true;
2038 proxy->SetIsPrimitive(prim_type);
2039 }
2040 }
2041 }
2042 }
2043 }
2044 }
2045 } while (changed);
2046 }
2047
2048
1997 } } // namespace v8::internal 2049 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/data-flow.h ('k') | src/prettyprinter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698