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

Side by Side Diff: src/accessors.cc

Issue 1611313003: Revert of 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: 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 }
220 } 207 }
221 208
222 209
223 Handle<AccessorInfo> Accessors::ArrayLengthInfo( 210 Handle<AccessorInfo> Accessors::ArrayLengthInfo(
224 Isolate* isolate, PropertyAttributes attributes) { 211 Isolate* isolate, PropertyAttributes attributes) {
225 return MakeAccessor(isolate, 212 return MakeAccessor(isolate,
226 isolate->factory()->length_string(), 213 isolate->factory()->length_string(),
227 &ArrayLengthGetter, 214 &ArrayLengthGetter,
228 &ArrayLengthSetter, 215 &ArrayLengthSetter,
229 attributes); 216 attributes);
(...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1410 isolate->ScheduleThrow(*exception); 1397 isolate->ScheduleThrow(*exception);
1411 return; 1398 return;
1412 } 1399 }
1413 info.GetReturnValue().Set(v8::Utils::ToLocal(Handle<Object>(value, isolate))); 1400 info.GetReturnValue().Set(v8::Utils::ToLocal(Handle<Object>(value, isolate)));
1414 } 1401 }
1415 1402
1416 1403
1417 static void ModuleSetExport(v8::Local<v8::Name> property, 1404 static void ModuleSetExport(v8::Local<v8::Name> property,
1418 v8::Local<v8::Value> value, 1405 v8::Local<v8::Value> value,
1419 const v8::PropertyCallbackInfo<void>& info) { 1406 const v8::PropertyCallbackInfo<void>& info) {
1420 if (!info.ShouldThrowOnError()) return;
1421 Handle<Name> name = v8::Utils::OpenHandle(*property); 1407 Handle<Name> name = v8::Utils::OpenHandle(*property);
1422 Isolate* isolate = name->GetIsolate(); 1408 Isolate* isolate = name->GetIsolate();
1423 Handle<Object> exception = 1409 Handle<Object> exception =
1424 isolate->factory()->NewTypeError(MessageTemplate::kNotDefined, name); 1410 isolate->factory()->NewTypeError(MessageTemplate::kNotDefined, name);
1425 isolate->ScheduleThrow(*exception); 1411 isolate->ScheduleThrow(*exception);
1426 } 1412 }
1427 1413
1428 1414
1429 Handle<AccessorInfo> Accessors::MakeModuleExport( 1415 Handle<AccessorInfo> Accessors::MakeModuleExport(
1430 Handle<String> name, 1416 Handle<String> name,
1431 int index, 1417 int index,
1432 PropertyAttributes attributes) { 1418 PropertyAttributes attributes) {
1433 Isolate* isolate = name->GetIsolate(); 1419 Isolate* isolate = name->GetIsolate();
1434 Handle<AccessorInfo> info = MakeAccessor(isolate, name, &ModuleGetExport, 1420 Handle<AccessorInfo> info = MakeAccessor(isolate, name, &ModuleGetExport,
1435 &ModuleSetExport, attributes); 1421 &ModuleSetExport, attributes);
1436 info->set_data(Smi::FromInt(index)); 1422 info->set_data(Smi::FromInt(index));
1437 return info; 1423 return info;
1438 } 1424 }
1439 1425
1440 1426
1441 } // namespace internal 1427 } // namespace internal
1442 } // namespace v8 1428 } // 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