| OLD | NEW | 
|    1 // Copyright 2013 the V8 project authors. All rights reserved. |    1 // Copyright 2013 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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  318 function some_function1() { return 10; } |  318 function some_function1() { return 10; } | 
|  319 var df2 = {}; |  319 var df2 = {}; | 
|  320 df2.first_double = 1.7; |  320 df2.first_double = 1.7; | 
|  321 df2.second_function = some_function1; |  321 df2.second_function = some_function1; | 
|  322 function some_function2() { return 20; } |  322 function some_function2() { return 20; } | 
|  323 var df3 = {}; |  323 var df3 = {}; | 
|  324 df3.first_double = 1.7; |  324 df3.first_double = 1.7; | 
|  325 df3.second_function = some_function2; |  325 df3.second_function = some_function2; | 
|  326 df1.first_double = 10; |  326 df1.first_double = 10; | 
|  327 read_first_double(df1); |  327 read_first_double(df1); | 
 |  328  | 
 |  329 // Test boilerplates with computed values. | 
 |  330 function none_boilerplate(a) { | 
 |  331   return {"a_none":a}; | 
 |  332 } | 
 |  333 %OptimizeFunctionOnNextCall(none_boilerplate); | 
 |  334 var none_double1 = none_boilerplate(1.7); | 
 |  335 var none_double2 = none_boilerplate(1.9); | 
 |  336 assertTrue(%HaveSameMap(none_double1, none_double2)); | 
 |  337 assertEquals(1.7, none_double1.a_none); | 
 |  338 assertEquals(1.9, none_double2.a_none); | 
 |  339 none_double2.a_none = 3.5; | 
 |  340 var none_double1 = none_boilerplate(1.7); | 
 |  341 var none_double2 = none_boilerplate(3.5); | 
 |  342  | 
 |  343 function none_to_smi(a) { | 
 |  344   return {"a_smi":a}; | 
 |  345 } | 
 |  346  | 
 |  347 var none_smi1 = none_to_smi(1); | 
 |  348 var none_smi2 = none_to_smi(2); | 
 |  349 %OptimizeFunctionOnNextCall(none_to_smi); | 
 |  350 var none_smi3 = none_to_smi(3); | 
 |  351 assertTrue(%HaveSameMap(none_smi1, none_smi2)); | 
 |  352 assertTrue(%HaveSameMap(none_smi1, none_smi3)); | 
 |  353 assertEquals(1, none_smi1.a_smi); | 
 |  354 assertEquals(2, none_smi2.a_smi); | 
 |  355 assertEquals(3, none_smi3.a_smi); | 
 |  356  | 
 |  357 function none_to_double(a) { | 
 |  358   return {"a_double":a}; | 
 |  359 } | 
 |  360  | 
 |  361 var none_to_double1 = none_to_double(1.5); | 
 |  362 var none_to_double2 = none_to_double(2.8); | 
 |  363 %OptimizeFunctionOnNextCall(none_to_double); | 
 |  364 var none_to_double3 = none_to_double(3.7); | 
 |  365 assertTrue(%HaveSameMap(none_to_double1, none_to_double2)); | 
 |  366 assertTrue(%HaveSameMap(none_to_double1, none_to_double3)); | 
 |  367 assertEquals(1.5, none_to_double1.a_double); | 
 |  368 assertEquals(2.8, none_to_double2.a_double); | 
 |  369 assertEquals(3.7, none_to_double3.a_double); | 
 |  370  | 
 |  371 function none_to_object(a) { | 
 |  372   return {"an_object":a}; | 
 |  373 } | 
 |  374  | 
 |  375 var none_to_object1 = none_to_object(true); | 
 |  376 var none_to_object2 = none_to_object(false); | 
 |  377 %OptimizeFunctionOnNextCall(none_to_object); | 
 |  378 var none_to_object3 = none_to_object(3.7); | 
 |  379 assertTrue(%HaveSameMap(none_to_object1, none_to_object2)); | 
 |  380 assertTrue(%HaveSameMap(none_to_object1, none_to_object3)); | 
 |  381 assertEquals(true, none_to_object1.an_object); | 
 |  382 assertEquals(false, none_to_object2.an_object); | 
 |  383 assertEquals(3.7, none_to_object3.an_object); | 
 |  384  | 
 |  385 function double_to_object(a) { | 
 |  386   var o = {"d_to_h":1.8}; | 
 |  387   o.d_to_h = a; | 
 |  388   return o; | 
 |  389 } | 
 |  390  | 
 |  391 var dh1 = double_to_object(true); | 
 |  392 var dh2 = double_to_object(false); | 
 |  393 assertTrue(%HaveSameMap(dh1, dh2)); | 
 |  394 assertEquals(true, dh1.d_to_h); | 
 |  395 assertEquals(false, dh2.d_to_h); | 
 |  396  | 
 |  397 function smi_to_object(a) { | 
 |  398   var o = {"s_to_t":18}; | 
 |  399   o.s_to_t = a; | 
 |  400   return o; | 
 |  401 } | 
 |  402  | 
 |  403 var st1 = smi_to_object(true); | 
 |  404 var st2 = smi_to_object(false); | 
 |  405 assertTrue(%HaveSameMap(st1, st2)); | 
 |  406 assertEquals(true, st1.s_to_t); | 
 |  407 assertEquals(false, st2.s_to_t); | 
| OLD | NEW |