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

Side by Side Diff: src/runtime/runtime-literals.cc

Issue 2006673002: Reduce boilerplace for common pattern to return MaybeHandle. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase and fix Created 4 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 | « src/runtime/runtime-json.cc ('k') | src/runtime/runtime-liveedit.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/allocation-site-scopes.h" 7 #include "src/allocation-site-scopes.h"
8 #include "src/arguments.h" 8 #include "src/arguments.h"
9 #include "src/ast/ast.h" 9 #include "src/ast/ast.h"
10 #include "src/isolate-inl.h" 10 #include "src/isolate-inl.h"
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 site = Handle<AllocationSite>::cast(literal_site); 256 site = Handle<AllocationSite>::cast(literal_site);
257 boilerplate = 257 boilerplate =
258 Handle<JSObject>(JSObject::cast(site->transition_info()), isolate); 258 Handle<JSObject>(JSObject::cast(site->transition_info()), isolate);
259 } 259 }
260 260
261 AllocationSiteUsageContext usage_context(isolate, site, enable_mementos); 261 AllocationSiteUsageContext usage_context(isolate, site, enable_mementos);
262 usage_context.EnterNewScope(); 262 usage_context.EnterNewScope();
263 MaybeHandle<Object> maybe_copy = 263 MaybeHandle<Object> maybe_copy =
264 JSObject::DeepCopy(boilerplate, &usage_context); 264 JSObject::DeepCopy(boilerplate, &usage_context);
265 usage_context.ExitScope(site, boilerplate); 265 usage_context.ExitScope(site, boilerplate);
266 Handle<Object> copy; 266 RETURN_RESULT_OR_FAILURE(isolate, maybe_copy);
267 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, copy, maybe_copy);
268 return *copy;
269 } 267 }
270 268
271 MUST_USE_RESULT static MaybeHandle<AllocationSite> GetLiteralAllocationSite( 269 MUST_USE_RESULT static MaybeHandle<AllocationSite> GetLiteralAllocationSite(
272 Isolate* isolate, Handle<LiteralsArray> literals, int literals_index, 270 Isolate* isolate, Handle<LiteralsArray> literals, int literals_index,
273 Handle<FixedArray> elements) { 271 Handle<FixedArray> elements) {
274 // Check if boilerplate exists. If not, create it first. 272 // Check if boilerplate exists. If not, create it first.
275 Handle<Object> literal_site(literals->literal(literals_index), isolate); 273 Handle<Object> literal_site(literals->literal(literals_index), isolate);
276 Handle<AllocationSite> site; 274 Handle<AllocationSite> site;
277 if (*literal_site == isolate->heap()->undefined_value()) { 275 if (*literal_site == isolate->heap()->undefined_value()) {
278 DCHECK(*elements != isolate->heap()->empty_fixed_array()); 276 DCHECK(*elements != isolate->heap()->empty_fixed_array());
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 324
327 325
328 RUNTIME_FUNCTION(Runtime_CreateArrayLiteral) { 326 RUNTIME_FUNCTION(Runtime_CreateArrayLiteral) {
329 HandleScope scope(isolate); 327 HandleScope scope(isolate);
330 DCHECK_EQ(4, args.length()); 328 DCHECK_EQ(4, args.length());
331 CONVERT_ARG_HANDLE_CHECKED(JSFunction, closure, 0); 329 CONVERT_ARG_HANDLE_CHECKED(JSFunction, closure, 0);
332 CONVERT_SMI_ARG_CHECKED(literals_index, 1); 330 CONVERT_SMI_ARG_CHECKED(literals_index, 1);
333 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); 331 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2);
334 CONVERT_SMI_ARG_CHECKED(flags, 3); 332 CONVERT_SMI_ARG_CHECKED(flags, 3);
335 333
336 Handle<JSObject> result;
337 Handle<LiteralsArray> literals(closure->literals(), isolate); 334 Handle<LiteralsArray> literals(closure->literals(), isolate);
338 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 335 RETURN_RESULT_OR_FAILURE(
339 isolate, result, CreateArrayLiteralImpl(isolate, literals, literals_index, 336 isolate, CreateArrayLiteralImpl(isolate, literals, literals_index,
340 elements, flags)); 337 elements, flags));
341 return *result;
342 } 338 }
343 339
344 340
345 RUNTIME_FUNCTION(Runtime_CreateArrayLiteralStubBailout) { 341 RUNTIME_FUNCTION(Runtime_CreateArrayLiteralStubBailout) {
346 HandleScope scope(isolate); 342 HandleScope scope(isolate);
347 DCHECK_EQ(3, args.length()); 343 DCHECK_EQ(3, args.length());
348 CONVERT_ARG_HANDLE_CHECKED(JSFunction, closure, 0); 344 CONVERT_ARG_HANDLE_CHECKED(JSFunction, closure, 0);
349 CONVERT_SMI_ARG_CHECKED(literals_index, 1); 345 CONVERT_SMI_ARG_CHECKED(literals_index, 1);
350 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); 346 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2);
351 347
352 Handle<JSObject> result;
353 Handle<LiteralsArray> literals(closure->literals(), isolate); 348 Handle<LiteralsArray> literals(closure->literals(), isolate);
354 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 349 RETURN_RESULT_OR_FAILURE(
355 isolate, result, 350 isolate,
356 CreateArrayLiteralImpl(isolate, literals, literals_index, elements, 351 CreateArrayLiteralImpl(isolate, literals, literals_index, elements,
357 ArrayLiteral::kShallowElements)); 352 ArrayLiteral::kShallowElements));
358 return *result;
359 } 353 }
360 354
361 } // namespace internal 355 } // namespace internal
362 } // namespace v8 356 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime-json.cc ('k') | src/runtime/runtime-liveedit.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698