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

Side by Side Diff: src/accessors.cc

Issue 1587073003: Array length reduction should throw in strict mode if it can't delete an element. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebasing for relanding Created 4 years, 11 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 | « include/v8.h ('k') | src/arguments.h » ('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/accessors.h" 5 #include "src/accessors.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/contexts.h" 8 #include "src/contexts.h"
9 #include "src/deoptimizer.h" 9 #include "src/deoptimizer.h"
10 #include "src/execution.h" 10 #include "src/execution.h"
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 197
198 uint32_t length = 0; 198 uint32_t length = 0;
199 if (!JSArray::AnythingToArrayLength(isolate, length_obj, &length)) { 199 if (!JSArray::AnythingToArrayLength(isolate, length_obj, &length)) {
200 isolate->OptionalRescheduleException(false); 200 isolate->OptionalRescheduleException(false);
201 return; 201 return;
202 } 202 }
203 203
204 if (JSArray::ObservableSetLength(array, length).is_null()) { 204 if (JSArray::ObservableSetLength(array, length).is_null()) {
205 isolate->OptionalRescheduleException(false); 205 isolate->OptionalRescheduleException(false);
206 } 206 }
207
208 if (info.ShouldThrowOnError()) {
209 uint32_t actual_new_len = 0;
210 CHECK(array->length()->ToArrayLength(&actual_new_len));
211 // Throw TypeError if there were non-deletable elements.
212 if (actual_new_len != length) {
213 Factory* factory = isolate->factory();
214 isolate->Throw(*factory->NewTypeError(
215 MessageTemplate::kStrictDeleteProperty,
216 factory->NewNumberFromUint(actual_new_len - 1), array));
217 isolate->OptionalRescheduleException(false);
218 }
219 }
207 } 220 }
208 221
209 222
210 Handle<AccessorInfo> Accessors::ArrayLengthInfo( 223 Handle<AccessorInfo> Accessors::ArrayLengthInfo(
211 Isolate* isolate, PropertyAttributes attributes) { 224 Isolate* isolate, PropertyAttributes attributes) {
212 return MakeAccessor(isolate, 225 return MakeAccessor(isolate,
213 isolate->factory()->length_string(), 226 isolate->factory()->length_string(),
214 &ArrayLengthGetter, 227 &ArrayLengthGetter,
215 &ArrayLengthSetter, 228 &ArrayLengthSetter,
216 attributes); 229 attributes);
(...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1397 isolate->ScheduleThrow(*exception); 1410 isolate->ScheduleThrow(*exception);
1398 return; 1411 return;
1399 } 1412 }
1400 info.GetReturnValue().Set(v8::Utils::ToLocal(Handle<Object>(value, isolate))); 1413 info.GetReturnValue().Set(v8::Utils::ToLocal(Handle<Object>(value, isolate)));
1401 } 1414 }
1402 1415
1403 1416
1404 static void ModuleSetExport(v8::Local<v8::Name> property, 1417 static void ModuleSetExport(v8::Local<v8::Name> property,
1405 v8::Local<v8::Value> value, 1418 v8::Local<v8::Value> value,
1406 const v8::PropertyCallbackInfo<void>& info) { 1419 const v8::PropertyCallbackInfo<void>& info) {
1420 if (!info.ShouldThrowOnError()) return;
1407 Handle<Name> name = v8::Utils::OpenHandle(*property); 1421 Handle<Name> name = v8::Utils::OpenHandle(*property);
1408 Isolate* isolate = name->GetIsolate(); 1422 Isolate* isolate = name->GetIsolate();
1409 Handle<Object> exception = 1423 Handle<Object> exception =
1410 isolate->factory()->NewTypeError(MessageTemplate::kNotDefined, name); 1424 isolate->factory()->NewTypeError(MessageTemplate::kNotDefined, name);
1411 isolate->ScheduleThrow(*exception); 1425 isolate->ScheduleThrow(*exception);
1412 } 1426 }
1413 1427
1414 1428
1415 Handle<AccessorInfo> Accessors::MakeModuleExport( 1429 Handle<AccessorInfo> Accessors::MakeModuleExport(
1416 Handle<String> name, 1430 Handle<String> name,
1417 int index, 1431 int index,
1418 PropertyAttributes attributes) { 1432 PropertyAttributes attributes) {
1419 Isolate* isolate = name->GetIsolate(); 1433 Isolate* isolate = name->GetIsolate();
1420 Handle<AccessorInfo> info = MakeAccessor(isolate, name, &ModuleGetExport, 1434 Handle<AccessorInfo> info = MakeAccessor(isolate, name, &ModuleGetExport,
1421 &ModuleSetExport, attributes); 1435 &ModuleSetExport, attributes);
1422 info->set_data(Smi::FromInt(index)); 1436 info->set_data(Smi::FromInt(index));
1423 return info; 1437 return info;
1424 } 1438 }
1425 1439
1426 1440
1427 } // namespace internal 1441 } // namespace internal
1428 } // namespace v8 1442 } // namespace v8
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/arguments.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698