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

Side by Side Diff: src/ia32/codegen-ia32.cc

Issue 4004006: Fix a bug that prevents constants from overwriting function values in object ... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 1 month 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
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 5541 matching lines...) Expand 10 before | Expand all | Expand 10 after
5552 // Should the object literal have fast elements? 5552 // Should the object literal have fast elements?
5553 frame_->Push(Smi::FromInt(node->fast_elements() ? 1 : 0)); 5553 frame_->Push(Smi::FromInt(node->fast_elements() ? 1 : 0));
5554 Result clone; 5554 Result clone;
5555 if (node->depth() > 1) { 5555 if (node->depth() > 1) {
5556 clone = frame_->CallRuntime(Runtime::kCreateObjectLiteral, 4); 5556 clone = frame_->CallRuntime(Runtime::kCreateObjectLiteral, 4);
5557 } else { 5557 } else {
5558 clone = frame_->CallRuntime(Runtime::kCreateObjectLiteralShallow, 4); 5558 clone = frame_->CallRuntime(Runtime::kCreateObjectLiteralShallow, 4);
5559 } 5559 }
5560 frame_->Push(&clone); 5560 frame_->Push(&clone);
5561 5561
5562 // Mark all computed expressions that are bound to a key that
5563 // is shadowed by a later occurrence of the same key. For the
5564 // marked expressions, no store code is emitted.
5565 node->CalculateEmitStore();
5566
5562 for (int i = 0; i < node->properties()->length(); i++) { 5567 for (int i = 0; i < node->properties()->length(); i++) {
5563 ObjectLiteral::Property* property = node->properties()->at(i); 5568 ObjectLiteral::Property* property = node->properties()->at(i);
5564 switch (property->kind()) { 5569 switch (property->kind()) {
5565 case ObjectLiteral::Property::CONSTANT: 5570 case ObjectLiteral::Property::CONSTANT:
5566 break; 5571 break;
5567 case ObjectLiteral::Property::MATERIALIZED_LITERAL: 5572 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
5568 if (CompileTimeValue::IsCompileTimeValue(property->value())) break; 5573 if (CompileTimeValue::IsCompileTimeValue(property->value())) break;
5569 // else fall through. 5574 // else fall through.
5570 case ObjectLiteral::Property::COMPUTED: { 5575 case ObjectLiteral::Property::COMPUTED: {
5571 Handle<Object> key(property->key()->handle()); 5576 Handle<Object> key(property->key()->handle());
5572 if (key->IsSymbol()) { 5577 if (key->IsSymbol()) {
5573 // Duplicate the object as the IC receiver. 5578 // Duplicate the object as the IC receiver.
5574 frame_->Dup(); 5579 frame_->Dup();
5575 Load(property->value()); 5580 Load(property->value());
5576 Result ignored = 5581 if (property->emit_store()) {
5577 frame_->CallStoreIC(Handle<String>::cast(key), false); 5582 Result ignored =
5578 // A test eax instruction following the store IC call would 5583 frame_->CallStoreIC(Handle<String>::cast(key), false);
5579 // indicate the presence of an inlined version of the 5584 // A test eax instruction following the store IC call would
5580 // store. Add a nop to indicate that there is no such 5585 // indicate the presence of an inlined version of the
5581 // inlined version. 5586 // store. Add a nop to indicate that there is no such
5582 __ nop(); 5587 // inlined version.
5588 __ nop();
5589 } else {
5590 frame_->Drop(2);
5591 }
5583 break; 5592 break;
5584 } 5593 }
5585 // Fall through 5594 // Fall through
5586 } 5595 }
5587 case ObjectLiteral::Property::PROTOTYPE: { 5596 case ObjectLiteral::Property::PROTOTYPE: {
5588 // Duplicate the object as an argument to the runtime call. 5597 // Duplicate the object as an argument to the runtime call.
5589 frame_->Dup(); 5598 frame_->Dup();
5590 Load(property->key()); 5599 Load(property->key());
5591 Load(property->value()); 5600 Load(property->value());
5592 Result ignored = frame_->CallRuntime(Runtime::kSetProperty, 3); 5601 if (property->emit_store()) {
5593 // Ignore the result. 5602 // Ignore the result.
5603 Result ignored = frame_->CallRuntime(Runtime::kSetProperty, 3);
5604 } else {
5605 frame_->Drop(3);
5606 }
5594 break; 5607 break;
5595 } 5608 }
5596 case ObjectLiteral::Property::SETTER: { 5609 case ObjectLiteral::Property::SETTER: {
5597 // Duplicate the object as an argument to the runtime call. 5610 // Duplicate the object as an argument to the runtime call.
5598 frame_->Dup(); 5611 frame_->Dup();
5599 Load(property->key()); 5612 Load(property->key());
5600 frame_->Push(Smi::FromInt(1)); 5613 frame_->Push(Smi::FromInt(1));
5601 Load(property->value()); 5614 Load(property->value());
5602 Result ignored = frame_->CallRuntime(Runtime::kDefineAccessor, 4); 5615 Result ignored = frame_->CallRuntime(Runtime::kDefineAccessor, 4);
5603 // Ignore the result. 5616 // Ignore the result.
(...skipping 4533 matching lines...) Expand 10 before | Expand all | Expand 10 after
10137 masm.GetCode(&desc); 10150 masm.GetCode(&desc);
10138 // Call the function from C++. 10151 // Call the function from C++.
10139 return FUNCTION_CAST<MemCopyFunction>(buffer); 10152 return FUNCTION_CAST<MemCopyFunction>(buffer);
10140 } 10153 }
10141 10154
10142 #undef __ 10155 #undef __
10143 10156
10144 } } // namespace v8::internal 10157 } } // namespace v8::internal
10145 10158
10146 #endif // V8_TARGET_ARCH_IA32 10159 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ast.cc ('k') | src/ia32/full-codegen-ia32.cc » ('j') | src/ia32/full-codegen-ia32.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698