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

Side by Side Diff: src/accessors.cc

Issue 59773002: Remove calls to SetLocalPropertyIgnoreAttributesTrampoline from accessors.cc (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: pre review Created 7 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
« no previous file with comments | « src/accessors.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 MaybeObject* Accessors::ArrayGetLength(Isolate* isolate, 141 MaybeObject* Accessors::ArrayGetLength(Isolate* isolate,
142 Object* object, 142 Object* object,
143 void*) { 143 void*) {
144 // Traverse the prototype chain until we reach an array. 144 // Traverse the prototype chain until we reach an array.
145 JSArray* holder = FindInstanceOf<JSArray>(isolate, object); 145 JSArray* holder = FindInstanceOf<JSArray>(isolate, object);
146 return holder == NULL ? Smi::FromInt(0) : holder->length(); 146 return holder == NULL ? Smi::FromInt(0) : holder->length();
147 } 147 }
148 148
149 149
150 // The helper function will 'flatten' Number objects. 150 // The helper function will 'flatten' Number objects.
151 Object* Accessors::FlattenNumber(Isolate* isolate, Object* value) { 151 Handle<Object> Accessors::FlattenNumber(Isolate* isolate,
152 Handle<Object> value) {
152 if (value->IsNumber() || !value->IsJSValue()) return value; 153 if (value->IsNumber() || !value->IsJSValue()) return value;
153 JSValue* wrapper = JSValue::cast(value); 154 Handle<JSValue> wrapper = Handle<JSValue>::cast(value);
154 ASSERT(wrapper->GetIsolate()->context()->native_context()->number_function()-> 155 ASSERT(wrapper->GetIsolate()->context()->native_context()->number_function()->
155 has_initial_map()); 156 has_initial_map());
156 Map* number_map = isolate->context()->native_context()-> 157 if (wrapper->map() ==
157 number_function()->initial_map(); 158 isolate->context()->native_context()->number_function()->initial_map()) {
158 if (wrapper->map() == number_map) return wrapper->value(); 159 return handle(wrapper->value(), isolate);
160 }
161
159 return value; 162 return value;
160 } 163 }
161 164
162 165
163 MaybeObject* Accessors::ArraySetLength(Isolate* isolate, 166 MaybeObject* Accessors::ArraySetLength(Isolate* isolate,
164 JSObject* object, 167 JSObject* object_raw,
165 Object* value, 168 Object* value_raw,
166 void*) { 169 void*) {
170 HandleScope scope(isolate);
171 Handle<JSObject> object(object_raw, isolate);
172 Handle<Object> value(value_raw, isolate);
173
167 // This means one of the object's prototypes is a JSArray and the 174 // This means one of the object's prototypes is a JSArray and the
168 // object does not have a 'length' property. Calling SetProperty 175 // object does not have a 'length' property. Calling SetProperty
169 // causes an infinite loop. 176 // causes an infinite loop.
170 if (!object->IsJSArray()) { 177 if (!object->IsJSArray()) {
171 return object->SetLocalPropertyIgnoreAttributesTrampoline( 178 return *JSObject::SetLocalPropertyIgnoreAttributes(object,
Michael Starzinger 2013/11/05 12:48:17 I think it's possible that setting the property fa
rafaelw 2013/11/05 13:35:16 Done.
172 isolate->heap()->length_string(), value, NONE); 179 isolate->factory()->length_string(), value, NONE);
173 } 180 }
174 181
175 value = FlattenNumber(isolate, value); 182 value = FlattenNumber(isolate, value);
176 183
177 // Need to call methods that may trigger GC. 184 Handle<JSArray> array_handle(Handle<JSArray>::cast(object));
Michael Starzinger 2013/11/05 12:48:17 nit: Better use assignment instead of constructor
rafaelw 2013/11/05 13:35:16 Done.
178 HandleScope scope(isolate);
179
180 // Protect raw pointers.
181 Handle<JSArray> array_handle(JSArray::cast(object), isolate);
182 Handle<Object> value_handle(value, isolate);
183 185
184 bool has_exception; 186 bool has_exception;
185 Handle<Object> uint32_v = 187 Handle<Object> uint32_v =
186 Execution::ToUint32(isolate, value_handle, &has_exception); 188 Execution::ToUint32(isolate, value, &has_exception);
187 if (has_exception) return Failure::Exception(); 189 if (has_exception) return Failure::Exception();
188 Handle<Object> number_v = 190 Handle<Object> number_v =
189 Execution::ToNumber(isolate, value_handle, &has_exception); 191 Execution::ToNumber(isolate, value, &has_exception);
190 if (has_exception) return Failure::Exception(); 192 if (has_exception) return Failure::Exception();
191 193
192 if (uint32_v->Number() == number_v->Number()) { 194 if (uint32_v->Number() == number_v->Number()) {
193 return array_handle->SetElementsLength(*uint32_v); 195 return array_handle->SetElementsLength(*uint32_v);
194 } 196 }
195 return isolate->Throw( 197 return isolate->Throw(
196 *isolate->factory()->NewRangeError("invalid_array_length", 198 *isolate->factory()->NewRangeError("invalid_array_length",
197 HandleVector<Object>(NULL, 0))); 199 HandleVector<Object>(NULL, 0)));
198 } 200 }
199 201
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 Handle<JSFunction> function(function_raw); 573 Handle<JSFunction> function(function_raw);
572 Handle<Object> proto = isolate->factory()->NewFunctionPrototype(function); 574 Handle<Object> proto = isolate->factory()->NewFunctionPrototype(function);
573 JSFunction::SetPrototype(function, proto); 575 JSFunction::SetPrototype(function, proto);
574 function_raw = *function; 576 function_raw = *function;
575 } 577 }
576 return function_raw->prototype(); 578 return function_raw->prototype();
577 } 579 }
578 580
579 581
580 MaybeObject* Accessors::FunctionSetPrototype(Isolate* isolate, 582 MaybeObject* Accessors::FunctionSetPrototype(Isolate* isolate,
581 JSObject* object, 583 JSObject* object_raw,
582 Object* value_raw, 584 Object* value_raw,
583 void*) { 585 void*) {
584 Heap* heap = isolate->heap(); 586 JSFunction* function_raw = FindInstanceOf<JSFunction>(isolate, object_raw);
585 JSFunction* function_raw = FindInstanceOf<JSFunction>(isolate, object); 587 if (function_raw == NULL) return isolate->heap()->undefined_value();
586 if (function_raw == NULL) return heap->undefined_value();
587 if (!function_raw->should_have_prototype()) {
588 // Since we hit this accessor, object will have no prototype property.
589 return object->SetLocalPropertyIgnoreAttributesTrampoline(
590 heap->prototype_string(), value_raw, NONE);
591 }
592 588
593 HandleScope scope(isolate); 589 HandleScope scope(isolate);
594 Handle<JSFunction> function(function_raw, isolate); 590 Handle<JSFunction> function(function_raw, isolate);
591 Handle<Object> object(object_raw, isolate);
595 Handle<Object> value(value_raw, isolate); 592 Handle<Object> value(value_raw, isolate);
593 if (!function->should_have_prototype()) {
594 // Since we hit this accessor, object will have no prototype property.
595 return *JSObject::SetLocalPropertyIgnoreAttributes(object,
Michael Starzinger 2013/11/05 12:48:17 Likewise. See the comment above about the possibil
rafaelw 2013/11/05 13:35:16 Done.
596 isolate->factory()->prototype_string(), value, NONE);
597 }
596 598
597 Handle<Object> old_value; 599 Handle<Object> old_value;
598 bool is_observed = 600 bool is_observed =
599 FLAG_harmony_observation && 601 FLAG_harmony_observation &&
600 *function == object && 602 *function == *object &&
601 function->map()->is_observed(); 603 function->map()->is_observed();
602 if (is_observed) { 604 if (is_observed) {
603 if (function->has_prototype()) 605 if (function->has_prototype())
604 old_value = handle(function->prototype(), isolate); 606 old_value = handle(function->prototype(), isolate);
605 else 607 else
606 old_value = isolate->factory()->NewFunctionPrototype(function); 608 old_value = isolate->factory()->NewFunctionPrototype(function);
607 } 609 }
608 610
609 JSFunction::SetPrototype(function, value); 611 JSFunction::SetPrototype(function, value);
610 ASSERT(function->prototype() == *value); 612 ASSERT(function->prototype() == *value);
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 info->set_data(Smi::FromInt(index)); 964 info->set_data(Smi::FromInt(index));
963 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); 965 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport);
964 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); 966 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport);
965 info->set_getter(*getter); 967 info->set_getter(*getter);
966 if (!(attributes & ReadOnly)) info->set_setter(*setter); 968 if (!(attributes & ReadOnly)) info->set_setter(*setter);
967 return info; 969 return info;
968 } 970 }
969 971
970 972
971 } } // namespace v8::internal 973 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/accessors.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698