| OLD | NEW |
| 1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 if (node->name()->IsEqualTo(CStrVector(entry->name))) { | 338 if (node->name()->IsEqualTo(CStrVector(entry->name))) { |
| 339 ((*this).*(entry->method))(args); | 339 ((*this).*(entry->method))(args); |
| 340 return true; | 340 return true; |
| 341 } | 341 } |
| 342 } | 342 } |
| 343 } | 343 } |
| 344 return false; | 344 return false; |
| 345 } | 345 } |
| 346 | 346 |
| 347 | 347 |
| 348 void CodeGenerator::GenerateFastCaseSwitchStatement( | 348 void CodeGenerator::GenerateFastCaseSwitchStatement(SwitchStatement* node, |
| 349 SwitchStatement *node, int min_index, int range, int default_index) { | 349 int min_index, |
| 350 | 350 int range, |
| 351 int default_index) { |
| 351 ZoneList<CaseClause*>* cases = node->cases(); | 352 ZoneList<CaseClause*>* cases = node->cases(); |
| 352 int length = cases->length(); | 353 int length = cases->length(); |
| 353 | 354 |
| 354 // Label pointer per number in range | 355 // Label pointer per number in range |
| 355 SmartPointer<Label*> case_targets(NewArray<Label*>(range)); | 356 SmartPointer<Label*> case_targets(NewArray<Label*>(range)); |
| 356 | 357 |
| 357 // Label per switch case | 358 // Label per switch case |
| 358 SmartPointer<Label> case_labels(NewArray<Label>(length)); | 359 SmartPointer<Label> case_labels(NewArray<Label>(length)); |
| 359 | 360 |
| 360 Label* fail_label = (default_index >= 0 ? &(case_labels[default_index]) | 361 Label* fail_label = default_index >= 0 ? &(case_labels[default_index]) |
| 361 : node->break_target()); | 362 : node->break_target(); |
| 362 | 363 |
| 363 // Populate array of label pointers for each number in the range. | 364 // Populate array of label pointers for each number in the range. |
| 364 // Initally put the failure label everywhere. | 365 // Initally put the failure label everywhere. |
| 365 for (int i = 0; i < range; i++) { | 366 for (int i = 0; i < range; i++) { |
| 366 case_targets[i] = fail_label; | 367 case_targets[i] = fail_label; |
| 367 } | 368 } |
| 368 | 369 |
| 369 // Overwrite with label of a case for the number value of that case. | 370 // Overwrite with label of a case for the number value of that case. |
| 370 // (In reverse order, so that if the same label occurs twice, the | 371 // (In reverse order, so that if the same label occurs twice, the |
| 371 // first one wins). | 372 // first one wins). |
| 372 for (int i = length-1; i >= 0 ; i--) { | 373 for (int i = length-1; i >= 0 ; i--) { |
| 373 CaseClause* clause = cases->at(i); | 374 CaseClause* clause = cases->at(i); |
| 374 if (!clause->is_default()) { | 375 if (!clause->is_default()) { |
| 375 Object* label_value = *(clause->label()->AsLiteral()->handle()); | 376 Object* label_value = *(clause->label()->AsLiteral()->handle()); |
| 376 int case_value = Smi::cast(label_value)->value(); | 377 int case_value = Smi::cast(label_value)->value(); |
| 377 case_targets[case_value - min_index] = &(case_labels[i]); | 378 case_targets[case_value - min_index] = &(case_labels[i]); |
| 378 } | 379 } |
| 379 } | 380 } |
| 380 | 381 |
| 381 GenerateFastCaseSwitchJumpTable(node, min_index, range, fail_label, | 382 GenerateFastCaseSwitchJumpTable(node, min_index, range, fail_label, |
| 382 case_targets, case_labels); | 383 case_targets, case_labels); |
| 383 } | 384 } |
| 384 | 385 |
| 386 |
| 385 void CodeGenerator::GenerateFastCaseSwitchCases( | 387 void CodeGenerator::GenerateFastCaseSwitchCases( |
| 386 SwitchStatement* node, SmartPointer<Label> &case_labels) { | 388 SwitchStatement* node, |
| 387 | 389 SmartPointer<Label>& case_labels) { |
| 388 ZoneList<CaseClause*>* cases = node->cases(); | 390 ZoneList<CaseClause*>* cases = node->cases(); |
| 389 int length = cases->length(); | 391 int length = cases->length(); |
| 390 | 392 |
| 391 for (int i = 0; i < length; i++) { | 393 for (int i = 0; i < length; i++) { |
| 392 Comment cmnt(masm(), "[ case clause"); | 394 Comment cmnt(masm(), "[ Case clause"); |
| 393 masm()->bind(&(case_labels[i])); | 395 masm()->bind(&(case_labels[i])); |
| 394 VisitStatements(cases->at(i)->statements()); | 396 VisitStatements(cases->at(i)->statements()); |
| 395 } | 397 } |
| 396 | 398 |
| 397 masm()->bind(node->break_target()); | 399 masm()->bind(node->break_target()); |
| 398 } | 400 } |
| 399 | 401 |
| 400 | 402 |
| 401 bool CodeGenerator::TryGenerateFastCaseSwitchStatement(SwitchStatement* node) { | 403 bool CodeGenerator::TryGenerateFastCaseSwitchStatement(SwitchStatement* node) { |
| 402 ZoneList<CaseClause*>* cases = node->cases(); | 404 ZoneList<CaseClause*>* cases = node->cases(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 void ArgumentsAccessStub::Generate(MacroAssembler* masm) { | 461 void ArgumentsAccessStub::Generate(MacroAssembler* masm) { |
| 460 switch (type_) { | 462 switch (type_) { |
| 461 case READ_LENGTH: GenerateReadLength(masm); break; | 463 case READ_LENGTH: GenerateReadLength(masm); break; |
| 462 case READ_ELEMENT: GenerateReadElement(masm); break; | 464 case READ_ELEMENT: GenerateReadElement(masm); break; |
| 463 case NEW_OBJECT: GenerateNewObject(masm); break; | 465 case NEW_OBJECT: GenerateNewObject(masm); break; |
| 464 } | 466 } |
| 465 } | 467 } |
| 466 | 468 |
| 467 | 469 |
| 468 } } // namespace v8::internal | 470 } } // namespace v8::internal |
| OLD | NEW |