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

Side by Side Diff: src/accessors.cc

Issue 952483002: NewError no longer returns a MaybeObject. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@reland
Patch Set: Created 5 years, 10 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/api.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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 isolate->OptionalRescheduleException(false); 235 isolate->OptionalRescheduleException(false);
236 return; 236 return;
237 } 237 }
238 238
239 if (uint32_v->Number() == number_v->Number()) { 239 if (uint32_v->Number() == number_v->Number()) {
240 maybe = JSArray::SetElementsLength(array_handle, uint32_v); 240 maybe = JSArray::SetElementsLength(array_handle, uint32_v);
241 if (maybe.is_null()) isolate->OptionalRescheduleException(false); 241 if (maybe.is_null()) isolate->OptionalRescheduleException(false);
242 return; 242 return;
243 } 243 }
244 244
245 Handle<Object> exception; 245 Handle<Object> exception = isolate->factory()->NewRangeError(
246 maybe = isolate->factory()->NewRangeError("invalid_array_length", 246 "invalid_array_length", HandleVector<Object>(NULL, 0));
247 HandleVector<Object>(NULL, 0));
248 if (!maybe.ToHandle(&exception)) {
249 isolate->OptionalRescheduleException(false);
250 return;
251 }
252
253 isolate->ScheduleThrow(*exception); 247 isolate->ScheduleThrow(*exception);
254 } 248 }
255 249
256 250
257 Handle<AccessorInfo> Accessors::ArrayLengthInfo( 251 Handle<AccessorInfo> Accessors::ArrayLengthInfo(
258 Isolate* isolate, PropertyAttributes attributes) { 252 Isolate* isolate, PropertyAttributes attributes) {
259 return MakeAccessor(isolate, 253 return MakeAccessor(isolate,
260 isolate->factory()->length_string(), 254 isolate->factory()->length_string(),
261 &ArrayLengthGetter, 255 &ArrayLengthGetter,
262 &ArrayLengthSetter, 256 &ArrayLengthSetter,
(...skipping 1189 matching lines...) Expand 10 before | Expand all | Expand 10 after
1452 const v8::PropertyCallbackInfo<v8::Value>& info) { 1446 const v8::PropertyCallbackInfo<v8::Value>& info) {
1453 JSModule* instance = JSModule::cast(*v8::Utils::OpenHandle(*info.Holder())); 1447 JSModule* instance = JSModule::cast(*v8::Utils::OpenHandle(*info.Holder()));
1454 Context* context = Context::cast(instance->context()); 1448 Context* context = Context::cast(instance->context());
1455 DCHECK(context->IsModuleContext()); 1449 DCHECK(context->IsModuleContext());
1456 int slot = info.Data()->Int32Value(); 1450 int slot = info.Data()->Int32Value();
1457 Object* value = context->get(slot); 1451 Object* value = context->get(slot);
1458 Isolate* isolate = instance->GetIsolate(); 1452 Isolate* isolate = instance->GetIsolate();
1459 if (value->IsTheHole()) { 1453 if (value->IsTheHole()) {
1460 Handle<String> name = v8::Utils::OpenHandle(*property); 1454 Handle<String> name = v8::Utils::OpenHandle(*property);
1461 1455
1462 Handle<Object> exception; 1456 Handle<Object> exception = isolate->factory()->NewReferenceError(
1463 MaybeHandle<Object> maybe = isolate->factory()->NewReferenceError(
1464 "not_defined", HandleVector(&name, 1)); 1457 "not_defined", HandleVector(&name, 1));
1465 if (!maybe.ToHandle(&exception)) {
1466 isolate->OptionalRescheduleException(false);
1467 return;
1468 }
1469
1470 isolate->ScheduleThrow(*exception); 1458 isolate->ScheduleThrow(*exception);
1471 return; 1459 return;
1472 } 1460 }
1473 info.GetReturnValue().Set(v8::Utils::ToLocal(Handle<Object>(value, isolate))); 1461 info.GetReturnValue().Set(v8::Utils::ToLocal(Handle<Object>(value, isolate)));
1474 } 1462 }
1475 1463
1476 1464
1477 static void ModuleSetExport( 1465 static void ModuleSetExport(
1478 v8::Local<v8::String> property, 1466 v8::Local<v8::String> property,
1479 v8::Local<v8::Value> value, 1467 v8::Local<v8::Value> value,
1480 const v8::PropertyCallbackInfo<v8::Value>& info) { 1468 const v8::PropertyCallbackInfo<v8::Value>& info) {
1481 JSModule* instance = JSModule::cast(*v8::Utils::OpenHandle(*info.Holder())); 1469 JSModule* instance = JSModule::cast(*v8::Utils::OpenHandle(*info.Holder()));
1482 Context* context = Context::cast(instance->context()); 1470 Context* context = Context::cast(instance->context());
1483 DCHECK(context->IsModuleContext()); 1471 DCHECK(context->IsModuleContext());
1484 int slot = info.Data()->Int32Value(); 1472 int slot = info.Data()->Int32Value();
1485 Object* old_value = context->get(slot); 1473 Object* old_value = context->get(slot);
1486 Isolate* isolate = context->GetIsolate(); 1474 Isolate* isolate = context->GetIsolate();
1487 if (old_value->IsTheHole()) { 1475 if (old_value->IsTheHole()) {
1488 Handle<String> name = v8::Utils::OpenHandle(*property); 1476 Handle<String> name = v8::Utils::OpenHandle(*property);
1489 Handle<Object> exception; 1477 Handle<Object> exception = isolate->factory()->NewReferenceError(
1490 MaybeHandle<Object> maybe = isolate->factory()->NewReferenceError(
1491 "not_defined", HandleVector(&name, 1)); 1478 "not_defined", HandleVector(&name, 1));
1492 if (!maybe.ToHandle(&exception)) {
1493 isolate->OptionalRescheduleException(false);
1494 return;
1495 }
1496
1497 isolate->ScheduleThrow(*exception); 1479 isolate->ScheduleThrow(*exception);
1498 return; 1480 return;
1499 } 1481 }
1500 context->set(slot, *v8::Utils::OpenHandle(*value)); 1482 context->set(slot, *v8::Utils::OpenHandle(*value));
1501 } 1483 }
1502 1484
1503 1485
1504 Handle<AccessorInfo> Accessors::MakeModuleExport( 1486 Handle<AccessorInfo> Accessors::MakeModuleExport(
1505 Handle<String> name, 1487 Handle<String> name,
1506 int index, 1488 int index,
1507 PropertyAttributes attributes) { 1489 PropertyAttributes attributes) {
1508 Isolate* isolate = name->GetIsolate(); 1490 Isolate* isolate = name->GetIsolate();
1509 Factory* factory = isolate->factory(); 1491 Factory* factory = isolate->factory();
1510 Handle<ExecutableAccessorInfo> info = factory->NewExecutableAccessorInfo(); 1492 Handle<ExecutableAccessorInfo> info = factory->NewExecutableAccessorInfo();
1511 info->set_property_attributes(attributes); 1493 info->set_property_attributes(attributes);
1512 info->set_all_can_read(true); 1494 info->set_all_can_read(true);
1513 info->set_all_can_write(true); 1495 info->set_all_can_write(true);
1514 info->set_name(*name); 1496 info->set_name(*name);
1515 info->set_data(Smi::FromInt(index)); 1497 info->set_data(Smi::FromInt(index));
1516 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); 1498 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport);
1517 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); 1499 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport);
1518 info->set_getter(*getter); 1500 info->set_getter(*getter);
1519 if (!(attributes & ReadOnly)) info->set_setter(*setter); 1501 if (!(attributes & ReadOnly)) info->set_setter(*setter);
1520 return info; 1502 return info;
1521 } 1503 }
1522 1504
1523 1505
1524 } } // namespace v8::internal 1506 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698