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

Side by Side Diff: src/accessors.cc

Issue 1191313003: More cleanup related to setting array.length (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « no previous file | src/ast.cc » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api.h" 8 #include "src/api.h"
9 #include "src/contexts.h" 9 #include "src/contexts.h"
10 #include "src/deoptimizer.h" 10 #include "src/deoptimizer.h"
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 JSArray* holder = JSArray::cast(*Utils::OpenHandle(*info.Holder())); 197 JSArray* holder = JSArray::cast(*Utils::OpenHandle(*info.Holder()));
198 Object* result = holder->length(); 198 Object* result = holder->length();
199 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(result, isolate))); 199 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(result, isolate)));
200 } 200 }
201 201
202 202
203 void Accessors::ArrayLengthSetter( 203 void Accessors::ArrayLengthSetter(
204 v8::Local<v8::Name> name, 204 v8::Local<v8::Name> name,
205 v8::Local<v8::Value> val, 205 v8::Local<v8::Value> val,
206 const v8::PropertyCallbackInfo<void>& info) { 206 const v8::PropertyCallbackInfo<void>& info) {
207 // TODO(verwaest): Speed up.
207 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); 208 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
208 HandleScope scope(isolate); 209 HandleScope scope(isolate);
209 Handle<JSObject> object = Utils::OpenHandle(*info.This()); 210 Handle<JSObject> object = Utils::OpenHandle(*info.This());
210 Handle<Object> value = Utils::OpenHandle(*val); 211 Handle<Object> value = Utils::OpenHandle(*val);
211 212
212 value = FlattenNumber(isolate, value); 213 value = FlattenNumber(isolate, value);
213 214
214 Handle<JSArray> array_handle = Handle<JSArray>::cast(object); 215 Handle<JSArray> array_handle = Handle<JSArray>::cast(object);
215 MaybeHandle<Object> maybe; 216 MaybeHandle<Object> maybe;
216 Handle<Object> uint32_v; 217 Handle<Object> uint32_v;
217 maybe = Execution::ToUint32(isolate, value); 218 maybe = Execution::ToUint32(isolate, value);
218 if (!maybe.ToHandle(&uint32_v)) { 219 if (!maybe.ToHandle(&uint32_v)) {
219 isolate->OptionalRescheduleException(false); 220 isolate->OptionalRescheduleException(false);
220 return; 221 return;
221 } 222 }
222 Handle<Object> number_v; 223 Handle<Object> number_v;
223 maybe = Execution::ToNumber(isolate, value); 224 maybe = Execution::ToNumber(isolate, value);
224 if (!maybe.ToHandle(&number_v)) { 225 if (!maybe.ToHandle(&number_v)) {
225 isolate->OptionalRescheduleException(false); 226 isolate->OptionalRescheduleException(false);
226 return; 227 return;
227 } 228 }
228 229
229 if (uint32_v->Number() == number_v->Number()) { 230 if (uint32_v->Number() == number_v->Number()) {
230 maybe = JSArray::SetElementsLength(array_handle, uint32_v); 231 uint32_t new_length = 0;
232 CHECK(uint32_v->ToArrayLength(&new_length));
233 maybe = JSArray::ObservableSetLength(array_handle, new_length);
231 if (maybe.is_null()) isolate->OptionalRescheduleException(false); 234 if (maybe.is_null()) isolate->OptionalRescheduleException(false);
232 return; 235 return;
233 } 236 }
234 237
235 Handle<Object> exception = 238 Handle<Object> exception =
236 isolate->factory()->NewRangeError(MessageTemplate::kInvalidArrayLength); 239 isolate->factory()->NewRangeError(MessageTemplate::kInvalidArrayLength);
237 isolate->ScheduleThrow(*exception); 240 isolate->ScheduleThrow(*exception);
238 } 241 }
239 242
240 243
(...skipping 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1491 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); 1494 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport);
1492 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); 1495 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport);
1493 info->set_getter(*getter); 1496 info->set_getter(*getter);
1494 if (!(attributes & ReadOnly)) info->set_setter(*setter); 1497 if (!(attributes & ReadOnly)) info->set_setter(*setter);
1495 return info; 1498 return info;
1496 } 1499 }
1497 1500
1498 1501
1499 } // namespace internal 1502 } // namespace internal
1500 } // namespace v8 1503 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698