| 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 emit_store_ = emit_store; | 208 emit_store_ = emit_store; |
| 209 } | 209 } |
| 210 | 210 |
| 211 | 211 |
| 212 bool ObjectLiteral::Property::emit_store() { | 212 bool ObjectLiteral::Property::emit_store() { |
| 213 return emit_store_; | 213 return emit_store_; |
| 214 } | 214 } |
| 215 | 215 |
| 216 | 216 |
| 217 bool IsEqualString(void* first, void* second) { | 217 bool IsEqualString(void* first, void* second) { |
| 218 ASSERT((*reinterpret_cast<String**>(first))->IsString()); |
| 219 ASSERT((*reinterpret_cast<String**>(second))->IsString()); |
| 218 Handle<String> h1(reinterpret_cast<String**>(first)); | 220 Handle<String> h1(reinterpret_cast<String**>(first)); |
| 219 Handle<String> h2(reinterpret_cast<String**>(second)); | 221 Handle<String> h2(reinterpret_cast<String**>(second)); |
| 220 return (*h1)->Equals(*h2); | 222 return (*h1)->Equals(*h2); |
| 221 } | 223 } |
| 222 | 224 |
| 223 bool IsEqualSmi(void* first, void* second) { | 225 bool IsEqualSmi(void* first, void* second) { |
| 226 ASSERT((*reinterpret_cast<Smi**>(first))->IsSmi()); |
| 227 ASSERT((*reinterpret_cast<Smi**>(second))->IsSmi()); |
| 224 Handle<Smi> h1(reinterpret_cast<Smi**>(first)); | 228 Handle<Smi> h1(reinterpret_cast<Smi**>(first)); |
| 225 Handle<Smi> h2(reinterpret_cast<Smi**>(second)); | 229 Handle<Smi> h2(reinterpret_cast<Smi**>(second)); |
| 226 return (*h1)->value() == (*h2)->value(); | 230 return (*h1)->value() == (*h2)->value(); |
| 227 } | 231 } |
| 228 | 232 |
| 229 void ObjectLiteral::CalculateEmitStore() { | 233 void ObjectLiteral::CalculateEmitStore() { |
| 230 HashMap properties(&IsEqualString); | 234 HashMap properties(&IsEqualString); |
| 231 HashMap elements(&IsEqualSmi); | 235 HashMap elements(&IsEqualSmi); |
| 232 for (int i = this->properties()->length() - 1; i >= 0; i--) { | 236 for (int i = this->properties()->length() - 1; i >= 0; i--) { |
| 233 ObjectLiteral::Property* property = this->properties()->at(i); | 237 ObjectLiteral::Property* property = this->properties()->at(i); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 259 Vector<char> buffer(arr, ARRAY_SIZE(arr)); | 263 Vector<char> buffer(arr, ARRAY_SIZE(arr)); |
| 260 const char* str = DoubleToCString(num, buffer); | 264 const char* str = DoubleToCString(num, buffer); |
| 261 Handle<String> name = Factory::NewStringFromAscii(CStrVector(str)); | 265 Handle<String> name = Factory::NewStringFromAscii(CStrVector(str)); |
| 262 key = name.location(); | 266 key = name.location(); |
| 263 hash = name->Hash(); | 267 hash = name->Hash(); |
| 264 table = &properties; | 268 table = &properties; |
| 265 } | 269 } |
| 266 // If the key of a computed property is in the table, do not emit | 270 // If the key of a computed property is in the table, do not emit |
| 267 // a store for the property later. | 271 // a store for the property later. |
| 268 if (property->kind() == ObjectLiteral::Property::COMPUTED) { | 272 if (property->kind() == ObjectLiteral::Property::COMPUTED) { |
| 269 if (table->Lookup(literal, hash, false) != NULL) { | 273 if (table->Lookup(key, hash, false) != NULL) { |
| 270 property->set_emit_store(false); | 274 property->set_emit_store(false); |
| 271 } | 275 } |
| 272 } | 276 } |
| 273 // Add key to the table. | 277 // Add key to the table. |
| 274 table->Lookup(literal, hash, true); | 278 table->Lookup(key, hash, true); |
| 275 } | 279 } |
| 276 } | 280 } |
| 277 | 281 |
| 278 | 282 |
| 279 void TargetCollector::AddTarget(BreakTarget* target) { | 283 void TargetCollector::AddTarget(BreakTarget* target) { |
| 280 // Add the label to the collector, but discard duplicates. | 284 // Add the label to the collector, but discard duplicates. |
| 281 int length = targets_->length(); | 285 int length = targets_->length(); |
| 282 for (int i = 0; i < length; i++) { | 286 for (int i = 0; i < length; i++) { |
| 283 if (targets_->at(i) == target) return; | 287 if (targets_->at(i) == target) return; |
| 284 } | 288 } |
| (...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1041 | 1045 |
| 1042 CaseClause::CaseClause(Expression* label, | 1046 CaseClause::CaseClause(Expression* label, |
| 1043 ZoneList<Statement*>* statements, | 1047 ZoneList<Statement*>* statements, |
| 1044 int pos) | 1048 int pos) |
| 1045 : label_(label), | 1049 : label_(label), |
| 1046 statements_(statements), | 1050 statements_(statements), |
| 1047 position_(pos), | 1051 position_(pos), |
| 1048 compare_type_(NONE) {} | 1052 compare_type_(NONE) {} |
| 1049 | 1053 |
| 1050 } } // namespace v8::internal | 1054 } } // namespace v8::internal |
| OLD | NEW |