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

Side by Side Diff: src/runtime.cc

Issue 222163002: Introduce MaybeHandle to police exception checking in handlified code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: renamed to MaybeHandle and added template Throw Created 6 years, 8 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 | Annotate | Revision Log
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 3220 matching lines...) Expand 10 before | Expand all | Expand 10 after
3231 Vector< Handle<Object> > argv = HandleVector<Object>(NULL, 0); 3231 Vector< Handle<Object> > argv = HandleVector<Object>(NULL, 0);
3232 Handle<Object> error = isolate->factory()->NewError(message, argv); 3232 Handle<Object> error = isolate->factory()->NewError(message, argv);
3233 return isolate->Throw(*error); 3233 return isolate->Throw(*error);
3234 } 3234 }
3235 3235
3236 3236
3237 RUNTIME_FUNCTION(MaybeObject*, Runtime_ObjectFreeze) { 3237 RUNTIME_FUNCTION(MaybeObject*, Runtime_ObjectFreeze) {
3238 HandleScope scope(isolate); 3238 HandleScope scope(isolate);
3239 ASSERT(args.length() == 1); 3239 ASSERT(args.length() == 1);
3240 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); 3240 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
3241 Handle<Object> result = JSObject::Freeze(object); 3241 Handle<Object> result;
3242 RETURN_IF_EMPTY_HANDLE(isolate, result); 3242 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, JSObject::Freeze(object));
3243 return *result; 3243 return *result;
3244 } 3244 }
3245 3245
3246 3246
3247 MUST_USE_RESULT static MaybeObject* CharFromCode(Isolate* isolate, 3247 MUST_USE_RESULT static MaybeObject* CharFromCode(Isolate* isolate,
3248 Object* char_code) { 3248 Object* char_code) {
3249 if (char_code->IsNumber()) { 3249 if (char_code->IsNumber()) {
3250 return isolate->heap()->LookupSingleCharacterStringFromCode( 3250 return isolate->heap()->LookupSingleCharacterStringFromCode(
3251 NumberToUint32(char_code) & 0xffff); 3251 NumberToUint32(char_code) & 0xffff);
3252 } 3252 }
(...skipping 9058 matching lines...) Expand 10 before | Expand all | Expand 10 after
12311 } 12311 }
12312 return *array; 12312 return *array;
12313 } 12313 }
12314 12314
12315 12315
12316 static const int kScopeDetailsTypeIndex = 0; 12316 static const int kScopeDetailsTypeIndex = 0;
12317 static const int kScopeDetailsObjectIndex = 1; 12317 static const int kScopeDetailsObjectIndex = 1;
12318 static const int kScopeDetailsSize = 2; 12318 static const int kScopeDetailsSize = 2;
12319 12319
12320 12320
12321 static Handle<JSObject> MaterializeScopeDetails(Isolate* isolate, 12321 static MaybeHandle<JSObject> MaterializeScopeDetails(Isolate* isolate,
12322 ScopeIterator* it) { 12322 ScopeIterator* it) {
12323 // Calculate the size of the result. 12323 // Calculate the size of the result.
12324 int details_size = kScopeDetailsSize; 12324 int details_size = kScopeDetailsSize;
12325 Handle<FixedArray> details = isolate->factory()->NewFixedArray(details_size); 12325 Handle<FixedArray> details = isolate->factory()->NewFixedArray(details_size);
12326 12326
12327 // Fill in scope details. 12327 // Fill in scope details.
12328 details->set(kScopeDetailsTypeIndex, Smi::FromInt(it->Type())); 12328 details->set(kScopeDetailsTypeIndex, Smi::FromInt(it->Type()));
12329 Handle<JSObject> scope_object = it->ScopeObject(); 12329 Handle<JSObject> scope_object;
12330 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, scope_object, Handle<JSObject>()); 12330 ASSIGN_RETURN_ON_EXCEPTION(
12331 isolate, scope_object, it->ScopeObject(), JSObject);
12331 details->set(kScopeDetailsObjectIndex, *scope_object); 12332 details->set(kScopeDetailsObjectIndex, *scope_object);
12332 12333
12333 return isolate->factory()->NewJSArrayWithElements(details); 12334 return isolate->factory()->NewJSArrayWithElements(details);
12334 } 12335 }
12335 12336
12336 12337
12337 // Return an array with scope details 12338 // Return an array with scope details
12338 // args[0]: number: break id 12339 // args[0]: number: break id
12339 // args[1]: number: frame index 12340 // args[1]: number: frame index
12340 // args[2]: number: inlined frame index 12341 // args[2]: number: inlined frame index
(...skipping 23 matching lines...) Expand all
12364 12365
12365 // Find the requested scope. 12366 // Find the requested scope.
12366 int n = 0; 12367 int n = 0;
12367 ScopeIterator it(isolate, frame, inlined_jsframe_index); 12368 ScopeIterator it(isolate, frame, inlined_jsframe_index);
12368 for (; !it.Done() && n < index; it.Next()) { 12369 for (; !it.Done() && n < index; it.Next()) {
12369 n++; 12370 n++;
12370 } 12371 }
12371 if (it.Done()) { 12372 if (it.Done()) {
12372 return isolate->heap()->undefined_value(); 12373 return isolate->heap()->undefined_value();
12373 } 12374 }
12374 Handle<JSObject> details = MaterializeScopeDetails(isolate, &it); 12375 Handle<JSObject> details;
12375 RETURN_IF_EMPTY_HANDLE(isolate, details); 12376 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
12377 isolate, details, MaterializeScopeDetails(isolate, &it));
12376 return *details; 12378 return *details;
12377 } 12379 }
12378 12380
12379 12381
12380 // Return an array of scope details 12382 // Return an array of scope details
12381 // args[0]: number: break id 12383 // args[0]: number: break id
12382 // args[1]: number: frame index 12384 // args[1]: number: frame index
12383 // args[2]: number: inlined frame index 12385 // args[2]: number: inlined frame index
12384 // args[3]: boolean: ignore nested scopes 12386 // args[3]: boolean: ignore nested scopes
12385 // 12387 //
(...skipping 20 matching lines...) Expand all
12406 } 12408 }
12407 12409
12408 // Get the frame where the debugging is performed. 12410 // Get the frame where the debugging is performed.
12409 StackFrame::Id id = UnwrapFrameId(wrapped_id); 12411 StackFrame::Id id = UnwrapFrameId(wrapped_id);
12410 JavaScriptFrameIterator frame_it(isolate, id); 12412 JavaScriptFrameIterator frame_it(isolate, id);
12411 JavaScriptFrame* frame = frame_it.frame(); 12413 JavaScriptFrame* frame = frame_it.frame();
12412 12414
12413 List<Handle<JSObject> > result(4); 12415 List<Handle<JSObject> > result(4);
12414 ScopeIterator it(isolate, frame, inlined_jsframe_index, ignore_nested_scopes); 12416 ScopeIterator it(isolate, frame, inlined_jsframe_index, ignore_nested_scopes);
12415 for (; !it.Done(); it.Next()) { 12417 for (; !it.Done(); it.Next()) {
12416 Handle<JSObject> details = MaterializeScopeDetails(isolate, &it); 12418 Handle<JSObject> details;
12417 RETURN_IF_EMPTY_HANDLE(isolate, details); 12419 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
12420 isolate, details, MaterializeScopeDetails(isolate, &it));
12418 result.Add(details); 12421 result.Add(details);
12419 } 12422 }
12420 12423
12421 Handle<FixedArray> array = isolate->factory()->NewFixedArray(result.length()); 12424 Handle<FixedArray> array = isolate->factory()->NewFixedArray(result.length());
12422 for (int i = 0; i < result.length(); ++i) { 12425 for (int i = 0; i < result.length(); ++i) {
12423 array->set(i, *result[i]); 12426 array->set(i, *result[i]);
12424 } 12427 }
12425 return *isolate->factory()->NewJSArrayWithElements(array); 12428 return *isolate->factory()->NewJSArrayWithElements(array);
12426 } 12429 }
12427 12430
(...skipping 26 matching lines...) Expand all
12454 // Find the requested scope. 12457 // Find the requested scope.
12455 int n = 0; 12458 int n = 0;
12456 ScopeIterator it(isolate, fun); 12459 ScopeIterator it(isolate, fun);
12457 for (; !it.Done() && n < index; it.Next()) { 12460 for (; !it.Done() && n < index; it.Next()) {
12458 n++; 12461 n++;
12459 } 12462 }
12460 if (it.Done()) { 12463 if (it.Done()) {
12461 return isolate->heap()->undefined_value(); 12464 return isolate->heap()->undefined_value();
12462 } 12465 }
12463 12466
12464 Handle<JSObject> details = MaterializeScopeDetails(isolate, &it); 12467 Handle<JSObject> details;
12465 RETURN_IF_EMPTY_HANDLE(isolate, details); 12468 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
12469 isolate, details, MaterializeScopeDetails(isolate, &it));
12466 return *details; 12470 return *details;
12467 } 12471 }
12468 12472
12469 12473
12470 static bool SetScopeVariableValue(ScopeIterator* it, int index, 12474 static bool SetScopeVariableValue(ScopeIterator* it, int index,
12471 Handle<String> variable_name, 12475 Handle<String> variable_name,
12472 Handle<Object> new_value) { 12476 Handle<Object> new_value) {
12473 for (int n = 0; !it->Done() && n < index; it->Next()) { 12477 for (int n = 0; !it->Done() && n < index; it->Next()) {
12474 n++; 12478 n++;
12475 } 12479 }
(...skipping 2755 matching lines...) Expand 10 before | Expand all | Expand 10 after
15231 } 15235 }
15232 } 15236 }
15233 15237
15234 15238
15235 void Runtime::OutOfMemory() { 15239 void Runtime::OutOfMemory() {
15236 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); 15240 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true);
15237 UNREACHABLE(); 15241 UNREACHABLE();
15238 } 15242 }
15239 15243
15240 } } // namespace v8::internal 15244 } } // namespace v8::internal
OLDNEW
« src/handles.h ('K') | « src/objects.cc ('k') | src/v8globals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698