1// Copyright 2012 the V8 project authors. All rights reserved. 2// Redistribution and use in source and binary forms, with or without 3// modification, are permitted provided that the following conditions are 4// met: 5// 6// * Redistributions of source code must retain the above copyright 7// notice, this list of conditions and the following disclaimer. 8// * Redistributions in binary form must reproduce the above 9// copyright notice, this list of conditions and the following 10// disclaimer in the documentation and/or other materials provided 11// with the distribution. 12// * Neither the name of Google Inc. nor the names of its 13// contributors may be used to endorse or promote products derived 14// from this software without specific prior written permission. 15// 16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 28// Flags: --allow-natives-syntax --inline-construct 29// Flags: --max-inlined-source-size=999999 --max-inlined-nodes=999999 30// Flags: --max-inlined-nodes-cumulative=999999 31 32// Test that huge constructors (more than 256 this assignments) are 33// handled correctly. 34 35// Test huge constructor when being inlined into hydrogen. 36function test() { 37 return new huge(); 38} 39test(); 40test(); 41%OptimizeFunctionOnNextCall(test); 42var o = test(); 43assertEquals(1, o.foo1); 44assertEquals(257, o.foo257); 45 46// Test huge constructor with specialized constructor stub. 47var o = new huge(); 48assertEquals(1, o.foo1); 49assertEquals(257, o.foo257); 50 51// The huge constructor, nothing interesting beyond this point. 52function huge() { 53 this.foo1 = 1; 54 this.foo2 = 2; 55 this.foo3 = 3; 56 this.foo4 = 4; 57 this.foo5 = 5; 58 this.foo6 = 6; 59 this.foo7 = 7; 60 this.foo8 = 8; 61 this.foo9 = 9; 62 this.foo10 = 10; 63 this.foo11 = 11; 64 this.foo12 = 12; 65 this.foo13 = 13; 66 this.foo14 = 14; 67 this.foo15 = 15; 68 this.foo16 = 16; 69 this.foo17 = 17; 70 this.foo18 = 18; 71 this.foo19 = 19; 72 this.foo20 = 20; 73 this.foo21 = 21; 74 this.foo22 = 22; 75 this.foo23 = 23; 76 this.foo24 = 24; 77 this.foo25 = 25; 78 this.foo26 = 26; 79 this.foo27 = 27; 80 this.foo28 = 28; 81 this.foo29 = 29; 82 this.foo30 = 30; 83 this.foo31 = 31; 84 this.foo32 = 32; 85 this.foo33 = 33; 86 this.foo34 = 34; 87 this.foo35 = 35; 88 this.foo36 = 36; 89 this.foo37 = 37; 90 this.foo38 = 38; 91 this.foo39 = 39; 92 this.foo40 = 40; 93 this.foo41 = 41; 94 this.foo42 = 42; 95 this.foo43 = 43; 96 this.foo44 = 44; 97 this.foo45 = 45; 98 this.foo46 = 46; 99 this.foo47 = 47; 100 this.foo48 = 48; 101 this.foo49 = 49; 102 this.foo50 = 50; 103 this.foo51 = 51; 104 this.foo52 = 52; 105 this.foo53 = 53; 106 this.foo54 = 54; 107 this.foo55 = 55; 108 this.foo56 = 56; 109 this.foo57 = 57; 110 this.foo58 = 58; 111 this.foo59 = 59; 112 this.foo60 = 60; 113 this.foo61 = 61; 114 this.foo62 = 62; 115 this.foo63 = 63; 116 this.foo64 = 64; 117 this.foo65 = 65; 118 this.foo66 = 66; 119 this.foo67 = 67; 120 this.foo68 = 68; 121 this.foo69 = 69; 122 this.foo70 = 70; 123 this.foo71 = 71; 124 this.foo72 = 72; 125 this.foo73 = 73; 126 this.foo74 = 74; 127 this.foo75 = 75; 128 this.foo76 = 76; 129 this.foo77 = 77; 130 this.foo78 = 78; 131 this.foo79 = 79; 132 this.foo80 = 80; 133 this.foo81 = 81; 134 this.foo82 = 82; 135 this.foo83 = 83; 136 this.foo84 = 84; 137 this.foo85 = 85; 138 this.foo86 = 86; 139 this.foo87 = 87; 140 this.foo88 = 88; 141 this.foo89 = 89; 142 this.foo90 = 90; 143 this.foo91 = 91; 144 this.foo92 = 92; 145 this.foo93 = 93; 146 this.foo94 = 94; 147 this.foo95 = 95; 148 this.foo96 = 96; 149 this.foo97 = 97; 150 this.foo98 = 98; 151 this.foo99 = 99; 152 this.foo100 = 100; 153 this.foo101 = 101; 154 this.foo102 = 102; 155 this.foo103 = 103; 156 this.foo104 = 104; 157 this.foo105 = 105; 158 this.foo106 = 106; 159 this.foo107 = 107; 160 this.foo108 = 108; 161 this.foo109 = 109; 162 this.foo110 = 110; 163 this.foo111 = 111; 164 this.foo112 = 112; 165 this.foo113 = 113; 166 this.foo114 = 114; 167 this.foo115 = 115; 168 this.foo116 = 116; 169 this.foo117 = 117; 170 this.foo118 = 118; 171 this.foo119 = 119; 172 this.foo120 = 120; 173 this.foo121 = 121; 174 this.foo122 = 122; 175 this.foo123 = 123; 176 this.foo124 = 124; 177 this.foo125 = 125; 178 this.foo126 = 126; 179 this.foo127 = 127; 180 this.foo128 = 128; 181 this.foo129 = 129; 182 this.foo130 = 130; 183 this.foo131 = 131; 184 this.foo132 = 132; 185 this.foo133 = 133; 186 this.foo134 = 134; 187 this.foo135 = 135; 188 this.foo136 = 136; 189 this.foo137 = 137; 190 this.foo138 = 138; 191 this.foo139 = 139; 192 this.foo140 = 140; 193 this.foo141 = 141; 194 this.foo142 = 142; 195 this.foo143 = 143; 196 this.foo144 = 144; 197 this.foo145 = 145; 198 this.foo146 = 146; 199 this.foo147 = 147; 200 this.foo148 = 148; 201 this.foo149 = 149; 202 this.foo150 = 150; 203 this.foo151 = 151; 204 this.foo152 = 152; 205 this.foo153 = 153; 206 this.foo154 = 154; 207 this.foo155 = 155; 208 this.foo156 = 156; 209 this.foo157 = 157; 210 this.foo158 = 158; 211 this.foo159 = 159; 212 this.foo160 = 160; 213 this.foo161 = 161; 214 this.foo162 = 162; 215 this.foo163 = 163; 216 this.foo164 = 164; 217 this.foo165 = 165; 218 this.foo166 = 166; 219 this.foo167 = 167; 220 this.foo168 = 168; 221 this.foo169 = 169; 222 this.foo170 = 170; 223 this.foo171 = 171; 224 this.foo172 = 172; 225 this.foo173 = 173; 226 this.foo174 = 174; 227 this.foo175 = 175; 228 this.foo176 = 176; 229 this.foo177 = 177; 230 this.foo178 = 178; 231 this.foo179 = 179; 232 this.foo180 = 180; 233 this.foo181 = 181; 234 this.foo182 = 182; 235 this.foo183 = 183; 236 this.foo184 = 184; 237 this.foo185 = 185; 238 this.foo186 = 186; 239 this.foo187 = 187; 240 this.foo188 = 188; 241 this.foo189 = 189; 242 this.foo190 = 190; 243 this.foo191 = 191; 244 this.foo192 = 192; 245 this.foo193 = 193; 246 this.foo194 = 194; 247 this.foo195 = 195; 248 this.foo196 = 196; 249 this.foo197 = 197; 250 this.foo198 = 198; 251 this.foo199 = 199; 252 this.foo200 = 200; 253 this.foo201 = 201; 254 this.foo202 = 202; 255 this.foo203 = 203; 256 this.foo204 = 204; 257 this.foo205 = 205; 258 this.foo206 = 206; 259 this.foo207 = 207; 260 this.foo208 = 208; 261 this.foo209 = 209; 262 this.foo210 = 210; 263 this.foo211 = 211; 264 this.foo212 = 212; 265 this.foo213 = 213; 266 this.foo214 = 214; 267 this.foo215 = 215; 268 this.foo216 = 216; 269 this.foo217 = 217; 270 this.foo218 = 218; 271 this.foo219 = 219; 272 this.foo220 = 220; 273 this.foo221 = 221; 274 this.foo222 = 222; 275 this.foo223 = 223; 276 this.foo224 = 224; 277 this.foo225 = 225; 278 this.foo226 = 226; 279 this.foo227 = 227; 280 this.foo228 = 228; 281 this.foo229 = 229; 282 this.foo230 = 230; 283 this.foo231 = 231; 284 this.foo232 = 232; 285 this.foo233 = 233; 286 this.foo234 = 234; 287 this.foo235 = 235; 288 this.foo236 = 236; 289 this.foo237 = 237; 290 this.foo238 = 238; 291 this.foo239 = 239; 292 this.foo240 = 240; 293 this.foo241 = 241; 294 this.foo242 = 242; 295 this.foo243 = 243; 296 this.foo244 = 244; 297 this.foo245 = 245; 298 this.foo246 = 246; 299 this.foo247 = 247; 300 this.foo248 = 248; 301 this.foo249 = 249; 302 this.foo250 = 250; 303 this.foo251 = 251; 304 this.foo252 = 252; 305 this.foo253 = 253; 306 this.foo254 = 254; 307 this.foo255 = 255; 308 this.foo256 = 256; 309 this.foo257 = 257; 310} 311